From b4fd7f00b777667614c0219fa1225fa04f93a766 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Oliver=20Gro=C3=9F?= Date: Mon, 13 Jul 2009 13:18:00 +0200 Subject: [PATCH] added dis-/charging colors --- batteryicon.cpp | 13 ++++++++++--- constants.h | 20 +++++++++++--------- powermanager.cpp | 14 +++++++++----- settings.cpp | 6 ++++-- settingsdialog.ui | 52 ++++++++++++++++++++++++++++++++++++---------------- 5 files changed, 70 insertions(+), 35 deletions(-) diff --git a/batteryicon.cpp b/batteryicon.cpp index 8d1ff9b..500fd4c 100644 --- a/batteryicon.cpp +++ b/batteryicon.cpp @@ -31,8 +31,12 @@ namespace qbat { m_Icon.fill(Qt::transparent); QPainter painter(&m_Icon); - if (m_Data.currentCapacity != m_Data.fullCapacity) { - painter.setPen(QColor(m_Settings->colors[UI_COLOR_PEN])); + if (m_Data.currentCapacity != m_Data.fullCapacity || m_Data.status != UI_BATTERY_FULL) { + if (m_Data.status == UI_BATTERY_DISCHARGING) + painter.setPen(QColor(m_Settings->colors[UI_COLOR_PEN_DISCHARGE])); + else + painter.setPen(QColor(m_Settings->colors[UI_COLOR_PEN_CHARGE])); + painter.setBrush(QColor(m_Settings->colors[UI_COLOR_BRUSH_EMPTY])); painter.drawRect(0, 4, 27, 23); @@ -40,7 +44,10 @@ namespace qbat { painter.fillRect(1, 5 + 22 - chargedPixels, 26, chargedPixels, QColor(m_Settings->colors[UI_COLOR_BRUSH_CHARGED])); - painter.setBrush(QColor(m_Settings->colors[UI_COLOR_BRUSH_POLE])); + if (m_Data.status == UI_BATTERY_DISCHARGING) + painter.setBrush(QColor(m_Settings->colors[UI_COLOR_BRUSH_POLE_DISCHARGE])); + else + painter.setBrush(QColor(m_Settings->colors[UI_COLOR_BRUSH_POLE_CHARGE])); } else { painter.setPen(QColor(m_Settings->colors[UI_COLOR_PEN_FULL])); diff --git a/constants.h b/constants.h index 4c3ef2e..5408602 100644 --- a/constants.h +++ b/constants.h @@ -26,14 +26,16 @@ #define UI_BATTERY_DISCHARGING 2 #define UI_BATTERY_FULL 3 -#define UI_COUNT_COLORS 7 - -#define UI_COLOR_PEN 0 -#define UI_COLOR_PEN_FULL 1 -#define UI_COLOR_BRUSH_CHARGED 2 -#define UI_COLOR_BRUSH_EMPTY 3 -#define UI_COLOR_BRUSH_FULL 4 -#define UI_COLOR_BRUSH_POLE 5 -#define UI_COLOR_BRUSH_POLE_FULL 6 +#define UI_COUNT_COLORS 9 + +#define UI_COLOR_PEN_CHARGE 0 +#define UI_COLOR_PEN_DISCHARGE 1 +#define UI_COLOR_PEN_FULL 2 +#define UI_COLOR_BRUSH_CHARGED 3 +#define UI_COLOR_BRUSH_EMPTY 4 +#define UI_COLOR_BRUSH_FULL 5 +#define UI_COLOR_BRUSH_POLE_CHARGE 6 +#define UI_COLOR_BRUSH_POLE_DISCHARGE 7 +#define UI_COLOR_BRUSH_POLE_FULL 8 #endif diff --git a/powermanager.cpp b/powermanager.cpp index 3bb0381..b09a2aa 100644 --- a/powermanager.cpp +++ b/powermanager.cpp @@ -54,13 +54,15 @@ namespace qbat { m_SettingsFile.beginGroup("TrayIcons"); m_Settings.mergeBatteries = m_SettingsFile.value("mergeBatteries", false).toBool(); - m_Settings.colors[UI_COLOR_PEN] = m_SettingsFile.value("textColor", 0).toUInt(); + m_Settings.colors[UI_COLOR_PEN_CHARGE] = m_SettingsFile.value("textChargingColor", 0).toUInt(); + m_Settings.colors[UI_COLOR_PEN_DISCHARGE] = m_SettingsFile.value("textDischargingColor", 0).toUInt(); m_Settings.colors[UI_COLOR_PEN_FULL] = m_SettingsFile.value("textFullColor", 0).toUInt(); m_Settings.colors[UI_COLOR_BRUSH_CHARGED] = m_SettingsFile.value("mainChargedColor", qRgb( 0, 255, 0)).toUInt(); m_Settings.colors[UI_COLOR_BRUSH_EMPTY] = m_SettingsFile.value("mainEmptyColor", qRgb(255, 255, 255)).toUInt(); m_Settings.colors[UI_COLOR_BRUSH_FULL] = m_SettingsFile.value("mainFullColor", m_Settings.colors[UI_COLOR_BRUSH_CHARGED]).toUInt(); - m_Settings.colors[UI_COLOR_BRUSH_POLE] = m_SettingsFile.value("poleColor", qRgb(255, 255, 0)).toUInt(); - m_Settings.colors[UI_COLOR_BRUSH_POLE_FULL] = m_SettingsFile.value("poleFullColor", m_Settings.colors[UI_COLOR_BRUSH_POLE]).toUInt(); + m_Settings.colors[UI_COLOR_BRUSH_POLE_CHARGE] = m_SettingsFile.value("poleChargingColor", qRgb(255, 255, 0)).toUInt(); + m_Settings.colors[UI_COLOR_BRUSH_POLE_DISCHARGE] = m_SettingsFile.value("poleDischargingColor", qRgb(255, 255, 0)).toUInt(); + m_Settings.colors[UI_COLOR_BRUSH_POLE_FULL] = m_SettingsFile.value("poleFullColor", m_Settings.colors[UI_COLOR_BRUSH_POLE_CHARGE]).toUInt(); m_SettingsFile.endGroup(); m_SettingsFile.beginGroup("CriticalEvent"); @@ -82,12 +84,14 @@ namespace qbat { m_SettingsFile.beginGroup("TrayIcons"); m_SettingsFile.setValue("mergeBatteries", m_Settings.mergeBatteries); - m_SettingsFile.setValue("textColor", m_Settings.colors[UI_COLOR_PEN]); + m_SettingsFile.setValue("textChargingColor", m_Settings.colors[UI_COLOR_PEN_CHARGE]); + m_SettingsFile.setValue("textDischargingColor", m_Settings.colors[UI_COLOR_PEN_DISCHARGE]); m_SettingsFile.setValue("textFullColor", m_Settings.colors[UI_COLOR_PEN_FULL]); m_SettingsFile.setValue("mainChargedColor", m_Settings.colors[UI_COLOR_BRUSH_CHARGED]); m_SettingsFile.setValue("mainEmptyColor", m_Settings.colors[UI_COLOR_BRUSH_EMPTY]); m_SettingsFile.setValue("mainFullColor", m_Settings.colors[UI_COLOR_BRUSH_FULL]); - m_SettingsFile.setValue("poleColor", m_Settings.colors[UI_COLOR_BRUSH_POLE]); + m_SettingsFile.setValue("poleChargingColor", m_Settings.colors[UI_COLOR_BRUSH_POLE_CHARGE]); + m_SettingsFile.setValue("poleDischargingColor", m_Settings.colors[UI_COLOR_BRUSH_POLE_DISCHARGE]); m_SettingsFile.setValue("poleFullColor", m_Settings.colors[UI_COLOR_BRUSH_POLE_FULL]); m_SettingsFile.endGroup(); diff --git a/settings.cpp b/settings.cpp index 251f6e1..b1314d2 100644 --- a/settings.cpp +++ b/settings.cpp @@ -17,9 +17,11 @@ namespace qbat { colorSelectButtons.addButton(ui.mainFullColorButton, 1 + UI_COLOR_BRUSH_FULL); colorSelectButtons.addButton(ui.mainChargedColorButton, 1 + UI_COLOR_BRUSH_CHARGED); colorSelectButtons.addButton(ui.mainEmptyColorButton, 1 + UI_COLOR_BRUSH_EMPTY); - colorSelectButtons.addButton(ui.textColorButton, 1 + UI_COLOR_PEN); + colorSelectButtons.addButton(ui.textChargingColorButton, 1 + UI_COLOR_PEN_CHARGE); + colorSelectButtons.addButton(ui.textDischargingColorButton, 1 + UI_COLOR_PEN_DISCHARGE); colorSelectButtons.addButton(ui.textFullColorButton, 1 + UI_COLOR_PEN_FULL); - colorSelectButtons.addButton(ui.poleColorButton, 1 + UI_COLOR_BRUSH_POLE); + colorSelectButtons.addButton(ui.poleChargingColorButton, 1 + UI_COLOR_BRUSH_POLE_CHARGE); + colorSelectButtons.addButton(ui.poleDischargingColorButton, 1 + UI_COLOR_BRUSH_POLE_DISCHARGE); colorSelectButtons.addButton(ui.poleFullColorButton, 1 + UI_COLOR_BRUSH_POLE_FULL); connect(&colorSelectButtons, SIGNAL(buttonClicked(int)), this, SLOT(editColor(int))); } diff --git a/settingsdialog.ui b/settingsdialog.ui index 02ccbb0..c72f6e8 100644 --- a/settingsdialog.ui +++ b/settingsdialog.ui @@ -6,7 +6,7 @@ 0 0 - 445 + 449 495 @@ -207,16 +207,6 @@ - - - - (dis)charging - - - (dis)charging - - - @@ -235,12 +225,12 @@ - + - (dis)charging + charging - (dis)charging + charging @@ -251,6 +241,36 @@ + + + + charging + + + charging + + + + + + + discharging + + + discharging + + + + + + + discharging + + + discharging + + + @@ -340,9 +360,9 @@ mainChargedColorButton mainEmptyColorButton textFullColorButton - textColorButton + textChargingColorButton poleFullColorButton - poleColorButton + poleChargingColorButton pollingRateSpin buttonBox -- 2.11.4.GIT