diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-03-21 14:06:39 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-03-21 14:06:39 +0000 |
| commit | 0871f8bb3d5ff1f19ebab5b660ccfe13ec959f43 (patch) | |
| tree | aa4961f12b2330331c0d4a43abbf08fe83e47c60 | |
| parent | ba6d5b13e4cd306a1c4517780fba496d669dd596 (diff) | |
| download | qmmp-0871f8bb3d5ff1f19ebab5b660ccfe13ec959f43.tar.gz qmmp-0871f8bb3d5ff1f19ebab5b660ccfe13ec959f43.tar.bz2 qmmp-0871f8bb3d5ff1f19ebab5b660ccfe13ec959f43.zip | |
library: added busy indicator
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9768 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/General/library/library.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/General/library/librarywidget.cpp | 28 | ||||
| -rw-r--r-- | src/plugins/General/library/librarywidget.h | 6 |
3 files changed, 35 insertions, 3 deletions
diff --git a/src/plugins/General/library/library.cpp b/src/plugins/General/library/library.cpp index c286e5878..b174f4fa8 100644 --- a/src/plugins/General/library/library.cpp +++ b/src/plugins/General/library/library.cpp @@ -76,7 +76,7 @@ Library::Library(QPointer<LibraryWidget> *libraryWidget, QObject *parent) : connect(&m_watcher, &QFutureWatcher<bool>::finished, [=] { if(!m_libraryWidget->isNull()) { - m_libraryWidget->data()->setEnabled(true); + m_libraryWidget->data()->setBusyMode(false); m_libraryWidget->data()->refresh(); } }); @@ -125,7 +125,7 @@ void Library::startDirectoryScanning() m_future = QtConcurrent::run(this, &Library::scanDirectories, m_dirs); m_watcher.setFuture(m_future); if(!m_libraryWidget->isNull()) - m_libraryWidget->data()->setEnabled(false); + m_libraryWidget->data()->setBusyMode(true); } bool Library::createTables() diff --git a/src/plugins/General/library/librarywidget.cpp b/src/plugins/General/library/librarywidget.cpp index d31ac585a..790ed410d 100644 --- a/src/plugins/General/library/librarywidget.cpp +++ b/src/plugins/General/library/librarywidget.cpp @@ -22,6 +22,7 @@ #include <QMenu> #include <QContextMenuEvent> #include <QIcon> +#include <QLabel> #include <qmmp/qmmp.h> #include "librarymodel.h" #include "ui_librarywidget.h" @@ -74,6 +75,33 @@ void LibraryWidget::refresh() m_model->refresh(); } +void LibraryWidget::setBusyMode(bool enabled) +{ + if(m_busyIndicator) + { + delete m_busyIndicator; + m_busyIndicator = nullptr; + } + + if(enabled) + { + m_busyIndicator = new QLabel(tr("Scanning of directories..."), this); + m_busyIndicator->setFrameShape(QFrame::Box); + m_busyIndicator->resize(m_busyIndicator->sizeHint()); + m_busyIndicator->move(width() / 2 - m_busyIndicator->width() / 2 , height() / 2 - m_busyIndicator->height() / 2); + m_busyIndicator->setAutoFillBackground(true); + m_busyIndicator->show(); + + m_ui->treeView->setEnabled(false); + m_ui->filterLineEdit->setEnabled(false); + } + else + { + m_ui->treeView->setEnabled(true); + m_ui->filterLineEdit->setEnabled(true); + } +} + void LibraryWidget::closeEvent(QCloseEvent *) { if(isWindow()) diff --git a/src/plugins/General/library/librarywidget.h b/src/plugins/General/library/librarywidget.h index 31f7b9c1d..e590e59c9 100644 --- a/src/plugins/General/library/librarywidget.h +++ b/src/plugins/General/library/librarywidget.h @@ -29,9 +29,10 @@ class LibraryWidget; class QMenu; class QAction; -class LibraryModel; class QContextMenuEvent; class QCloseEvent; +class QLabel; +class LibraryModel; class LibraryWidget : public QWidget { @@ -41,6 +42,8 @@ public: ~LibraryWidget(); void refresh(); + void setBusyMode(bool enabled); + private: void closeEvent(QCloseEvent *) override; void contextMenuEvent(QContextMenuEvent *e) override; @@ -55,6 +58,7 @@ private: LibraryModel *m_model; QMenu *m_menu; QAction *m_filterAction; + QLabel *m_busyIndicator = nullptr; }; #endif // LIBRARYWIDGET_H |
