From f22c2f8c7b356fe0fae099f21d362dcd36a1a2d0 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 20 Jun 2008 20:16:56 +0000 Subject: [PATCH] - Save spitters position to remember them on restart (RSS) --- src/rss.ui | 7 +++---- src/rss_imp.cpp | 25 +++++++++++++++++++++++++ src/rss_imp.h | 2 ++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/rss.ui b/src/rss.ui index 130c1e11f..3ccd424c6 100644 --- a/src/rss.ui +++ b/src/rss.ui @@ -14,7 +14,7 @@ - + Qt::Horizontal @@ -155,7 +155,7 @@ listStreams - + @@ -171,7 +171,7 @@ - + Qt::Vertical @@ -180,7 +180,6 @@ - splitter diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 3950654e5..ffc5e6b74 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -239,6 +239,26 @@ item->setData(Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png"))); updateFeedNbNews(selectedFeedUrl); } + + void RSSImp::saveSlidersPosition() { + // Remember sliders positions + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue("rss/splitter_h", splitter_h->saveState()); + settings.setValue("rss/splitter_v", splitter_v->saveState()); + qDebug("Splitters position saved"); + } + + void RSSImp::restoreSlidersPosition() { + QSettings settings("qBittorrent", "qBittorrent"); + QByteArray pos_h = settings.value("rss/splitter_h", QByteArray()).toByteArray(); + if(!pos_h.isNull()) { + splitter_h->restoreState(pos_h); + } + QByteArray pos_v = settings.value("rss/splitter_v", QByteArray()).toByteArray(); + if(!pos_v.isNull()) { + splitter_v->restoreState(pos_v); + } + } QTreeWidgetItem* RSSImp::getTreeItemFromUrl(QString url) const{ unsigned int nbItems = listStreams->topLevelItemCount(); @@ -313,6 +333,11 @@ selectFirstFeed(); // Refresh all feeds rssmanager->refreshAll(); + // Restore sliders position + restoreSlidersPosition(); + // Bind saveSliders slots + connect(splitter_v, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition())); + connect(splitter_h, SIGNAL(splitterMoved(int, int)), this, SLOT(saveSlidersPosition())); qDebug("RSSImp constructed"); } diff --git a/src/rss_imp.h b/src/rss_imp.h index 401c264e9..9f698cf2e 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -58,6 +58,8 @@ class RSSImp : public QWidget, public Ui::RSS{ void selectFirstNews(); void updateFeedNbNews(QString url); void on_actionMark_all_as_read_triggered(); + void saveSlidersPosition(); + void restoreSlidersPosition(); public: RSSImp();