From 2817d543e927c075a4f3545dac0b8a0f4a95b708 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 20 Jul 2023 20:40:46 -0500 Subject: [PATCH] Add Slides menu, Camera Preset menu, and Help > About --- src/consts.hpp | 3 ++ src/mainwindow.cpp | 71 ++++++++++++++++++++++++++++++++++++------ src/settingsdialog.cpp | 8 ++--- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/src/consts.hpp b/src/consts.hpp index 5f360eb..81d5cdd 100644 --- a/src/consts.hpp +++ b/src/consts.hpp @@ -8,3 +8,6 @@ #pragma once +constexpr auto MaxCameraPresets = 9; +constexpr auto MaxViews = 9; + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 11fb112..7d4eedf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -78,16 +79,66 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) { void MainWindow::setupMenu() { // file menu - auto const fileMenu = menuBar()->addMenu(tr("&File")); - auto const settingsAct = new QAction(tr("&Settings"), this); - auto const quitAct = new QAction(tr("E&xit"), this); - settingsAct->setShortcuts(QKeySequence::Preferences); - connect(settingsAct, &QAction::triggered, this, &MainWindow::openSettings); - quitAct->setShortcuts(QKeySequence::Quit); - quitAct->setStatusTip(tr("Exit application")); - connect(quitAct, &QAction::triggered, &QApplication::quit); - fileMenu->addAction(settingsAct); - fileMenu->addAction(quitAct); + { + auto const menu = menuBar()->addMenu(tr("&File")); + auto const settingsAct = new QAction(tr("&Settings"), this); + auto const quitAct = new QAction(tr("E&xit"), this); + settingsAct->setShortcuts(QKeySequence::Preferences); + connect(settingsAct, &QAction::triggered, this, &MainWindow::openSettings); + quitAct->setShortcuts(QKeySequence::Quit); + quitAct->setStatusTip(tr("Exit application")); + connect(quitAct, &QAction::triggered, &QApplication::quit); + menu->addAction(settingsAct); + menu->addAction(quitAct); + } + // slides menu + { + auto const menu = menuBar()->addMenu(tr("&Slides")); + auto const hideSlidesAct = new QAction(tr("&Hide Slides"), this); + hideSlidesAct->setShortcut(Qt::CTRL | Qt::Key_1); + connect(hideSlidesAct, &QAction::triggered, &m_openlpClient, &OpenLPClient::blankScreen); + connect(hideSlidesAct, &QAction::triggered, &m_obsClient, &OBSClient::hideSlides); + menu->addAction(hideSlidesAct); + auto const showSlidesInOpenLpAct = new QAction(tr("Show in &OpenLP Only"), this); + showSlidesInOpenLpAct->setShortcut(Qt::CTRL | Qt::Key_2); + connect(showSlidesInOpenLpAct, &QAction::triggered, &m_openlpClient, &OpenLPClient::showSlides); + connect(showSlidesInOpenLpAct, &QAction::triggered, &m_obsClient, &OBSClient::hideSlides); + menu->addAction(showSlidesInOpenLpAct); + auto const showSlidesAct = new QAction(tr("&Show Slides"), this); + showSlidesAct->setShortcut(Qt::CTRL | Qt::Key_3); + connect(showSlidesAct, &QAction::triggered, &m_obsClient, &OBSClient::showSlides); + connect(showSlidesAct, &QAction::triggered, &m_openlpClient, &OpenLPClient::showSlides); + menu->addAction(showSlidesAct); + } + // camera preset menu + { + auto const menu = menuBar()->addMenu(tr("&Camera Preset")); + for (auto i = 0; i < MaxCameraPresets; ++i) { + auto const cameraPresetAct = new QAction(tr("Camera Preset &%1").arg(i + 1), this); + cameraPresetAct->setShortcut(Qt::ALT | static_cast(Qt::Key_1 + i)); + connect(cameraPresetAct, &QAction::triggered, &m_cameraClient, [this, i] { + m_cameraClient.setPreset(i + 1); + }); + menu->addAction(cameraPresetAct); + } + } + // help menu + { + auto const menu = menuBar()->addMenu(tr("&Help")); + auto const aboutAct = new QAction(tr("&About"), this); + connect(aboutAct, &QAction::triggered, &m_cameraClient, [this] { + QMessageBox about(this); + about.setText(tr( +R"(Slide Controller 9000 - 1.0-beta +Build date: %1 + +Copyright 2021 - 2023 Gary Talent (gary@drinkingtea.net) +Slide Controller 9000 is released under the MPL 2.0 +Built on Qt library under LGPL 2.0)").arg(__DATE__)); + about.exec(); + }); + menu->addAction(aboutAct); + } } void MainWindow::setupDefaultViewControls(QGridLayout *viewCtlLyt) { diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index a7669f4..af3cf9e 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -19,11 +19,9 @@ #include #include +#include "consts.hpp" #include "settingsdialog.hpp" -constexpr auto MaxPresets = 9; -constexpr auto MaxViews = 9; - enum ViewColumn { Name = 0, Slides, @@ -209,8 +207,8 @@ int SettingsDialog::collectViews(QVector &views) const { return 1; } const auto cameraPreset = m_viewTable->item(row, ViewColumn::CameraPreset)->text().toInt(&ok); - if (!ok || cameraPreset < 1 || cameraPreset > MaxPresets) { - m_errLbl->setText(tr("View %1 has invalid preset (1-%2)").arg(viewNo).arg(MaxPresets)); + if (!ok || cameraPreset < 1 || cameraPreset > MaxCameraPresets) { + m_errLbl->setText(tr("View %1 has invalid preset (1-%2)").arg(viewNo).arg(MaxCameraPresets)); return 2; } views.emplace_back(View{