mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
add new color coded progress bar option
This commit is contained in:
parent
f11abd493b
commit
85f883d5ac
5 changed files with 35 additions and 1 deletions
|
@ -186,6 +186,19 @@ void Preferences::setAlternatingRowColors(const bool b)
|
||||||
setValue(u"Preferences/General/AlternatingRowColors"_s, b);
|
setValue(u"Preferences/General/AlternatingRowColors"_s, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Preferences::useColorCodedProgressBar() const
|
||||||
|
{
|
||||||
|
return value(u"Preferences/General/ColorCodedProgressBar"_s, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setColorCodedProgressBar(const bool b)
|
||||||
|
{
|
||||||
|
if (b == useColorCodedProgressBar())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setValue(u"Preferences/General/ColorCodedProgressBar"_s, b);
|
||||||
|
}
|
||||||
|
|
||||||
bool Preferences::getHideZeroValues() const
|
bool Preferences::getHideZeroValues() const
|
||||||
{
|
{
|
||||||
return value(u"Preferences/General/HideZeroValues"_s, false);
|
return value(u"Preferences/General/HideZeroValues"_s, false);
|
||||||
|
|
|
@ -113,6 +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 useColorCodedProgressBar() const;
|
||||||
|
void setColorCodedProgressBar(bool b);
|
||||||
bool getHideZeroValues() const;
|
bool getHideZeroValues() const;
|
||||||
void setHideZeroValues(bool b);
|
void setHideZeroValues(bool b);
|
||||||
int getHideZeroComboValues() const;
|
int getHideZeroComboValues() const;
|
||||||
|
|
|
@ -261,6 +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->colorCodedProgressBar->setChecked(pref->useColorCodedProgressBar());
|
||||||
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());
|
||||||
|
@ -389,6 +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->colorCodedProgressBar, &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);
|
||||||
|
@ -483,6 +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->setColorCodedProgressBar(m_ui->colorCodedProgressBar->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());
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="colorCodedProgressBar">
|
||||||
|
<property name="text">
|
||||||
|
<string extracomment="Progress bar color is based on torrent state.">Use color-coded progress bar</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "transferlistmodel.h"
|
#include "transferlistmodel.h"
|
||||||
|
#include "base/preferences.h"
|
||||||
|
|
||||||
TransferListDelegate::TransferListDelegate(QObject *parent)
|
TransferListDelegate::TransferListDelegate(QObject *parent)
|
||||||
: QStyledItemDelegate {parent}
|
: QStyledItemDelegate {parent}
|
||||||
|
@ -90,7 +91,12 @@ 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));
|
||||||
|
|
||||||
const QColor color = index.data(Qt::ForegroundRole).value<QColor>();
|
QColor color = {};
|
||||||
|
|
||||||
|
if (Preferences::instance()->useColorCodedProgressBar())
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue