Browse Source

- Created "Advanced settings" tab in program preferences and moved "Disk cache" there

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
8618f13b7a
  1. BIN
      src/Icons/oxygen/gear32.png
  2. 64
      src/advancedsettings.h
  3. 1
      src/icons.qrc
  4. 15
      src/options_imp.cpp
  5. 2
      src/options_imp.h
  6. 9
      src/preferences.h
  7. 3
      src/src.pro
  8. 114
      src/ui/options.ui

BIN
src/Icons/oxygen/gear32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

64
src/advancedsettings.h

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
#ifndef ADVANCEDSETTINGS_H
#define ADVANCEDSETTINGS_H
#include <QTableWidget>
#include <QHeaderView>
#include <QSpinBox>
#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

1
src/icons.qrc

@ -149,6 +149,7 @@ @@ -149,6 +149,7 @@
<file>Icons/oxygen/encrypted.png</file>
<file>Icons/oxygen/edit_clear.png</file>
<file>Icons/oxygen/download.png</file>
<file>Icons/oxygen/gear32.png</file>
<file>Icons/oxygen/gear.png</file>
<file>Icons/oxygen/remove.png</file>
<file>Icons/oxygen/dialog-warning.png</file>

15
src/options_imp.cpp

@ -55,6 +55,7 @@ @@ -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){ @@ -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){ @@ -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){ @@ -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(){ @@ -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(){ @@ -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(){ @@ -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();

2
src/options_imp.h

@ -42,6 +42,7 @@ enum DoubleClickAction {TOGGLE_PAUSE, OPEN_DEST}; @@ -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: @@ -50,6 +51,7 @@ private:
QButtonGroup choiceLanguage;
QStringList locales;
QAbstractButton *applyButton;
AdvancedSettings *advancedSettings;
public:
// Contructor / Destructor

9
src/preferences.h

@ -181,9 +181,14 @@ public: @@ -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() {

3
src/src.pro

@ -249,7 +249,8 @@ contains(DEFINES, DISABLE_GUI) { @@ -249,7 +249,8 @@ contains(DEFINES, DISABLE_GUI) {
downloadfromurldlg.h \
torrentadditiondlg.h \
trackerlogin.h \
pieceavailabilitybar.h
pieceavailabilitybar.h \
advancedsettings.h
}
!contains(DEFINES, DISABLE_GUI) {

114
src/ui/options.ui

@ -219,6 +219,15 @@ @@ -219,6 +219,15 @@
<set>ItemIsSelectable|ItemIsEnabled</set>
</property>
</item>
<item>
<property name="text">
<string>Advanced</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/gear32.png</normaloff>:/Icons/oxygen/gear32.png</iconset>
</property>
</item>
</widget>
</item>
<item>
@ -629,7 +638,7 @@ QGroupBox { @@ -629,7 +638,7 @@ QGroupBox {
<x>0</x>
<y>0</y>
<width>644</width>
<height>583</height>
<height>548</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
@ -868,50 +877,6 @@ QGroupBox { @@ -868,50 +877,6 @@ QGroupBox {
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Disk cache:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinCache">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>MiB (advanced)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -1436,8 +1401,8 @@ QGroupBox { @@ -1436,8 +1401,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>366</width>
<height>332</height>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
@ -1841,8 +1806,8 @@ QGroupBox { @@ -1841,8 +1806,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>466</width>
<height>415</height>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
@ -2258,8 +2223,8 @@ QGroupBox { @@ -2258,8 +2223,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>312</height>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
@ -2692,8 +2657,8 @@ QGroupBox { @@ -2692,8 +2657,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>290</width>
<height>124</height>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -3119,6 +3084,49 @@ QGroupBox { @@ -3119,6 +3084,49 @@ QGroupBox {
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_35">
<item>
<widget class="QScrollArea" name="scrollArea_advanced">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_10">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36">
<item>
<widget class="QTableWidget" name="tableWidget">
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Parameter</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

Loading…
Cancel
Save