mirror of
https://github.com/gtalent/sc9k.git
synced 2025-07-04 01:21:46 -05:00
Add camera reboot option
This commit is contained in:
@ -73,6 +73,11 @@ 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));
|
||||
@ -81,7 +86,14 @@ void CameraClient::setBaseUrl() {
|
||||
void CameraClient::get(QString const&urlExt) {
|
||||
QUrl url(QString(m_baseUrl) + urlExt);
|
||||
QNetworkRequest rqst(url);
|
||||
auto reply = m_nam->get(rqst);
|
||||
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);
|
||||
auto const reply = m_nam->post(rqst, QByteArray{});
|
||||
connect(reply, &QIODevice::readyRead, reply, &QObject::deleteLater);
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,16 @@ 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);
|
||||
|
||||
void poll();
|
||||
|
||||
void handlePollResponse(QNetworkReply *reply);
|
||||
|
@ -112,7 +112,7 @@ void MainWindow::setupMenu() {
|
||||
}
|
||||
// camera preset menu
|
||||
{
|
||||
auto const menu = menuBar()->addMenu(tr("&Camera Preset"));
|
||||
auto const menu = menuBar()->addMenu(tr("&Camera"));
|
||||
for (auto i = 0; i < std::min(9, 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));
|
||||
@ -121,6 +121,18 @@ void MainWindow::setupMenu() {
|
||||
});
|
||||
menu->addAction(cameraPresetAct);
|
||||
}
|
||||
menu->addSeparator();
|
||||
auto const rebootAct = new QAction(tr("&Reboot"), this);
|
||||
connect(rebootAct, &QAction::triggered, &m_cameraClient, [this] {
|
||||
QMessageBox confirm(this);
|
||||
confirm.setText(tr("Are you sure you want to reboot the camera? This will take about 20 seconds."));
|
||||
confirm.addButton(tr("&No"), QMessageBox::ButtonRole::NoRole);
|
||||
confirm.addButton(tr("&Yes"), QMessageBox::ButtonRole::YesRole);
|
||||
if (confirm.exec() == QMessageBox::YesRole) {
|
||||
m_cameraClient.reboot();
|
||||
}
|
||||
});
|
||||
menu->addAction(rebootAct);
|
||||
}
|
||||
// help menu
|
||||
{
|
||||
|
Reference in New Issue
Block a user