Clementine-audio-player-Mac.../src/multiloadingindicator.cpp

54 lines
1.2 KiB
C++
Raw Normal View History

2010-01-16 18:52:51 +01:00
#include "multiloadingindicator.h"
MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
: QWidget(parent)
{
ui_.setupUi(this);
}
2010-02-23 19:33:09 +01:00
void MultiLoadingIndicator::TaskStarted(TaskType type) {
if (tasks_.contains(type))
2010-01-18 03:23:55 +01:00
return;
2010-02-23 19:33:09 +01:00
tasks_ << type;
2010-01-16 18:52:51 +01:00
UpdateText();
show();
}
2010-02-23 19:33:09 +01:00
void MultiLoadingIndicator::TaskFinished(TaskType type) {
tasks_.removeAll(type);
2010-01-16 18:52:51 +01:00
UpdateText();
if (tasks_.count() == 0)
hide();
}
void MultiLoadingIndicator::UpdateText() {
2010-02-03 22:48:00 +01:00
QStringList strings;
2010-02-23 19:33:09 +01:00
foreach (TaskType type, tasks_) {
QString task(TaskTypeToString(type));
2010-02-03 22:48:00 +01:00
task[0] = task[0].toLower();
strings << task;
}
QString text(strings.join(", "));
if (!text.isEmpty()) {
text[0] = text[0].toUpper();
}
ui_.text->setText(text + "...");
2010-01-16 18:52:51 +01:00
}
2010-02-23 19:33:09 +01:00
QString MultiLoadingIndicator::TaskTypeToString(TaskType type) {
switch (type) {
case LoadingAudioEngine: return tr("Loading audio engine");
case UpdatingLibrary: return tr("Updating library");
case GettingChannels: return tr("Getting channels");
case LoadingStream: return tr("Loading stream");
case LoadingLastFM: return tr("Loading Last.fm radio");
default: return QString::null;
}
}