From a2b8073ce8752520ba0ebabf365e443eb3d3b8eb Mon Sep 17 00:00:00 2001 From: A/V User Date: Sun, 18 Jul 2021 21:09:04 -0500 Subject: [PATCH] Initial commit --- .gitignore | Bin 0 -> 54 bytes SlideController.pro | 27 ++++ SlideController.pro.user | 319 +++++++++++++++++++++++++++++++++++++++ main.cpp | 10 ++ mainwindow.cpp | 69 +++++++++ mainwindow.hpp | 21 +++ obsclient.cpp | 30 ++++ obsclient.hpp | 31 ++++ openlpclient.cpp | 37 +++++ openlpclient.hpp | 34 +++++ slideview.cpp | 6 + slideview.hpp | 14 ++ 12 files changed, 598 insertions(+) create mode 100644 .gitignore create mode 100644 SlideController.pro create mode 100644 SlideController.pro.user create mode 100644 main.cpp create mode 100644 mainwindow.cpp create mode 100644 mainwindow.hpp create mode 100644 obsclient.cpp create mode 100644 obsclient.hpp create mode 100644 openlpclient.cpp create mode 100644 openlpclient.hpp create mode 100644 slideview.cpp create mode 100644 slideview.hpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..cc75aa04463bbc4bd3b129f19171add57e805d77 GIT binary patch literal 54 ycmezWFPI^RA(J76A(g?IA)g_Sp@g9bNap}yDv+hePypuZF_bbCgGG25xEKI^M+=q! literal 0 HcmV?d00001 diff --git a/SlideController.pro b/SlideController.pro new file mode 100644 index 0000000..494fbd8 --- /dev/null +++ b/SlideController.pro @@ -0,0 +1,27 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += webenginewidgets widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + obsclient.cpp \ + openlpclient.cpp \ + slideview.cpp + +HEADERS += \ + mainwindow.hpp \ + obsclient.hpp \ + openlpclient.hpp \ + slideview.hpp + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/SlideController.pro.user b/SlideController.pro.user new file mode 100644 index 0000000..e01bf2e --- /dev/null +++ b/SlideController.pro.user @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {08334014-cc98-402b-addd-6d89112df7cb} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.Questionable + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.15.2 MSVC2019 64bit + Desktop Qt 5.15.2 MSVC2019 64bit + qt.qt5.5152.win64_msvc2019_64_kit + 0 + 0 + 0 + + 0 + C:\Users\avuser\Documents\build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug + C:/Users/avuser/Documents/build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 0 + + + C:\Users\avuser\Documents\build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Release + C:/Users/avuser/Documents/build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + + 0 + C:\Users\avuser\Documents\build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile + C:/Users/avuser/Documents/build-SlideController-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..73a960b --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include "mainwindow.hpp" + +#include + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..b59e423 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "mainwindow.hpp" + +MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) { + move(0, 0); + setFixedSize(590, 555); + setWindowTitle(tr("Slide Controller 9000")); + const auto mainWidget = new QWidget(this); + const auto rootLyt = new QVBoxLayout; + const auto viewsLayout = new QHBoxLayout; + const auto controlsLayout = new QGridLayout; + const auto slideView = new QWebEngineView(mainWidget); + setCentralWidget(mainWidget); + mainWidget->setLayout(rootLyt); + viewsLayout->addWidget(slideView, 1); + viewsLayout->setSizeConstraint(QLayout::SetFixedSize); + rootLyt->addLayout(viewsLayout); + rootLyt->addLayout(controlsLayout); + slideView->setUrl(QUrl("http://127.0.0.1:4316/main")); + // setup slide controls + const auto btnPrevSong = new QPushButton(tr("Previous Song (Left)"), this); + const auto btnPrevSlide = new QPushButton(tr("Previous Slide (Up)"), this); + const auto btnNextSlide = new QPushButton(tr("Next Slide (Down)"), this); + const auto btnNextSong = new QPushButton(tr("Next Song (Right))"), this); + const auto btnBlankSlides = new QPushButton(tr("Blank Slides (,)"), this); + const auto btnShowSlides = new QPushButton(tr("Show Slides (.)"), this); + rootLyt->addLayout(controlsLayout); + controlsLayout->addWidget(btnPrevSong, 0, 0); + controlsLayout->addWidget(btnPrevSlide, 0, 1); + controlsLayout->addWidget(btnNextSlide, 1, 0); + controlsLayout->addWidget(btnNextSong, 1, 1); + controlsLayout->addWidget(btnBlankSlides, 2, 0); + controlsLayout->addWidget(btnShowSlides, 2, 1); + btnNextSong->setShortcut(Qt::Key_Right); + btnPrevSong->setShortcut(Qt::Key_Left); + btnNextSlide->setShortcut(Qt::Key_Down); + btnPrevSlide->setShortcut(Qt::Key_Up); + btnBlankSlides->setShortcut(Qt::Key_Comma); + btnShowSlides->setShortcut(Qt::Key_Period); + btnBlankSlides->setToolTip(tr("Also hides slides in OBS")); + connect(btnNextSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSlide); + connect(btnPrevSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSlide); + connect(btnNextSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSong); + connect(btnPrevSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSong); + connect(btnBlankSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::blankScreen); + connect(btnBlankSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides); + connect(btnShowSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::showSlides); + // setup scene selector + const auto btnObsHideSlides = new QPushButton(tr("Hide Slides in OBS (;)"), mainWidget); + const auto btnObsShowSlides = new QPushButton(tr("Show Slides in OBS (')"), mainWidget); + controlsLayout->addWidget(btnObsHideSlides, 3, 0); + controlsLayout->addWidget(btnObsShowSlides, 3, 1); + btnObsHideSlides->setShortcut(Qt::Key_Semicolon); + btnObsShowSlides->setShortcut(Qt::Key_Apostrophe); + btnObsShowSlides->setToolTip(tr("Also shows slides in OpenLP")); + connect(btnObsHideSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides); + connect(btnObsShowSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::showSlides); + connect(btnObsShowSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::showSlides); +} + +MainWindow::~MainWindow() { +} diff --git a/mainwindow.hpp b/mainwindow.hpp new file mode 100644 index 0000000..13f0545 --- /dev/null +++ b/mainwindow.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include + +#include "obsclient.hpp" +#include "openlpclient.hpp" + +class MainWindow: public QMainWindow { + Q_OBJECT + + private: + OBSClient m_obsClient; + OpenLPClient m_openlpClient; + + public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + private slots: + +}; diff --git a/obsclient.cpp b/obsclient.cpp new file mode 100644 index 0000000..2aa421a --- /dev/null +++ b/obsclient.cpp @@ -0,0 +1,30 @@ +#include "obsclient.hpp" + +OBSClient::OBSClient(QObject *parent): QObject(parent) { +} + +void OBSClient::setScene(QString scene) { + get(QString("/Scene?name=%1").arg(scene)); +} + +void OBSClient::showSlides() { + setScene("MusicScene"); +} + +void OBSClient::hideSlides() { + setScene("SpeakerScene"); +} + +void OBSClient::setSlidesVisible(int state) { + if (state) { + setScene("MusicScene"); + } else { + setScene("SpeakerScene"); + } +} + +void OBSClient::get(QString urlExt) { + QUrl url(QString(BaseUrl) + urlExt); + QNetworkRequest rqst(url); + m_nam->get(rqst); +} diff --git a/obsclient.hpp b/obsclient.hpp new file mode 100644 index 0000000..667cc10 --- /dev/null +++ b/obsclient.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +class OBSClient : public QObject +{ + Q_OBJECT + private: + static constexpr auto BaseUrl = "http://127.0.0.1:9302"; + QNetworkAccessManager *m_nam = new QNetworkAccessManager(this); + + public: + explicit OBSClient(QObject *parent = nullptr); + + public slots: + void setScene(QString scene); + + void showSlides(); + + void hideSlides(); + + void setSlidesVisible(int state); + + private: + void get(QString url); + + signals: + +}; + diff --git a/openlpclient.cpp b/openlpclient.cpp new file mode 100644 index 0000000..59faf6c --- /dev/null +++ b/openlpclient.cpp @@ -0,0 +1,37 @@ + + +#include "openlpclient.hpp" + +OpenLPClient::OpenLPClient(QObject *parent): QObject(parent) { + +} + +void OpenLPClient::nextSlide() { + get("/api/controller/live/next"); +} + +void OpenLPClient::prevSlide() { + get("/api/controller/live/previous"); +} + +void OpenLPClient::nextSong() { + get("/api/service/next"); +} + +void OpenLPClient::prevSong() { + get("/api/service/previous"); +} + +void OpenLPClient::blankScreen() { + get("/api/display/hide"); +} + +void OpenLPClient::showSlides() { + get("/api/display/show"); +} + +void OpenLPClient::get(QString urlExt) { + QUrl url(QString(BaseUrl) + urlExt); + QNetworkRequest rqst(url); + m_nam->get(rqst); +} diff --git a/openlpclient.hpp b/openlpclient.hpp new file mode 100644 index 0000000..ac75955 --- /dev/null +++ b/openlpclient.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include +#include + +class OpenLPClient: public QObject { + Q_OBJECT + private: + static constexpr auto BaseUrl = "http://127.0.0.1:4316"; + QNetworkAccessManager *m_nam = new QNetworkAccessManager(this); + + public: + explicit OpenLPClient(QObject *parent = nullptr); + + public slots: + void nextSlide(); + + void prevSlide(); + + void nextSong(); + + void prevSong(); + + void blankScreen(); + + void showSlides(); + + private: + void get(QString url); + + signals: + +}; + diff --git a/slideview.cpp b/slideview.cpp new file mode 100644 index 0000000..77b7c6b --- /dev/null +++ b/slideview.cpp @@ -0,0 +1,6 @@ +#include "slideview.hpp" + +SlideView::SlideView(QWidget *parent) : QWidget(parent) +{ + +} diff --git a/slideview.hpp b/slideview.hpp new file mode 100644 index 0000000..34a917a --- /dev/null +++ b/slideview.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include + +class SlideView : public QWidget +{ + Q_OBJECT +public: + explicit SlideView(QWidget *parent = nullptr); + +signals: + +}; +