diff --git a/gui/folderpage.cpp b/gui/folderpage.cpp index 98bc89e33..d016570ed 100644 --- a/gui/folderpage.cpp +++ b/gui/folderpage.cpp @@ -35,6 +35,7 @@ FolderPage::FolderPage(MainWindow *p) : QWidget(p) + , enabled(false) { setupUi(this); addToPlaylist->setDefaultAction(p->addToPlaylistAction); @@ -59,9 +60,6 @@ FolderPage::FolderPage(MainWindow *p) proxy.setSourceModel(&model); view->setModel(&proxy); view->init(p->replacePlaylistAction, p->addToPlaylistAction); - connect(MPDConnection::self(), SIGNAL(dirViewUpdated(DirViewItemRoot *)), &model, SLOT(updateDirView(DirViewItemRoot *))); - connect(MPDConnection::self(), SIGNAL(updatingFileList()), view, SLOT(showSpinner())); - connect(MPDConnection::self(), SIGNAL(updatedFileList()), view, SLOT(hideSpinner())); connect(this, SIGNAL(listAll()), MPDConnection::self(), SLOT(listAll())); connect(this, SIGNAL(add(const QStringList &)), MPDConnection::self(), SLOT(add(const QStringList &))); connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &))); @@ -75,10 +73,31 @@ FolderPage::~FolderPage() { } +void FolderPage::setEnabled(bool e) +{ + if (e==enabled) { + return; + } + enabled=e; + + if (enabled) { + connect(MPDConnection::self(), SIGNAL(dirViewUpdated(DirViewItemRoot *)), &model, SLOT(updateDirView(DirViewItemRoot *))); + connect(MPDConnection::self(), SIGNAL(updatingFileList()), view, SLOT(showSpinner())); + connect(MPDConnection::self(), SIGNAL(updatedFileList()), view, SLOT(hideSpinner())); + refresh(); + } else { + disconnect(MPDConnection::self(), SIGNAL(dirViewUpdated(DirViewItemRoot *)), &model, SLOT(updateDirView(DirViewItemRoot *))); + disconnect(MPDConnection::self(), SIGNAL(updatingFileList()), view, SLOT(showSpinner())); + disconnect(MPDConnection::self(), SIGNAL(updatedFileList()), view, SLOT(hideSpinner())); + } +} + void FolderPage::refresh() { - view->showSpinner(); - emit listAll(); + if (enabled) { + view->showSpinner(); + emit listAll(); + } } void FolderPage::clear() diff --git a/gui/folderpage.h b/gui/folderpage.h index 27cdc6235..9f4251d14 100644 --- a/gui/folderpage.h +++ b/gui/folderpage.h @@ -36,6 +36,8 @@ public: FolderPage(MainWindow *p); virtual ~FolderPage(); + void setEnabled(bool e); + bool isEnabled() const { return enabled; } void refresh(); void clear(); void addSelectionToPlaylist(const QString &name=QString()); @@ -55,6 +57,7 @@ private: QStringList walk(QModelIndex rootItem); private: + bool enabled; DirViewModel model; DirViewProxyModel proxy; }; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 79192ce23..dd4c7b554 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -549,6 +549,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), tabWidget->AddTab(devicesPage, devicesTabAction->icon(), devicesTabAction->text(), !hiddenPages.contains(devicesPage->metaObject()->className())); #endif AlbumsModel::self()->setEnabled(!hiddenPages.contains(albumsPage->metaObject()->className())); + folderPage->setEnabled(!hiddenPages.contains(folderPage->metaObject()->className())); tabWidget->SetMode(FancyTabWidget::Mode_LargeSidebar); connect(tabWidget, SIGNAL(CurrentChanged(int)), this, SLOT(currentTabChanged(int))); @@ -1836,6 +1837,8 @@ void MainWindow::tabToggled(int index) { if(PAGE_ALBUMS==index) { AlbumsModel::self()->setEnabled(!AlbumsModel::self()->isEnabled()); + } else if(PAGE_FOLDERS==index) { + folderPage->setEnabled(!folderPage->isEnabled()); } }