From 7bbdd7a7a2213f083ef61f8efa9027010c181990 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 20 Jul 2013 21:11:52 +0200 Subject: [PATCH] Switchable color for webbrowser progressbar. --- src/gui/formsettings.cpp | 28 +++++++++++++ src/gui/formsettings.h | 8 +++- src/gui/formsettings.ui | 76 +++++++++++++++++++++++++++++++++--- src/gui/locationlineedit.cpp | 12 ++++-- 4 files changed, 114 insertions(+), 10 deletions(-) diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 836ebf5d4..b7bbcb6e8 100644 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "gui/formsettings.h" #include "gui/themefactory.h" @@ -42,6 +43,8 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form this, &FormSettings::onProxyTypeChanged); connect(m_ui->m_checkShowPassword, &QCheckBox::stateChanged, this, &FormSettings::displayProxyPassword); + connect(m_ui->m_btnBrowserProgressColor, &QPushButton::clicked, + this, &FormSettings::changeBrowserProgressColor); // Load all settings. loadGeneral(); @@ -55,6 +58,15 @@ FormSettings::~FormSettings() { delete m_ui; } +void FormSettings::changeBrowserProgressColor() { + QColorDialog color_dialog(m_initialSettings.m_webBrowserProgress, this); + color_dialog.setWindowTitle(tr("Select color for web browser progress bar")); + color_dialog.setOption(QColorDialog::ShowAlphaChannel); + color_dialog.exec(); + + m_initialSettings.m_webBrowserProgress = color_dialog.selectedColor(); +} + void FormSettings::displayProxyPassword(int state) { if (state == Qt::Checked) { m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal); @@ -243,6 +255,14 @@ void FormSettings::loadInterface() { m_ui->m_grpTray->setDisabled(true); } + // Load settings of web browser GUI. + m_initialSettings.m_webBrowserProgress = Settings::getInstance()->value(APP_CFG_GUI, + "browser_progress_color", + QColor(0, 255, 0, 100)).value(); + m_ui->m_checkBrowserProgressColor->setChecked(Settings::getInstance()->value(APP_CFG_GUI, + "browser_colored_progress_enabled", + true).toBool()); + // Load settings of icon theme. QString current_theme = ThemeFactory::getCurrentIconTheme(); @@ -290,6 +310,14 @@ void FormSettings::saveInterface() { } } + // Save settings of GUI of web browser. + Settings::getInstance()->setValue(APP_CFG_GUI, + "browser_progress_color", + m_initialSettings.m_webBrowserProgress); + Settings::getInstance()->setValue(APP_CFG_GUI, + "browser_colored_progress_enabled", + m_ui->m_checkBrowserProgressColor->isChecked()); + // Save selected icon theme. ThemeFactory::setCurrentIconTheme(m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString()); } diff --git a/src/gui/formsettings.h b/src/gui/formsettings.h index 66504fde7..12a149f8a 100644 --- a/src/gui/formsettings.h +++ b/src/gui/formsettings.h @@ -10,6 +10,11 @@ namespace Ui { class FormSettings; } +// Structure holding some initial values. +struct TemporarySettings { + QColor m_webBrowserProgress; +}; + class FormSettings : public QDialog { Q_OBJECT @@ -21,9 +26,9 @@ class FormSettings : public QDialog { // Saves settings into global configuration. void saveSettings(); - // Load/save GUI settings. void loadInterface(); void saveInterface(); + void changeBrowserProgressColor(); void loadGeneral(); void saveGeneral(); @@ -42,6 +47,7 @@ class FormSettings : public QDialog { private: Ui::FormSettings *m_ui; + TemporarySettings m_initialSettings; }; #endif // FORMSETTINGS_H diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index ad4948291..016499ea0 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -65,7 +65,7 @@ - 4 + 2 @@ -117,8 +117,8 @@ 0 0 - 100 - 30 + 506 + 367 @@ -163,7 +163,7 @@ QTabWidget::North - 0 + 2 @@ -256,10 +256,42 @@ - + - Fonts + Web browser + + + + + Color of website loading progress bar + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 20 + + + + + + + &Change... + + + + + + + Use custom color for web browser progress bar + + + true + + + + @@ -562,5 +594,37 @@ + + m_checkBrowserProgressColor + toggled(bool) + m_btnBrowserProgressColor + setVisible(bool) + + + 416 + 48 + + + 519 + 74 + + + + + m_checkBrowserProgressColor + toggled(bool) + m_lblBrowserProgressColor + setVisible(bool) + + + 416 + 48 + + + 275 + 73 + + + diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp index 076a3181b..8c7d5ba69 100644 --- a/src/gui/locationlineedit.cpp +++ b/src/gui/locationlineedit.cpp @@ -3,6 +3,8 @@ #include #include +#include "core/defs.h" +#include "core/settings.h" #include "gui/locationlineedit.h" @@ -48,9 +50,13 @@ void LocationLineEdit::mousePressEvent(QMouseEvent *event) { void LocationLineEdit::paintEvent(QPaintEvent *event) { // Draw "progress bar" if needed. - if (m_progress > 0) { + if (m_progress > 0 && Settings::getInstance()->value(APP_CFG_GUI, + "browser_colored_progress_enabled", + true).toBool()) { QPalette current_palette = palette(); - QColor loadingColor = QColor(0, 255, 0, 100); + QColor loadingColor = Settings::getInstance()->value(APP_CFG_GUI, + "browser_progress_color", + QColor(0, 255, 0, 100)).value(); QLinearGradient gradient(0, 0, width(), 0); qreal percentage_border = m_progress / 100.0; @@ -63,7 +69,7 @@ void LocationLineEdit::paintEvent(QPaintEvent *event) { setPalette(current_palette); } - // No "progress bar" is needed, restore default palette. + // No "progress bar" is needed or enabled, restore default palette. else { setPalette(m_defaultPalette); }