From 2324544aaf973fc13bebebcf95dcaff3e7ebcd38 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 17 Dec 2015 10:03:15 +0100 Subject: [PATCH] Fixed #134. --- CMakeLists.txt | 6 ++- resources/text/CHANGELOG | 7 +++ src/gui/colorlabel.cpp | 27 ++++++++++++ src/gui/colorlabel.h | 24 +++++++++++ src/gui/dialogs/formsettings.cpp | 11 +++++ src/gui/dialogs/formsettings.h | 3 +- src/gui/dialogs/formsettings.ui | 59 ++++++++++++++++++++++---- src/gui/notifications/notification.cpp | 3 +- src/gui/notifications/notification.h | 1 + src/miscellaneous/settings.cpp | 3 ++ src/miscellaneous/settings.h | 5 +++ 11 files changed, 137 insertions(+), 12 deletions(-) create mode 100755 src/gui/colorlabel.cpp create mode 100755 src/gui/colorlabel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 313bfecdb..fe55b1e33 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,8 @@ project(rssguard) set(APP_NAME "RSS Guard") set(APP_LOW_NAME "rssguard") -set(APP_VERSION "3.0.0") -set(FILE_VERSION "3,0,0,0") +set(APP_VERSION "3.0.1") +set(FILE_VERSION "3,0,1,0") set(APP_AUTHOR "Martin Rotter") set(APP_URL "http://bitbucket.org/skunkos/rssguard") set(APP_URL_ISSUES "http://bitbucket.org/skunkos/rssguard/issues") @@ -381,6 +381,7 @@ set(APP_SOURCES src/gui/edittableview.cpp src/gui/squeezelabel.cpp src/gui/discoverfeedsbutton.cpp + src/gui/colorlabel.cpp # DYNAMIC-SHORTCUTS sources. src/dynamic-shortcuts/shortcutcatcher.cpp @@ -516,6 +517,7 @@ set(APP_HEADERS src/gui/edittableview.h src/gui/squeezelabel.h src/gui/discoverfeedsbutton.h + src/gui/colorlabel.h # DYNAMIC-SHORTCUTS headers. src/dynamic-shortcuts/dynamicshortcutswidget.h diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 3b42cf41e..5773a034d 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -1,3 +1,10 @@ +3.0.1 +————— + +Added: + +▪ Background color of notifications is now changeable. (issue #134) + 3.0.0 ————— diff --git a/src/gui/colorlabel.cpp b/src/gui/colorlabel.cpp new file mode 100755 index 000000000..407471e04 --- /dev/null +++ b/src/gui/colorlabel.cpp @@ -0,0 +1,27 @@ +#include "gui/colorlabel.h" + +#include +#include + + +ColorLabel::ColorLabel(QWidget *parent) : QLabel(parent), m_color(QColor()) { + setFixedWidth(20); +} + +ColorLabel::~ColorLabel() { +} + +QColor ColorLabel::color() const { + return m_color; +} + +void ColorLabel::setColor(const QColor &color) { + m_color = color; + + repaint(); +} + +void ColorLabel::paintEvent(QPaintEvent *event) { + QPainter painter(this); + painter.fillRect(event->rect(), m_color); +} diff --git a/src/gui/colorlabel.h b/src/gui/colorlabel.h new file mode 100755 index 000000000..7574ca66d --- /dev/null +++ b/src/gui/colorlabel.h @@ -0,0 +1,24 @@ +#ifndef COLORLABEL_H +#define COLORLABEL_H + +#include + + +class ColorLabel : public QLabel { + Q_OBJECT + + public: + explicit ColorLabel(QWidget *parent = 0); + virtual ~ColorLabel(); + + QColor color() const; + void setColor(const QColor &color); + + protected: + void paintEvent(QPaintEvent *event); + + private: + QColor m_color; +}; + +#endif // COLORLABEL_H diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index 181bd0c45..259acd104 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -136,6 +136,7 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form connect(m_ui->m_cmbDatabaseDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(selectSqlBackend(int))); connect(m_ui->m_btnDownloadsTargetDirectory, SIGNAL(clicked()), this, SLOT(selectDownloadsDirectory())); connect(m_ui->m_checkMysqlShowPassword, SIGNAL(toggled(bool)), this, SLOT(switchMysqlPasswordVisiblity(bool))); + connect(m_ui->m_btnChangeNotificationColor, SIGNAL(clicked()), this, SLOT(selectNewNotificationColor())); // Load all settings. loadGeneral(); @@ -170,6 +171,14 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current, } } +void FormSettings::selectNewNotificationColor() { + QColorDialog dialog(m_ui->m_lblNotificationColor->color(), this); + + if (dialog.exec() == QDialog::Accepted) { + m_ui->m_lblNotificationColor->setColor(dialog.selectedColor()); + } +} + void FormSettings::loadDownloads() { m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetDirectory)).toString())); @@ -733,6 +742,7 @@ void FormSettings::loadInterface() { m_ui->m_cmbNotificationPosition->addItem(tr("Top-right corner"), Qt::TopRightCorner); m_ui->m_cmbNotificationPosition->setCurrentIndex(m_ui->m_cmbNotificationPosition->findData(static_cast(settings->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt()))); m_ui->m_grpBaseNotifications->setChecked(settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); + m_ui->m_lblNotificationColor->setColor(settings->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value()); // Load settings of icon theme. QString current_theme = qApp->icons()->currentIconTheme(); @@ -837,6 +847,7 @@ void FormSettings::saveInterface() { settings->setValue(GROUP(GUI), GUI::UseFancyNotifications, m_ui->m_grpNotifications->isChecked()); settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_grpBaseNotifications->isChecked()); settings->setValue(GROUP(GUI), GUI::FancyNotificationsPosition, static_cast(m_ui->m_cmbNotificationPosition->itemData(m_ui->m_cmbNotificationPosition->currentIndex()).toInt())); + settings->setValue(GROUP(GUI), GUI::NotificationBackgroundColor, m_ui->m_lblNotificationColor->color()); // Save selected icon theme. QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString(); diff --git a/src/gui/dialogs/formsettings.h b/src/gui/dialogs/formsettings.h index cdaa14663..d4e36f177 100755 --- a/src/gui/dialogs/formsettings.h +++ b/src/gui/dialogs/formsettings.h @@ -39,7 +39,7 @@ struct TemporarySettings { class FormSettings : public QDialog { Q_OBJECT - + public: // Constructors and destructors. explicit FormSettings(QWidget *parent = 0); @@ -60,6 +60,7 @@ class FormSettings : public QDialog { void loadInterface(); void saveInterface(); void onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous); + void selectNewNotificationColor(); void loadDownloads(); void saveDownloads(); diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui index d4f2f5e96..ca7285db0 100755 --- a/src/gui/dialogs/formsettings.ui +++ b/src/gui/dialogs/formsettings.ui @@ -88,7 +88,7 @@ - 1 + 3 @@ -463,7 +463,7 @@ Authors of this application are NOT responsible for lost data. QTabWidget::North - 0 + 1 @@ -666,6 +666,44 @@ Authors of this application are NOT responsible for lost data. + + + + Background color + + + + + + + + + + + + + + + + Change + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -1568,18 +1606,18 @@ Authors of this application are NOT responsible for lost data. - - LineEditWithStatus - QWidget -
lineeditwithstatus.h
- 1 -
LabelWithStatus QWidget
labelwithstatus.h
1
+ + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
DynamicShortcutsWidget QWidget @@ -1592,6 +1630,11 @@ Authors of this application are NOT responsible for lost data.
toolbareditor.h
1
+ + ColorLabel + QLabel +
colorlabel.h
+
m_cmbDatabaseDriver diff --git a/src/gui/notifications/notification.cpp b/src/gui/notifications/notification.cpp index 510acf9c5..d0bba9461 100755 --- a/src/gui/notifications/notification.cpp +++ b/src/gui/notifications/notification.cpp @@ -221,7 +221,7 @@ void Notification::paintEvent(QPaintEvent *event) { #else painter.setRenderHints(QPainter::HighQualityAntialiasing); #endif - painter.setBrush(QColor(220, 220, 220)); + painter.setBrush(m_backgroundColor); painter.setPen(Qt::NoPen); painter.drawRoundedRect(0, 0, width(), height(), 5.0, 5.0); @@ -274,6 +274,7 @@ void Notification::timerEvent(QTimerEvent *event) { void Notification::loadSettings() { m_position = static_cast(qApp->settings()->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt()); + m_backgroundColor = qApp->settings()->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value(); } void Notification::setupWidget() { diff --git a/src/gui/notifications/notification.h b/src/gui/notifications/notification.h index dceb7bcc4..f0de72d7c 100755 --- a/src/gui/notifications/notification.h +++ b/src/gui/notifications/notification.h @@ -70,6 +70,7 @@ class Notification : public QWidget { void setupWidget(); void updateGeometries(); + QColor m_backgroundColor; QString m_title; QString m_text; QPixmap m_icon; diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index bf1179f07..61d21a338 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -78,6 +78,9 @@ DVALUE(char*) GUI::SplitterFeedsDef = ""; DKEY GUI::SplitterMessages = "splitter_messages"; DVALUE(char*) GUI::SplitterMessagesDef = ""; +DKEY GUI::NotificationBackgroundColor = "notification_background_color"; +DVALUE(QColor) GUI::NotificationBackgroundColorDef = QColor(220, 220, 220); + DKEY GUI::ToolbarStyle = "toolbar_style"; DVALUE(Qt::ToolButtonStyle) GUI::ToolbarStyleDef = Qt::ToolButtonIconOnly; diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index 35746dd5b..4a1f89a12 100755 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -26,6 +26,7 @@ #include #include +#include #define KEY extern const char* #define DKEY const char* @@ -37,6 +38,7 @@ #define DEFAULT_VALUE(x) x##Def #define GROUP(x) x::ID + // Feeds. namespace Feeds { KEY ID; @@ -93,6 +95,9 @@ namespace GUI { KEY SplitterMessages; VALUE(char*) SplitterMessagesDef; + KEY NotificationBackgroundColor; + VALUE(QColor) NotificationBackgroundColorDef; + KEY ToolbarStyle; VALUE(Qt::ToolButtonStyle) ToolbarStyleDef;