From 7d9b7792aeb3db45e235f923061254de96d37e04 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 16 Jan 2021 19:03:33 +0000 Subject: library: added window mode (#147) git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9646 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/library/library.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/plugins/General/library/library.cpp') diff --git a/src/plugins/General/library/library.cpp b/src/plugins/General/library/library.cpp index adcf2eb7a..fe3da9bd4 100644 --- a/src/plugins/General/library/library.cpp +++ b/src/plugins/General/library/library.cpp @@ -63,9 +63,15 @@ Library::Library(QPointer *libraryWidget, QObject *parent) : QSettings settings(Qmmp::configFile(), QSettings::IniFormat); m_dirs = settings.value("Library/dirs").toStringList(); - QAction *action = new QAction(QIcon::fromTheme("view-refresh"), tr("Update library"), this); - UiHelper::instance()->addAction(action, UiHelper::TOOLS_MENU); - connect(action, SIGNAL(triggered()), SLOT(startDirectoryScanning())); + m_showAction = new QAction(QIcon::fromTheme("text-x-generic"), tr("Library"), this); + UiHelper::instance()->addAction(m_showAction, UiHelper::TOOLS_MENU); + connect(m_showAction, SIGNAL(triggered()), SLOT(showLibraryWindow())); + if(!m_libraryWidget->isNull() && !m_libraryWidget->data()->isWindow()) + m_showAction->setVisible(false); + + QAction *refreshAction = new QAction(QIcon::fromTheme("view-refresh"), tr("Update library"), this); + UiHelper::instance()->addAction(refreshAction, UiHelper::TOOLS_MENU); + connect(refreshAction, SIGNAL(triggered()), SLOT(startDirectoryScanning())); connect(&m_watcher, &QFutureWatcher::finished, [=] { if(!m_libraryWidget->isNull()) @@ -96,12 +102,18 @@ bool Library::isRunning() const return m_future.isRunning(); } +QAction *Library::showAction() const +{ + return m_showAction; +} + void Library::showLibraryWindow() { - /*if(!m_historyWindow) - m_historyWindow = new HistoryWindow(QSqlDatabase::database(CONNECTION_NAME), qApp->activeWindow()); - m_historyWindow->show(); - m_historyWindow->activateWindow();*/ + if(m_libraryWidget->isNull()) + *m_libraryWidget = new LibraryWidget(true, qApp->activeWindow()); + + if(m_libraryWidget->data()->isWindow()) + m_libraryWidget->data()->show(); } void Library::startDirectoryScanning() -- cgit v1.2.3-13-gbd6f