mirror of
https://github.com/gtalent/sc9k.git
synced 2025-05-10 17:51:37 -05:00
Add next song to status line
This commit is contained in:
parent
7999cc486f
commit
b0eeb81592
@ -3,6 +3,7 @@ from urllib.parse import urlparse, parse_qs
|
|||||||
import threading
|
import threading
|
||||||
import obspython as obs
|
import obspython as obs
|
||||||
|
|
||||||
|
|
||||||
def set_current_scene(scene_name):
|
def set_current_scene(scene_name):
|
||||||
scenes = obs.obs_frontend_get_scenes()
|
scenes = obs.obs_frontend_get_scenes()
|
||||||
for scene in scenes:
|
for scene in scenes:
|
||||||
@ -12,6 +13,7 @@ def set_current_scene(scene_name):
|
|||||||
return 0
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
class RqstHandler(BaseHTTPRequestHandler):
|
class RqstHandler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
@ -25,12 +27,15 @@ class RqstHandler(BaseHTTPRequestHandler):
|
|||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
|
|
||||||
def log_message(self, format, *args):
|
def log_message(self, format, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run(name):
|
def run(name):
|
||||||
httpd = HTTPServer(('127.0.0.1', 9302), RqstHandler)
|
httpd = HTTPServer(('127.0.0.1', 9302), RqstHandler)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
t = threading.Thread(target=run, args=(1,), daemon=True)
|
t = threading.Thread(target=run, args=(1,), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -20,10 +20,10 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
|||||||
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 btnPrevSong = new QPushButton(tr("Previous Song (Left)"), this);
|
const auto btnPrevSong = new QPushButton(tr("Previous Song (Left)"), this);
|
||||||
@ -52,12 +52,12 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
|||||||
connect(btnBlankSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::blankScreen);
|
connect(btnBlankSlides, &QPushButton::clicked, &m_openlpClient, &OpenLPClient::blankScreen);
|
||||||
connect(btnBlankSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides);
|
connect(btnBlankSlides, &QPushButton::clicked, &m_obsClient, &OBSClient::hideSlides);
|
||||||
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);
|
const auto btnObsHideSlides = new QPushButton(tr("Hide Slides in OBS (;)"), mainWidget);
|
||||||
const auto btnObsShowSlides = new QPushButton(tr("Show Slides in OBS (')"), mainWidget);
|
const auto btnObsShowSlides = new QPushButton(tr("Show Slides in OBS (')"), mainWidget);
|
||||||
@ -107,5 +107,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_slideView->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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user