From d79297db1a6fb39e2cad02d23284c2c268369b77 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sun, 22 Jan 2017 14:59:03 +0300 Subject: [PATCH] Save/load category filter widget state --- src/gui/categoryfilterwidget.cpp | 1 + src/gui/transferlistfilterswidget.cpp | 8 +++++++- src/gui/transferlistfilterswidget.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/categoryfilterwidget.cpp b/src/gui/categoryfilterwidget.cpp index 536086fe6..dd4ffe47a 100644 --- a/src/gui/categoryfilterwidget.cpp +++ b/src/gui/categoryfilterwidget.cpp @@ -78,6 +78,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent) setAttribute(Qt::WA_MacShowFocusRect, false); #endif setContextMenuPolicy(Qt::CustomContextMenu); + setCurrentIndex(model()->index(0, 0)); connect(this, SIGNAL(collapsed(QModelIndex)), SLOT(callUpdateGeometry())); connect(this, SIGNAL(expanded(QModelIndex)), SLOT(callUpdateGeometry())); diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index b3c86b002..d99185dd0 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -580,7 +580,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi , transferList, SLOT(startVisibleTorrents())); connect(m_categoryFilterWidget, SIGNAL(categoryChanged(QString)) , transferList, SLOT(applyCategoryFilter(QString))); - onCategoryFilterStateChanged(pref->getCategoryFilterState()); + toggleCategoryFilter(pref->getCategoryFilterState()); frameLayout->addWidget(m_categoryFilterWidget); QCheckBox *trackerLabel = new QCheckBox(tr("Trackers"), this); @@ -638,6 +638,12 @@ void TransferListFiltersWidget::trackerError(BitTorrent::TorrentHandle *const to } void TransferListFiltersWidget::onCategoryFilterStateChanged(bool enabled) +{ + toggleCategoryFilter(enabled); + Preferences::instance()->setCategoryFilterState(enabled); +} + +void TransferListFiltersWidget::toggleCategoryFilter(bool enabled) { m_categoryFilterWidget->setVisible(enabled); m_transferList->applyCategoryFilter(enabled ? m_categoryFilterWidget->currentCategory() : QString()); diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index 8f1638673..b2b7ad0f5 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -162,6 +162,8 @@ private slots: void onCategoryFilterStateChanged(bool enabled); private: + void toggleCategoryFilter(bool enabled); + TransferListWidget *m_transferList; TrackerFiltersList *m_trackerFilters; CategoryFilterWidget *m_categoryFilterWidget;