Add a little spinner
This commit is contained in:
parent
82b010eeba
commit
3526fb3bdc
|
@ -51,7 +51,11 @@ void Library::BackendInitialised() {
|
|||
}
|
||||
|
||||
void Library::WatcherInitialised() {
|
||||
connect(watcher_->Worker().get(), SIGNAL(ScanStarted()), SIGNAL(ScanStarted()));
|
||||
connect(watcher_->Worker().get(), SIGNAL(ScanFinished()), SIGNAL(ScanFinished()));
|
||||
|
||||
watcher_->Worker()->SetEngine(engine_);
|
||||
|
||||
if (--waiting_for_threads_ == 0)
|
||||
Initialise();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ class Library : public SimpleTreeModel<LibraryItem> {
|
|||
void Error(const QString& message);
|
||||
void TotalSongCountUpdated(int count);
|
||||
|
||||
void ScanStarted();
|
||||
void ScanFinished();
|
||||
|
||||
public slots:
|
||||
void ShowConfig();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "osd.h"
|
||||
#include "trackslider.h"
|
||||
#include "edittagdialog.h"
|
||||
#include "multiloadingindicator.h"
|
||||
|
||||
#include "qxtglobalshortcut.h"
|
||||
|
||||
|
@ -36,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
osd_(new OSD(tray_icon_, this)),
|
||||
track_slider_(new TrackSlider(this)),
|
||||
edit_tag_dialog_(new EditTagDialog(this)),
|
||||
multi_loading_indicator_(new MultiLoadingIndicator(this)),
|
||||
radio_model_(new RadioModel(this)),
|
||||
playlist_(new Playlist(this)),
|
||||
player_(new Player(playlist_, radio_model_->GetLastFMService(), this)),
|
||||
|
@ -135,6 +137,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(ui_.library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryDoubleClick(QModelIndex)));
|
||||
connect(ui_.library_view, SIGNAL(ShowConfigDialog()), library_, SLOT(ShowConfig()));
|
||||
connect(library_, SIGNAL(TotalSongCountUpdated(int)), ui_.library_view, SLOT(TotalSongCountUpdated(int)));
|
||||
connect(library_, SIGNAL(ScanStarted()), SLOT(LibraryScanStarted()));
|
||||
connect(library_, SIGNAL(ScanFinished()), SLOT(LibraryScanFinished()));
|
||||
|
||||
// Age filters
|
||||
QActionGroup* filter_age_group = new QActionGroup(this);
|
||||
|
@ -220,6 +224,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Statusbar widgets
|
||||
ui_.statusBar->addPermanentWidget(track_slider_);
|
||||
ui_.statusBar->addWidget(multi_loading_indicator_);
|
||||
multi_loading_indicator_->hide();
|
||||
|
||||
// Load theme
|
||||
QFile stylesheet(":mainwindow.css");
|
||||
|
@ -491,3 +497,11 @@ void MainWindow::EditTracks() {
|
|||
|
||||
playlist_->ReloadItems(rows);
|
||||
}
|
||||
|
||||
void MainWindow::LibraryScanStarted() {
|
||||
multi_loading_indicator_->TaskStarted("Updating library");
|
||||
}
|
||||
|
||||
void MainWindow::LibraryScanFinished() {
|
||||
multi_loading_indicator_->TaskFinished("Updating library");
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class RadioItem;
|
|||
class OSD;
|
||||
class TrackSlider;
|
||||
class EditTagDialog;
|
||||
class MultiLoadingIndicator;
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
class SystemTrayIcon;
|
||||
|
@ -63,6 +64,9 @@ class MainWindow : public QMainWindow {
|
|||
void ScrobblingEnabledChanged(bool value);
|
||||
void Love();
|
||||
|
||||
void LibraryScanStarted();
|
||||
void LibraryScanFinished();
|
||||
|
||||
private:
|
||||
void SaveGeometry();
|
||||
|
||||
|
@ -75,6 +79,7 @@ class MainWindow : public QMainWindow {
|
|||
OSD* osd_;
|
||||
TrackSlider* track_slider_;
|
||||
EditTagDialog* edit_tag_dialog_;
|
||||
MultiLoadingIndicator* multi_loading_indicator_;
|
||||
|
||||
RadioModel* radio_model_;
|
||||
Playlist* playlist_;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#include "multiloadingindicator.h"
|
||||
|
||||
MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui_.setupUi(this);
|
||||
}
|
||||
|
||||
void MultiLoadingIndicator::TaskStarted(const QString &name) {
|
||||
tasks_ << name;
|
||||
|
||||
UpdateText();
|
||||
show();
|
||||
}
|
||||
|
||||
void MultiLoadingIndicator::TaskFinished(const QString &name) {
|
||||
tasks_.removeAll(name);
|
||||
|
||||
UpdateText();
|
||||
if (tasks_.count() == 0)
|
||||
hide();
|
||||
}
|
||||
|
||||
void MultiLoadingIndicator::UpdateText() {
|
||||
ui_.text->setText(tasks_.join(", ") + "...");
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef MULTILOADINGINDICATOR_H
|
||||
#define MULTILOADINGINDICATOR_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_multiloadingindicator.h"
|
||||
|
||||
class MultiLoadingIndicator : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultiLoadingIndicator(QWidget* parent = 0);
|
||||
|
||||
public slots:
|
||||
void TaskStarted(const QString& name);
|
||||
void TaskFinished(const QString& name);
|
||||
|
||||
private:
|
||||
void UpdateText();
|
||||
|
||||
private:
|
||||
Ui::MultiLoadingIndicator ui_;
|
||||
|
||||
QStringList tasks_;
|
||||
};
|
||||
|
||||
#endif // MULTILOADINGINDICATOR_H
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MultiLoadingIndicator</class>
|
||||
<widget class="QWidget" name="MultiLoadingIndicator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>191</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BusyIndicator" name="spinner">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="text"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BusyIndicator</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>busyindicator.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -6,6 +6,7 @@ RadioLoadingIndicator::RadioLoadingIndicator(QWidget *parent)
|
|||
: QWidget(parent)
|
||||
{
|
||||
ui_.setupUi(this);
|
||||
ui_.text->setText("<b>Loading radio stream...</b>");
|
||||
}
|
||||
|
||||
void RadioLoadingIndicator::paintEvent(QPaintEvent*) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>160</width>
|
||||
<width>191</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -30,11 +30,7 @@
|
|||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="text">
|
||||
<property name="text">
|
||||
<string><span style=" font-weight:600;">Loading radio stream...</span></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="text"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BusyIndicator" name="spinner">
|
||||
|
|
|
@ -47,7 +47,8 @@ SOURCES += main.cpp \
|
|||
osd.cpp \
|
||||
trackslider.cpp \
|
||||
edittagdialog.cpp \
|
||||
lineedit.cpp
|
||||
lineedit.cpp \
|
||||
multiloadingindicator.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
player.h \
|
||||
library.h \
|
||||
|
@ -95,7 +96,8 @@ HEADERS += mainwindow.h \
|
|||
osd.h \
|
||||
trackslider.h \
|
||||
edittagdialog.h \
|
||||
lineedit.h
|
||||
lineedit.h \
|
||||
multiloadingindicator.h
|
||||
FORMS += mainwindow.ui \
|
||||
libraryconfig.ui \
|
||||
fileview.ui \
|
||||
|
@ -103,7 +105,8 @@ FORMS += mainwindow.ui \
|
|||
radioloadingindicator.ui \
|
||||
lastfmstationdialog.ui \
|
||||
trackslider.ui \
|
||||
edittagdialog.ui
|
||||
edittagdialog.ui \
|
||||
multiloadingindicator.ui
|
||||
RESOURCES += ../data/data.qrc
|
||||
OTHER_FILES += ../data/schema.sql \
|
||||
../data/mainwindow.css
|
||||
|
|
Loading…
Reference in New Issue