From 215f9b4d1d776c852c50fa0c86c3ec5dd6f9a6af Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 29 Oct 2024 00:45:42 -0500 Subject: [PATCH] Cleanup --- src/cameraclient.cpp | 33 ++++++++++++++++----------------- src/cameraclient.hpp | 14 ++++++-------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/cameraclient.cpp b/src/cameraclient.cpp index 71b09ae..f073475 100644 --- a/src/cameraclient.cpp +++ b/src/cameraclient.cpp @@ -8,8 +8,8 @@ #include #include -#include +#include "consts.hpp" #include "settingsdata.hpp" #include "cameraclient.hpp" @@ -43,6 +43,16 @@ void CameraClient::setPreset(int preset) { } } +void CameraClient::reboot() { + post("/cgi-bin/param.cgi?post_reboot"); + emit pollFailed(); +} + +void CameraClient::setBaseUrl() { + auto const [host, port] = getCameraConnectionData(); + m_baseUrl = QString("http://%1:%2").arg(host, QString::number(port)); +} + void CameraClient::setBrightness(int val) { if (val > -1) { get(QString("/cgi-bin/ptzctrl.cgi?post_image_value&bright&%1").arg(val)); @@ -73,33 +83,22 @@ void CameraClient::setHue(int val) { } } -void CameraClient::reboot() { - post("/cgi-bin/param.cgi?post_reboot"); - emit pollFailed(); -} - -void CameraClient::setBaseUrl() { - auto const [host, port] = getCameraConnectionData(); - m_baseUrl = QString("http://%1:%2").arg(host, QString::number(port)); -} - void CameraClient::get(QString const&urlExt) { - QUrl url(QString(m_baseUrl) + urlExt); - QNetworkRequest rqst(url); + QUrl const url{QString{m_baseUrl} + urlExt}; + QNetworkRequest rqst{url}; auto const reply = m_nam->get(rqst); connect(reply, &QIODevice::readyRead, reply, &QObject::deleteLater); } void CameraClient::post(QString const&urlExt) { - QUrl url(QString(m_baseUrl) + urlExt); - QNetworkRequest rqst(url); + QNetworkRequest const rqst{QUrl{QString{m_baseUrl} + urlExt}}; auto const reply = m_nam->post(rqst, QByteArray{}); connect(reply, &QIODevice::readyRead, reply, &QObject::deleteLater); } void CameraClient::poll() { - QUrl url(QString(m_baseUrl) + "/cgi-bin/param.cgi?get_device_conf"); - QNetworkRequest rqst(url); + QUrl const url{QString{m_baseUrl} + "/cgi-bin/param.cgi?get_device_conf"}; + QNetworkRequest const rqst{url}; m_pollingNam->get(rqst); } diff --git a/src/cameraclient.hpp b/src/cameraclient.hpp index 93de281..a9ed8f8 100644 --- a/src/cameraclient.hpp +++ b/src/cameraclient.hpp @@ -12,8 +12,6 @@ #include #include -#include "consts.hpp" - class CameraClient: public QObject { Q_OBJECT private: @@ -29,6 +27,12 @@ class CameraClient: public QObject { void setPreset(int preset); + void reboot(); + + public slots: + void setBaseUrl(); + + private: void setBrightness(int val); void setSaturation(int val); @@ -39,12 +43,6 @@ class CameraClient: public QObject { void setHue(int val); - void reboot(); - - public slots: - void setBaseUrl(); - - private: void get(QString const&url); void post(QString const&url);