Changeset View
Changeset View
Standalone View
Standalone View
src/statusbar/statusbarspaceinfo.cpp
Show All 16 Lines | |||||
17 | * Free Software Foundation, Inc., * | 17 | * Free Software Foundation, Inc., * | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
20 | 20 | | |||
21 | #include "statusbarspaceinfo.h" | 21 | #include "statusbarspaceinfo.h" | ||
22 | 22 | | |||
23 | #include "spaceinfoobserver.h" | 23 | #include "spaceinfoobserver.h" | ||
24 | 24 | | |||
25 | #include <KColorScheme> | ||||
25 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
26 | #include <KNS3/KMoreToolsMenuFactory> | 27 | #include <KNS3/KMoreToolsMenuFactory> | ||
27 | 28 | | |||
cfeck: `#include <KColorScheme>' (and move above the KLocalizedString, we (sometimes) try to keep… | |||||
28 | #include <QMouseEvent> | 29 | #include <QMouseEvent> | ||
30 | #include <QPalette> | ||||
29 | 31 | | |||
30 | StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) : | 32 | StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) : | ||
31 | KCapacityBar(KCapacityBar::DrawTextInline, parent), | 33 | KCapacityBar(KCapacityBar::DrawTextInline, parent), | ||
32 | m_observer(nullptr) | 34 | m_observer(nullptr) | ||
33 | { | 35 | { | ||
34 | setCursor(Qt::PointingHandCursor); | 36 | setCursor(Qt::PointingHandCursor); | ||
35 | } | 37 | } | ||
36 | 38 | | |||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 100 | if (size == 0) { | |||
99 | setText(i18nc("@info:status", "Unknown size")); | 101 | setText(i18nc("@info:status", "Unknown size")); | ||
100 | setValue(0); | 102 | setValue(0); | ||
101 | update(); | 103 | update(); | ||
102 | } else { | 104 | } else { | ||
103 | const quint64 available = m_observer->available(); | 105 | const quint64 available = m_observer->available(); | ||
104 | const quint64 used = size - available; | 106 | const quint64 used = size - available; | ||
105 | const int percentUsed = qRound(100.0 * qreal(used) / qreal(size)); | 107 | const int percentUsed = qRound(100.0 * qreal(used) / qreal(size)); | ||
106 | 108 | | |||
109 | QPalette new_palette = palette(); | ||||
elvisangelaccio: Please use a descriptive variable name (e.g. `palette`) | |||||
110 | KColorScheme colorScheme(QPalette::Active, KColorScheme::Window); | ||||
Why KColorScheme::Selection ? That should be used for items that can be selected. We should probably use KColorScheme::Window instead elvisangelaccio: Why `KColorScheme::Selection` ? That should be used for items that can be selected.
We should… | |||||
111 | | ||||
112 | if (percentUsed >= 90) { | ||||
113 | // breeze style | ||||
Why QPalette::Highlight ? That's supposed to be used for the selected text's color elvisangelaccio: Why `QPalette::Highlight` ? That's supposed to be used for the selected text's color | |||||
sourabhboss: Then what should i use
For text i have used
```
QPalette::HighlightedText
``` | |||||
114 | new_palette.setBrush(QPalette::Highlight, colorScheme.foreground(KColorScheme::NegativeText)); | ||||
elvisangelaccio: What's the second `setBrush()` needed for? | |||||
115 | // fusion style | ||||
cfeck: Shouldn't this be `QPalette::HightlightedText`? | |||||
... and it should also be in the previous if branch ? I was confused until I read the actual mail. cfeck: ... and it should also be in the previous `if` branch ? I was confused until I read the actual… | |||||
116 | new_palette.setBrush(QPalette::Background, colorScheme.foreground(KColorScheme::NegativeText)); | ||||
cfeck: `} else {` | |||||
117 | } else { | ||||
118 | // breeze style | ||||
119 | new_palette.setBrush(QPalette::Highlight, colorScheme.foreground(KColorScheme::ActiveText)); | ||||
120 | // fusion style | ||||
121 | new_palette.setBrush(QPalette::Background, colorScheme.background(KColorScheme::NormalBackground)); | ||||
meven: Is this the correct way to do this ? | |||||
122 | } | ||||
123 | | ||||
124 | setPalette(new_palette); | ||||
125 | | ||||
107 | setText(i18nc("@info:status Free disk space", "%1 free", KIO::convertSize(available))); | 126 | setText(i18nc("@info:status Free disk space", "%1 free", KIO::convertSize(available))); | ||
127 | setToolTip(i18nc("@info:status Free disk space", "%1% used", percentUsed)); | ||||
108 | setUpdatesEnabled(false); | 128 | setUpdatesEnabled(false); | ||
109 | setValue(percentUsed); | 129 | setValue(percentUsed); | ||
110 | setUpdatesEnabled(true); | 130 | setUpdatesEnabled(true); | ||
111 | update(); | 131 | update(); | ||
112 | } | 132 | } | ||
113 | } | 133 | } | ||
114 | 134 | |
`#include <KColorScheme>' (and move above the KLocalizedString, we (sometimes) try to keep includes alphabetical)