Skip to content

Commit 323ddd8

Browse files
committed
#3357 nextclouddeckdialog: allow adding card link to current note
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent a26ba08 commit 323ddd8

File tree

4 files changed

+206
-171
lines changed

4 files changed

+206
-171
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# QOwnNotes Changelog
22

3+
## 25.10.2
4+
5+
- You can now **add a link to a card** to the current note in the
6+
**Nextcloud Deck dialog** (for [#3357](https://github.com/pbek/QOwnNotes/issues/3357))
7+
38
## 25.10.1
49

510
- You now are also able to **send and receive HTML and image clipboard content**

src/dialogs/nextclouddeckdialog.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ void NextcloudDeckDialog::on_cardItemTreeWidget_customContextMenuRequested(const
368368
QAction *openUrlAction = menu.addAction(tr("&Open card in browser"));
369369
openUrlAction->setIcon(QIcon::fromTheme(QStringLiteral("text-html"),
370370
QIcon(":icons/breeze-qownnotes/16x16/text-html.svg")));
371+
QAction *cardLinkAction = menu.addAction(tr("&Add card link to note"));
372+
openUrlAction->setIcon(QIcon::fromTheme(
373+
QStringLiteral("document-new"), QIcon(":icons/breeze-qownnotes/16x16/document-new.svg")));
374+
371375
QAction *selectedItem = menu.exec(globalPos);
372376

373377
if (selectedItem == nullptr) {
@@ -378,5 +382,25 @@ void NextcloudDeckDialog::on_cardItemTreeWidget_customContextMenuRequested(const
378382

379383
if (selectedItem == openUrlAction) {
380384
openUrlInBrowserForItem(item);
385+
} else if (selectedItem == cardLinkAction) {
386+
addCardLinkToCurrentNote(item);
387+
}
388+
}
389+
390+
void NextcloudDeckDialog::addCardLinkToCurrentNote(const QTreeWidgetItem *item) {
391+
const int cardId = item->data(0, Qt::UserRole).toInt();
392+
393+
if (cardId > 0) {
394+
const auto title = item->text(0);
395+
const auto linkText = QStringLiteral("[%1](%2)")
396+
.arg(title, NextcloudDeckService(this).getCardLinkForId(cardId));
397+
398+
#ifndef INTEGRATION_TESTS
399+
// Only insert the link if we're creating a new card, not updating an existing one
400+
MainWindow *mainWindow = MainWindow::instance();
401+
if (mainWindow != nullptr) {
402+
mainWindow->activeNoteTextEdit()->insertPlainText(linkText);
403+
}
404+
#endif
381405
}
382406
}

src/dialogs/nextclouddeckdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class NextcloudDeckDialog : public MasterDialog {
7171
NextcloudDeckService::Card _currentCard;
7272

7373
void openUrlInBrowserForItem(const QTreeWidgetItem *item);
74+
void addCardLinkToCurrentNote(const QTreeWidgetItem *item);
7475
};
7576

7677
#endif // NEXTCLOUDDECKDIALOG_H

0 commit comments

Comments
 (0)