From 9457e720f24d8365ed6a1e82b016078b0bc17eb6 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sat, 6 Mar 2021 15:26:07 +0100 Subject: Implements proper multi-window support. --- src/mainwindow.cpp | 56 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bd33153..6f39b42 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -253,7 +253,8 @@ void MainWindow::setUiDensity(UIDensity density, bool previewing) if (previewing) { - if (!this->curTab()) return; + if (not this->curTab()) + return; this->curTab()->setUiDensity(density); } else @@ -278,6 +279,27 @@ QString MainWindow::newGroupDialog() return dialog.textValue(); } +void MainWindow::applySettings() +{ + // Flag open tabs for re-render so theme + // changes are instantly applied. + for (int i = 0; i < this->ui->browser_tabs->count(); ++i) + { + BrowserTab *t = this->tabAt(i); + t->refreshOptionalToolbarItems(); + t->refreshToolbarIcons(); + t->needs_rerender = true; + } + + // Re-render the currently-open tab if we have one. + BrowserTab * tab = this->curTab(); + if (tab) + tab->rerenderPage(); + + // Update new-tab button visibility. + this->ui->browser_tabs->tab_bar->new_tab_btn->setVisible(kristall::options.enable_newtab_btn); +} + void MainWindow::mousePressEvent(QMouseEvent *event) { QMainWindow::mousePressEvent(event); @@ -439,27 +461,9 @@ void MainWindow::on_actionSettings_triggered() kristall::protocols = dialog.protocols(); kristall::document_style = dialog.geminiStyle(); - kristall::saveSettings(); - - kristall::setTheme(kristall::options.theme); - this->setUiDensity(kristall::options.ui_density, false); + kristall::applySettings(); - // Flag open tabs for re-render so theme - // changes are instantly applied. - for (int i = 0; i < this->ui->browser_tabs->count(); ++i) - { - BrowserTab *t = this->tabAt(i); - t->refreshOptionalToolbarItems(); - t->refreshToolbarIcons(); - t->needs_rerender = true; - } - // Re-render the currently-open tab if we have one. - BrowserTab * tab = this->curTab(); - if (tab) tab->rerenderPage(); - - // Update new-tab button visibility. - this->ui->browser_tabs->tab_bar->new_tab_btn - ->setVisible(kristall::options.enable_newtab_btn); + kristall::saveSettings(); } void MainWindow::on_actionNew_Tab_triggered() @@ -777,3 +781,13 @@ void MainWindow::on_actionShow_document_source_triggered() { this->viewPageSource(); } + +void MainWindow::on_actionNew_window_triggered() +{ + kristall::openNewWindow(false); +} + +void MainWindow::on_actionClose_Window_triggered() +{ + this->deleteLater(); +} -- cgit v1.2.3