Apply suggestions from code review

apply code review suggestions

Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This commit is contained in:
Mark Yu 2025-07-10 14:32:22 -04:00 committed by GitHub
commit 1e2d85a2d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 18 deletions

View file

@ -186,17 +186,17 @@ void Preferences::setAlternatingRowColors(const bool b)
setValue(u"Preferences/General/AlternatingRowColors"_s, b); setValue(u"Preferences/General/AlternatingRowColors"_s, b);
} }
bool Preferences::useProgressBarFollowTextColor() const bool Preferences::getProgressBarFollowsTextColor() const
{ {
return value(u"Preferences/General/ProgressBarFollowTextColor"_s, false); return value(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, false);
} }
void Preferences::setProgressBarFollowTextColor(const bool b) void Preferences::setProgressBarFollowsTextColor(const bool value)
{ {
if (b == useProgressBarFollowTextColor()) if (value == getProgressBarFollowsTextColor())
return; return;
setValue(u"Preferences/General/ProgressBarFollowTextColor"_s, b); setValue(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, value);
} }
bool Preferences::getHideZeroValues() const bool Preferences::getHideZeroValues() const

View file

@ -113,8 +113,8 @@ public:
void showSpeedInTitleBar(bool show); void showSpeedInTitleBar(bool show);
bool useAlternatingRowColors() const; bool useAlternatingRowColors() const;
void setAlternatingRowColors(bool b); void setAlternatingRowColors(bool b);
bool useProgressBarFollowTextColor() const; bool getProgressBarFollowsTextColor() const;
void setProgressBarFollowTextColor(bool b); void setProgressBarFollowsTextColor(bool value);
bool getHideZeroValues() const; bool getHideZeroValues() const;
void setHideZeroValues(bool b); void setHideZeroValues(bool b);
int getHideZeroComboValues() const; int getHideZeroComboValues() const;

View file

@ -261,7 +261,7 @@ void OptionsDialog::loadBehaviorTabOptions()
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion()); m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors()); m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
m_ui->progressBarFollowTextColor->setChecked(pref->useProgressBarFollowTextColor()); m_ui->checkProgressBarFollowsTextColor->setChecked(pref->getProgressBarFollowsTextColor());
m_ui->checkHideZero->setChecked(pref->getHideZeroValues()); m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues()); m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked()); m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked());
@ -390,7 +390,7 @@ void OptionsDialog::loadBehaviorTabOptions()
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->progressBarFollowTextColor, &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, m_ui->comboHideZero, &QWidget::setEnabled);
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->comboHideZero, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->comboHideZero, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
@ -485,7 +485,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked()); pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked()); pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
pref->setProgressBarFollowTextColor(m_ui->progressBarFollowTextColor->isChecked()); pref->setProgressBarFollowsTextColor(m_ui->checkProgressBarFollowsTextColor->isChecked());
pref->setHideZeroValues(m_ui->checkHideZero->isChecked()); pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex()); pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());

View file

@ -298,7 +298,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="progressBarFollowTextColor"> <widget class="QCheckBox" name="checkProgressBarFollowTextColor">
<property name="text"> <property name="text">
<string extracomment="Progress bar color is based on text color.">Make progress bars follow text colors</string> <string extracomment="Progress bar color is based on text color.">Make progress bars follow text colors</string>
</property> </property>

View file

@ -30,8 +30,8 @@
#include <QModelIndex> #include <QModelIndex>
#include "transferlistmodel.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "transferlistmodel.h"
TransferListDelegate::TransferListDelegate(QObject *parent) TransferListDelegate::TransferListDelegate(QObject *parent)
: QStyledItemDelegate {parent} : QStyledItemDelegate {parent}
@ -91,12 +91,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QStyleOptionViewItem customOption {option}; QStyleOptionViewItem customOption {option};
customOption.state.setFlag(QStyle::State_Enabled, isEnableState(torrentState)); customOption.state.setFlag(QStyle::State_Enabled, isEnableState(torrentState));
QColor color = {}; const QColor color = Preferences::instance()->getProgressBarFollowsTextColor() ? index.data(Qt::ForegroundRole).value<QColor>() : QColor();
if (Preferences::instance()->useProgressBarFollowTextColor())
{
color = index.data(Qt::ForegroundRole).value<QColor>();
}
m_progressBarPainter.paint(painter, customOption, index.data().toString(), progress, color); m_progressBarPainter.paint(painter, customOption, index.data().toString(), progress, color);
} }