summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qtspotify.ui56
-rw-r--r--qtspotifymain.cpp29
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 @@
<string>&amp;File</string>
</property>
<addaction name="actionLogIn"/>
+ <addaction name="actionSearch"/>
<addaction name="actionDebuggingOutput"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
- <widget class="QMenu" name="menuPlaylist">
- <property name="title">
- <string>&amp;Playlist</string>
- </property>
- <addaction name="actionSearch"/>
- </widget>
- <widget class="QMenu" name="menuPlayback">
- <property name="title">
- <string>Playback</string>
- </property>
- <addaction name="actionPlayOrStop"/>
- <addaction name="actionPauseOrResume"/>
- </widget>
<addaction name="menu_File"/>
- <addaction name="menuPlaylist"/>
- <addaction name="menuPlayback"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
- <action name="actionLogIn">
- <property name="text">
- <string>&amp;Log in...</string>
+ <action name="actionDebuggingOutput">
+ <property name="checkable">
+ <bool>true</bool>
</property>
- <property name="shortcut">
- <string>Ctrl+L</string>
+ <property name="checked">
+ <bool>true</bool>
</property>
- </action>
- <action name="actionExit">
<property name="text">
- <string>E&amp;xit</string>
- </property>
- <property name="shortcut">
- <string>Alt+X, Ctrl+Q</string>
+ <string>Debugging output</string>
</property>
</action>
<action name="actionSearch">
@@ -254,31 +235,20 @@
<string>Ctrl+S</string>
</property>
</action>
- <action name="actionPlayOrStop">
+ <action name="actionExit">
<property name="text">
- <string>&amp;Play / stop</string>
+ <string>E&amp;xit</string>
</property>
<property name="shortcut">
- <string>Backspace</string>
+ <string>Alt+X, Ctrl+Q</string>
</property>
</action>
- <action name="actionPauseOrResume">
+ <action name="actionLogIn">
<property name="text">
- <string>P&amp;ause / resume</string>
+ <string>&amp;Log in...</string>
</property>
<property name="shortcut">
- <string>Space</string>
- </property>
- </action>
- <action name="actionDebuggingOutput">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Debugging output</string>
+ <string>Ctrl+L</string>
</property>
</action>
</widget>
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<track *>();
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'"));