From 8618f13b7a9e14017f7f82fde3293effbec1f45e Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 31 Jan 2010 15:11:15 +0000 Subject: [PATCH] - Created "Advanced settings" tab in program preferences and moved "Disk cache" there --- src/Icons/oxygen/gear32.png | Bin 0 -> 1836 bytes src/advancedsettings.h | 64 ++++++++++++++++++++ src/icons.qrc | 1 + src/options_imp.cpp | 15 ++++- src/options_imp.h | 2 + src/preferences.h | 9 ++- src/src.pro | 3 +- src/ui/options.ui | 114 +++++++++++++++++++----------------- 8 files changed, 149 insertions(+), 59 deletions(-) create mode 100644 src/Icons/oxygen/gear32.png create mode 100644 src/advancedsettings.h diff --git a/src/Icons/oxygen/gear32.png b/src/Icons/oxygen/gear32.png new file mode 100644 index 0000000000000000000000000000000000000000..4d9a9dc4a3a4d3181ae0db3c96d0f540d19fd7fd GIT binary patch literal 1836 zcmV+{2h;e8P)o&RpD`V#}HrTo2&@tB0(Qb1G#x@2+*x~j4 zVN1H=w6w{S|JV0>-sgG$|L^#Oh&(p*_q1ZF;x#~#cV!Z*4uka z0BvI9 zva|CtIy!nrFgbO~dR1dDD<&#tA3d7Y;w^wSG5X-ZB~C6HXa!Tiv|oPNoijWGLjf3i)4OxuH5`}Ze1@7}#9!GK&eyn1NkLHpkd2+7Q}B2$!o}e*Srvgoj5-M8pPJvnCqQCPp8eF*%)` zH^pKpx{4;+c;JPnZvihDjVI3a^z_SkC@Lx!gJG*|+O%DwqqoVrb(2ygEME&%jV6o^5c)c$@=x1M#IA+YL+h#`*P8u zMXvzb#OQ+qmmGf`wDG_TPrQ96V2I+Kg$tJ+cey&Hz5NE@lgY2Y?$OU1r{>Xvk&$bc zj5nj{g9Dcwa=kieqKyY$-iheH^G(~nea{KEyGy(<8qKm}#~-qFYwW1O@U6#ue87QA z4!OQsXyf6#GkV|tIZst@WMrIT7z8+-?Q-Bivc$#3%a$!aRgn+~;F3cw8eToL@xTjD zyeVKxUS4Tge*W2dT_%p&+Qt!wqfNl2OAa}5Btv(=1c`~+9u{Z;aLFMT4X+;Bc;JO6 z-W2d=K|!@tRyOE*Zq_B}lE%h=V6!#oXFRSO%HiRdn3&K&3xG=wxoCLx(8dEVJn^Q0 zxhX06;zep|fn;W$k&`FO`iKFx~@WXa_m@EWuOJX)f~-j5tFI-p%&VB;DsmN{>yOsk|mKQqp?sE z3M4(fSXx`V#BRSP<>ghQ7EA6I|7Q*dE;(&&U0S$Rizt$`v_e4}58q|zf6ogw7=B2~ z$SBbacWHm35)2A!-5IHA#c@?^pn)U9-!P2L*xq0;b`HD)b)f$$Yn;Qyf6Qd6f z+{>4pQdn56Iu$%ALg!MMepQPNFaN`6YFymGVm>=>pPhYHNVHmOrMS38N=t2W^{Pt- z1_pIc@7Jr=P2FJHbXheG1KPysgVWUH)*-u~=Ruw3*6Wh1lAN4!ieOmvJUCd4r*8oh zXU&@Zd17MD5TwJ0&G(|BzITm2kI227P-mF8=BF)V%onW1E<3_Il+SjhNvSReBIE6yN#fwdPPgre13(bg#b$Q|8 zUz_m4(|;09;A-u;`A+g&pBC)c@q1%K!?lM7PG>8Z4qY98s&R*&be+PJ|JSd#DbKC@ ze!C9Yb=kQyt`QBi&_o*#yaKtDJ~e;-{I|=>YVJ^g!{NeA$N7f7bTulD zxzMczJSbL&uI>&RXa#dCo}8L$O4rY>=DfLEmM&eEyJ3T&#Aq~jxZUoNfq?-5wA0ek zIt+%5CCipA%XPckDT1${>pwFctzZgxaoe_?DK#}0hxqIX35V<&<89bJKS)YSy3*Iz zCxA9F`rsTolxSy2>g(-8v9Y^S&jq*&`(A3n_3d{j* zV)Vg*8y}xgK`t6-J#GR1SG7>DxhFndhan$xK${qS-Xh5Hy?O;uK;ZDq>bDf10@}oa a(fS)`!CPK_>KDoY0000 +#include +#include +#include "preferences.h" + +enum AdvSettingsCols {PROPERTY, VALUE}; +enum AdvSettingsRows {DISK_CACHE}; +#define ROW_COUNT 1 +enum AdvValueTYPE {UINT=1001}; + +class AdvancedSettings: public QTableWidget { + Q_OBJECT + +private: + QSpinBox *spin_cache; + +public: + AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { + // Set visual appearance + setColumnCount(2); + QStringList header; + header << tr("Property") << tr("Value"); + setHorizontalHeaderLabels(header); + setColumnWidth(0, width()/2); + horizontalHeader()->setStretchLastSection(true); + setRowCount(ROW_COUNT); + // Load settings + loadAdvancedSettings(); + } + + ~AdvancedSettings() { + delete spin_cache; + } + + public slots: + void saveAdvancedSettings() { + // Disk cache + Preferences::setDiskCacheSize(spin_cache->value()); + } + +protected slots: + void loadAdvancedSettings() { + // Disk write cache + setItem(DISK_CACHE, PROPERTY, new QTableWidgetItem(tr("Disk write cache size (MiB)"), UINT)); + spin_cache = new QSpinBox(); + connect(spin_cache, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged())); + spin_cache->setMinimum(1); + spin_cache->setMaximum(200); + spin_cache->setValue(Preferences::diskCacheSize()); + setCellWidget(DISK_CACHE, VALUE, spin_cache); + } + + void emitSettingsChanged() { + emit settingsChanged(); + } + +signals: + void settingsChanged(); +}; + +#endif // ADVANCEDSETTINGS_H diff --git a/src/icons.qrc b/src/icons.qrc index e875a45e8..7b5c31814 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -149,6 +149,7 @@ Icons/oxygen/encrypted.png Icons/oxygen/edit_clear.png Icons/oxygen/download.png + Icons/oxygen/gear32.png Icons/oxygen/gear.png Icons/oxygen/remove.png Icons/oxygen/dialog-warning.png diff --git a/src/options_imp.cpp b/src/options_imp.cpp index b0ed8bd40..4c9c345e7 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -55,6 +55,7 @@ #include "options_imp.h" #include "preferences.h" #include "misc.h" +#include "advancedsettings.h" // Constructor options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -199,7 +200,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(checkAppendLabel, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkAppendqB, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkPreallocateAll, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); - connect(spinCache, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkStartPaused, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkScanDir, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); @@ -283,6 +283,12 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ #ifndef LIBTORRENT_0_15 checkAppendqB->setVisible(false); #endif + // Load Advanced settings + QVBoxLayout *adv_layout = new QVBoxLayout(); + advancedSettings = new AdvancedSettings(); + adv_layout->addWidget(advancedSettings); + scrollArea_advanced->setLayout(adv_layout); + connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton())); // Adapt size loadWindowState(); show(); @@ -291,6 +297,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ // Main destructor options_imp::~options_imp(){ qDebug("-> destructing Options"); + delete scrollArea_advanced->layout(); + delete advancedSettings; } void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous) { @@ -393,7 +401,6 @@ void options_imp::saveOptions(){ settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked()); #endif settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles()); - settings.setValue(QString::fromUtf8("DiskCache"), spinCache->value()); settings.setValue(QString::fromUtf8("AdditionDialog"), useAdditionDialog()); settings.setValue(QString::fromUtf8("StartInPause"), addTorrentsInPause()); settings.setValue(QString::fromUtf8("ScanDir"), getScanDir()); @@ -518,6 +525,9 @@ void options_imp::saveOptions(){ settings.endGroup(); // End preferences settings.endGroup(); + + // Save advanced settings + advancedSettings->saveAdvancedSettings(); } bool options_imp::isFilteringEnabled() const{ @@ -617,7 +627,6 @@ void options_imp::loadOptions(){ checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension()); #endif checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles()); - spinCache->setValue(Preferences::diskCacheSize()); checkAdditionDialog->setChecked(Preferences::useAdditionDialog()); checkStartPaused->setChecked(Preferences::addTorrentsInPause()); strValue = Preferences::getScanDir(); diff --git a/src/options_imp.h b/src/options_imp.h index 7544acf8a..e9cedc91e 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -42,6 +42,7 @@ enum DoubleClickAction {TOGGLE_PAUSE, OPEN_DEST}; using namespace libtorrent; class QCloseEvent; +class AdvancedSettings; class options_imp : public QDialog, private Ui_Preferences { Q_OBJECT @@ -50,6 +51,7 @@ private: QButtonGroup choiceLanguage; QStringList locales; QAbstractButton *applyButton; + AdvancedSettings *advancedSettings; public: // Contructor / Destructor diff --git a/src/preferences.h b/src/preferences.h index c65229f7d..06b016dc7 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -181,9 +181,14 @@ public: return settings.setValue(QString::fromUtf8("Preferences/Downloads/PreAllocation"), enabled); } - static int diskCacheSize() { + static uint diskCacheSize() { QSettings settings("qBittorrent", "qBittorrent"); - return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toInt(); + return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt(); + } + + static void setDiskCacheSize(uint size) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Downloads/DiskCache"), size); } static bool useAdditionDialog() { diff --git a/src/src.pro b/src/src.pro index ba2ff159b..31a621921 100644 --- a/src/src.pro +++ b/src/src.pro @@ -249,7 +249,8 @@ contains(DEFINES, DISABLE_GUI) { downloadfromurldlg.h \ torrentadditiondlg.h \ trackerlogin.h \ - pieceavailabilitybar.h + pieceavailabilitybar.h \ + advancedsettings.h } !contains(DEFINES, DISABLE_GUI) { diff --git a/src/ui/options.ui b/src/ui/options.ui index 0f75e61fa..f63567a83 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -219,6 +219,15 @@ ItemIsSelectable|ItemIsEnabled + + + Advanced + + + + :/Icons/oxygen/gear32.png:/Icons/oxygen/gear32.png + + @@ -629,7 +638,7 @@ QGroupBox { 0 0 644 - 583 + 548 @@ -868,50 +877,6 @@ QGroupBox { - - - - - - Disk cache: - - - - - - - 1 - - - 9999 - - - 16 - - - - - - - MiB (advanced) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -1436,8 +1401,8 @@ QGroupBox { 0 0 - 366 - 332 + 620 + 490 @@ -1841,8 +1806,8 @@ QGroupBox { 0 0 - 466 - 415 + 620 + 490 @@ -2258,8 +2223,8 @@ QGroupBox { 0 0 - 484 - 312 + 620 + 490 @@ -2692,8 +2657,8 @@ QGroupBox { 0 0 - 290 - 124 + 620 + 490 @@ -3119,6 +3084,49 @@ QGroupBox { + + + + + + true + + + + + 0 + 0 + 620 + 490 + + + + + + + true + + + true + + + + Parameter + + + + + Value + + + + + + + + + +