mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -06:00
Compare commits
2 Commits
f5a93be544
...
b18a964a0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b18a964a0b | ||
|
|
9fc7bd938f |
@@ -186,6 +186,19 @@ void Preferences::setAlternatingRowColors(const bool b)
|
||||
setValue(u"Preferences/General/AlternatingRowColors"_s, b);
|
||||
}
|
||||
|
||||
bool Preferences::getProgressBarFollowsTextColor() const
|
||||
{
|
||||
return value(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setProgressBarFollowsTextColor(const bool value)
|
||||
{
|
||||
if (value == getProgressBarFollowsTextColor())
|
||||
return;
|
||||
|
||||
setValue(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, value);
|
||||
}
|
||||
|
||||
bool Preferences::getHideZeroValues() const
|
||||
{
|
||||
return value(u"Preferences/General/HideZeroValues"_s, false);
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
void showSpeedInTitleBar(bool show);
|
||||
bool useAlternatingRowColors() const;
|
||||
void setAlternatingRowColors(bool b);
|
||||
bool getProgressBarFollowsTextColor() const;
|
||||
void setProgressBarFollowsTextColor(bool value);
|
||||
bool getHideZeroValues() const;
|
||||
void setHideZeroValues(bool b);
|
||||
int getHideZeroComboValues() const;
|
||||
|
||||
@@ -261,6 +261,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
||||
|
||||
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
|
||||
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
|
||||
m_ui->checkProgressBarFollowsTextColor->setChecked(pref->getProgressBarFollowsTextColor());
|
||||
m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
|
||||
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
|
||||
m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked());
|
||||
@@ -389,6 +390,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
||||
|
||||
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkProgressBarFollowsTextColor, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkHideZero, &QAbstractButton::toggled, m_ui->comboHideZero, &QWidget::setEnabled);
|
||||
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->comboHideZero, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
@@ -483,6 +485,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
||||
|
||||
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
|
||||
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
|
||||
pref->setProgressBarFollowsTextColor(m_ui->checkProgressBarFollowsTextColor->isChecked());
|
||||
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
|
||||
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());
|
||||
|
||||
|
||||
@@ -297,6 +297,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkProgressBarFollowsTextColor">
|
||||
<property name="text">
|
||||
<string extracomment="Progress bar color is based on text color.">Make progress bars follow text colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
||||
@@ -54,7 +54,7 @@ ProgressBarPainter::ProgressBarPainter(QObject *parent)
|
||||
connect(UIThemeManager::instance(), &UIThemeManager::themeChanged, this, &ProgressBarPainter::applyUITheme);
|
||||
}
|
||||
|
||||
void ProgressBarPainter::paint(QPainter *painter, const QStyleOptionViewItem &option, const QString &text, const int progress) const
|
||||
void ProgressBarPainter::paint(QPainter *painter, const QStyleOptionViewItem &option, const QString &text, const int progress, const QColor &color) const
|
||||
{
|
||||
QStyleOptionProgressBar styleOption;
|
||||
styleOption.initFrom(&m_dummyProgressBar);
|
||||
@@ -65,15 +65,21 @@ void ProgressBarPainter::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
styleOption.text = text;
|
||||
styleOption.textVisible = true;
|
||||
// QStyleOption fields
|
||||
styleOption.rect = option.rect;
|
||||
styleOption.rect = option.rect.adjusted(0, 1, 0, -1);
|
||||
// Qt 6 requires QStyle::State_Horizontal to be set for correctly drawing horizontal progress bar
|
||||
styleOption.state = option.state | QStyle::State_Horizontal;
|
||||
|
||||
const bool isEnabled = option.state.testFlag(QStyle::State_Enabled);
|
||||
styleOption.palette.setCurrentColorGroup(isEnabled ? QPalette::Active : QPalette::Disabled);
|
||||
|
||||
if (m_chunkColor.isValid())
|
||||
if (color.isValid())
|
||||
{
|
||||
styleOption.palette.setColor(QPalette::Highlight, color);
|
||||
}
|
||||
else if (m_chunkColor.isValid())
|
||||
{
|
||||
styleOption.palette.setColor(QPalette::Highlight, m_chunkColor);
|
||||
}
|
||||
|
||||
painter->save();
|
||||
const QStyle *style = m_dummyProgressBar.style();
|
||||
|
||||
@@ -43,7 +43,7 @@ class ProgressBarPainter : public QObject
|
||||
public:
|
||||
explicit ProgressBarPainter(QObject *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QString &text, int progress) const;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QString &text, int progress, const QColor &color = {}) const;
|
||||
|
||||
private:
|
||||
void applyUITheme();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <QModelIndex>
|
||||
|
||||
#include "base/preferences.h"
|
||||
#include "transferlistmodel.h"
|
||||
|
||||
TransferListDelegate::TransferListDelegate(QObject *parent)
|
||||
@@ -90,7 +91,9 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
QStyleOptionViewItem customOption {option};
|
||||
customOption.state.setFlag(QStyle::State_Enabled, isEnableState(torrentState));
|
||||
|
||||
m_progressBarPainter.paint(painter, customOption, index.data().toString(), progress);
|
||||
const QColor color = Preferences::instance()->getProgressBarFollowsTextColor() ? index.data(Qt::ForegroundRole).value<QColor>() : QColor();
|
||||
|
||||
m_progressBarPainter.paint(painter, customOption, index.data().toString(), progress, color);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user