diff --git a/src/Icons/oxygen/gear32.png b/src/Icons/oxygen/gear32.png new file mode 100644 index 000000000..4d9a9dc4a Binary files /dev/null and b/src/Icons/oxygen/gear32.png differ diff --git a/src/advancedsettings.h b/src/advancedsettings.h new file mode 100644 index 000000000..8b1cbdea1 --- /dev/null +++ b/src/advancedsettings.h @@ -0,0 +1,64 @@ +#ifndef ADVANCEDSETTINGS_H +#define ADVANCEDSETTINGS_H + +#include +#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 + + + + + + + + + +