Browse Source

- Selected filter is now restored on startup

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
a0beccc04b
  1. 6
      src/GUI.cpp
  2. 28
      src/TransferListFiltersWidget.h

6
src/GUI.cpp

@ -139,11 +139,11 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis @@ -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);

28
src/TransferListFiltersWidget.h

@ -4,10 +4,17 @@ @@ -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: @@ -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

Loading…
Cancel
Save