Skip to content

Commit 23b4490

Browse files
committed
#3357 nextclouddeck: allow opening of URL in browser
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent ca4483d commit 23b4490

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 25.9.6
44

5+
- You can now **open the URL to a card** in the **Nextcloud Deck dialog** in the
6+
browser by right-clicking on the card and choosing _Open in browser_ or double-clicking
7+
on the card in the list (for [#3357](https://github.com/pbek/QOwnNotes/issues/3357))
58
- There now is a software repository for **openSUSE Leap 16.0**
69
- Please visit the [openSUSE installation page](https://www.qownnotes.org/installation/opensuse.html)
710
for instructions

src/dialogs/nextclouddeckdialog.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "nextclouddeckdialog.h"
22

3+
#include <QDesktopServices>
34
#include <QMenu>
45
#include <QShortcut>
56
#include <QTimeZone>
@@ -337,9 +338,45 @@ void NextcloudDeckDialog::on_archiveCardButton_clicked() {
337338
}
338339

339340
NextcloudDeckService nextcloudDeckService(this);
340-
bool isSuccess = nextcloudDeckService.archiveCard(_currentCard.id);
341+
const bool isSuccess = nextcloudDeckService.archiveCard(_currentCard.id);
341342

342343
if (isSuccess) {
343344
reloadCardList();
344345
}
345346
}
347+
348+
void NextcloudDeckDialog::openUrlInBrowserForItem(const QTreeWidgetItem *item) {
349+
if (item == nullptr) {
350+
return;
351+
}
352+
353+
QDesktopServices::openUrl(
354+
QUrl(NextcloudDeckService(this).getCardLinkForId(item->data(0, Qt::UserRole).toInt())));
355+
}
356+
357+
void NextcloudDeckDialog::on_cardItemTreeWidget_itemDoubleClicked(QTreeWidgetItem *item,
358+
int column) {
359+
Q_UNUSED(column)
360+
361+
openUrlInBrowserForItem(item);
362+
}
363+
364+
void NextcloudDeckDialog::on_cardItemTreeWidget_customContextMenuRequested(const QPoint &pos) {
365+
const QPoint globalPos = ui->cardItemTreeWidget->mapToGlobal(pos);
366+
QMenu menu;
367+
368+
QAction *openUrlAction = menu.addAction(tr("&Open card in browser"));
369+
openUrlAction->setIcon(QIcon::fromTheme(QStringLiteral("text-html"),
370+
QIcon(":icons/breeze-qownnotes/16x16/text-html.svg")));
371+
QAction *selectedItem = menu.exec(globalPos);
372+
373+
if (selectedItem == nullptr) {
374+
return;
375+
}
376+
377+
QTreeWidgetItem *item = ui->cardItemTreeWidget->currentItem();
378+
379+
if (selectedItem == openUrlAction) {
380+
openUrlInBrowserForItem(item);
381+
}
382+
}

src/dialogs/nextclouddeckdialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class NextcloudDeckDialog : public MasterDialog {
5555

5656
void on_archiveCardButton_clicked();
5757

58+
void on_cardItemTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
59+
60+
void on_cardItemTreeWidget_customContextMenuRequested(const QPoint &pos);
61+
5862
private:
5963
Ui::NextcloudDeckDialog *ui;
6064
void setupMainSplitter();
@@ -65,6 +69,8 @@ class NextcloudDeckDialog : public MasterDialog {
6569
void jumpToCard(int id);
6670
QHash<int, NextcloudDeckService::Card> _cards;
6771
NextcloudDeckService::Card _currentCard;
72+
73+
void openUrlInBrowserForItem(const QTreeWidgetItem *item);
6874
};
6975

7076
#endif // NEXTCLOUDDECKDIALOG_H

0 commit comments

Comments
 (0)