mirror of
https://github.com/gtalent/sc9k.git
synced 2025-01-23 00:33:36 -06:00
Add preview button to Image tab in settings
This commit is contained in:
parent
77df4257c5
commit
8a4989923c
@ -20,11 +20,21 @@ CameraClient::CameraClient(QObject *parent): QObject(parent) {
|
|||||||
connect(m_pollingNam, &QNetworkAccessManager::finished, this, &CameraClient::handlePollResponse);
|
connect(m_pollingNam, &QNetworkAccessManager::finished, this, &CameraClient::handlePollResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CameraClient::setPresetVC(int preset, VideoConfig const&vc) {
|
||||||
|
if (preset > 0 && preset < MaxCameraPresets) {
|
||||||
|
get(QString("/cgi-bin/ptzctrl.cgi?ptzcmd&poscall&%1").arg(preset));
|
||||||
|
setBrightness(vc.brightness);
|
||||||
|
setSaturation(vc.saturation);
|
||||||
|
setContrast(vc.contrast);
|
||||||
|
setSharpness(vc.sharpness);
|
||||||
|
setHue(vc.hue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CameraClient::setPreset(int preset) {
|
void CameraClient::setPreset(int preset) {
|
||||||
if (preset > 0 && preset < MaxCameraPresets) {
|
if (preset > 0 && preset < MaxCameraPresets) {
|
||||||
get(QString("/cgi-bin/ptzctrl.cgi?ptzcmd&poscall&%1").arg(preset));
|
get(QString("/cgi-bin/ptzctrl.cgi?ptzcmd&poscall&%1").arg(preset));
|
||||||
--preset;
|
auto const vc = getVideoConfig()[preset - 1];
|
||||||
auto const vc = getVideoConfig()[preset];
|
|
||||||
setBrightness(vc.brightness);
|
setBrightness(vc.brightness);
|
||||||
setSaturation(vc.saturation);
|
setSaturation(vc.saturation);
|
||||||
setContrast(vc.contrast);
|
setContrast(vc.contrast);
|
||||||
|
@ -25,6 +25,8 @@ class CameraClient: public QObject {
|
|||||||
public:
|
public:
|
||||||
explicit CameraClient(QObject *parent = nullptr);
|
explicit CameraClient(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void setPresetVC(int preset, struct VideoConfig const&vc);
|
||||||
|
|
||||||
void setPreset(int preset);
|
void setPreset(int preset);
|
||||||
|
|
||||||
void setBrightness(int val);
|
void setBrightness(int val);
|
||||||
|
@ -198,6 +198,7 @@ void MainWindow::setupViewControls(QVBoxLayout *rootLyt) {
|
|||||||
|
|
||||||
void MainWindow::openSettings() {
|
void MainWindow::openSettings() {
|
||||||
SettingsDialog d(this);
|
SettingsDialog d(this);
|
||||||
|
connect(&d, &SettingsDialog::previewPreset, &m_cameraClient, &CameraClient::setPreset);
|
||||||
auto const result = d.exec();
|
auto const result = d.exec();
|
||||||
if (result == QDialog::Accepted) {
|
if (result == QDialog::Accepted) {
|
||||||
m_cameraClient.setBaseUrl();
|
m_cameraClient.setBaseUrl();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QHash>
|
#include <cstdint>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ void setVideoConfig(class QSettings &settings, QVector<VideoConfig> const&vc);
|
|||||||
|
|
||||||
void setVideoConfig(QVector<VideoConfig> const&vc);
|
void setVideoConfig(QVector<VideoConfig> const&vc);
|
||||||
|
|
||||||
QVector<VideoConfig> getVideoConfig(QSettings &settings);
|
QVector<VideoConfig> getVideoConfig(class QSettings &settings);
|
||||||
|
|
||||||
QVector<VideoConfig> getVideoConfig();
|
QVector<VideoConfig> getVideoConfig();
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSlider>
|
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
@ -87,37 +86,56 @@ QWidget *SettingsDialog::setupNetworkInputs(QWidget *parent) {
|
|||||||
|
|
||||||
QWidget *SettingsDialog::setupImageConfig(QWidget *parent) {
|
QWidget *SettingsDialog::setupImageConfig(QWidget *parent) {
|
||||||
auto const root = new QWidget(parent);
|
auto const root = new QWidget(parent);
|
||||||
auto const lyt = new QFormLayout(root);
|
auto const lyt = new QVBoxLayout(root);
|
||||||
m_videoConfig = getVideoConfig();
|
{
|
||||||
auto const mkSb = [parent, lyt](QString lbl) {
|
auto const formRoot = new QWidget(parent);
|
||||||
auto const s = new QSpinBox(parent);
|
auto const formLyt = new QFormLayout(formRoot);
|
||||||
s->setAlignment(Qt::AlignRight);
|
lyt->addWidget(formRoot);
|
||||||
s->setRange(0, 14);
|
m_videoConfig = getVideoConfig();
|
||||||
lyt->addRow(lbl, s);
|
auto const mkSb = [parent, formLyt](QString const&lbl) {
|
||||||
return s;
|
auto const s = new QSpinBox(parent);
|
||||||
};
|
s->setAlignment(Qt::AlignRight);
|
||||||
auto const presetNo = new QComboBox(parent);
|
s->setRange(0, 14);
|
||||||
connect(presetNo, &QComboBox::currentIndexChanged, this, &SettingsDialog::updateVidConfigPreset);
|
formLyt->addRow(lbl, s);
|
||||||
for (auto i = 0; i < MaxCameraPresets; ++i) {
|
return s;
|
||||||
presetNo->addItem(tr("Camera Preset %1").arg(i + 1));
|
};
|
||||||
|
auto const presetNo = new QComboBox(parent);
|
||||||
|
connect(presetNo, &QComboBox::currentIndexChanged, this, &SettingsDialog::updateVidConfigPreset);
|
||||||
|
for (auto i = 0; i < MaxCameraPresets; ++i) {
|
||||||
|
presetNo->addItem(tr("Camera Preset %1").arg(i + 1));
|
||||||
|
}
|
||||||
|
formLyt->addRow(presetNo);
|
||||||
|
m_vidBrightness = mkSb(tr("&Brightness:"));
|
||||||
|
m_vidSaturation = mkSb(tr("&Saturation:"));
|
||||||
|
m_vidContrast = mkSb(tr("Con&trast:"));
|
||||||
|
m_vidSharpness = mkSb(tr("Sh&arpness:"));
|
||||||
|
m_vidHue = mkSb(tr("&Hue:"));
|
||||||
|
updateVidConfigPreset(0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto const btnRoot = new QWidget(parent);
|
||||||
|
auto const btnLyt = new QHBoxLayout(btnRoot);
|
||||||
|
lyt->addWidget(btnRoot);
|
||||||
|
btnLyt->setAlignment(Qt::AlignRight);
|
||||||
|
auto const previewBtn = new QPushButton(tr("&Preview"), btnRoot);
|
||||||
|
btnLyt->addWidget(previewBtn);
|
||||||
|
connect(previewBtn, &QPushButton::clicked, this, [this] {
|
||||||
|
this->collectVideoConfig();
|
||||||
|
auto const &vc = m_videoConfig[m_vidCurrentPreset];
|
||||||
|
emit previewPreset(m_vidCurrentPreset + 1, vc);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
lyt->addRow(presetNo);
|
|
||||||
m_vidBrightness = mkSb(tr("&Brightness:"));
|
|
||||||
m_vidSaturation = mkSb(tr("&Saturation:"));
|
|
||||||
m_vidContrast = mkSb(tr("Con&trast:"));
|
|
||||||
m_vidSharpness = mkSb(tr("Sh&arpness:"));
|
|
||||||
m_vidHue = mkSb(tr("&Hue:"));
|
|
||||||
updateVidConfigPreset(0);
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *SettingsDialog::setupViewConfig(QWidget *parent) {
|
QWidget *SettingsDialog::setupViewConfig(QWidget *parent) {
|
||||||
auto const root = new QWidget(parent);
|
auto const root = new QWidget(parent);
|
||||||
auto const lyt = new QVBoxLayout(root);
|
auto const lyt = new QVBoxLayout(root);
|
||||||
// table
|
auto const btnsRoot = new QWidget(root);
|
||||||
m_viewTable = new QTableWidget(parent);
|
m_viewTable = new QTableWidget(root);
|
||||||
{
|
lyt->addWidget(btnsRoot);
|
||||||
lyt->addWidget(m_viewTable);
|
lyt->addWidget(m_viewTable);
|
||||||
|
{ // table
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
columns.resize(ViewColumn::Count);
|
columns.resize(ViewColumn::Count);
|
||||||
columns[ViewColumn::Name] = tr("Name");
|
columns[ViewColumn::Name] = tr("Name");
|
||||||
@ -134,19 +152,16 @@ QWidget *SettingsDialog::setupViewConfig(QWidget *parent) {
|
|||||||
m_viewTable->setColumnWidth(3, 70);
|
m_viewTable->setColumnWidth(3, 70);
|
||||||
hdr->setStretchLastSection(true);
|
hdr->setStretchLastSection(true);
|
||||||
}
|
}
|
||||||
// add/removes buttons
|
{ // add/removes buttons
|
||||||
{
|
|
||||||
auto const btnsRoot = new QWidget(root);
|
|
||||||
auto const btnsLyt = new QHBoxLayout(btnsRoot);
|
auto const btnsLyt = new QHBoxLayout(btnsRoot);
|
||||||
auto const addBtn = new QPushButton("+", btnsRoot);
|
auto const addBtn = new QPushButton("&Add", btnsRoot);
|
||||||
auto const rmBtn = new QPushButton("-", btnsRoot);
|
auto const rmBtn = new QPushButton("&Remove", btnsRoot);
|
||||||
addBtn->setFixedWidth(20);
|
addBtn->setFixedWidth(70);
|
||||||
rmBtn->setFixedWidth(20);
|
rmBtn->setFixedWidth(70);
|
||||||
rmBtn->setDisabled(true);
|
rmBtn->setDisabled(true);
|
||||||
lyt->addWidget(btnsRoot);
|
|
||||||
btnsLyt->addWidget(addBtn);
|
btnsLyt->addWidget(addBtn);
|
||||||
btnsLyt->addWidget(rmBtn);
|
btnsLyt->addWidget(rmBtn);
|
||||||
btnsLyt->addSpacerItem(new QSpacerItem(1000, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
btnsLyt->setAlignment(Qt::AlignLeft);
|
||||||
connect(addBtn, &QPushButton::clicked, this, [this, addBtn] {
|
connect(addBtn, &QPushButton::clicked, this, [this, addBtn] {
|
||||||
auto const row = m_viewTable->rowCount();
|
auto const row = m_viewTable->rowCount();
|
||||||
m_viewTable->setRowCount(row + 1);
|
m_viewTable->setRowCount(row + 1);
|
||||||
|
@ -49,4 +49,6 @@ class SettingsDialog: public QDialog {
|
|||||||
void collectVideoConfig();
|
void collectVideoConfig();
|
||||||
void updateVidConfigPreset(int preset);
|
void updateVidConfigPreset(int preset);
|
||||||
void updateVidConfigPresetCollect(int preset);
|
void updateVidConfigPresetCollect(int preset);
|
||||||
|
signals:
|
||||||
|
void previewPreset(int, VideoConfig const&);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user