diff --git a/.gitignore b/.gitignore
index 06b7d96..814cdc6 100755
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@
# Qt Creator User Project Files
*.pro.user
*.eccba64
+
+/CMakeLists.txt.user*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c05309c..34714db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ project(Labcontrol CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
find_package(Qt5 COMPONENTS Core Network Widgets REQUIRED)
diff --git a/src/helpmessagesender/helpmessagewindow.cpp b/src/helpmessagesender/helpmessagewindow.cpp
index 9a8300a..95d816a 100644
--- a/src/helpmessagesender/helpmessagewindow.cpp
+++ b/src/helpmessagesender/helpmessagewindow.cpp
@@ -1,35 +1,63 @@
+/*
+ * Copyright 2018 Markus Prasser
+ *
+ * This file is part of Labcontrol.
+ *
+ * Labcontrol is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Labcontrol is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Labcontrol. If not, see .
+ */
+
#include "helpmessagewindow.h"
+#include "ui_helpmessagewindow.h"
+
+#include
+#include
+#include
+#include
#include
lcHelpMessageWindow::lcHelpMessageWindow(const QString &argServerIP,
- const unsigned short int &argServerPort,
- QWidget *argParent) :
+ const quint16 argServerPort,
+ QWidget *const argParent) :
QMainWindow{argParent},
- helpMessageSocket {new QTcpSocket{this}},
- serverPort{argServerPort},
serverAddress{argServerIP},
+ serverPort{argServerPort},
ui{new Ui::HelpMessageWindow}
{
+ helpMessageSocket = new QTcpSocket{this};
+
ui->setupUi(this);
connect(ui->PBAskForHelp, &QPushButton::clicked,
this, &lcHelpMessageWindow::RequestHelp);
connect(helpMessageSocket, &QTcpSocket::readyRead,
this, &lcHelpMessageWindow::ReadHelpReply);
- connect(helpMessageSocket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(DisplayError(QAbstractSocket::SocketError)));
+ connect(helpMessageSocket,
+ static_cast
+ (&QAbstractSocket::error),
+ this, &lcHelpMessageWindow::DisplayError);
QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
+ if (manager.capabilities()
+ & QNetworkConfigurationManager::NetworkSessionRequired) {
// Get saved network configuration
QSettings settings{QSettings::UserScope, QLatin1String{"QtProject"}};
settings.beginGroup(QLatin1String{"QtNetwork"});
- const QString id
- = settings.value(QLatin1String{"DefaultNetworkConfiguration"}).toString();
+ const auto id{settings.value("DefaultNetworkConfiguration").toString()};
settings.endGroup();
// If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier( id );
+ QNetworkConfiguration config = manager.configurationFromIdentifier(id);
if ((config.state() & QNetworkConfiguration::Discovered)
!= QNetworkConfiguration::Discovered) {
config = manager.defaultConfiguration();
@@ -47,9 +75,9 @@ lcHelpMessageWindow::~lcHelpMessageWindow() {
delete ui;
}
-void lcHelpMessageWindow::DisplayError(QAbstractSocket::SocketError socketError) {
+void lcHelpMessageWindow::DisplayError(QAbstractSocket::SocketError argSocketError) {
QString errorMessage;
- switch (socketError) {
+ switch (argSocketError) {
case QAbstractSocket::RemoteHostClosedError:
return;
case QAbstractSocket::HostNotFoundError:
@@ -70,9 +98,9 @@ void lcHelpMessageWindow::DisplayError(QAbstractSocket::SocketError socketError)
void lcHelpMessageWindow::OpenedSession() {
// Save the used configuration
- QNetworkConfiguration config = networkSession->configuration();
QString id;
- if (config.type() == QNetworkConfiguration::UserChoice) {
+ if (const auto config{networkSession->configuration()};
+ config.type() == QNetworkConfiguration::UserChoice) {
id = networkSession->sessionProperty(
QLatin1String{"UserChoiceConfiguration"}).toString();
} else {
@@ -86,11 +114,12 @@ void lcHelpMessageWindow::OpenedSession() {
}
void lcHelpMessageWindow::ReadHelpReply() {
- QDataStream in(helpMessageSocket);
+ QDataStream in{helpMessageSocket};
in.setVersion(QDataStream::Qt_5_2);
if (blockSize == 0) {
- if (helpMessageSocket->bytesAvailable() < (int)sizeof(quint16)) {
+ if (helpMessageSocket->bytesAvailable()
+ < static_cast(sizeof(quint16))) {
return;
}
diff --git a/src/helpmessagesender/helpmessagewindow.h b/src/helpmessagesender/helpmessagewindow.h
index 2d1e293..a00d75f 100644
--- a/src/helpmessagesender/helpmessagewindow.h
+++ b/src/helpmessagesender/helpmessagewindow.h
@@ -1,11 +1,30 @@
+/*
+ * Copyright 2018 Markus Prasser
+ *
+ * This file is part of Labcontrol.
+ *
+ * Labcontrol is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Labcontrol is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Labcontrol. If not, see .
+ */
+
#ifndef HELPMESSAGEWINDOW_H
#define HELPMESSAGEWINDOW_H
-#include "ui_helpmessagewindow.h"
-
+#include
#include
-#include
-#include
+
+class QNetworkSession;
+class QTcpSocket;
namespace Ui {
class HelpMessageWindow;
@@ -17,23 +36,23 @@ class lcHelpMessageWindow : public QMainWindow
public:
explicit lcHelpMessageWindow(const QString &argServerIP,
- const unsigned short int &argServerPort,
- QWidget *argParent = nullptr);
- ~lcHelpMessageWindow();
+ const quint16 argServerPort,
+ QWidget *const argParent = nullptr);
+ ~lcHelpMessageWindow() override;
private:
quint16 blockSize = 0;
QTcpSocket *helpMessageSocket = nullptr;
QNetworkSession *networkSession = nullptr;
- const quint16 serverPort = 0;
const QHostAddress serverAddress;
- Ui::HelpMessageWindow *ui;
+ const quint16 serverPort = 0;
+ Ui::HelpMessageWindow *const ui = nullptr;
private slots:
- void RequestHelp();
- void ReadHelpReply();
- void DisplayError(QAbstractSocket::SocketError socketError);
+ void DisplayError(QAbstractSocket::SocketError argSocketError);
void OpenedSession();
+ void ReadHelpReply();
+ void RequestHelp();
};
#endif // HELPMESSAGEWINDOW_H
diff --git a/src/helpmessagesender/main.cpp b/src/helpmessagesender/main.cpp
index fc63008..84be188 100644
--- a/src/helpmessagesender/main.cpp
+++ b/src/helpmessagesender/main.cpp
@@ -1,14 +1,47 @@
+/*
+ * Copyright 2018 Markus Prasser
+ *
+ * This file is part of Labcontrol.
+ *
+ * Labcontrol is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Labcontrol is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Labcontrol. If not, see .
+ */
+
#include "helpmessagewindow.h"
#include
+#include
+
+#include
int main(int argc, char *argv[])
{
- QApplication a(argc, argv);
+ QApplication app{argc, argv};
+
QSettings labSettings{"Economic Laboratory", "Labcontrol"};
+
+ bool convSuccess = false;
+ const auto portNum{
+ static_cast(labSettings.value("client_help_server_port", "0")
+ .toUInt(&convSuccess))};
+ if (convSuccess == false) {
+ std::cerr << "Failed to convert \"client_help_server_port\" setting\n";
+ return 1;
+ }
+
lcHelpMessageWindow w{labSettings.value("server_ip", "127.0.0.1").toString(),
- labSettings.value("client_help_server_port", "0").toUInt()};
+ portNum};
w.show();
- return a.exec();
+ return app.exec();
}