sc9k/openlpclient.hpp

72 lines
1.4 KiB
C++
Raw Normal View History

2021-07-18 21:09:04 -05:00
#pragma once
#include <QHash>
2021-07-18 21:09:04 -05:00
#include <QNetworkAccessManager>
#include <QObject>
#include <QTimer>
2021-07-18 21:09:04 -05:00
class OpenLPClient: public QObject {
Q_OBJECT
private:
struct Song {
QString name;
QString id;
};
2021-07-18 21:09:04 -05:00
static constexpr auto BaseUrl = "http://127.0.0.1:4316";
QNetworkAccessManager *m_nam = new QNetworkAccessManager(this);
QNetworkAccessManager *m_pollingNam = new QNetworkAccessManager(this);
QNetworkAccessManager *m_songListNam = new QNetworkAccessManager(this);
QNetworkAccessManager *m_slideListNam = new QNetworkAccessManager(this);
QTimer m_pollTimer;
QHash<QString, QString> m_songNameMap;
int m_currentServiceId = -1;
QString m_currentSongId;
2021-07-18 21:09:04 -05:00
public:
explicit OpenLPClient(QObject *parent = nullptr);
public slots:
void nextSlide();
void prevSlide();
void nextSong();
void prevSong();
void blankScreen();
void showSlides();
void changeSong(int it);
void changeSlide(int slide);
2021-07-18 21:09:04 -05:00
private:
void get(QString url);
void requestSongList();
void requestSlideList();
private slots:
void poll();
void handleGeneralResponse(QNetworkReply *reply);
void handlePollResponse(QNetworkReply *reply);
void handleSongListResponse(QNetworkReply *reply);
void handleSlideListResponse(QNetworkReply *reply);
2021-07-18 21:09:04 -05:00
signals:
void pollUpdate(QString songId, int slideNum);
void songListUpdate(QStringList);
void slideListUpdate(QStringList, QStringList);
2021-07-18 21:09:04 -05:00
};