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. 43
      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)
setValue("Preferences/General/HideZeroValues", 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 bool Preferences::useRandomPort() const
{ {
return value("Preferences/General/UseRandomPort", false).toBool(); return value("Preferences/General/UseRandomPort", false).toBool();

2
src/base/preferences.h

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

43
src/gui/options.ui

@ -163,7 +163,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>480</width> <width>480</width>
<height>698</height> <height>702</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
@ -258,11 +258,42 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkHideZero"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="text"> <item>
<string>Hide zero and infinity values</string> <widget class="QCheckBox" name="checkHideZero">
</property> <property name="text">
</widget> <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>
<item> <item>
<widget class="QGroupBox" name="groupBox_7"> <widget class="QGroupBox" name="groupBox_7">

3
src/gui/options_imp.cpp

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

8
src/gui/transferlistdelegate.cpp

@ -59,7 +59,13 @@ TransferListDelegate::TransferListDelegate(QObject *parent)
void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{ {
painter->save(); 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); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);

Loading…
Cancel
Save