Add "Paused torrents only" option for "Hide zero and infinity values"

This commit is contained in:
Chocobo1 2016-02-01 20:19:28 +08:00
parent 1a010cbfc6
commit ee277bf126
5 changed files with 59 additions and 7 deletions

View File

@ -283,6 +283,16 @@ void Preferences::setHideZeroValues(bool b)
setValue("Preferences/General/HideZeroValues", b);
}
int Preferences::getHideZeroComboValues() const
{
return value("Preferences/General/HideZeroComboValues", 0).toInt();
}
void Preferences::setHideZeroComboValues(int n)
{
setValue("Preferences/General/HideZeroComboValues", n);
}
bool Preferences::useRandomPort() const
{
return value("Preferences/General/UseRandomPort", false).toBool();

View File

@ -134,6 +134,8 @@ public:
void setAlternatingRowColors(bool b);
bool getHideZeroValues() const;
void setHideZeroValues(bool b);
int getHideZeroComboValues() const;
void setHideZeroComboValues(int n);
bool useRandomPort() const;
void setRandomPort(bool b);
bool systrayIntegration() const;

View File

@ -163,7 +163,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>698</height>
<height>702</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@ -258,11 +258,42 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkHideZero">
<property name="text">
<string>Hide zero and infinity values</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkHideZero">
<property name="text">
<string>Hide zero and infinity values</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboHideZero">
<item>
<property name="text">
<string>Always</string>
</property>
</item>
<item>
<property name="text">
<string>Paused torrents only</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">

View File

@ -142,6 +142,7 @@ options_imp::options_imp(QWidget *parent)
connect(confirmDeletion, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkAltRowColors, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkHideZero, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(comboHideZero, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(checkShowSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkCloseToSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMinimizeToSysTray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -394,6 +395,7 @@ void options_imp::saveOptions()
pref->setConfirmTorrentDeletion(confirmDeletion->isChecked());
pref->setAlternatingRowColors(checkAltRowColors->isChecked());
pref->setHideZeroValues(checkHideZero->isChecked());
pref->setHideZeroComboValues(comboHideZero->currentIndex());
pref->setSystrayIntegration(systrayIntegration());
pref->setTrayIconStyle(TrayIcon::Style(comboTrayIcon->currentIndex()));
pref->setCloseToTray(closeToTray());
@ -576,6 +578,7 @@ void options_imp::loadOptions()
confirmDeletion->setChecked(pref->confirmTorrentDeletion());
checkAltRowColors->setChecked(pref->useAlternatingRowColors());
checkHideZero->setChecked(pref->getHideZeroValues());
comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
checkShowSplash->setChecked(!pref->isSplashScreenDisabled());
checkStartMinimized->setChecked(pref->startMinimized());

View File

@ -59,7 +59,13 @@ TransferListDelegate::TransferListDelegate(QObject *parent)
void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
painter->save();
const bool hideValues = Preferences::instance()->getHideZeroValues();
bool isHideState = true;
if (Preferences::instance()->getHideZeroComboValues() == 1) { // paused torrents only
QModelIndex stateIndex = index.sibling(index.row(), TorrentModel::TR_STATUS);
if (stateIndex.data().toInt() != BitTorrent::TorrentState::PausedDownloading)
isHideState = false;
}
const bool hideValues = Preferences::instance()->getHideZeroValues() & isHideState;
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
QItemDelegate::drawBackground(painter, opt, index);