Show multiple errors in the same dialog

This commit is contained in:
David Sansome 2010-05-31 20:49:44 +00:00
parent 5d272a89ee
commit bfebbc20c9
30 changed files with 291 additions and 10 deletions

View File

@ -1251,6 +1251,9 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1257,6 +1257,9 @@ msgstr "Dokončen seznam skladeb"
msgid "Volume %1%"
msgstr "Hlasitost %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1260,6 +1260,9 @@ msgstr "Spilleliste afsluttet"
msgid "Volume %1%"
msgstr "Lydstyrke %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1260,6 +1260,9 @@ msgstr "Wiedergabeliste beendet"
msgid "Volume %1%"
msgstr "Lautstärke %1"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1261,6 +1261,9 @@ msgstr "Η λίστα τελείωσε"
msgid "Volume %1%"
msgstr "Ένταση %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1255,6 +1255,9 @@ msgstr "Playlist finished"
msgid "Volume %1%"
msgstr "Volume %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1267,6 +1267,9 @@ msgstr "Lista de reproducción finalizada"
msgid "Volume %1%"
msgstr "Volumen %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1251,5 +1251,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1265,6 +1265,9 @@ msgstr "Liste de lecture terminée"
msgid "Volume %1%"
msgstr "Volume %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1253,5 +1253,8 @@ msgstr "Lista de músicas terminada"
msgid "Volume %1%"
msgstr "Volume %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1264,6 +1264,9 @@ msgstr "Scaletta terminata"
msgid "Volume %1%"
msgstr "Volume %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1253,5 +1253,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1257,6 +1257,9 @@ msgstr "Spillelisten er ferdigspilt"
msgid "Volume %1%"
msgstr "Volum %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1251,6 +1251,9 @@ msgstr "Lista de lectura acabada"
msgid "Volume %1%"
msgstr "Volum %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1255,6 +1255,9 @@ msgstr "Zakończono playlistę"
msgid "Volume %1%"
msgstr "Głośność %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1258,6 +1258,9 @@ msgstr "Lista de músicas terminada"
msgid "Volume %1%"
msgstr "Volume %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1251,5 +1251,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1252,6 +1252,9 @@ msgstr ""
msgid "Volume %1%"
msgstr "Volum %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1258,6 +1258,9 @@ msgstr "Плейлист закончен"
msgid "Volume %1%"
msgstr "Громкость %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1259,6 +1259,9 @@ msgstr "Playlist skončený"
msgid "Volume %1%"
msgstr "Hlasitosť %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1260,6 +1260,9 @@ msgstr "Spellistan klar"
msgid "Volume %1%"
msgstr "Volym %1%"
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr "0:00:00"

View File

@ -1251,5 +1251,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1242,5 +1242,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -1251,5 +1251,8 @@ msgstr ""
msgid "Volume %1%"
msgstr ""
msgid "Clementine Error"
msgstr ""
msgid "0:00:00"
msgstr ""

View File

@ -51,6 +51,7 @@
#include "ui/iconloader.h"
#include "ui/settingsdialog.h"
#include "ui/systemtrayicon.h"
#include "widgets/errordialog.h"
#include "widgets/multiloadingindicator.h"
#include "widgets/osd.h"
#include "widgets/trackslider.h"
@ -116,6 +117,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
equalizer_(new Equalizer),
transcode_dialog_(new TranscodeDialog),
global_shortcuts_dialog_(new GlobalShortcutsDialog(global_shortcuts_)),
error_dialog_(new ErrorDialog),
playlist_menu_(new QMenu(this)),
library_sort_model_(new QSortFilterProxyModel(this)),
track_position_timer_(new QTimer(this)),
@ -241,7 +243,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
// Player connections
connect(ui_->volume, SIGNAL(valueChanged(int)), player_, SLOT(SetVolume(int)));
connect(player_, SIGNAL(Error(QString)), SLOT(ReportError(QString)));
connect(player_, SIGNAL(Error(QString)), error_dialog_.get(), SLOT(ShowMessage(QString)));
connect(player_, SIGNAL(Paused()), SLOT(MediaPaused()));
connect(player_, SIGNAL(Playing()), SLOT(MediaPlaying()));
connect(player_, SIGNAL(Stopped()), SLOT(MediaStopped()));
@ -267,7 +269,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
connect(playlists_, SIGNAL(CurrentSongChanged(Song)), player_, SLOT(CurrentMetadataChanged(Song)));
connect(playlists_, SIGNAL(PlaylistChanged()), player_, SLOT(PlaylistChanged()));
connect(playlists_, SIGNAL(EditingFinished(QModelIndex)), SLOT(PlaylistEditFinished(QModelIndex)));
connect(playlists_, SIGNAL(Error(QString)), SLOT(ReportError(QString)));
connect(playlists_, SIGNAL(Error(QString)), error_dialog_.get(), SLOT(ShowMessage(QString)));
connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
connect(ui_->playlist->view(), SIGNAL(PlayPauseItem(QModelIndex)), SLOT(PlayIndex(QModelIndex)));
@ -276,7 +278,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
connect(track_slider_, SIGNAL(ValueChanged(int)), player_, SLOT(Seek(int)));
// Database connections
connect(database_, SIGNAL(Error(QString)), SLOT(ReportError(QString)));
connect(database_, SIGNAL(Error(QString)), error_dialog_.get(), SLOT(ShowMessage(QString)));
// Library connections
connect(ui_->library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryItemDoubleClicked(QModelIndex)));
@ -315,7 +317,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
// Radio connections
connect(radio_model_, SIGNAL(TaskStarted(MultiLoadingIndicator::TaskType)), multi_loading_indicator_, SLOT(TaskStarted(MultiLoadingIndicator::TaskType)));
connect(radio_model_, SIGNAL(TaskFinished(MultiLoadingIndicator::TaskType)), multi_loading_indicator_, SLOT(TaskFinished(MultiLoadingIndicator::TaskType)));
connect(radio_model_, SIGNAL(StreamError(QString)), SLOT(ReportError(QString)));
connect(radio_model_, SIGNAL(StreamError(QString)), error_dialog_.get(), SLOT(ShowMessage(QString)));
connect(radio_model_, SIGNAL(AsyncLoadFinished(PlaylistItem::SpecialLoadResult)), player_, SLOT(HandleSpecialLoad(PlaylistItem::SpecialLoadResult)));
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), playlists_, SLOT(SetActiveStreamMetadata(QUrl,Song)));
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
@ -503,11 +505,6 @@ void MainWindow::AddFilesToPlaylist(bool clear_first, const QList<QUrl>& urls) {
}
}
void MainWindow::ReportError(const QString& message) {
// TODO: rate limiting
QMessageBox::warning(this, "Error", message);
}
void MainWindow::MediaStopped() {
ui_->action_stop->setEnabled(false);
ui_->action_stop_after_this_track->setEnabled(false);

View File

@ -34,6 +34,7 @@ class CommandlineOptions;
class Database;
class EditTagDialog;
class Equalizer;
class ErrorDialog;
class GlobalShortcuts;
class GlobalShortcutsDialog;
class GroupByDialog;
@ -88,7 +89,6 @@ class MainWindow : public QMainWindow {
private slots:
void FilePathChanged(const QString& path);
void ReportError(const QString& message);
void MediaStopped();
void MediaPaused();
void MediaPlaying();
@ -174,6 +174,7 @@ class MainWindow : public QMainWindow {
boost::scoped_ptr<Equalizer> equalizer_;
boost::scoped_ptr<TranscodeDialog> transcode_dialog_;
boost::scoped_ptr<GlobalShortcutsDialog> global_shortcuts_dialog_;
boost::scoped_ptr<ErrorDialog> error_dialog_;
QMenu* playlist_menu_;
QAction* playlist_play_pause_;

View File

@ -6,6 +6,7 @@ set(SOURCES
autoexpandingtreeview.cpp
busyindicator.cpp
equalizerslider.cpp
errordialog.cpp
fileview.cpp
fileviewlist.cpp
lineedit.cpp
@ -23,6 +24,7 @@ set(HEADERS
autoexpandingtreeview.h
busyindicator.h
equalizerslider.h
errordialog.h
fileview.h
fileviewlist.h
lineedit.h
@ -37,6 +39,7 @@ set(HEADERS
set(UI
equalizerslider.ui
errordialog.ui
fileview.ui
multiloadingindicator.ui
osdpretty.ui

View File

@ -0,0 +1,62 @@
/* 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/>.
*/
#include "errordialog.h"
#include "ui_errordialog.h"
ErrorDialog::ErrorDialog(QWidget *parent)
: QDialog(parent),
ui_(new Ui_ErrorDialog)
{
ui_->setupUi(this);
QIcon warning_icon(style()->standardIcon(QStyle::SP_MessageBoxWarning));
QPixmap warning_pixmap(warning_icon.pixmap(48));
QPalette messages_palette(ui_->messages->palette());
messages_palette.setColor(QPalette::Base, messages_palette.color(QPalette::Background));
ui_->messages->setPalette(messages_palette);
ui_->icon->setPixmap(warning_pixmap);
}
ErrorDialog::~ErrorDialog() {
delete ui_;
}
void ErrorDialog::ShowMessage(const QString &message) {
current_messages_ << message;
UpdateContent();
show();
raise();
activateWindow();
}
void ErrorDialog::hideEvent(QHideEvent *) {
current_messages_.clear();
UpdateContent();
}
void ErrorDialog::UpdateContent() {
QString html;
foreach (const QString& message, current_messages_) {
if (!html.isEmpty())
html += "<hr/>";
html += Qt::escape(message);
}
ui_->messages->setHtml(html);
}

45
src/widgets/errordialog.h Normal file
View File

@ -0,0 +1,45 @@
/* 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/>.
*/
#ifndef ERRORDIALOG_H
#define ERRORDIALOG_H
#include <QDialog>
class Ui_ErrorDialog;
class ErrorDialog : public QDialog {
Q_OBJECT
public:
ErrorDialog(QWidget* parent = 0);
~ErrorDialog();
public slots:
void ShowMessage(const QString& message);
protected:
void hideEvent(QHideEvent *);
private:
void UpdateContent();
Ui_ErrorDialog* ui_;
QStringList current_messages_;
};
#endif // ERRORDIALOG_H

101
src/widgets/errordialog.ui Normal file
View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ErrorDialog</class>
<widget class="QDialog" name="ErrorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Clementine Error</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="icon"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="messages">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ErrorDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ErrorDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>