aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2021-03-06 15:26:07 +0100
committerFelix (xq) Queißner <git@mq32.de>2021-03-06 15:26:07 +0100
commit9457e720f24d8365ed6a1e82b016078b0bc17eb6 (patch)
treed810dcd8189ce508a9a0e666f7d819f3c63bcbca /src/mainwindow.cpp
parente16c85887a58381f225d706a8d740bf96a5fdf6a (diff)
downloadkristall-9457e720f24d8365ed6a1e82b016078b0bc17eb6.tar.gz
Implements proper multi-window support.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp56
1 files changed, 35 insertions, 21 deletions
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();
+}