Allow to customize PiecesBar colors

PR #22922.
This commit is contained in:
Vladimir Golovnev 2025-06-28 08:53:47 +03:00 committed by GitHub
parent dd4a2eb583
commit e447baa04a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 5 deletions

View file

@ -36,11 +36,16 @@
#include <QList> #include <QList>
#include "base/global.h" #include "base/global.h"
#include "gui/uithememanager.h"
namespace namespace
{ {
QColor dlPieceColor(const QColor &pieceColor) QColor dlPieceColor(const QColor &pieceColor)
{ {
const QColor color = UIThemeManager::instance()->getColor(u"PiecesBar.PartialPiece"_s);
if (color.isValid())
return color;
const QColor green {Qt::green}; const QColor green {Qt::green};
return QColor::fromHsl(green.hslHue(), pieceColor.hslSaturation(), pieceColor.lightness()); return QColor::fromHsl(green.hslHue(), pieceColor.hslSaturation(), pieceColor.lightness());
} }

View file

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2024 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2024-2025 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2016 Eugene Shalygin * Copyright (C) 2016 Eugene Shalygin
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez
* *
@ -42,6 +42,7 @@
#include "base/indexrange.h" #include "base/indexrange.h"
#include "base/path.h" #include "base/path.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "gui/uithememanager.h"
namespace namespace
{ {
@ -216,17 +217,20 @@ void PiecesBar::redraw()
QColor PiecesBar::backgroundColor() const QColor PiecesBar::backgroundColor() const
{ {
return palette().color(QPalette::Active, QPalette::Base); const QColor color = UIThemeManager::instance()->getColor(u"PiecesBar.MissingPiece"_s);
return color.isValid() ? color : palette().color(QPalette::Active, QPalette::Base);
} }
QColor PiecesBar::borderColor() const QColor PiecesBar::borderColor() const
{ {
return palette().color(QPalette::Active, QPalette::Dark); const QColor color = UIThemeManager::instance()->getColor(u"PiecesBar.Border"_s);
return color.isValid() ? color : palette().color(QPalette::Active, QPalette::Dark);
} }
QColor PiecesBar::pieceColor() const QColor PiecesBar::pieceColor() const
{ {
return palette().color(QPalette::Active, QPalette::Highlight); const QColor color = UIThemeManager::instance()->getColor(u"PiecesBar.Piece"_s);
return color.isValid() ? color : palette().color(QPalette::Active, QPalette::Highlight);
} }
QColor PiecesBar::highlightedPieceColor() const QColor PiecesBar::highlightedPieceColor() const

View file

@ -80,7 +80,12 @@ inline QHash<QString, UIThemeColor> defaultUIThemeColors()
{u"TransferList.StoppedUploading"_s, {Color::Primer::Light::doneFg, Color::Primer::Dark::doneFg}}, {u"TransferList.StoppedUploading"_s, {Color::Primer::Light::doneFg, Color::Primer::Dark::doneFg}},
{u"TransferList.Moving"_s, {Color::Primer::Light::successFg, Color::Primer::Dark::successFg}}, {u"TransferList.Moving"_s, {Color::Primer::Light::successFg, Color::Primer::Dark::successFg}},
{u"TransferList.MissingFiles"_s, {Color::Primer::Light::dangerFg, Color::Primer::Dark::dangerFg}}, {u"TransferList.MissingFiles"_s, {Color::Primer::Light::dangerFg, Color::Primer::Dark::dangerFg}},
{u"TransferList.Error"_s, {Color::Primer::Light::dangerFg, Color::Primer::Dark::dangerFg}} {u"TransferList.Error"_s, {Color::Primer::Light::dangerFg, Color::Primer::Dark::dangerFg}},
{u"PiecesBar.Border"_s, {{}, {}}},
{u"PiecesBar.Piece"_s, {{}, {}}},
{u"PiecesBar.PartialPiece"_s, {{}, {}}},
{u"PiecesBar.MissingPiece"_s, {{}, {}}}
}; };
} }