aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2021-01-01 19:26:15 +1100
committerFelix Queißner <felix@ib-queissner.de>2021-01-01 15:02:42 +0100
commit19c8bf98885074617f9cc0a0b2f60ebf47ddf714 (patch)
tree570b591a687e574bddd0c79009e2829d9f496f78 /src/mainwindow.cpp
parent808288ce691a3c1520db513c7cff79fd22d3c53f (diff)
downloadkristall-19c8bf98885074617f9cc0a0b2f60ebf47ddf714.tar.gz
Added UI density option.
'Compact' is the default - saves screen space a bit. The old layout is available in the 'Classic' option
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index f9266bc..b30d98a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -173,6 +173,24 @@ void MainWindow::updateWindowTitle()
this->setWindowTitle(QString("%0 - %1").arg(tab->page_title, "Kristall"));
}
+void MainWindow::setUiDensity(UIDensity density, bool previewing)
+{
+ // If we are previewing, we only update the current tab.
+ // If not, we update all tabs as it means user accepted the settings
+ // dialog.
+
+ if (previewing)
+ {
+ if (!this->curTab()) return;
+ this->curTab()->setUiDensity(density);
+ }
+ else
+ {
+ for (int i = 0; i < this->ui->browser_tabs->count(); ++i)
+ this->tabAt(i)->setUiDensity(density);
+ }
+}
+
void MainWindow::mousePressEvent(QMouseEvent *event)
{
QMainWindow::mousePressEvent(event);
@@ -301,6 +319,7 @@ void MainWindow::on_actionSettings_triggered()
if(dialog.exec() != QDialog::Accepted) {
kristall::setTheme(kristall::options.theme);
+ this->setUiDensity(kristall::options.ui_density, false);
update_url_style(false);
return;
}
@@ -317,6 +336,7 @@ void MainWindow::on_actionSettings_triggered()
kristall::saveSettings();
kristall::setTheme(kristall::options.theme);
+ this->setUiDensity(kristall::options.ui_density, false);
// Flag open tabs for re-render so theme
// changes are instantly applied.