Browse Source

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

adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
ee277bf126
  1. 10
      src/base/preferences.cpp
  2. 2
      src/base/preferences.h
  3. 33
      src/gui/options.ui
  4. 3
      src/gui/options_imp.cpp
  5. 8
      src/gui/transferlistdelegate.cpp

10
src/base/preferences.cpp

@ -283,6 +283,16 @@ void Preferences::setHideZeroValues(bool b) @@ -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();

2
src/base/preferences.h

@ -134,6 +134,8 @@ public: @@ -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;

33
src/gui/options.ui

@ -163,7 +163,7 @@ @@ -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">
@ -257,6 +257,8 @@ @@ -257,6 +257,8 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkHideZero">
<property name="text">
@ -264,6 +266,35 @@ @@ -264,6 +266,35 @@
</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">
<property name="font">

3
src/gui/options_imp.cpp

@ -142,6 +142,7 @@ options_imp::options_imp(QWidget *parent) @@ -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() @@ -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() @@ -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());

8
src/gui/transferlistdelegate.cpp

@ -59,7 +59,13 @@ TransferListDelegate::TransferListDelegate(QObject *parent) @@ -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);

Loading…
Cancel
Save