From a0beccc04bc01073ac5993441af6571a13ba5a29 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 8 Nov 2009 12:35:12 +0000 Subject: [PATCH] - Selected filter is now restored on startup --- src/GUI.cpp | 6 +++--- src/TransferListFiltersWidget.h | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 94f29925f..fe4b0ec40 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -139,11 +139,11 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis vSplitter = new QSplitter(Qt::Horizontal); // Transfer List tab - transferListFilters = new TransferListFiltersWidget(vSplitter); - vSplitter->addWidget(transferListFilters); transferList = new TransferListWidget(vSplitter, BTSession); - vSplitter->addWidget(transferList); + transferListFilters = new TransferListFiltersWidget(vSplitter, transferList); + vSplitter->addWidget(transferListFilters); + vSplitter->addWidget(transferList); tabs->addTab(vSplitter, QIcon(QString::fromUtf8(":/Icons/oxygen/folder-remote.png")), tr("Transfers")); vboxLayout->addWidget(tabs); diff --git a/src/TransferListFiltersWidget.h b/src/TransferListFiltersWidget.h index db05a423f..746f9c714 100644 --- a/src/TransferListFiltersWidget.h +++ b/src/TransferListFiltersWidget.h @@ -4,10 +4,17 @@ #include #include #include +#include + +#include "TransferListWidget.h" class TransferListFiltersWidget: public QListWidget { + +private: + TransferListWidget *transferList; + public: - TransferListFiltersWidget(QWidget *parent): QListWidget(parent) { + TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList): QListWidget(parent), transferList(transferList) { // Add filters QListWidgetItem *all = new QListWidgetItem(this); all->setData(Qt::DisplayRole, tr("All")); @@ -24,7 +31,26 @@ public: QListWidgetItem *inactive = new QListWidgetItem(this); inactive->setData(Qt::DisplayRole, tr("Inactive")); inactive->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/draw-rectangle.png")); + // Load settings + loadSettings(); + } + + ~TransferListFiltersWidget() { + saveSettings(); } + + void saveSettings() const { + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.beginGroup(QString::fromUtf8("TransferListFilters")); + settings.setValue("selectedFilterIndex", QVariant(currentRow())); + } + + void loadSettings() { + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.beginGroup(QString::fromUtf8("TransferListFilters")); + setCurrentRow(settings.value("selectedFilterIndex", 0).toInt()); + } + }; #endif // TRANSFERLISTFILTERSWIDGET_H