Add Slides menu, Camera Preset menu, and Help > About

This commit is contained in:
Gary Talent 2023-07-20 20:40:46 -05:00
parent 8f3693a1e5
commit 2817d543e9
3 changed files with 67 additions and 15 deletions

View File

@ -8,3 +8,6 @@
#pragma once #pragma once
constexpr auto MaxCameraPresets = 9;
constexpr auto MaxViews = 9;

View File

@ -9,6 +9,7 @@
#include <QApplication> #include <QApplication>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QStatusBar> #include <QStatusBar>
@ -78,7 +79,8 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
void MainWindow::setupMenu() { void MainWindow::setupMenu() {
// file menu // file menu
auto const fileMenu = menuBar()->addMenu(tr("&File")); {
auto const menu = menuBar()->addMenu(tr("&File"));
auto const settingsAct = new QAction(tr("&Settings"), this); auto const settingsAct = new QAction(tr("&Settings"), this);
auto const quitAct = new QAction(tr("E&xit"), this); auto const quitAct = new QAction(tr("E&xit"), this);
settingsAct->setShortcuts(QKeySequence::Preferences); settingsAct->setShortcuts(QKeySequence::Preferences);
@ -86,8 +88,57 @@ void MainWindow::setupMenu() {
quitAct->setShortcuts(QKeySequence::Quit); quitAct->setShortcuts(QKeySequence::Quit);
quitAct->setStatusTip(tr("Exit application")); quitAct->setStatusTip(tr("Exit application"));
connect(quitAct, &QAction::triggered, &QApplication::quit); connect(quitAct, &QAction::triggered, &QApplication::quit);
fileMenu->addAction(settingsAct); menu->addAction(settingsAct);
fileMenu->addAction(quitAct); 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>(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) { void MainWindow::setupDefaultViewControls(QGridLayout *viewCtlLyt) {

View File

@ -19,11 +19,9 @@
#include <QTableWidget> #include <QTableWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "consts.hpp"
#include "settingsdialog.hpp" #include "settingsdialog.hpp"
constexpr auto MaxPresets = 9;
constexpr auto MaxViews = 9;
enum ViewColumn { enum ViewColumn {
Name = 0, Name = 0,
Slides, Slides,
@ -209,8 +207,8 @@ int SettingsDialog::collectViews(QVector<View> &views) const {
return 1; return 1;
} }
const auto cameraPreset = m_viewTable->item(row, ViewColumn::CameraPreset)->text().toInt(&ok); const auto cameraPreset = m_viewTable->item(row, ViewColumn::CameraPreset)->text().toInt(&ok);
if (!ok || cameraPreset < 1 || cameraPreset > MaxPresets) { if (!ok || cameraPreset < 1 || cameraPreset > MaxCameraPresets) {
m_errLbl->setText(tr("View %1 has invalid preset (1-%2)").arg(viewNo).arg(MaxPresets)); m_errLbl->setText(tr("View %1 has invalid preset (1-%2)").arg(viewNo).arg(MaxCameraPresets));
return 2; return 2;
} }
views.emplace_back(View{ views.emplace_back(View{