Switchable color for webbrowser progressbar.
This commit is contained in:
parent
93a191058e
commit
7bbdd7a7a2
4 changed files with 114 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
#include <QColorDialog>
|
||||||
|
|
||||||
#include "gui/formsettings.h"
|
#include "gui/formsettings.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/themefactory.h"
|
||||||
|
@ -42,6 +43,8 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||||
this, &FormSettings::onProxyTypeChanged);
|
this, &FormSettings::onProxyTypeChanged);
|
||||||
connect(m_ui->m_checkShowPassword, &QCheckBox::stateChanged,
|
connect(m_ui->m_checkShowPassword, &QCheckBox::stateChanged,
|
||||||
this, &FormSettings::displayProxyPassword);
|
this, &FormSettings::displayProxyPassword);
|
||||||
|
connect(m_ui->m_btnBrowserProgressColor, &QPushButton::clicked,
|
||||||
|
this, &FormSettings::changeBrowserProgressColor);
|
||||||
|
|
||||||
// Load all settings.
|
// Load all settings.
|
||||||
loadGeneral();
|
loadGeneral();
|
||||||
|
@ -55,6 +58,15 @@ FormSettings::~FormSettings() {
|
||||||
delete m_ui;
|
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) {
|
void FormSettings::displayProxyPassword(int state) {
|
||||||
if (state == Qt::Checked) {
|
if (state == Qt::Checked) {
|
||||||
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal);
|
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal);
|
||||||
|
@ -243,6 +255,14 @@ void FormSettings::loadInterface() {
|
||||||
m_ui->m_grpTray->setDisabled(true);
|
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<QColor>();
|
||||||
|
m_ui->m_checkBrowserProgressColor->setChecked(Settings::getInstance()->value(APP_CFG_GUI,
|
||||||
|
"browser_colored_progress_enabled",
|
||||||
|
true).toBool());
|
||||||
|
|
||||||
// Load settings of icon theme.
|
// Load settings of icon theme.
|
||||||
QString current_theme = ThemeFactory::getCurrentIconTheme();
|
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.
|
// Save selected icon theme.
|
||||||
ThemeFactory::setCurrentIconTheme(m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString());
|
ThemeFactory::setCurrentIconTheme(m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,11 @@ namespace Ui {
|
||||||
class FormSettings;
|
class FormSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Structure holding some initial values.
|
||||||
|
struct TemporarySettings {
|
||||||
|
QColor m_webBrowserProgress;
|
||||||
|
};
|
||||||
|
|
||||||
class FormSettings : public QDialog {
|
class FormSettings : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -21,9 +26,9 @@ class FormSettings : public QDialog {
|
||||||
// Saves settings into global configuration.
|
// Saves settings into global configuration.
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
// Load/save GUI settings.
|
|
||||||
void loadInterface();
|
void loadInterface();
|
||||||
void saveInterface();
|
void saveInterface();
|
||||||
|
void changeBrowserProgressColor();
|
||||||
|
|
||||||
void loadGeneral();
|
void loadGeneral();
|
||||||
void saveGeneral();
|
void saveGeneral();
|
||||||
|
@ -42,6 +47,7 @@ class FormSettings : public QDialog {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FormSettings *m_ui;
|
Ui::FormSettings *m_ui;
|
||||||
|
TemporarySettings m_initialSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FORMSETTINGS_H
|
#endif // FORMSETTINGS_H
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>4</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pageGeneral">
|
<widget class="QWidget" name="m_pageGeneral">
|
||||||
<layout class="QFormLayout" name="formLayout_5">
|
<layout class="QFormLayout" name="formLayout_5">
|
||||||
|
@ -117,8 +117,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>506</width>
|
||||||
<height>30</height>
|
<height>367</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_tabIconSkin">
|
<widget class="QWidget" name="m_tabIconSkin">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -256,10 +256,42 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="m_tabFonts">
|
<widget class="QWidget" name="m_tabWebBrowser">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Fonts</string>
|
<string>Web browser</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<layout class="QFormLayout" name="formLayout_7">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblBrowserProgressColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color of website loading progress bar</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="indent">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="m_btnBrowserProgressColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Change...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_checkBrowserProgressColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use custom color for web browser progress bar</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="m_tabMisc">
|
<widget class="QWidget" name="m_tabMisc">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -562,5 +594,37 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_checkBrowserProgressColor</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>m_btnBrowserProgressColor</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>416</x>
|
||||||
|
<y>48</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>519</x>
|
||||||
|
<y>74</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_checkBrowserProgressColor</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>m_lblBrowserProgressColor</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>416</x>
|
||||||
|
<y>48</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>275</x>
|
||||||
|
<y>73</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include "core/defs.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "gui/locationlineedit.h"
|
#include "gui/locationlineedit.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,9 +50,13 @@ void LocationLineEdit::mousePressEvent(QMouseEvent *event) {
|
||||||
|
|
||||||
void LocationLineEdit::paintEvent(QPaintEvent *event) {
|
void LocationLineEdit::paintEvent(QPaintEvent *event) {
|
||||||
// Draw "progress bar" if needed.
|
// 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();
|
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<QColor>();
|
||||||
QLinearGradient gradient(0, 0, width(), 0);
|
QLinearGradient gradient(0, 0, width(), 0);
|
||||||
qreal percentage_border = m_progress / 100.0;
|
qreal percentage_border = m_progress / 100.0;
|
||||||
|
|
||||||
|
@ -63,7 +69,7 @@ void LocationLineEdit::paintEvent(QPaintEvent *event) {
|
||||||
|
|
||||||
setPalette(current_palette);
|
setPalette(current_palette);
|
||||||
}
|
}
|
||||||
// No "progress bar" is needed, restore default palette.
|
// No "progress bar" is needed or enabled, restore default palette.
|
||||||
else {
|
else {
|
||||||
setPalette(m_defaultPalette);
|
setPalette(m_defaultPalette);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue