Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show better error messages when talking to MusicBrainz. #19

Merged
merged 11 commits into from
Jun 25, 2013
20 changes: 19 additions & 1 deletion src/dlgtagfetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
DlgTagFetcher::DlgTagFetcher(QWidget *parent)
: QWidget(parent),
m_track(NULL),
m_TagFetcher(parent) {
m_TagFetcher(parent),
m_networkError(NOERROR) {
setupUi(this);

connect(btnApply, SIGNAL(clicked()),
Expand All @@ -26,6 +27,8 @@ DlgTagFetcher::DlgTagFetcher(QWidget *parent)
this, SLOT(fetchTagFinished(const TrackPointer,const QList<TrackPointer>&)));
connect(&m_TagFetcher, SIGNAL(fetchProgress(QString)),
this, SLOT(fetchTagProgress(QString)));
connect(&m_TagFetcher, SIGNAL(networkError(int, QString)),
this, SLOT(slotNetworkError(int, QString)));

// Resize columns, this can't be set in the ui file
results->setColumnWidth(0, 50); // Track column
Expand Down Expand Up @@ -93,10 +96,25 @@ void DlgTagFetcher::fetchTagFinished(const TrackPointer track,
updateStack();
}

void DlgTagFetcher::slotNetworkError(int errorCode, QString app) {
m_networkError = errorCode==0 ? FTWERROR : HTTPERROR;
m_data.m_pending = false;
ErrorCode->setText(QString::number(errorCode));
applicationName->setText(app);
applicationName_httpError->setText(app);
updateStack();
}

void DlgTagFetcher::updateStack() {
if (m_data.m_pending) {
stack->setCurrentWidget(loading_page);
return;
} else if (m_networkError == HTTPERROR) {
stack->setCurrentWidget(networkError_page);
return;
} else if (m_networkError == FTWERROR) {
stack->setCurrentWidget(generalnetworkError_page);
return;
} else if (m_data.m_results.isEmpty()) {
stack->setCurrentWidget(error_page);
return;
Expand Down
16 changes: 10 additions & 6 deletions src/dlgtagfetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,30 @@ class DlgTagFetcher : public QWidget, public Ui::DlgTagFetcher {

void init(const TrackPointer track);

enum networkError {
NOERROR,
HTTPERROR,
FTWERROR
};


signals:
void next();
void previous();

public slots:
private slots:
void fetchTagFinished(const TrackPointer,const QList<TrackPointer>& tracks);
void resultSelected();
void fetchTagProgress(QString);

private slots:
void slotNetworkError(int, QString);
void apply();
void quit();

private:

void updateStack();
void addDivider(const QString& text, QTreeWidget* parent) const;
void addTrack(const TrackPointer track, int resultIndex,
QTreeWidget* parent) const;

private:
struct Data {
Data() : m_pending(true), m_selectedResult(-1) {}

Expand All @@ -52,6 +55,7 @@ class DlgTagFetcher : public QWidget, public Ui::DlgTagFetcher {
Data m_data;
QString m_progress;
TagFetcher m_TagFetcher;
networkError m_networkError;
};

#endif // DLGTAGFETCHER_H
260 changes: 251 additions & 9 deletions src/dlgtagfetcher.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<item>
<widget class="QStackedWidget" name="stack">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="results_page">
<widget class="QWidget" name="verticalLayoutWidget_2">
Expand Down Expand Up @@ -132,10 +132,10 @@
</property>
</spacer>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="message1">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Fetching track data from MusicBrainz&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Fetching track data from MusicBrainz</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -169,10 +169,10 @@
</property>
</spacer>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="status">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Status:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Status:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -214,6 +214,245 @@
</layout>
</widget>
</widget>
<widget class="QWidget" name="networkError_page">
<widget class="QWidget" name="verticalLayoutWidget_6">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>791</width>
<height>341</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_7">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Courier 10 Pitch&quot;;</string>
</property>
<property name="text">
<string>Error</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Mixxx can't connect to </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="applicationName_httpError">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>HTTP Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ErrorCode">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_8">
<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>
</widget>
</widget>
<widget class="QWidget" name="generalnetworkError_page">
<widget class="QWidget" name="verticalLayoutWidget_7">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_5">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;DejaVu Serif&quot;;</string>
</property>
<property name="text">
<string>Error</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Mixxx can't connect to </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="applicationName">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string> for an unkown reason</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_6">
<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>
</widget>
</widget>
<widget class="QWidget" name="error_page">
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
Expand All @@ -238,17 +477,20 @@
</property>
</spacer>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">font: 75 16pt &quot;DejaVu Serif&quot;;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Sorry&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Sorry</string>
</property>
</widget>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Mixxx could not find this song&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Mixxx could not find this song</string>
</property>
</widget>
</item>
Expand Down
Loading