diff options
| -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 |
