mirror of
https://github.com/gtalent/sc9k.git
synced 2025-07-03 05:11:44 -05:00
Compare commits
13 Commits
release-0.
...
release-0.
Author | SHA1 | Date | |
---|---|---|---|
6f6f77f104 | |||
e57ba9e8f2 | |||
382e09d4b4 | |||
181e1b8599 | |||
3115083267 | |||
2d5af03724 | |||
c1cab3e3f3 | |||
8d0b0fb4c5 | |||
f9122c2942 | |||
b0eeb81592 | |||
7999cc486f | |||
09065f3e92 | |||
0ff1dfd300 |
39
deps/buildcore/base.mk
vendored
39
deps/buildcore/base.mk
vendored
@ -16,7 +16,15 @@ else
|
|||||||
HOST_ENV=${OS}-$(shell uname -m)
|
HOST_ENV=${OS}-$(shell uname -m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(shell python -c 'import sys; print(sys.version_info[0])'),3)
|
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
|
DEVENV_IMAGE=${PROJECT_NAME}-devenv
|
||||||
|
ifneq ($(shell which docker 2> /dev/null),)
|
||||||
|
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
||||||
|
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell ${ENV_RUN} python -c 'import sys; print(sys.version_info[0])'),3)
|
||||||
PYTHON3=python
|
PYTHON3=python
|
||||||
else
|
else
|
||||||
PYTHON3=python3
|
PYTHON3=python3
|
||||||
@ -26,6 +34,7 @@ SCRIPTS=${BUILDCORE_PATH}/scripts
|
|||||||
SETUP_BUILD=${PYTHON3} ${SCRIPTS}/setup-build.py
|
SETUP_BUILD=${PYTHON3} ${SCRIPTS}/setup-build.py
|
||||||
PYBB=${PYTHON3} ${SCRIPTS}/pybb.py
|
PYBB=${PYTHON3} ${SCRIPTS}/pybb.py
|
||||||
CMAKE_BUILD=${PYBB} cmake-build
|
CMAKE_BUILD=${PYBB} cmake-build
|
||||||
|
CTEST=${PYBB} ctest-all
|
||||||
RM_RF=${PYBB} rm
|
RM_RF=${PYBB} rm
|
||||||
ifdef USE_VCPKG
|
ifdef USE_VCPKG
|
||||||
ifndef VCPKG_DIR_BASE
|
ifndef VCPKG_DIR_BASE
|
||||||
@ -43,13 +52,6 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
|
VCPKG_DIR=$(VCPKG_DIR_BASE)/$(VCPKG_VERSION)-$(HOST_ENV)
|
||||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
|
||||||
DEVENV_IMAGE=${PROJECT_NAME}-devenv
|
|
||||||
ifneq ($(shell which docker 2> /dev/null),)
|
|
||||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
|
||||||
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
CURRENT_BUILD=$(HOST_ENV)-$(shell ${PYBB} cat .current_build)
|
CURRENT_BUILD=$(HOST_ENV)-$(shell ${PYBB} cat .current_build)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
@ -69,6 +71,12 @@ purge:
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build
|
test: build
|
||||||
${ENV_RUN} ${CMAKE_BUILD} build test
|
${ENV_RUN} ${CMAKE_BUILD} build test
|
||||||
|
.PHONY: test-verbose
|
||||||
|
test-verbose: build
|
||||||
|
${ENV_RUN} ${CTEST} build --output-on-failure
|
||||||
|
.PHONY: test-rerun-verbose
|
||||||
|
test-rerun-verbose: build
|
||||||
|
${ENV_RUN} ${CTEST} build --rerun-failed --output-on-failure
|
||||||
|
|
||||||
.PHONY: devenv-image
|
.PHONY: devenv-image
|
||||||
devenv-image:
|
devenv-image:
|
||||||
@ -89,11 +97,14 @@ devenv-create:
|
|||||||
.PHONY: devenv-destroy
|
.PHONY: devenv-destroy
|
||||||
devenv-destroy:
|
devenv-destroy:
|
||||||
docker rm -f ${DEVENV}
|
docker rm -f ${DEVENV}
|
||||||
|
ifdef ENV_RUN
|
||||||
.PHONY: devenv-shell
|
.PHONY: devenv-shell
|
||||||
devenv-shell:
|
devenv-shell:
|
||||||
${ENV_RUN} bash
|
${ENV_RUN} bash
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef USE_VCPKG
|
ifdef USE_VCPKG
|
||||||
|
|
||||||
.PHONY: vcpkg
|
.PHONY: vcpkg
|
||||||
vcpkg: ${VCPKG_DIR} vcpkg-install
|
vcpkg: ${VCPKG_DIR} vcpkg-install
|
||||||
|
|
||||||
@ -114,18 +125,20 @@ ifneq (${OS},windows)
|
|||||||
else
|
else
|
||||||
${VCPKG_DIR}/vcpkg install --triplet x64-windows ${VCPKG_PKGS}
|
${VCPKG_DIR}/vcpkg install --triplet x64-windows ${VCPKG_PKGS}
|
||||||
endif
|
endif
|
||||||
else # USE_VCPKG
|
|
||||||
|
else # USE_VCPKG ################################################
|
||||||
|
|
||||||
.PHONY: setup-conan
|
.PHONY: setup-conan
|
||||||
conan-config:
|
conan-config:
|
||||||
conan profile new nostalgia --detect --force
|
${ENV_RUN} conan profile new ${PROJECT_NAME} --detect --force
|
||||||
ifeq ($(OS),linux)
|
ifeq ($(OS),linux)
|
||||||
conan profile update settings.compiler.libcxx=libstdc++11 ${PROJECT_NAME}
|
${ENV_RUN} conan profile update settings.compiler.libcxx=libstdc++11 ${PROJECT_NAME}
|
||||||
endif
|
endif
|
||||||
.PHONY: conan
|
.PHONY: conan
|
||||||
conan:
|
conan:
|
||||||
@mkdir -p .conanbuild && cd .conanbuild && conan install ../ --build=missing -pr=${PROJECT_NAME}
|
${ENV_RUN} ${PYBB} conan-install ${PROJECT_NAME}
|
||||||
endif # USE_VCPKG
|
#@mkdir -p .conanbuild && cd .conanbuild && conan install ../ --build=missing -pr=${PROJECT_NAME}
|
||||||
|
endif # USE_VCPKG ###############################################
|
||||||
|
|
||||||
.PHONY: configure-xcode
|
.PHONY: configure-xcode
|
||||||
configure-xcode:
|
configure-xcode:
|
||||||
|
41
obs_scene_switcher.py
Normal file
41
obs_scene_switcher.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
from urllib.parse import urlparse, parse_qs
|
||||||
|
import threading
|
||||||
|
import obspython as obs
|
||||||
|
|
||||||
|
|
||||||
|
def set_current_scene(scene_name):
|
||||||
|
scenes = obs.obs_frontend_get_scenes()
|
||||||
|
for scene in scenes:
|
||||||
|
name = obs.obs_source_get_name(scene)
|
||||||
|
if name == scene_name:
|
||||||
|
obs.obs_frontend_set_current_scene(scene)
|
||||||
|
return 0
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
class RqstHandler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
up = urlparse(self.path)
|
||||||
|
if up.path == '/Scene':
|
||||||
|
qc = parse_qs(up.query)
|
||||||
|
set_current_scene(qc.get('name', [''])[0])
|
||||||
|
self.send_response(200)
|
||||||
|
self.end_headers()
|
||||||
|
elif up.path == '/ping':
|
||||||
|
self.send_response(200)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
|
||||||
|
def log_message(self, format, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def run(name):
|
||||||
|
httpd = HTTPServer(('127.0.0.1', 9302), RqstHandler)
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
t = threading.Thread(target=run, args=(1,), daemon=True)
|
||||||
|
t.start()
|
@ -6,9 +6,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
|
||||||
@ -17,62 +15,61 @@
|
|||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
||||||
move(0, 0);
|
move(0, 0);
|
||||||
setFixedSize(590, 555);
|
setFixedSize(600, 555);
|
||||||
setWindowTitle(tr("Slide Controller 9000"));
|
setWindowTitle(tr("Slide Controller 9000"));
|
||||||
const auto mainWidget = new QWidget(this);
|
const auto mainWidget = new QWidget(this);
|
||||||
const auto rootLyt = new QVBoxLayout;
|
const auto rootLyt = new QVBoxLayout;
|
||||||
const auto controlsLayout = new QGridLayout;
|
const auto controlsLayout = new QGridLayout;
|
||||||
const auto slideView = new SlideView(this);
|
m_slideView = new SlideView(this);
|
||||||
setCentralWidget(mainWidget);
|
setCentralWidget(mainWidget);
|
||||||
mainWidget->setLayout(rootLyt);
|
mainWidget->setLayout(rootLyt);
|
||||||
rootLyt->addWidget(slideView);
|
rootLyt->addWidget(m_slideView);
|
||||||
rootLyt->addLayout(controlsLayout);
|
rootLyt->addLayout(controlsLayout);
|
||||||
// setup slide controls
|
// setup slide controls
|
||||||
|
const auto showHideLyt = new QHBoxLayout;
|
||||||
|
rootLyt->addLayout(showHideLyt);
|
||||||
const auto btnPrevSong = new QPushButton(tr("Previous Song (Left)"), this);
|
const auto btnPrevSong = new QPushButton(tr("Previous Song (Left)"), this);
|
||||||
const auto btnPrevSlide = new QPushButton(tr("Previous Slide (Up)"), this);
|
const auto btnPrevSlide = new QPushButton(tr("Previous Slide (Up)"), this);
|
||||||
const auto btnNextSlide = new QPushButton(tr("Next Slide (Down)"), this);
|
const auto btnNextSlide = new QPushButton(tr("Next Slide (Down)"), this);
|
||||||
const auto btnNextSong = new QPushButton(tr("Next Song (Right))"), this);
|
const auto btnNextSong = new QPushButton(tr("Next Song (Right)"), this);
|
||||||
const auto btnBlankSlides = new QPushButton(tr("Blank Slides (,)"), this);
|
const auto btnHideSlides = new QPushButton(tr("Hide (1)"), this);
|
||||||
const auto btnShowSlides = new QPushButton(tr("Show Slides (.)"), this);
|
const auto btnOpenLpShowSlides = new QPushButton(tr("Show in OpenLP Only (2)"), this);
|
||||||
controlsLayout->addWidget(btnPrevSlide, 0, 0);
|
const auto btnShowSlides = new QPushButton(tr("Show (3)"), mainWidget);
|
||||||
controlsLayout->addWidget(btnNextSlide, 0, 1);
|
controlsLayout->addWidget(btnPrevSlide, 0, 1);
|
||||||
controlsLayout->addWidget(btnPrevSong, 1, 0);
|
controlsLayout->addWidget(btnNextSlide, 0, 2);
|
||||||
controlsLayout->addWidget(btnNextSong, 1, 1);
|
controlsLayout->addWidget(btnPrevSong, 0, 0);
|
||||||
controlsLayout->addWidget(btnBlankSlides, 2, 0);
|
controlsLayout->addWidget(btnNextSong, 0, 3);
|
||||||
controlsLayout->addWidget(btnShowSlides, 2, 1);
|
showHideLyt->addWidget(btnHideSlides);
|
||||||
|
showHideLyt->addWidget(btnOpenLpShowSlides);
|
||||||
|
showHideLyt->addWidget(btnShowSlides);
|
||||||
btnNextSong->setShortcut(Qt::Key_Right);
|
btnNextSong->setShortcut(Qt::Key_Right);
|
||||||
btnPrevSong->setShortcut(Qt::Key_Left);
|
btnPrevSong->setShortcut(Qt::Key_Left);
|
||||||
btnNextSlide->setShortcut(Qt::Key_Down);
|
btnNextSlide->setShortcut(Qt::Key_Down);
|
||||||
btnPrevSlide->setShortcut(Qt::Key_Up);
|
btnPrevSlide->setShortcut(Qt::Key_Up);
|
||||||
btnBlankSlides->setShortcut(Qt::Key_Comma);
|
btnHideSlides->setShortcut(Qt::Key_1);
|
||||||
btnShowSlides->setShortcut(Qt::Key_Period);
|
btnOpenLpShowSlides->setShortcut(Qt::Key_2);
|
||||||
btnBlankSlides->setToolTip(tr("Also hides slides in OBS"));
|
btnHideSlides->setToolTip(tr("Also hides slides in OBS"));
|
||||||
|
btnShowSlides->setShortcut(Qt::Key_3);
|
||||||
connect(btnNextSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSlide);
|
connect(btnNextSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSlide);
|
||||||
connect(btnPrevSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSlide);
|
connect(btnPrevSlide, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSlide);
|
||||||
connect(btnNextSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSong);
|
connect(btnNextSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::nextSong);
|
||||||
connect(btnPrevSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSong);
|
connect(btnPrevSong, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::prevSong);
|
||||||
connect(btnBlankSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::blankScreen);
|
connect(btnHideSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::blankScreen);
|
||||||
connect(btnBlankSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides);
|
connect(btnHideSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides);
|
||||||
|
connect(btnOpenLpShowSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::showSlides);
|
||||||
|
connect(btnShowSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::showSlides);
|
||||||
connect(btnShowSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::showSlides);
|
connect(btnShowSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::showSlides);
|
||||||
connect(&m_openlpClient, &OpenLPClient::pollUpdate, slideView, &SlideView::pollUpdate);
|
connect(&m_openlpClient, &OpenLPClient::pollUpdate, m_slideView, &SlideView::pollUpdate);
|
||||||
connect(&m_openlpClient, &OpenLPClient::songListUpdate, slideView, &SlideView::songListUpdate);
|
connect(&m_openlpClient, &OpenLPClient::songListUpdate, m_slideView, &SlideView::songListUpdate);
|
||||||
connect(&m_openlpClient, &OpenLPClient::slideListUpdate, slideView, &SlideView::slideListUpdate);
|
connect(&m_openlpClient, &OpenLPClient::slideListUpdate, m_slideView, &SlideView::slideListUpdate);
|
||||||
connect(&m_openlpClient, &OpenLPClient::pollFailed, slideView, &SlideView::reset);
|
connect(&m_openlpClient, &OpenLPClient::pollFailed, m_slideView, &SlideView::reset);
|
||||||
connect(slideView, &SlideView::songChanged, &m_openlpClient, &OpenLPClient::changeSong);
|
connect(m_slideView, &SlideView::songChanged, &m_openlpClient, &OpenLPClient::changeSong);
|
||||||
connect(slideView, &SlideView::slideChanged, &m_openlpClient, &OpenLPClient::changeSlide);
|
connect(m_slideView, &SlideView::slideChanged, &m_openlpClient, &OpenLPClient::changeSlide);
|
||||||
// setup scene selector
|
// setup scene selector
|
||||||
const auto btnObsHideSlides = new QPushButton(tr("Hide Slides in OBS (;)"), mainWidget);
|
connect(btnOpenLpShowSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides);
|
||||||
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);
|
|
||||||
// setup status bar
|
// setup status bar
|
||||||
setStatusBar(new QStatusBar(this));
|
setStatusBar(new QStatusBar(this));
|
||||||
|
connect(&m_openlpClient, &OpenLPClient::songChanged, this, &MainWindow::refreshStatusBar);
|
||||||
connect(&m_openlpClient, &OpenLPClient::pollUpdate, this, &MainWindow::openLpConnectionInit);
|
connect(&m_openlpClient, &OpenLPClient::pollUpdate, this, &MainWindow::openLpConnectionInit);
|
||||||
connect(&m_obsClient, &OBSClient::pollUpdate, this, &MainWindow::obsConnectionInit);
|
connect(&m_obsClient, &OBSClient::pollUpdate, this, &MainWindow::obsConnectionInit);
|
||||||
refreshStatusBar();
|
refreshStatusBar();
|
||||||
@ -109,5 +106,7 @@ void MainWindow::obsConnectionLost() {
|
|||||||
void MainWindow::refreshStatusBar() {
|
void MainWindow::refreshStatusBar() {
|
||||||
const auto openLpStatus = m_openLpConnected ? tr("OpenLP: Connected") : tr("OpenLP: Not Connected");
|
const auto openLpStatus = m_openLpConnected ? tr("OpenLP: Connected") : tr("OpenLP: Not Connected");
|
||||||
const auto obsStatus = m_obsConnected ? tr("OBS: Connected") : tr("OBS: Not Connected");
|
const auto obsStatus = m_obsConnected ? tr("OBS: Connected") : tr("OBS: Not Connected");
|
||||||
statusBar()->showMessage(openLpStatus + " | " + obsStatus);
|
const auto nextSong = m_openlpClient.getNextSong();
|
||||||
|
const auto nextSongTxt = m_openLpConnected ? " | Next Song: " + nextSong : "";
|
||||||
|
statusBar()->showMessage(openLpStatus + " | " + obsStatus + nextSongTxt);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class MainWindow: public QMainWindow {
|
|||||||
private:
|
private:
|
||||||
OBSClient m_obsClient;
|
OBSClient m_obsClient;
|
||||||
OpenLPClient m_openlpClient;
|
OpenLPClient m_openlpClient;
|
||||||
|
class SlideView *m_slideView = nullptr;
|
||||||
bool m_openLpConnected = false;
|
bool m_openLpConnected = false;
|
||||||
bool m_obsConnected = false;
|
bool m_obsConnected = false;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@ -40,7 +41,8 @@ void OBSClient::setSlidesVisible(int state) {
|
|||||||
void OBSClient::get(QString urlExt) {
|
void OBSClient::get(QString urlExt) {
|
||||||
QUrl url(QString(BaseUrl) + urlExt);
|
QUrl url(QString(BaseUrl) + urlExt);
|
||||||
QNetworkRequest rqst(url);
|
QNetworkRequest rqst(url);
|
||||||
m_nam->get(rqst)->deleteLater();
|
auto reply = m_nam->get(rqst);
|
||||||
|
connect(reply, &QIODevice::readyRead, reply, &QObject::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSClient::poll() {
|
void OBSClient::poll() {
|
||||||
|
@ -24,6 +24,15 @@ OpenLPClient::OpenLPClient(QObject *parent): QObject(parent) {
|
|||||||
connect(m_pollingNam, &QNetworkAccessManager::finished, this, &OpenLPClient::handlePollResponse);
|
connect(m_pollingNam, &QNetworkAccessManager::finished, this, &OpenLPClient::handlePollResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString OpenLPClient::getNextSong() {
|
||||||
|
const auto currentSong = m_songNameMap[m_currentSongId];
|
||||||
|
const auto songIdx = m_songList.indexOf(currentSong) + 1;
|
||||||
|
if (songIdx < m_songList.size()) {
|
||||||
|
return m_songList[songIdx];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void OpenLPClient::nextSlide() {
|
void OpenLPClient::nextSlide() {
|
||||||
get("/api/controller/live/next");
|
get("/api/controller/live/next");
|
||||||
}
|
}
|
||||||
@ -117,6 +126,7 @@ void OpenLPClient::handlePollResponse(QNetworkReply *reply) {
|
|||||||
if (m_currentSongId != songId) {
|
if (m_currentSongId != songId) {
|
||||||
requestSlideList();
|
requestSlideList();
|
||||||
m_currentSongId = songId;
|
m_currentSongId = songId;
|
||||||
|
emit songChanged(songId);
|
||||||
}
|
}
|
||||||
emit pollUpdate(m_songNameMap[songId], slide);
|
emit pollUpdate(m_songNameMap[songId], slide);
|
||||||
}
|
}
|
||||||
@ -130,18 +140,18 @@ void OpenLPClient::handleSongListResponse(QNetworkReply *reply) {
|
|||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList songList;
|
|
||||||
auto doc = QJsonDocument::fromJson(data);
|
auto doc = QJsonDocument::fromJson(data);
|
||||||
auto items = doc.object()["results"].toObject()["items"].toArray();
|
auto items = doc.object()["results"].toObject()["items"].toArray();
|
||||||
m_songNameMap.clear();
|
m_songNameMap.clear();
|
||||||
|
m_songList.clear();
|
||||||
for (const auto &item : items) {
|
for (const auto &item : items) {
|
||||||
auto song = item.toObject();
|
auto song = item.toObject();
|
||||||
auto name = song["title"].toString();
|
auto name = song["title"].toString();
|
||||||
auto id = song["id"].toString();
|
auto id = song["id"].toString();
|
||||||
m_songNameMap[id] = name;
|
m_songNameMap[id] = name;
|
||||||
songList.push_back(name);
|
m_songList.push_back(name);
|
||||||
}
|
}
|
||||||
emit songListUpdate(songList);
|
emit songListUpdate(m_songList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenLPClient::handleSlideListResponse(QNetworkReply *reply) {
|
void OpenLPClient::handleSlideListResponse(QNetworkReply *reply) {
|
||||||
|
@ -30,13 +30,17 @@ class OpenLPClient: public QObject {
|
|||||||
QNetworkAccessManager *m_slideListNam = new QNetworkAccessManager(this);
|
QNetworkAccessManager *m_slideListNam = new QNetworkAccessManager(this);
|
||||||
QTimer m_pollTimer;
|
QTimer m_pollTimer;
|
||||||
QHash<QString, QString> m_songNameMap;
|
QHash<QString, QString> m_songNameMap;
|
||||||
|
QStringList m_songList;
|
||||||
int m_currentServiceId = -1;
|
int m_currentServiceId = -1;
|
||||||
QString m_currentSongId;
|
QString m_currentSongId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OpenLPClient(QObject *parent = nullptr);
|
explicit OpenLPClient(QObject *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
[[nodiscard]]
|
||||||
|
QString getNextSong();
|
||||||
|
|
||||||
|
public slots:
|
||||||
void nextSlide();
|
void nextSlide();
|
||||||
|
|
||||||
void prevSlide();
|
void prevSlide();
|
||||||
@ -80,5 +84,6 @@ class OpenLPClient: public QObject {
|
|||||||
|
|
||||||
void slideListUpdate(QStringList, QStringList);
|
void slideListUpdate(QStringList, QStringList);
|
||||||
|
|
||||||
|
void songChanged(QString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,15 @@ SlideView::SlideView(QWidget *parent): QWidget(parent) {
|
|||||||
connect(m_slideTable, &QTableWidget::currentCellChanged, this, &SlideView::slideChanged);
|
connect(m_slideTable, &QTableWidget::currentCellChanged, this, &SlideView::slideChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SlideView::getNextSong() const {
|
||||||
|
const auto cnt = m_songSelector->count();
|
||||||
|
const auto idx = m_songSelector->currentIndex() + 1;
|
||||||
|
if (idx < cnt) {
|
||||||
|
return m_songSelector->itemText(idx);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void SlideView::pollUpdate(QString songName, int slide) {
|
void SlideView::pollUpdate(QString songName, int slide) {
|
||||||
if (songName != m_currentSong) {
|
if (songName != m_currentSong) {
|
||||||
m_currentSong = songName;
|
m_currentSong = songName;
|
||||||
|
@ -19,6 +19,8 @@ class SlideView: public QWidget {
|
|||||||
public:
|
public:
|
||||||
explicit SlideView(QWidget *parent = nullptr);
|
explicit SlideView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
QString getNextSong() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void pollUpdate(QString songId, int slideNum);
|
void pollUpdate(QString songId, int slideNum);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user