diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-02-17 15:19:47 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-02-17 09:24:05 +0100 |
| commit | b82ecad5462eec767e2e3216e9e96dfebf04f1cc (patch) | |
| tree | abb3c9ac713aae70d63d496d27348cade698a260 /src/mainwindow.cpp | |
| parent | 9bf17318f91b0d5a42c970491d0963178fd23938 (diff) | |
| download | kristall-b82ecad5462eec767e2e3216e9e96dfebf04f1cc.tar.gz | |
Add basic root/parent navigation options to menu, with shortcuts
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d656867..d2623eb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -482,6 +482,35 @@ void MainWindow::on_actionBackward_triggered() } } +void MainWindow::on_actionRoot_triggered() +{ + BrowserTab * tab = this->curTab(); + if(tab != nullptr && !tab->is_internal_location) { + QUrl url = tab->current_location; + url.setPath("/"); + tab->navigateTo(url, BrowserTab::PushImmediate); + } +} + +void MainWindow::on_actionParent_triggered() +{ + BrowserTab * tab = this->curTab(); + if(tab != nullptr && !tab->is_internal_location) { + QUrl url = tab->current_location; + + // Make sure we have a trailing slash, or else + // QUrl::resolved will not work + if (!url.path().endsWith("/")) + { + url.setPath(url.path() + "/"); + } + + // Go up one directory + url = url.resolved(QUrl{".."}); + tab->navigateTo(url, BrowserTab::PushImmediate); + } +} + void MainWindow::on_actionRefresh_triggered() { BrowserTab * tab = this->curTab(); |
