diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-10 00:31:56 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-10 00:31:56 +0200 |
| commit | 656391ecc0555b3462266b886434ae0f120a401c (patch) | |
| tree | bb87b6889c2dae9a5c65c6b9bcb783139bebdf3c /src/mainwindow.cpp | |
| parent | 0739bce0be84e8ccebdc632726efd0fd6f612789 (diff) | |
| download | kristall-656391ecc0555b3462266b886434ae0f120a401c.tar.gz | |
Adds some right click menus, fixes bug in gopher.
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f735b2a..10302d2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -84,6 +84,9 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) : global_settings.endGroup(); } + this->ui->favourites_view->setContextMenuPolicy(Qt::CustomContextMenu); + this->ui->history_view->setContextMenuPolicy(Qt::CustomContextMenu); + reloadTheme(); } @@ -402,3 +405,49 @@ void MainWindow::on_actionHelp_triggered() { this->addNewTab(true, QUrl("about:help")); } + +void MainWindow::on_history_view_customContextMenuRequested(const QPoint &pos) +{ + if(auto idx = this->ui->history_view->indexAt(pos); idx.isValid()) { + BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + if(QUrl url = tab->history.get(idx); url.isValid()) { + QMenu menu; + + connect(menu.addAction("Open here"), &QAction::triggered, [tab, idx]() { + // We do the same thing as a double click here + tab->navigateBack(idx); + }); + + connect(menu.addAction("Open in new tab"), &QAction::triggered, [this, url]() { + addNewTab(true, url); + }); + + menu.exec(this->ui->history_view->mapToGlobal(pos)); + } + } + } +} + +void MainWindow::on_favourites_view_customContextMenuRequested(const QPoint &pos) +{ + if(auto idx = this->ui->favourites_view->indexAt(pos); idx.isValid()) { + if(QUrl url = favourites.get(idx); url.isValid()) { + QMenu menu; + + BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + connect(menu.addAction("Open here"), &QAction::triggered, [tab, url]() { + tab->navigateTo(url, BrowserTab::PushImmediate); + }); + } + + connect(menu.addAction("Open in new tab"), &QAction::triggered, [this, url]() { + addNewTab(true, url); + }); + + menu.exec(this->ui->favourites_view->mapToGlobal(pos)); + + } + } +} |
