From 1c69913a170f8f1b767d6797ad3f2638cc386477 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 30 Oct 2009 15:35:27 +0100 Subject: Some more UI stuff. Despotify seems to have trouble when starting a song while another one is playing (crashes) and can no longer pause/resume songs. This is also reproducible with the despotify client. --- qtspotify.ui | 56 +++++++++++++------------------------------------------ qtspotifymain.cpp | 29 +++++++++++++--------------- 2 files changed, 26 insertions(+), 59 deletions(-) diff --git a/qtspotify.ui b/qtspotify.ui index 5b4bcd3..773af59 100644 --- a/qtspotify.ui +++ b/qtspotify.ui @@ -208,42 +208,23 @@ &File + - - - &Playlist - - - - - - Playback - - - - - - - - - &Log in... + + + true - - Ctrl+L + + true - - - E&xit - - - Alt+X, Ctrl+Q + Debugging output @@ -254,31 +235,20 @@ Ctrl+S - + - &Play / stop + E&xit - Backspace + Alt+X, Ctrl+Q - + - P&ause / resume + &Log in... - Space - - - - - true - - - true - - - Debugging output + Ctrl+L diff --git a/qtspotifymain.cpp b/qtspotifymain.cpp index b383672..38b19a5 100644 --- a/qtspotifymain.cpp +++ b/qtspotifymain.cpp @@ -62,6 +62,7 @@ namespace { static void callback(despotify_session *session, int signal, void *data, void *callbackData) { + qDebug("callback"); if (callbackData == 0 || data == 0 || session == 0) return; @@ -73,6 +74,8 @@ static void callback(despotify_session *session, int signal, void *data, void *c QCoreApplication::postEvent(qsm, new SelectTrackEvent(t)); } }; + + qDebug("return"); } QtSpotifyMain::QtSpotifyMain(QWidget *parent) @@ -211,7 +214,10 @@ void QtSpotifyMain::stop() void QtSpotifyMain::pause() { debug(tr("Pausing")); - despotify_pause(m_session); + if (!despotify_pause(m_session)) { + QMessageBox::warning(this, tr("Error when pausing track"), + tr("Despotify error: %1").arg(QString::fromUtf8(m_session->last_error))); + } } void QtSpotifyMain::resume() @@ -231,7 +237,7 @@ void QtSpotifyMain::play() track *t = data.value(); if (t != 0) { debug(tr("Playing '%1'").arg(t->title)); - if (!despotify_play(m_session, t, true)) { + if (!despotify_play(m_session, t, false)) { QMessageBox::information(this, tr("Error when playing track"), tr("Despotify error: %1").arg(QString::fromUtf8(m_session->last_error))); } else { @@ -240,6 +246,8 @@ void QtSpotifyMain::play() } else { qWarning("No track connected to current item"); } + + qDebug("here"); } void QtSpotifyMain::initPlayingState(QState *playingState) @@ -259,8 +267,6 @@ void QtSpotifyMain::initPlayingState(QState *playingState) connect(paused, SIGNAL(exited()), this, SLOT(resume())); } - notPaused->addTransition(m_ui.actionPauseOrResume, SIGNAL(triggered()), paused); - paused->addTransition(m_ui.actionPauseOrResume, SIGNAL(triggered()), notPaused); notPaused->addTransition(m_ui.playButton, SIGNAL(clicked()), paused); paused->addTransition(m_ui.playButton, SIGNAL(clicked()), notPaused); } @@ -271,7 +277,9 @@ void QtSpotifyMain::decideLoginResult() debug(tr("Login succeeded")); emit loggedIn(); } else { - debug(tr("Login failed, error==%1").arg(QString::fromUtf8(m_session->last_error))); + QMessageBox::warning(this, tr("Failed to log in"), + tr("Sorry, I failed to log in with your credentials.\n" + "Despotify error: %1").arg(QString::fromUtf8(m_session->last_error))); emit loginFailed(); } } @@ -280,8 +288,6 @@ void QtSpotifyMain::initPlayBackHandlingState(QState *playBackHandlingState) { QState *stoppedState = new QState(playBackHandlingState); { - stoppedState->assignProperty(m_ui.actionPauseOrResume, "enabled", false); - stoppedState->assignProperty(m_ui.actionPlayOrStop, "enabled", true); stoppedState->assignProperty(m_ui.albumLabel, "text", QString()); stoppedState->assignProperty(m_ui.artistLabel, "text", QString()); stoppedState->assignProperty(m_ui.songLabel, "text", QString()); @@ -297,18 +303,13 @@ void QtSpotifyMain::initPlayBackHandlingState(QState *playBackHandlingState) QState *playingState = new QState(playBackHandlingState); { playingState->setObjectName("playingState"); - playingState->assignProperty(m_ui.actionPlayOrStop, "enabled", true); playingState->assignProperty(m_ui.topLevelTabs, "currentIndex", 2); connect(playingState, SIGNAL(entered()), this, SLOT(play())); - playingState->assignProperty(m_ui.actionPauseOrResume, "enabled", true); playingState->assignProperty(m_ui.playButton, "enabled", true); playingState->assignProperty(m_ui.skipSongButton, "enabled", true); initPlayingState(playingState); } - stoppedState->addTransition(m_ui.actionPlayOrStop, SIGNAL(triggered()), playingState); - playingState->addTransition(m_ui.actionPlayOrStop, SIGNAL(triggered()), stoppedState); - stoppedState->addTransition(m_ui.playList, SIGNAL(doubleClicked(QModelIndex)), playingState); playingState->addTransition(m_ui.playList, SIGNAL(doubleClicked(QModelIndex)), @@ -415,8 +416,6 @@ void QtSpotifyMain::initMachine() notLoggedInState->assignProperty(m_ui.actionSearch, "enabled", false); notLoggedInState->assignProperty(m_ui.centralwidget, "enabled", false); - notLoggedInState->assignProperty(m_ui.actionPauseOrResume, "enabled", false); - notLoggedInState->assignProperty(m_ui.actionPlayOrStop, "enabled", false); notLoggedInState->assignProperty(statusBar(), "statusMessage", tr("Select 'log in' from menu to log in")); notLoggedInState->assignProperty(this, "debuggingMessage", tr("Entered 'notLoggedInState'")); @@ -430,8 +429,6 @@ void QtSpotifyMain::initMachine() loggingInState->assignProperty(m_ui.actionLogIn, "enabled", false); loggingInState->assignProperty(m_ui.actionSearch, "enabled", false); loggingInState->assignProperty(m_ui.centralwidget, "enabled", false); - loggingInState->assignProperty(m_ui.actionPauseOrResume, "enabled", false); - loggingInState->assignProperty(m_ui.actionPlayOrStop, "enabled", false); loggingInState->setObjectName("loggingInState"); loggingInState->assignProperty(this, "debuggingMessage", tr("Entered 'loggingInState'")); -- cgit v1.2.3