Browse Source

- Save spitters position to remember them on restart (RSS)

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
f22c2f8c7b
  1. 7
      src/rss.ui
  2. 25
      src/rss_imp.cpp
  3. 2
      src/rss_imp.h

7
src/rss.ui

@ -14,7 +14,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2" > <layout class="QVBoxLayout" name="verticalLayout_2" >
<item> <item>
<widget class="QSplitter" name="splitter_2" > <widget class="QSplitter" name="splitter_h" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -155,7 +155,7 @@
<zorder>listStreams</zorder> <zorder>listStreams</zorder>
<zorder></zorder> <zorder></zorder>
</widget> </widget>
<widget class="QWidget" name="" > <widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" name="verticalLayout" >
<item> <item>
<widget class="QLabel" name="news_lbl" > <widget class="QLabel" name="news_lbl" >
@ -171,7 +171,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSplitter" name="splitter" > <widget class="QSplitter" name="splitter_v" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -180,7 +180,6 @@
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>splitter</zorder>
</widget> </widget>
</widget> </widget>
</item> </item>

25
src/rss_imp.cpp

@ -239,6 +239,26 @@
item->setData(Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png"))); item->setData(Qt::DecorationRole, QVariant(QIcon(":/Icons/sphere.png")));
updateFeedNbNews(selectedFeedUrl); 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{ QTreeWidgetItem* RSSImp::getTreeItemFromUrl(QString url) const{
unsigned int nbItems = listStreams->topLevelItemCount(); unsigned int nbItems = listStreams->topLevelItemCount();
@ -313,6 +333,11 @@
selectFirstFeed(); selectFirstFeed();
// Refresh all feeds // Refresh all feeds
rssmanager->refreshAll(); 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"); qDebug("RSSImp constructed");
} }

2
src/rss_imp.h

@ -58,6 +58,8 @@ class RSSImp : public QWidget, public Ui::RSS{
void selectFirstNews(); void selectFirstNews();
void updateFeedNbNews(QString url); void updateFeedNbNews(QString url);
void on_actionMark_all_as_read_triggered(); void on_actionMark_all_as_read_triggered();
void saveSlidersPosition();
void restoreSlidersPosition();
public: public:
RSSImp(); RSSImp();

Loading…
Cancel
Save