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

This commit is contained in:
Christophe Dumez 2008-06-20 20:16:56 +00:00
parent 981d7fd5ce
commit f22c2f8c7b
3 changed files with 30 additions and 4 deletions

View File

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

View File

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

View File

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