Remember current page
This commit is contained in:
committed by
Craig Drummond
parent
8f8afef44f
commit
26ba385b46
@@ -30,6 +30,7 @@
|
||||
#include "widgets/icons.h"
|
||||
#include "stdactions.h"
|
||||
#include "support/actioncollection.h"
|
||||
#include "support/configuration.h"
|
||||
#include "widgets/tableview.h"
|
||||
#include "widgets/spacerwidget.h"
|
||||
#include "widgets/menubutton.h"
|
||||
@@ -446,10 +447,14 @@ PlaylistsPage::PlaylistsPage(QWidget *p)
|
||||
addPage(Dynamic::self()->name(), Dynamic::self()->icon(), Dynamic::self()->title(), Dynamic::self()->descr(), dynamic);
|
||||
|
||||
connect(stored, SIGNAL(addToDevice(QString,QString,QList<Song>)), SIGNAL(addToDevice(QString,QString,QList<Song>)));
|
||||
Configuration config(metaObject()->className());
|
||||
load(config);
|
||||
}
|
||||
|
||||
PlaylistsPage::~PlaylistsPage()
|
||||
{
|
||||
Configuration config(metaObject()->className());
|
||||
save(config);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "podcastwidget.h"
|
||||
#include "streams/streamspage.h"
|
||||
#include "models/streamsmodel.h"
|
||||
#include "support/configuration.h"
|
||||
|
||||
OnlineServicesPage::OnlineServicesPage(QWidget *p)
|
||||
: MultiPageWidget(p)
|
||||
@@ -51,10 +52,15 @@ OnlineServicesPage::OnlineServicesPage(QWidget *p)
|
||||
podcast=new PodcastService(this);
|
||||
addPage(podcast->name(), podcast->icon(), podcast->title(), podcast->descr(), new PodcastWidget(podcast, this));
|
||||
connect(podcast, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
|
||||
|
||||
Configuration config(metaObject()->className());
|
||||
load(config);
|
||||
}
|
||||
|
||||
OnlineServicesPage::~OnlineServicesPage()
|
||||
{
|
||||
Configuration config(metaObject()->className());
|
||||
save(config);
|
||||
}
|
||||
|
||||
bool OnlineServicesPage::isDownloading()
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "support/utils.h"
|
||||
#include "support/squeezedtextlabel.h"
|
||||
#include "support/proxystyle.h"
|
||||
#include "support/configuration.h"
|
||||
#include "listview.h"
|
||||
#include "sizewidget.h"
|
||||
#include "singlepagewidget.h"
|
||||
@@ -124,6 +125,36 @@ MultiPageWidget::~MultiPageWidget()
|
||||
{
|
||||
}
|
||||
|
||||
static const char *constCurrentPageKey="currentPage";
|
||||
|
||||
void MultiPageWidget::load(Configuration &config)
|
||||
{
|
||||
QString p=config.get(constCurrentPageKey, QString());
|
||||
|
||||
if (!p.isEmpty()) {
|
||||
QMap<QString, Entry>::ConstIterator it=entries.find(p);
|
||||
if (it!=entries.constEnd()) {
|
||||
setCurrentWidget(it.value().page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultiPageWidget::save(Configuration &config) const
|
||||
{
|
||||
QString p;
|
||||
QWidget *cw=currentWidget();
|
||||
|
||||
QMap<QString, Entry>::ConstIterator it=entries.constBegin();
|
||||
QMap<QString, Entry>::ConstIterator end=entries.constEnd();
|
||||
|
||||
for (; it!=end; ++it) {
|
||||
if (it.value().page==cw) {
|
||||
p=it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
config.set(constCurrentPageKey, p);
|
||||
}
|
||||
void MultiPageWidget::setInfoText(const QString &text)
|
||||
{
|
||||
infoLabel->setText(text);
|
||||
|
||||
@@ -33,6 +33,7 @@ class Icon;
|
||||
class SelectorButton;
|
||||
class SizeWidget;
|
||||
class QLabel;
|
||||
class Configuration;
|
||||
|
||||
class MultiPageWidget : public StackedPageWidget
|
||||
{
|
||||
@@ -49,6 +50,8 @@ public:
|
||||
MultiPageWidget(QWidget *p);
|
||||
virtual ~MultiPageWidget();
|
||||
|
||||
void load(Configuration &config);
|
||||
void save(Configuration &config) const;
|
||||
void setInfoText(const QString &text);
|
||||
void addPage(const QString &name, const QString &icon, const QString &text, const QString &subText, QWidget *widget);
|
||||
void addPage(const QString &name, const Icon &icon, const QString &text, const QString &subText, QWidget *widget);
|
||||
|
||||
Reference in New Issue
Block a user