From 19c8bf98885074617f9cc0a0b2f60ebf47ddf714 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Fri, 1 Jan 2021 19:26:15 +1100 Subject: Added UI density option. 'Compact' is the default - saves screen space a bit. The old layout is available in the 'Classic' option --- src/mainwindow.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/mainwindow.cpp') 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. -- cgit v1.2.3