From 25fcf4a129545cdcdceb87ca8deaeabaf2239e03 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Mon, 8 Jun 2020 12:20:31 +0200 Subject: Adds changelog, utility menus, and support for file:// --- src/mainwindow.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e8dbd23..f2c4390 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include MainWindow::MainWindow(QApplication * app, QWidget *parent) : QMainWindow(parent), @@ -45,6 +46,13 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) : connect(act, QOverload::of(&QAction::triggered), dock, &QDockWidget::setVisible); } + connect(this->ui->menuNavigation, &QMenu::aboutToShow, [this]() { + BrowserTab * tab = qobject_cast(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + ui->actionAdd_to_favourites->setChecked(this->favourites.contains(tab->current_location)); + } + }); + connect(this->ui->menuView, &QMenu::aboutToShow, [this]() { for(QAction * act : this->ui->menuView->actions()) { @@ -309,3 +317,30 @@ void MainWindow::reloadTheme() application->setStyleSheet(stream.readAll()); } } + +void MainWindow::on_actionSave_as_triggered() +{ + BrowserTab * tab = qobject_cast(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + QFileDialog::saveFileContent( + tab->current_buffer, + tab->current_location.fileName() + ); + } +} + +void MainWindow::on_actionGo_to_home_triggered() +{ + BrowserTab * tab = qobject_cast(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + tab->navigateTo(QUrl(this->settings.value("start_page").toString()), BrowserTab::PushAfterSuccess); + } +} + +void MainWindow::on_actionAdd_to_favourites_triggered() +{ + BrowserTab * tab = qobject_cast(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + tab->toggleIsFavourite(); + } +} -- cgit v1.2.3