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

70 lines
1.8 KiB
C++
Raw Normal View History

/* This file is part of Clementine.
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}