Browse Source

Adjust color scheme for dark themes. Closes #1359.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
6aceac152d
  1. 26
      src/core/qtlibtorrent/torrentmodel.cpp

26
src/core/qtlibtorrent/torrentmodel.cpp

@ -29,6 +29,8 @@ @@ -29,6 +29,8 @@
*/
#include <QDebug>
#include <QApplication>
#include <QPalette>
#include "torrentmodel.h"
#include "torrentpersistentdata.h"
@ -84,6 +86,14 @@ QIcon get_error_icon() { @@ -84,6 +86,14 @@ QIcon get_error_icon() {
static QIcon cached = QIcon(":/icons/skin/error.png");
return cached;
}
bool isDarkTheme()
{
QPalette pal = QApplication::palette();
// QPalette::Base is used for the background of the Treeview
QColor color = pal.color(QPalette::Active, QPalette::Base);
return (color.lightness() < 127);
}
}
TorrentStatusReport::TorrentStatusReport()
@ -187,6 +197,7 @@ QIcon TorrentModelItem::getIconByState(State state) { @@ -187,6 +197,7 @@ QIcon TorrentModelItem::getIconByState(State state) {
}
QColor TorrentModelItem::getColorByState(State state) {
bool dark = isDarkTheme();
switch (state) {
case STATE_DOWNLOADING:
case STATE_DOWNLOADING_META:
@ -194,13 +205,22 @@ QColor TorrentModelItem::getColorByState(State state) { @@ -194,13 +205,22 @@ QColor TorrentModelItem::getColorByState(State state) {
case STATE_ALLOCATING:
case STATE_STALLED_DL:
case STATE_STALLED_UP:
return QColor(0, 0, 0); // Black
if (!dark)
return QColor(0, 0, 0); // Black
else
return QColor(255, 255, 255); // White
case STATE_SEEDING:
return QColor(65, 105, 225); // Royal Blue
if (!dark)
return QColor(65, 105, 225); // Royal Blue
else
return QColor(100, 149, 237); // Cornflower Blue
case STATE_PAUSED_DL:
return QColor(250, 128, 114); // Salmon
case STATE_PAUSED_UP:
return QColor(0, 0, 139); // Dark Blue
if (!dark)
return QColor(0, 0, 139); // Dark Blue
else
return QColor(65, 105, 225); // Royal Blue
case STATE_PAUSED_MISSING:
return QColor(255, 0, 0); // red
case STATE_QUEUED_DL:

Loading…
Cancel
Save