From 19046566a62f9e616a23584ebbe045ddbc132023 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Thu, 7 Jan 2021 16:17:58 +1100 Subject: favourite popup: adding group combobox! --- src/mainwindow.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f46ed75..d93cac8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -189,6 +189,21 @@ void MainWindow::setUiDensity(UIDensity density, bool previewing) } } +QString MainWindow::newGroupDialog() +{ + QInputDialog dialog { this }; + + dialog.setInputMode(QInputDialog::TextInput); + dialog.setLabelText(tr("Enter name of the new group:")); + + if(dialog.exec() != QDialog::Accepted) + return QString { }; + + kristall::favourites.addGroup(dialog.textValue()); + + return dialog.textValue(); +} + void MainWindow::mousePressEvent(QMouseEvent *event) { QMainWindow::mousePressEvent(event); @@ -565,15 +580,7 @@ void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint pos) QMenu menu; connect(menu.addAction("Create new group..."), &QAction::triggered, [this]() { - QInputDialog dialog { this }; - - dialog.setInputMode(QInputDialog::TextInput); - dialog.setLabelText(tr("Enter name of the new group:")); - - if(dialog.exec() != QDialog::Accepted) - return; - - kristall::favourites.addGroup(dialog.textValue()); + this->newGroupDialog(); }); menu.exec(this->ui->favourites_view->mapToGlobal(pos)); -- cgit v1.2.3