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 | #include <knewstuff_version.h> | 28 | #include <knewstuff_version.h> | ||
28 | 29 | | |||
cfeck: `#include <KColorScheme>' (and move above the KLocalizedString, we (sometimes) try to keep… | |||||
29 | #include <QMouseEvent> | 30 | #include <QMouseEvent> | ||
31 | #include <QPalette> | ||||
30 | 32 | | |||
31 | StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) : | 33 | StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) : | ||
32 | KCapacityBar(KCapacityBar::DrawTextInline, parent), | 34 | KCapacityBar(KCapacityBar::DrawTextInline, parent), | ||
33 | m_observer(nullptr) | 35 | m_observer(nullptr) | ||
34 | { | 36 | { | ||
35 | setCursor(Qt::PointingHandCursor); | 37 | setCursor(Qt::PointingHandCursor); | ||
36 | } | 38 | } | ||
37 | 39 | | |||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 101 | if (size == 0) { | |||
100 | setText(i18nc("@info:status", "Unknown size")); | 102 | setText(i18nc("@info:status", "Unknown size")); | ||
101 | setValue(0); | 103 | setValue(0); | ||
102 | update(); | 104 | update(); | ||
103 | } else { | 105 | } else { | ||
104 | const quint64 available = m_observer->available(); | 106 | const quint64 available = m_observer->available(); | ||
105 | const quint64 used = size - available; | 107 | const quint64 used = size - available; | ||
106 | const int percentUsed = qRound(100.0 * qreal(used) / qreal(size)); | 108 | const int percentUsed = qRound(100.0 * qreal(used) / qreal(size)); | ||
107 | 109 | | |||
110 | QPalette p = palette(); | ||||
elvisangelaccio: Please use a descriptive variable name (e.g. `palette`) | |||||
111 | KColorScheme colorScheme(QPalette::Active, KColorScheme::Selection); | ||||
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… | |||||
112 | | ||||
113 | if (percentUsed >= 90) { | ||||
114 | p.setBrush(QPalette::Highlight, colorScheme.background(KColorScheme::NegativeBackground)); | ||||
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
``` | |||||
115 | p.setBrush(QPalette::HighlightedText, colorScheme.foreground(KColorScheme::NegativeText)); | ||||
elvisangelaccio: What's the second `setBrush()` needed for? | |||||
116 | } else { | ||||
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… | |||||
117 | p.setBrush(QPalette::Highlight, colorScheme.background(KColorScheme::NormalBackground)); | ||||
cfeck: `} else {` | |||||
118 | p.setBrush(QPalette::HighlightedText, colorScheme.foreground(KColorScheme::NormalText)); | ||||
119 | } | ||||
120 | | ||||
121 | setPalette(p); | ||||
122 | | ||||
meven: Is this the correct way to do this ? | |||||
108 | setText(i18nc("@info:status Free disk space", "%1 free", KIO::convertSize(available))); | 123 | setText(i18nc("@info:status Free disk space", "%1 free", KIO::convertSize(available))); | ||
109 | setUpdatesEnabled(false); | 124 | setUpdatesEnabled(false); | ||
110 | setValue(percentUsed); | 125 | setValue(percentUsed); | ||
111 | setUpdatesEnabled(true); | 126 | setUpdatesEnabled(true); | ||
112 | update(); | 127 | update(); | ||
113 | } | 128 | } | ||
114 | } | 129 | } | ||
115 | 130 | |
`#include <KColorScheme>' (and move above the KLocalizedString, we (sometimes) try to keep includes alphabetical)