diff --git a/src/core/qtlibtorrent/torrentmodel.cpp b/src/core/qtlibtorrent/torrentmodel.cpp index 3d86d44ee..1579665b7 100644 --- a/src/core/qtlibtorrent/torrentmodel.cpp +++ b/src/core/qtlibtorrent/torrentmodel.cpp @@ -29,6 +29,8 @@ */ #include +#include +#include #include "torrentmodel.h" #include "torrentpersistentdata.h" @@ -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) { } 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) { 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: