summaryrefslogtreecommitdiffstats
path: root/qtspotifymain.h
diff options
context:
space:
mode:
Diffstat (limited to 'qtspotifymain.h')
-rw-r--r--qtspotifymain.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/qtspotifymain.h b/qtspotifymain.h
new file mode 100644
index 0000000..69f2bfb
--- /dev/null
+++ b/qtspotifymain.h
@@ -0,0 +1,106 @@
+#ifndef QTSPOTIFYMAIN_H
+#define QTSPOTIFYMAIN_H
+
+#include "ui_qtspotify.h"
+
+#include <QtGui/QMainWindow>
+
+#include <QtCore/QFuture>
+#include <QtCore/QFutureWatcher>
+
+class MyStatusBar: public QStatusBar
+{
+ Q_OBJECT
+ Q_PROPERTY(QString statusMessage READ statusMessage WRITE setStatusMessage);
+public:
+ MyStatusBar(QWidget *parent = 0) : QStatusBar(parent)
+ {
+ m_label = new QLabel();
+ addPermanentWidget(m_label);
+ }
+
+ void setStatusMessage(const QString &text)
+ {
+ m_label->setText(text);
+ }
+
+ QString statusMessage() const
+ {
+ return m_label->text();
+ }
+
+private:
+ QLabel *m_label;
+};
+
+struct despotify_session;
+struct track;
+struct playlist;
+struct search_result;
+
+class QStateMachine;
+class QState;
+
+class LogInDialog;
+class QtSpotifyMain: public QMainWindow
+{
+ Q_OBJECT
+ Q_PROPERTY(QString debuggingMessage READ debuggingMessage WRITE debug)
+public:
+ QtSpotifyMain(QWidget *parent = 0);
+ ~QtSpotifyMain();
+
+ void setNewTrack(track *t);
+
+ // Just a dummy so we can use the property mechanism to call the debug() function
+ QString debuggingMessage() const { return QString(); }
+
+ bool debugging() const { return m_debugging; }
+
+private slots:
+ void logIn();
+ void endSession();
+ void retrievePlayLists();
+ void populateSearchBox();
+ void play();
+ void pause();
+ void stop();
+ void resume();
+ void selectPlayList();
+ void decideLoginResult();
+ void debug(const QString &text);
+ void setDebugging(bool on) { m_debugging = on; }
+
+signals:
+ void loggedIn();
+ void loginFailed();
+
+private:
+ void setPlayList(track *t);
+
+ void initUi();
+ void initWatchers();
+
+ void initMachine();
+ void initLoggingInState(QState *);
+ void initLoggedInState(QState *);
+ void initPlayListHandlingState(QState *);
+ void initPlayBackHandlingState(QState *);
+ void initPlayingState(QState *);
+
+ Ui_QtSpotifyMain m_ui;
+ despotify_session *m_session;
+ search_result *m_searchResult;
+ playlist *m_storedPlaylist;
+ QStateMachine *m_machine;
+
+ bool m_debugging;
+
+ QFutureWatcher<bool> *m_authenticationWatcher;
+ QFutureWatcher<playlist *> *m_retrievingPlayListWatcher;
+
+ LogInDialog *m_logInDialog;
+
+};
+
+#endif // QTSPOTIFYMAIN_H