diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-01-07 19:28:39 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-01-07 10:05:00 +0100 |
| commit | 2e0b8d3495d6c46c2d3afb88787fd7ca3ed1558e (patch) | |
| tree | e0e878b871b81a4e6e3bc24bf39ca135dfe91671 /src/mainwindow.cpp | |
| parent | 19046566a62f9e616a23584ebbe045ddbc132023 (diff) | |
Added new context menus to favourite group
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d93cac8..4a09811 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -538,30 +538,30 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos) menu.addSeparator(); - connect(menu.addAction("Rename"), &QAction::triggered, [this, idx]() { + connect(menu.addAction("Relocate"), &QAction::triggered, [this, idx]() { QInputDialog dialog { this }; dialog.setInputMode(QInputDialog::TextInput); - dialog.setLabelText(tr("New name of this favourite:")); - dialog.setTextValue(kristall::favourites.getFavourite(idx).getTitle()); + dialog.setLabelText(tr("Enter new location of this favourite:")); + dialog.setTextValue(kristall::favourites.getFavourite(idx).destination.toString(QUrl::FullyEncoded)); if (dialog.exec() != QDialog::Accepted) return; - kristall::favourites.editFavouriteTitle(idx, dialog.textValue()); + kristall::favourites.editFavouriteDest(idx, QUrl(dialog.textValue())); }); - connect(menu.addAction("Relocate"), &QAction::triggered, [this, idx]() { + connect(menu.addAction("Rename"), &QAction::triggered, [this, idx]() { QInputDialog dialog { this }; dialog.setInputMode(QInputDialog::TextInput); - dialog.setLabelText(tr("Enter new location of this favourite:")); - dialog.setTextValue(kristall::favourites.getFavourite(idx).destination.toString(QUrl::FullyEncoded)); + dialog.setLabelText(tr("New name of this favourite:")); + dialog.setTextValue(kristall::favourites.getFavourite(idx).getTitle()); if (dialog.exec() != QDialog::Accepted) return; - kristall::favourites.editFavouriteDest(idx, QUrl(dialog.textValue())); + kristall::favourites.editFavouriteTitle(idx, dialog.textValue()); }); menu.addSeparator(); @@ -573,7 +573,39 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos) menu.exec(this->ui->favourites_view->mapToGlobal(pos)); } else if(QString group = kristall::favourites.group(idx); not group.isEmpty()) { - qDebug() << group; + QMenu menu; + + connect(menu.addAction("Rename group"), &QAction::triggered, [this, group]() { + QInputDialog dialog { this }; + + dialog.setInputMode(QInputDialog::TextInput); + dialog.setLabelText(tr("New name of this group:")); + dialog.setTextValue(group); + + if (dialog.exec() != QDialog::Accepted) + return; + + if (!kristall::favourites.renameGroup(group, dialog.textValue())) + QMessageBox::information(this, "Kristall", "Rename failed: group name already in use."); + }); + + menu.addSeparator(); + + connect(menu.addAction("Delete group"), &QAction::triggered, [this, idx]() { + if (QMessageBox::question( + this, + "Kristall", + "Are you sure you want to delete this Favourite Group?\n" + "All favourites in this group will be lost.\n\n" + "This action cannot be undone!" + ) != QMessageBox::Yes) + { + return; + } + kristall::favourites.deleteGroupRecursive(kristall::favourites.group(idx)); + }); + + menu.exec(this->ui->favourites_view->mapToGlobal(pos)); } } else { |
