diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-13 23:26:46 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-13 23:26:46 -0400 |
| commit | ba0b2c2a29d32d290a16d88ff71475dbd61a8ffd (patch) | |
| tree | 1e06cfdb0426ba2d669125ed4b79633e7334f3f8 /src | |
| parent | 4a7a77480bfd44c7780e9e37bceadac7e367c062 (diff) | |
switched to stylesheet for api colors, palette doesn't seem to survive hiding/unhiding very well
Diffstat (limited to 'src')
| -rw-r--r-- | src/statusbar.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/statusbar.cpp b/src/statusbar.cpp index 68c0642a..4effa6a3 100644 --- a/src/statusbar.cpp +++ b/src/statusbar.cpp @@ -23,7 +23,6 @@ StatusBar::StatusBar(QStatusBar* bar, Ui::MainWindow* ui) : m_notifications->set(false); m_api->setObjectName("apistats"); - m_api->setStyleSheet("QLabel{ padding: 0.1em 0 0.1em 0; }"); m_bar->clearMessage(); setProgress(-1); @@ -55,28 +54,36 @@ void StatusBar::setAPI(const APIStats& stats, const APIUserAccount& user) .arg(user.limits().remainingDailyRequests) .arg(user.limits().remainingHourlyRequests)); - QColor textColor; - QColor backgroundColor; + QString textColor; + QString backgroundColor; if (user.type() == APIUserAccountTypes::None) { - backgroundColor = Qt::transparent; + backgroundColor = "transparent"; } else if (user.remainingRequests() > 300) { textColor = "white"; - backgroundColor = Qt::darkGreen; + backgroundColor = "darkgreen"; } else if (user.remainingRequests() < 150) { textColor = "white"; - backgroundColor = Qt::darkRed; + backgroundColor = "darkred"; } else { textColor = "black"; - backgroundColor = Qt::darkYellow; + backgroundColor = "rgb(226, 192, 0)"; // yellow } - QPalette palette = m_api->palette(); + m_api->setStyleSheet(QString(R"( + QLabel + { + padding-left: 0.1em; + padding-right: 0.1em; + padding-top: 0; + padding-bottom: 0; + color: %1; + background-color: %2; + } + )") + .arg(textColor) + .arg(backgroundColor)); - palette.setColor(QPalette::WindowText, textColor); - palette.setColor(QPalette::Background, backgroundColor); - - m_api->setPalette(palette); m_api->setAutoFillBackground(true); } |
