- Selected filter is now restored on startup

This commit is contained in:
Christophe Dumez 2009-11-08 12:35:12 +00:00
parent 6b6181a3ee
commit a0beccc04b
2 changed files with 30 additions and 4 deletions

View file

@ -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);

View file

@ -4,10 +4,17 @@
#include <QListWidget>
#include <QListWidgetItem>
#include <QIcon>
#include <QSettings>
#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