From 89edb0a4db6dc54b8c6b9b163273325fba78f2ad Mon Sep 17 00:00:00 2001 From: iakov Date: Wed, 15 Jan 2025 15:14:07 +0300 Subject: [PATCH] Just code improvements (#815) * Add note for signals problem * Use newer syntax to connect signals * Purge Qt keywords, use Q_EMIT, Q_SIGNALS, Q_SLOTS, Q_FOREVER instead * Remove locations from translations * Support Q_SLOTS and Q_SIGNALS in Vera++ script --- scripts/vera++/scripts/rules/Comments.tcl | 8 +-- .../trikCommunicator/trikCommunicator.h | 2 +- trikCommunicator/src/connection.cpp | 2 +- trikCommunicator/src/connection.h | 2 +- .../include/trikControl/batteryInterface.h | 2 +- .../include/trikControl/brickInterface.h | 60 ++++++++++--------- .../trikControl/colorSensorInterface.h | 4 +- .../include/trikControl/displayInterface.h | 2 +- .../trikControl/displayWidgetInterface.h | 2 +- .../include/trikControl/encoderInterface.h | 2 +- .../include/trikControl/eventCodeInterface.h | 2 +- .../trikControl/eventDeviceInterface.h | 4 +- .../include/trikControl/eventInterface.h | 4 +- .../include/trikControl/fifoInterface.h | 12 ++-- .../include/trikControl/gamepadInterface.h | 21 +++---- .../include/trikControl/gyroSensorInterface.h | 19 +++--- .../include/trikControl/irCameraInterface.h | 9 +-- .../include/trikControl/keysInterface.h | 4 +- .../include/trikControl/ledInterface.h | 2 +- .../include/trikControl/lineSensorInterface.h | 13 ++-- .../include/trikControl/markerInterface.h | 2 +- .../include/trikControl/motorInterface.h | 2 +- .../trikControl/objectSensorInterface.h | 4 +- .../include/trikControl/pwmCaptureInterface.h | 2 +- .../include/trikControl/sensorInterface.h | 2 +- .../trikControl/soundSensorInterface.h | 4 +- .../trikControl/vectorSensorInterface.h | 4 +- .../src/abstractVirtualSensorWorker.cpp | 2 +- trikControl/src/abstractVirtualSensorWorker.h | 6 +- trikControl/src/analogSensor.h | 2 +- trikControl/src/audioSynthDevice.cpp | 2 +- trikControl/src/battery.h | 2 +- trikControl/src/brick.h | 2 +- trikControl/src/colorSensor.cpp | 2 +- trikControl/src/colorSensor.h | 4 +- trikControl/src/colorSensorWorker.h | 2 +- trikControl/src/configurerHelper.cpp | 6 +- trikControl/src/digitalSensor.h | 2 +- trikControl/src/display.h | 2 +- trikControl/src/encoder.h | 2 +- trikControl/src/event.cpp | 2 +- trikControl/src/event.h | 2 +- trikControl/src/eventCode.cpp | 2 +- trikControl/src/eventCode.h | 2 +- trikControl/src/eventDeviceWorker.cpp | 2 +- trikControl/src/eventDeviceWorker.h | 4 +- .../incorrectDeviceConfigurationException.h | 3 +- .../incorrectStateChangeException.h | 7 ++- trikControl/src/fifoworker.cpp | 4 +- trikControl/src/fifoworker.h | 6 +- trikControl/src/gamepad.cpp | 14 ++--- trikControl/src/gamepad.h | 4 +- trikControl/src/graphicsWidget.cpp | 4 +- trikControl/src/guiWorker.h | 2 +- trikControl/src/gyroSensor.cpp | 4 +- trikControl/src/gyroSensor.h | 2 +- trikControl/src/i2cDevice.h | 2 +- trikControl/src/irCamera.cpp | 6 +- trikControl/src/irCamera.h | 2 +- trikControl/src/irCameraWorker.cpp | 6 +- trikControl/src/irCameraWorker.h | 4 +- trikControl/src/keys.cpp | 2 +- trikControl/src/keys.h | 6 +- trikControl/src/keysWorker.cpp | 4 +- trikControl/src/keysWorker.h | 6 +- trikControl/src/led.h | 2 +- trikControl/src/lidarWorker.h | 2 +- trikControl/src/lineSensor.cpp | 2 +- trikControl/src/lineSensor.h | 12 ++-- trikControl/src/lineSensorWorker.h | 2 +- trikControl/src/objectSensor.cpp | 5 +- trikControl/src/objectSensor.h | 4 +- trikControl/src/objectSensorWorker.h | 2 +- trikControl/src/powerMotor.cpp | 2 +- trikControl/src/powerMotor.h | 2 +- trikControl/src/pwmCapture.h | 2 +- trikControl/src/rangeSensor.h | 4 +- trikControl/src/rangeSensorWorker.cpp | 2 +- trikControl/src/rangeSensorWorker.h | 6 +- trikControl/src/servoMotor.h | 2 +- trikControl/src/soundSensor.h | 2 +- trikControl/src/soundSensorWorker.h | 2 +- trikControl/src/tonePlayer.h | 4 +- trikControl/src/vectorSensor.h | 5 +- trikControl/src/vectorSensorWorker.cpp | 2 +- trikControl/src/vectorSensorWorker.h | 6 +- trikGui/abstractIndicator.h | 2 +- trikGui/accelerometerWidget.h | 2 +- trikGui/autoRunner.cpp | 2 +- trikGui/autoRunner.h | 4 +- trikGui/backgroundWidget.cpp | 26 ++++---- trikGui/backgroundWidget.h | 10 ++-- trikGui/batteryIndicator.h | 2 +- trikGui/cameraWidget.h | 2 +- trikGui/commandSettingsWidget.cpp | 8 +-- trikGui/commandSettingsWidget.h | 2 +- trikGui/commandsListWidget.cpp | 6 +- trikGui/commandsListWidget.h | 2 +- trikGui/communicationSettingsWidget.h | 4 +- trikGui/connectButton.cpp | 4 +- trikGui/connectButton.h | 2 +- trikGui/controller.cpp | 10 ++-- trikGui/controller.h | 6 +- trikGui/digitSelector.cpp | 8 +-- trikGui/digitSelector.h | 2 +- trikGui/encoderIndicator.h | 2 +- trikGui/fileManagerWidget.h | 2 +- trikGui/gamepadIndicator.cpp | 4 +- trikGui/gamepadIndicator.h | 2 +- trikGui/gyroscopeIndicator.h | 2 +- trikGui/informationWidget.h | 2 +- trikGui/lazyMainWidget.h | 4 +- trikGui/lazyMainWidgetWrapper.cpp | 6 +- trikGui/lazyMainWidgetWrapper.h | 2 +- trikGui/mainWidget.h | 4 +- trikGui/motorsWidget.cpp | 2 +- trikGui/motorsWidget.h | 2 +- trikGui/networkWidget.h | 2 +- trikGui/numberSelectionWidget.cpp | 3 +- trikGui/numberSelectionWidget.h | 4 +- trikGui/openSocketIndicator.h | 2 +- trikGui/programmingWidget.cpp | 2 +- trikGui/programmingWidget.h | 2 +- trikGui/pwmCaptureIndicator.h | 2 +- trikGui/runningWidget.h | 2 +- trikGui/sensorIndicator.h | 2 +- trikGui/sensorLever.h | 2 +- trikGui/sensorSettingsWidget.cpp | 6 +- trikGui/sensorSettingsWidget.h | 2 +- trikGui/startWidget.cpp | 32 +++++----- trikGui/startWidget.h | 2 +- trikGui/systemSettingsWidget.cpp | 4 +- trikGui/systemSettingsWidget.h | 4 +- trikGui/trikGuiApplication.h | 2 +- trikGui/updateWidget.h | 2 +- trikGui/wiFiClientWidget.h | 2 +- trikGui/wiFiIndicator.h | 2 +- trikGui/wiFiInitWidget.cpp | 2 +- trikGui/wiFiInitWidget.h | 2 +- trikGui/wiFiModeWidget.cpp | 6 +- trikHal/include/trikHal/IIOFileInterface.h | 2 +- trikHal/include/trikHal/eventFileInterface.h | 2 +- trikHal/include/trikHal/fifoInterface.h | 2 +- trikHal/src/trik/trikEventFile.cpp | 2 +- trikHal/src/trik/trikEventFile.h | 2 +- trikHal/src/trik/trikFifo.cpp | 6 +- trikHal/src/trik/trikFifo.h | 2 +- trikHal/src/trik/trikIIOFile.cpp | 55 +++++++++-------- trikHal/src/trik/trikIIOFile.h | 2 +- trikHal/src/trik/trikV4l2VideoDevice.cpp | 2 +- trikHal/src/trik/trikV4l2VideoDevice.h | 4 +- .../exceptions/failedToOpenFileException.h | 7 ++- .../exceptions/failedToParseXmlException.h | 3 +- .../exceptions/internalErrorException.h | 3 +- .../exceptions/malformedConfigException.h | 3 +- .../exceptions/trikRuntimeException.h | 2 +- trikKernel/src/configurer.cpp | 15 +++-- trikKernel/src/deinitializationHelper.cpp | 2 +- trikNetwork/include/trikNetwork/connection.h | 4 +- .../include/trikNetwork/mailboxInterface.h | 4 +- trikNetwork/include/trikNetwork/trikServer.h | 6 +- trikNetwork/src/connection.cpp | 4 +- trikNetwork/src/mailbox.cpp | 4 +- trikNetwork/src/mailbox.h | 6 +- trikNetwork/src/mailboxConnection.cpp | 8 +-- trikNetwork/src/mailboxConnection.h | 2 +- trikNetwork/src/mailboxServer.cpp | 2 +- trikNetwork/src/mailboxServer.h | 4 +- trikNetwork/src/trikServer.cpp | 6 +- trikRun/trikRunMain.cpp | 1 + .../pytrikcontrol/pytrikcontrol0.h | 58 +++++++++--------- .../trikScriptRunner/trikJavaScriptRunner.h | 4 +- .../trikScriptRunner/trikPythonRunner.h | 2 +- .../trikScriptControlInterface.h | 4 +- .../trikScriptRunner/trikScriptRunner.h | 4 +- .../trikScriptRunnerInterface.h | 4 +- .../trikScriptRunner/trikVariablesServer.h | 6 +- trikScriptRunner/src/pythonEngineWorker.cpp | 20 +++---- trikScriptRunner/src/pythonEngineWorker.h | 6 +- trikScriptRunner/src/scriptEngineWorker.cpp | 10 ++-- trikScriptRunner/src/scriptEngineWorker.h | 6 +- .../src/scriptExecutionControl.cpp | 6 +- trikScriptRunner/src/scriptExecutionControl.h | 7 ++- trikScriptRunner/src/scriptThread.cpp | 4 +- trikScriptRunner/src/scriptThread.h | 4 +- trikScriptRunner/src/threading.cpp | 2 +- trikScriptRunner/src/threading.h | 2 +- trikScriptRunner/src/trikJavaScriptRunner.cpp | 4 +- trikScriptRunner/src/trikScriptRunner.cpp | 2 +- trikScriptRunner/src/trikVariablesServer.cpp | 2 +- trikWiFi/include/trikWiFi/trikWiFi.h | 2 +- trikWiFi/src/trikWiFiWorker.cpp | 27 +++++---- trikWiFi/src/trikWiFiWorker.h | 4 +- 193 files changed, 505 insertions(+), 487 deletions(-) diff --git a/scripts/vera++/scripts/rules/Comments.tcl b/scripts/vera++/scripts/rules/Comments.tcl index 1f340f11f..9d4dadc15 100644 --- a/scripts/vera++/scripts/rules/Comments.tcl +++ b/scripts/vera++/scripts/rules/Comments.tcl @@ -13,15 +13,15 @@ # limitations under the License. proc ClassSection { old line } { - if { [regexp {public:} $line] || [regexp {public slots:} $line] || [regexp {signals:} $line] } { + if { [regexp {public:} $line] || [regexp {public (Q_SLOTS|slots):} $line] || [regexp {(Q_SIGNALS|signals):} $line] } { return "public" } - if { [regexp {protected:} $line] || [regexp {protected slots:} $line] } { + if { [regexp {protected:} $line] || [regexp {protected (Q_SLOTS|slots):} $line] } { return "protected" } - if { [regexp {private:} $line] || [regexp {private slots:} $line] } { + if { [regexp {private:} $line] || [regexp {private (Q_SLOTS|slots):} $line] } { return "private" } @@ -92,4 +92,4 @@ proc CheckComments { fileName } { foreach fileName [getSourceFileNames] { CheckComments $fileName -} \ No newline at end of file +} diff --git a/trikCommunicator/include/trikCommunicator/trikCommunicator.h b/trikCommunicator/include/trikCommunicator/trikCommunicator.h index 3c8b2de63..3f1006041 100644 --- a/trikCommunicator/include/trikCommunicator/trikCommunicator.h +++ b/trikCommunicator/include/trikCommunicator/trikCommunicator.h @@ -60,7 +60,7 @@ class TrikCommunicator : public trikNetwork::TrikServer ~TrikCommunicator() override; -signals: +Q_SIGNALS: /// Emitted when stop command received from a computer. void stopCommandReceived(); diff --git a/trikCommunicator/src/connection.cpp b/trikCommunicator/src/connection.cpp index 8c7ad3552..3c273512f 100644 --- a/trikCommunicator/src/connection.cpp +++ b/trikCommunicator/src/connection.cpp @@ -57,7 +57,7 @@ void Connection::processData(const QByteArray &data) QMetaObject::invokeMethod(&mTrikScriptRunner, [=](){mTrikScriptRunner.run(fileContents, command);}); } else if (command == "stop") { - emit stopCommandReceived(); + Q_EMIT stopCommandReceived(); } else if (command.startsWith("direct:")) { command.remove(0, QString("direct:").length()); QMetaObject::invokeMethod(&mTrikScriptRunner, [=](){mTrikScriptRunner.runDirectCommand(command);}); diff --git a/trikCommunicator/src/connection.h b/trikCommunicator/src/connection.h index e07dc7fe7..12aca7d8b 100644 --- a/trikCommunicator/src/connection.h +++ b/trikCommunicator/src/connection.h @@ -47,7 +47,7 @@ class Connection : public trikNetwork::Connection /// Writes a given message to inner socket. void sendMessage(const QString &message); -signals: +Q_SIGNALS: /// Emitted when a stop command received from a computer. void stopCommandReceived(); diff --git a/trikControl/include/trikControl/batteryInterface.h b/trikControl/include/trikControl/batteryInterface.h index 38c8b13a6..98835789a 100644 --- a/trikControl/include/trikControl/batteryInterface.h +++ b/trikControl/include/trikControl/batteryInterface.h @@ -26,7 +26,7 @@ namespace trikControl { class TRIKCONTROL_EXPORT BatteryInterface : public QObject, public DeviceInterface { Q_OBJECT -public slots: +public Q_SLOTS: /// Returns current battery voltage in volts. virtual float readVoltage() = 0; diff --git a/trikControl/include/trikControl/brickInterface.h b/trikControl/include/trikControl/brickInterface.h index f24b4c9d0..376b06a1c 100644 --- a/trikControl/include/trikControl/brickInterface.h +++ b/trikControl/include/trikControl/brickInterface.h @@ -63,7 +63,7 @@ class TRIKCONTROL_EXPORT BrickInterface : public QObject /// Returns version of system configuration file. virtual QString configVersion() const = 0; -public slots: +public Q_SLOTS: /// Configures given device on given port. Port must be listed in model-config.xml, device shall be listed /// in system-config.xml, and device shall be able to be configured on a port (it is also described /// in system-config.xml). Previously configured device is properly shut down, and new device is created @@ -87,87 +87,89 @@ public slots: /// Returns reference to motor of a given type on a given port virtual trikControl::MotorInterface *motor(const QString &port) = 0; + /// Stops listening given event device and destroys its watcher object. + virtual void stopEventDevice(const QString &deviceFile) = 0; + +public: /// Returns reference to PWM signal capture device on a given port. - virtual trikControl::PwmCaptureInterface *pwmCapture(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::PwmCaptureInterface *pwmCapture(const QString &port) = 0; /// Returns reference to sensor on a given port. - virtual trikControl::SensorInterface *sensor(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::SensorInterface *sensor(const QString &port) = 0; /// Retruns list of ports for motors of a given type. - virtual QStringList motorPorts(MotorInterface::Type type) const = 0; + Q_INVOKABLE virtual QStringList motorPorts(MotorInterface::Type type) const = 0; /// Returns list of PWM signal capture device ports. - virtual QStringList pwmCapturePorts() const = 0; + Q_INVOKABLE virtual QStringList pwmCapturePorts() const = 0; /// Returns list of ports for sensors of a given type. - virtual QStringList sensorPorts(SensorInterface::Type type) const = 0; + Q_INVOKABLE virtual QStringList sensorPorts(SensorInterface::Type type) const = 0; /// Returns list of encoder ports - virtual QStringList encoderPorts() const = 0; + Q_INVOKABLE virtual QStringList encoderPorts() const = 0; /// Returns on-board accelerometer. - virtual trikControl::VectorSensorInterface *accelerometer() = 0; + Q_INVOKABLE virtual trikControl::VectorSensorInterface *accelerometer() = 0; /// Returns on-board gyroscope. - virtual trikControl::GyroSensorInterface *gyroscope() = 0; + Q_INVOKABLE virtual trikControl::GyroSensorInterface *gyroscope() = 0; /// Returns high-level line detector sensor using camera on given port (video0 or video1). - virtual trikControl::LineSensorInterface *lineSensor(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::LineSensorInterface *lineSensor(const QString &port) = 0; /// Returns high-level color sensor using camera on given port (video0 or video1). - virtual trikControl::ColorSensorInterface *colorSensor(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::ColorSensorInterface *colorSensor(const QString &port) = 0; /// Returns high-level object detector sensor using camera on given port (video0 or video1). - virtual trikControl::ObjectSensorInterface *objectSensor(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::ObjectSensorInterface *objectSensor(const QString &port) = 0; /// Returns lidar on given port. - virtual trikControl::LidarInterface *lidar() = 0; + Q_INVOKABLE virtual trikControl::LidarInterface *lidar() = 0; /// Returns i2c device object - virtual trikControl::I2cDeviceInterface *i2c(int bus, int address) = 0; + Q_INVOKABLE virtual trikControl::I2cDeviceInterface *i2c(int bus, int address) = 0; /// Returns QVector with image using camera on given port (video0 or video1). - virtual QVector getStillImage() = 0; + Q_INVOKABLE virtual QVector getStillImage() = 0; /// Returns high-level sound detector sensor using microphones. - virtual trikControl::SoundSensorInterface *soundSensor(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::SoundSensorInterface *soundSensor(const QString &port) = 0; /// Returns encoder on given port. - virtual trikControl::EncoderInterface *encoder(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::EncoderInterface *encoder(const QString &port) = 0; /// Returns battery. - virtual trikControl::BatteryInterface *battery() = 0; + Q_INVOKABLE virtual trikControl::BatteryInterface *battery() = 0; /// Returns keys on a control brick. - virtual trikControl::KeysInterface *keys() = 0; + Q_INVOKABLE virtual trikControl::KeysInterface *keys() = 0; /// Returns class that provides drawing on display. - virtual trikControl::DisplayInterface *display() = 0; + Q_INVOKABLE virtual trikControl::DisplayInterface *display() = 0; /// Returns LED control class. - virtual trikControl::LedInterface *led() = 0; + Q_INVOKABLE virtual trikControl::LedInterface *led() = 0; /// Returns handler for Android gamepad. - virtual trikControl::GamepadInterface *gamepad() = 0; + Q_INVOKABLE virtual trikControl::GamepadInterface *gamepad() = 0; /// Returns custom FIFO file which can be used as sensor. - virtual trikControl::FifoInterface *fifo(const QString &port) = 0; + Q_INVOKABLE virtual trikControl::FifoInterface *fifo(const QString &port) = 0; /// Returns marker. - virtual trikControl::MarkerInterface *marker() = 0; + Q_INVOKABLE virtual trikControl::MarkerInterface *marker() = 0; /// Returns IR camera - virtual trikControl::IrCameraInterface *irCamera() = 0; + Q_INVOKABLE virtual trikControl::IrCameraInterface *irCamera() = 0; /// Returns custom event device that can be used as a sensor, for example, for custom gamepad support. /// Creates new event device on first access to a file, then returns already opened device. /// Ownership retained by brick. - virtual trikControl::EventDeviceInterface *eventDevice(const QString &deviceFile) = 0; + Q_INVOKABLE virtual trikControl::EventDeviceInterface *eventDevice(const QString &deviceFile) = 0; - /// Stops listening given event device and destroys its watcher object. - virtual void stopEventDevice(const QString &deviceFile) = 0; -signals: +Q_SIGNALS: /// Emitted when all deferred deinitialization is completed and brick completely stopped. Note that if there is no /// deferred deinitialization (no video sensors are on, for example), signal will NOT be emitted. void stopped(); diff --git a/trikControl/include/trikControl/colorSensorInterface.h b/trikControl/include/trikControl/colorSensorInterface.h index 1bcc757a6..c2b8515d6 100644 --- a/trikControl/include/trikControl/colorSensorInterface.h +++ b/trikControl/include/trikControl/colorSensorInterface.h @@ -28,11 +28,11 @@ class TRIKCONTROL_EXPORT ColorSensorInterface : public QObject, public DeviceInt { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when sensor is stopped successfully. void stopped(); -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. virtual void init(bool showOnDisplay) = 0; diff --git a/trikControl/include/trikControl/displayInterface.h b/trikControl/include/trikControl/displayInterface.h index b90c3f126..6df83640a 100644 --- a/trikControl/include/trikControl/displayInterface.h +++ b/trikControl/include/trikControl/displayInterface.h @@ -33,7 +33,7 @@ class TRIKCONTROL_EXPORT DisplayInterface : public QObject /// Returns widget on which everything is drawn. virtual DisplayWidgetInterface &graphicsWidget() = 0; -public slots: +public Q_SLOTS: /// Shows given image on a display. /// @param fileName - file name (with path) of an image to show. Refer to Qt documentation for /// supported formats, but .jpg, .png, .bmp, .gif are supported. diff --git a/trikControl/include/trikControl/displayWidgetInterface.h b/trikControl/include/trikControl/displayWidgetInterface.h index acd9226a2..0f85ff59a 100644 --- a/trikControl/include/trikControl/displayWidgetInterface.h +++ b/trikControl/include/trikControl/displayWidgetInterface.h @@ -35,7 +35,7 @@ class TRIKCONTROL_EXPORT DisplayWidgetInterface : public QWidget DisplayWidgetInterface() = default; ~DisplayWidgetInterface() override = default; -signals: +Q_SIGNALS: /// Emitted when widget is shown. void shown(); diff --git a/trikControl/include/trikControl/encoderInterface.h b/trikControl/include/trikControl/encoderInterface.h index 64a5af44f..e0983bfa0 100644 --- a/trikControl/include/trikControl/encoderInterface.h +++ b/trikControl/include/trikControl/encoderInterface.h @@ -27,7 +27,7 @@ class TRIKCONTROL_EXPORT EncoderInterface : public QObject, public DeviceInterfa { Q_OBJECT -public slots: +public Q_SLOTS: /// Returns current encoder reading (in degrees). virtual int read() = 0; diff --git a/trikControl/include/trikControl/eventCodeInterface.h b/trikControl/include/trikControl/eventCodeInterface.h index c5d672248..cae135093 100644 --- a/trikControl/include/trikControl/eventCodeInterface.h +++ b/trikControl/include/trikControl/eventCodeInterface.h @@ -28,7 +28,7 @@ class TRIKCONTROL_EXPORT EventCodeInterface : public QObject { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when there is new event with specific type and code in an event file. /// @param value - value sent with the event. /// @param eventTime - time stamp of the event, in milliseconds from start of the Unix time (modulo 2^32). diff --git a/trikControl/include/trikControl/eventDeviceInterface.h b/trikControl/include/trikControl/eventDeviceInterface.h index eaca37eba..6003fdf73 100644 --- a/trikControl/include/trikControl/eventDeviceInterface.h +++ b/trikControl/include/trikControl/eventDeviceInterface.h @@ -28,11 +28,11 @@ class TRIKCONTROL_EXPORT EventDeviceInterface : public QObject, public DeviceInt { Q_OBJECT -public slots: +public Q_SLOTS: /// Returns object that allows to selectively subscribe only to event with given code. virtual EventInterface *onEvent(int eventType) = 0; -signals: +Q_SIGNALS: /// Emitted when there is new event in an event file. /// @param event - type of the event. /// @param code - code of the event inside a type. diff --git a/trikControl/include/trikControl/eventInterface.h b/trikControl/include/trikControl/eventInterface.h index feb142ea0..4d06d4f01 100644 --- a/trikControl/include/trikControl/eventInterface.h +++ b/trikControl/include/trikControl/eventInterface.h @@ -28,12 +28,12 @@ class TRIKCONTROL_EXPORT EventInterface : public QObject { Q_OBJECT -public slots: +public Q_SLOTS: /// Returns object that emits only events with specific code. See evtest output for a list of codes for /// specific device. virtual EventCodeInterface *code(int code) = 0; -signals: +Q_SIGNALS: /// Emitted when there is new event in an event file. /// @param code - code of the event inside a type. /// @param value - value sent with the event. diff --git a/trikControl/include/trikControl/fifoInterface.h b/trikControl/include/trikControl/fifoInterface.h index 782658bcd..0366c588c 100644 --- a/trikControl/include/trikControl/fifoInterface.h +++ b/trikControl/include/trikControl/fifoInterface.h @@ -27,18 +27,18 @@ class TRIKCONTROL_EXPORT FifoInterface : public QObject, public DeviceInterface { Q_OBJECT -public slots: +public: /// Reads line from this FIFO file, returning all available data as string. - virtual QString read() = 0; + Q_INVOKABLE virtual QString read() = 0; /// Reads data from this FIFO file, returning all available data as string. - virtual QVector readRaw() = 0; + Q_INVOKABLE virtual QVector readRaw() = 0; /// Returns true if FIFO has new line in it. - virtual bool hasLine() const = 0; + Q_INVOKABLE virtual bool hasLine() const = 0; /// Returns true if FIFO has new bytes in it. - virtual bool hasData() const = 0; + Q_INVOKABLE virtual bool hasData() const = 0; -signals: +Q_SIGNALS: /// Emitted once per each text line that arrives to FIFO. void newLine(const QString &data); /// Emitted when new bytes have arrived to FIFO file. diff --git a/trikControl/include/trikControl/gamepadInterface.h b/trikControl/include/trikControl/gamepadInterface.h index cf26534c7..588b96814 100644 --- a/trikControl/include/trikControl/gamepadInterface.h +++ b/trikControl/include/trikControl/gamepadInterface.h @@ -25,39 +25,40 @@ class TRIKCONTROL_EXPORT GamepadInterface : public QObject { Q_OBJECT -public slots: +public Q_SLOTS: /// Clear data about previous pad events. virtual void reset() = 0; +public: /// Returns true, if given pad button is pressed, and clears "pressed" state for that button. /// Buttons have indexes from 1 to 5. - virtual bool buttonWasPressed(int buttonNumber) = 0; + Q_INVOKABLE virtual bool buttonWasPressed(int buttonNumber) = 0; /// Returns true, if given pad button is pressed now. Buttons have indexes from 1 to 5. - virtual bool buttonIsPressed(int buttonNumber) = 0; + Q_INVOKABLE virtual bool buttonIsPressed(int buttonNumber) = 0; /// Returns current state of the pad, true if pressed. - virtual bool isPadPressed(int pad) const = 0; + Q_INVOKABLE virtual bool isPadPressed(int pad) const = 0; /// Returns current X coordinate of given pad or -1 if this pad is not pressed. - virtual int padX(int pad) const = 0; + Q_INVOKABLE virtual int padX(int pad) const = 0; /// Returns current Y coordinate of given pad or -1 if this pad is not pressed. - virtual int padY(int pad) const = 0; + Q_INVOKABLE virtual int padY(int pad) const = 0; /// Returns current tilt angle of Android device when "wheel" is turned on. - virtual int wheel() const = 0; + Q_INVOKABLE virtual int wheel() const = 0; /// Returns true if a gamepad is currently connected to a robot. - virtual bool isConnected() const = 0; + Q_INVOKABLE virtual bool isConnected() const = 0; /// Disconnects a gamepad. /// Emits `disconnected` signal and then resets button state if a gamepad was connected to a robot. /// Returns true if a gamepad was connected - virtual bool disconnect() = 0; + Q_INVOKABLE virtual bool disconnect() = 0; -signals: +Q_SIGNALS: /// Emitted when user pulls finger off a pad. /// @param pad - id of a pad on which the event occurs. void padUp(int pad); diff --git a/trikControl/include/trikControl/gyroSensorInterface.h b/trikControl/include/trikControl/gyroSensorInterface.h index 722226e70..c28e29bdf 100644 --- a/trikControl/include/trikControl/gyroSensorInterface.h +++ b/trikControl/include/trikControl/gyroSensorInterface.h @@ -28,31 +28,32 @@ class TRIKCONTROL_EXPORT GyroSensorInterface : public VectorSensorInterface { Q_OBJECT -signals: +Q_SIGNALS: /// Emites when average mean of bias is counted. void calibrationFinished(); -public slots: +public Q_SLOTS: /// Calibrates bias value of sensor, sets new bias value, resets other values include tilt values. /// Preffered duration of calibration -- 15-20 seconds. /// @param msec - duration of calibration in milliseconds virtual void calibrate(int msec) = 0; - /// Returns vector with calibration values, which consists of 6 elements: - /// 0-2 -- gyroscope bias, 3-5 -- average accelerometer values. - /// Updated values is available only after calibration is done. - virtual QVector getCalibrationValues() = 0; - /// Sets vector with calibration values to gyroscope sensor. /// It consists of 6 elements: 0-2 -- gyroscope bias, 3-5 -- average accelerometer values at rest. virtual void setCalibrationValues(const QVector &values) = 0; +public: + /// Returns vector with calibration values, which consists of 6 elements: + /// 0-2 -- gyroscope bias, 3-5 -- average accelerometer values. + /// Updated values is available only after calibration is done. + Q_INVOKABLE virtual QVector getCalibrationValues() = 0; + /// Checks if bias is counted or not. - virtual bool isCalibrated() const = 0; + Q_INVOKABLE virtual bool isCalibrated() const = 0; /// Returns current raw reading of a sensor. - virtual QVector readRawData() const = 0; + Q_INVOKABLE virtual QVector readRawData() const = 0; }; } diff --git a/trikControl/include/trikControl/irCameraInterface.h b/trikControl/include/trikControl/irCameraInterface.h index 208101c38..822c0f7b7 100644 --- a/trikControl/include/trikControl/irCameraInterface.h +++ b/trikControl/include/trikControl/irCameraInterface.h @@ -38,17 +38,18 @@ public Q_SLOTS: /// Stops frames capturing until init() will be called again. virtual void stop() = 0; +public: /// Gets photo as a vector of uint8_t in Grayscale8 format. - virtual QVector getImage() const = 0; + Q_INVOKABLE virtual QVector getImage() const = 0; /// Returns average value in given cell of a grid. /// @param[in] m row number /// @param[in] n column number - virtual int readSensor(int m, int n) const = 0; + Q_INVOKABLE virtual int readSensor(int m, int n) const = 0; - Status status() const override = 0; + Q_INVOKABLE Status status() const override = 0; -signals: +Q_SIGNALS: /// Emitted when new image is ready. void imageUpdated(); diff --git a/trikControl/include/trikControl/keysInterface.h b/trikControl/include/trikControl/keysInterface.h index 7d493c7b2..5b4dd188b 100644 --- a/trikControl/include/trikControl/keysInterface.h +++ b/trikControl/include/trikControl/keysInterface.h @@ -27,7 +27,7 @@ class TRIKCONTROL_EXPORT KeysInterface : public QObject, public DeviceInterface { Q_OBJECT -public slots: +public Q_SLOTS: /// Clear data about previous key pressures. virtual void reset() = 0; @@ -40,7 +40,7 @@ public slots: /// Returns a code of a pressed button. virtual int buttonCode(bool wait = true) = 0; -signals: +Q_SIGNALS: /// Triggered when button state changed (pressed or released). /// @param code - key code. /// @param value - key state. diff --git a/trikControl/include/trikControl/ledInterface.h b/trikControl/include/trikControl/ledInterface.h index 40067acfa..df58fbcd4 100644 --- a/trikControl/include/trikControl/ledInterface.h +++ b/trikControl/include/trikControl/ledInterface.h @@ -27,7 +27,7 @@ class TRIKCONTROL_EXPORT LedInterface : public QObject, public DeviceInterface { Q_OBJECT -public slots: +public Q_SLOTS: /// Turn LED on with red color. virtual void red() = 0; diff --git a/trikControl/include/trikControl/lineSensorInterface.h b/trikControl/include/trikControl/lineSensorInterface.h index a10c69e7c..78b2a0167 100644 --- a/trikControl/include/trikControl/lineSensorInterface.h +++ b/trikControl/include/trikControl/lineSensorInterface.h @@ -30,11 +30,11 @@ class TRIKCONTROL_EXPORT LineSensorInterface : public QObject, public DeviceInte { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when sensor is stopped successfully. void stopped(); -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. virtual void init(bool showOnDisplay) = 0; @@ -42,15 +42,16 @@ public slots: /// Detects the color of an object in center of current frame and memorizes it. virtual void detect() = 0; - /// Returns current raw x coordinate of detected object. Sensor returns 0 if detect() was not called. - virtual QVector read() = 0; - /// Stops detection until init() will be called again. virtual void stop() = 0; +public: + /// Returns current raw x coordinate of detected object. Sensor returns 0 if detect() was not called. + Q_INVOKABLE virtual QVector read() = 0; + /// Get values returned by last "detect" operation. Returned vector has 6 components - hue, saturation and value /// of a dominant color (got by "detect") and hue, saturation and value tolerance factors. - virtual QVector getDetectParameters() const = 0; + Q_INVOKABLE virtual QVector getDetectParameters() const = 0; }; } diff --git a/trikControl/include/trikControl/markerInterface.h b/trikControl/include/trikControl/markerInterface.h index a14956046..820b8f729 100644 --- a/trikControl/include/trikControl/markerInterface.h +++ b/trikControl/include/trikControl/markerInterface.h @@ -28,7 +28,7 @@ class TRIKCONTROL_EXPORT MarkerInterface : public QObject, public DeviceInterfac { Q_OBJECT -public slots: +public Q_SLOTS: /// Moves the marker down to the floor. virtual void down(const QString &color) = 0; diff --git a/trikControl/include/trikControl/motorInterface.h b/trikControl/include/trikControl/motorInterface.h index 5bdd4af3f..25aaf384a 100644 --- a/trikControl/include/trikControl/motorInterface.h +++ b/trikControl/include/trikControl/motorInterface.h @@ -39,7 +39,7 @@ class TRIKCONTROL_EXPORT MotorInterface : public QObject, public DeviceInterface /// Returns maximal value of control accepted by a motor (-90..90, 0..100, for example). virtual int maxControl() const = 0; -public slots: +public Q_SLOTS: /// Sets current motor power to specified value, 0 to stop motor. /// @param power - power of a motor, from -100 (full reverse) to 100 (full forward), 0 --- break. /// @param constrain - if true, power will be constrained in an interval [-100, 100], if false, "power" value diff --git a/trikControl/include/trikControl/objectSensorInterface.h b/trikControl/include/trikControl/objectSensorInterface.h index 0fe16bd3b..f8003d6e7 100644 --- a/trikControl/include/trikControl/objectSensorInterface.h +++ b/trikControl/include/trikControl/objectSensorInterface.h @@ -29,11 +29,11 @@ class TRIKCONTROL_EXPORT ObjectSensorInterface : public QObject, public DeviceIn { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when sensor is stopped successfully. void stopped(); -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. virtual void init(bool showOnDisplay) = 0; diff --git a/trikControl/include/trikControl/pwmCaptureInterface.h b/trikControl/include/trikControl/pwmCaptureInterface.h index cab945e68..c265a629a 100644 --- a/trikControl/include/trikControl/pwmCaptureInterface.h +++ b/trikControl/include/trikControl/pwmCaptureInterface.h @@ -35,7 +35,7 @@ class TRIKCONTROL_EXPORT PwmCaptureInterface : public QObject, public DeviceInte /// Gets maximal possible value for PWM capture reading received by duty() slot. virtual long maxValue() const = 0; -public slots: +public Q_SLOTS: /// Returns three readings of PWM signal frequency. virtual QVector frequency() = 0; diff --git a/trikControl/include/trikControl/sensorInterface.h b/trikControl/include/trikControl/sensorInterface.h index 3e9cbc728..febf6315b 100644 --- a/trikControl/include/trikControl/sensorInterface.h +++ b/trikControl/include/trikControl/sensorInterface.h @@ -40,7 +40,7 @@ class TRIKCONTROL_EXPORT SensorInterface : public QObject, public DeviceInterfac /// Gets maximal possible value for sensor reading received by read() slot. virtual int maxValue() const = 0; -public slots: +public Q_SLOTS: /// Returns current reading of a sensor. virtual int read() = 0; diff --git a/trikControl/include/trikControl/soundSensorInterface.h b/trikControl/include/trikControl/soundSensorInterface.h index c82afff2d..ef2e206bf 100644 --- a/trikControl/include/trikControl/soundSensorInterface.h +++ b/trikControl/include/trikControl/soundSensorInterface.h @@ -28,11 +28,11 @@ class TRIKCONTROL_EXPORT SoundSensorInterface : public QObject, public DeviceInt { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when sensor is stopped successfully. void stopped(); -public slots: +public Q_SLOTS: /// Initializes an ALSA /// @param showOnDisplay - true if we want an image from DSP to be drawn on robot display. virtual void init(bool showOnDisplay) = 0; diff --git a/trikControl/include/trikControl/vectorSensorInterface.h b/trikControl/include/trikControl/vectorSensorInterface.h index 8ec84ed20..dd1189660 100644 --- a/trikControl/include/trikControl/vectorSensorInterface.h +++ b/trikControl/include/trikControl/vectorSensorInterface.h @@ -30,11 +30,11 @@ class TRIKCONTROL_EXPORT VectorSensorInterface : public QObject, public DeviceIn { Q_OBJECT -signals: +Q_SIGNALS: /// Emitted when new sensor reading is ready. void newData(QVector reading, const trikKernel::TimeVal &eventTime); -public slots: +public Q_SLOTS: /// Returns current raw reading of a sensor. virtual QVector read() const = 0; }; diff --git a/trikControl/src/abstractVirtualSensorWorker.cpp b/trikControl/src/abstractVirtualSensorWorker.cpp index c814c9892..eaa0da888 100644 --- a/trikControl/src/abstractVirtualSensorWorker.cpp +++ b/trikControl/src/abstractVirtualSensorWorker.cpp @@ -168,7 +168,7 @@ void AbstractVirtualSensorWorker::deinitialize() QLOG_INFO() << QString("Successfully stopped %1 sensor").arg(sensorName()); } - emit stopped(); + Q_EMIT stopped(); mState.off(); } diff --git a/trikControl/src/abstractVirtualSensorWorker.h b/trikControl/src/abstractVirtualSensorWorker.h index d46adef1a..f6be75ae9 100644 --- a/trikControl/src/abstractVirtualSensorWorker.h +++ b/trikControl/src/abstractVirtualSensorWorker.h @@ -52,11 +52,11 @@ class AbstractVirtualSensorWorker : public QObject, public DeviceInterface Status status() const override; -signals: +Q_SIGNALS: /// Emitted when sensor is stopped successfully. void stopped(); -public slots: +public Q_SLOTS: /// Stops detection until init() will be called again. virtual void stop(); @@ -67,7 +67,7 @@ public slots: /// If sensor is ready, sends a command to its input FIFO, otherwise queues this command and sends it later. void sendCommand(const QString &command); -private slots: +private Q_SLOTS: /// Updates current reading when new value is ready. void onNewDataInOutputFifo(const QString &data); diff --git a/trikControl/src/analogSensor.h b/trikControl/src/analogSensor.h index 3fa40892f..707807933 100644 --- a/trikControl/src/analogSensor.h +++ b/trikControl/src/analogSensor.h @@ -47,7 +47,7 @@ class AnalogSensor : public SensorInterface int maxValue() const override; -public slots: +public Q_SLOTS: /// Returns current reading of a sensor. int read() override; diff --git a/trikControl/src/audioSynthDevice.cpp b/trikControl/src/audioSynthDevice.cpp index 19d595125..f58a0f8c5 100644 --- a/trikControl/src/audioSynthDevice.cpp +++ b/trikControl/src/audioSynthDevice.cpp @@ -51,7 +51,7 @@ void AudioSynthDevice::start(int hzFreq) mBuffer.resize(length); generate(mBuffer.data(), length); } - emit readyRead(); + Q_EMIT readyRead(); } void AudioSynthDevice::stop() diff --git a/trikControl/src/battery.h b/trikControl/src/battery.h index 107f2fba1..f69bf5bba 100644 --- a/trikControl/src/battery.h +++ b/trikControl/src/battery.h @@ -34,7 +34,7 @@ class /* TRIKCONTROL_EXPORT for ScriptRunner/PythonQt */ TRIKCONTROL_EXPORT Batt Status status() const override; -public slots: +public Q_SLOTS: float readVoltage() override; float readRawDataVoltage() override; diff --git a/trikControl/src/brick.h b/trikControl/src/brick.h index 1d6b7dd01..e26ed42ed 100644 --- a/trikControl/src/brick.h +++ b/trikControl/src/brick.h @@ -86,7 +86,7 @@ class /* TRIKCONTROL_EXPORT for ScriptRunner/PythonQt */ TRIKCONTROL_EXPORT Bric QString configVersion() const override; -public slots: +public Q_SLOTS: void configure(const QString &portName, const QString &deviceName) override; void playSound(const QString &soundFileName) override; diff --git a/trikControl/src/colorSensor.cpp b/trikControl/src/colorSensor.cpp index 8d8a0155c..1c8769ba6 100644 --- a/trikControl/src/colorSensor.cpp +++ b/trikControl/src/colorSensor.cpp @@ -77,5 +77,5 @@ void ColorSensor::stop() void ColorSensor::onStopped() { - emit stopped(); + Q_EMIT stopped(); } diff --git a/trikControl/src/colorSensor.h b/trikControl/src/colorSensor.h index 5c59b807d..7b1c17db6 100644 --- a/trikControl/src/colorSensor.h +++ b/trikControl/src/colorSensor.h @@ -50,14 +50,14 @@ class ColorSensor : public ColorSensorInterface Status status() const override; -public slots: +public Q_SLOTS: void init(bool showOnDisplay) override; QVector read(int m, int n) override; void stop() override; -private slots: +private Q_SLOTS: void onStopped(); private: diff --git a/trikControl/src/colorSensorWorker.h b/trikControl/src/colorSensorWorker.h index be4c8b50f..d8848fa3c 100644 --- a/trikControl/src/colorSensorWorker.h +++ b/trikControl/src/colorSensorWorker.h @@ -42,7 +42,7 @@ class ColorSensorWorker : public AbstractVirtualSensorWorker ~ColorSensorWorker() override; -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. void init(bool showOnDisplay); diff --git a/trikControl/src/configurerHelper.cpp b/trikControl/src/configurerHelper.cpp index a7330e7fa..cd520558d 100644 --- a/trikControl/src/configurerHelper.cpp +++ b/trikControl/src/configurerHelper.cpp @@ -33,7 +33,7 @@ int ConfigurerHelper::configureInt(const trikKernel::Configurer &configurer, Dev int parameter = configurer.attributeByPort(port, parameterName).toInt(&ok, 0); if (!ok) { QLOG_ERROR() << QString(R"(Incorrect configuration for parameter "%1" for port "%2": "%3" )") - .arg(parameterName).arg(port).arg(configurer.attributeByPort(port, parameterName)); + .arg(parameterName, port, configurer.attributeByPort(port, parameterName)); state.fail(); return 0; } @@ -53,7 +53,7 @@ long ConfigurerHelper::configureLong(const trikKernel::Configurer &configurer, D long parameter = configurer.attributeByPort(port, parameterName).toLong(&ok, 0); if (!ok) { QLOG_ERROR() << QString(R"(Incorrect configuration for parameter "%1" for port "%2": "%3" )") - .arg(parameterName).arg(port).arg(configurer.attributeByPort(port, parameterName)); + .arg(parameterName, port, configurer.attributeByPort(port, parameterName)); state.fail(); return 0; } @@ -73,7 +73,7 @@ qreal ConfigurerHelper::configureReal(const trikKernel::Configurer &configurer, const qreal parameter = configurer.attributeByPort(port, parameterName).toDouble(&ok); if (!ok) { QLOG_ERROR() << QString(R"(Incorrect configuration for parameter "%1" for port "%2": "%3" )") - .arg(parameterName).arg(port).arg(configurer.attributeByPort(port, parameterName)); + .arg(parameterName, port, configurer.attributeByPort(port, parameterName)); state.fail(); return 0; diff --git a/trikControl/src/digitalSensor.h b/trikControl/src/digitalSensor.h index 18261e3cc..68a57f855 100644 --- a/trikControl/src/digitalSensor.h +++ b/trikControl/src/digitalSensor.h @@ -49,7 +49,7 @@ class DigitalSensor : public SensorInterface int maxValue() const override; -public slots: +public Q_SLOTS: int read() override; int readRawData() override; diff --git a/trikControl/src/display.h b/trikControl/src/display.h index 49d3c26e5..70ee5a635 100644 --- a/trikControl/src/display.h +++ b/trikControl/src/display.h @@ -39,7 +39,7 @@ class /* TRIKCONTROL_EXPORT for ScriptRunner/PythonQt */ TRIKCONTROL_EXPORT Dis DisplayWidgetInterface &graphicsWidget() override; -public slots: +public Q_SLOTS: void setBackground(const QString &color) override; void showImage(const QString &fileName) override; diff --git a/trikControl/src/encoder.h b/trikControl/src/encoder.h index a9356fc7b..802925c1e 100644 --- a/trikControl/src/encoder.h +++ b/trikControl/src/encoder.h @@ -41,7 +41,7 @@ class Encoder : public EncoderInterface Status status() const override; -public slots: +public Q_SLOTS: int read() override; int readRawData() override; diff --git a/trikControl/src/event.cpp b/trikControl/src/event.cpp index 46af55149..ff27307ac 100644 --- a/trikControl/src/event.cpp +++ b/trikControl/src/event.cpp @@ -37,6 +37,6 @@ EventCodeInterface *Event::code(int codeNum) void Event::onEvent(int event, int code, int value, int eventTime) { if (event == mEventType) { - emit on(code, value, eventTime); + Q_EMIT on(code, value, eventTime); } } diff --git a/trikControl/src/event.h b/trikControl/src/event.h index e59d7147d..f10d4c8d9 100644 --- a/trikControl/src/event.h +++ b/trikControl/src/event.h @@ -35,7 +35,7 @@ class Event : public EventInterface EventCodeInterface *code(int codeNum) override; -public slots: +public Q_SLOTS: /// Supposed to be called by event device when new event is emitted by event device file. Filters events by type /// and re-emits signal. void onEvent(int onEvent, int code, int value, int eventTime); diff --git a/trikControl/src/eventCode.cpp b/trikControl/src/eventCode.cpp index 7f19b23b9..004d1a6ab 100644 --- a/trikControl/src/eventCode.cpp +++ b/trikControl/src/eventCode.cpp @@ -24,6 +24,6 @@ EventCode::EventCode(int code) void EventCode::onEvent(int code, int value, int eventTime) { if (code == mEventCode) { - emit on(value, eventTime); + Q_EMIT on(value, eventTime); } } diff --git a/trikControl/src/eventCode.h b/trikControl/src/eventCode.h index 7117e8a53..0d8fb367f 100644 --- a/trikControl/src/eventCode.h +++ b/trikControl/src/eventCode.h @@ -30,7 +30,7 @@ class EventCode : public EventCodeInterface /// @param code - code of the event to filter, see evtest output for a list of codes for specific device. explicit EventCode(int code); -public slots: +public Q_SLOTS: /// Supposed to be called by event type filter when new event is emitted. Filters events of this /// type by code and re-emits signal. void onEvent(int code, int value, int eventTime); diff --git a/trikControl/src/eventDeviceWorker.cpp b/trikControl/src/eventDeviceWorker.cpp index 24189c5cc..e4ae1a144 100644 --- a/trikControl/src/eventDeviceWorker.cpp +++ b/trikControl/src/eventDeviceWorker.cpp @@ -42,5 +42,5 @@ void EventDeviceWorker::init() void EventDeviceWorker::onNewEvent(int eventType, int code, int value, const trikKernel::TimeVal &eventTime) { - emit newEvent(eventType, code, value, eventTime.packedUInt32()); + Q_EMIT newEvent(eventType, code, value, eventTime.packedUInt32()); } diff --git a/trikControl/src/eventDeviceWorker.h b/trikControl/src/eventDeviceWorker.h index 7753678f7..3d0c415b1 100644 --- a/trikControl/src/eventDeviceWorker.h +++ b/trikControl/src/eventDeviceWorker.h @@ -39,7 +39,7 @@ class EventDeviceWorker : public QObject /// Execute init() after worker thread started. void init(); -signals: +Q_SIGNALS: /// Emitted when there is new event in an event file. /// @param event - type of the event. /// @param code - code of the event inside a type. @@ -47,7 +47,7 @@ class EventDeviceWorker : public QObject /// @param eventTime - time stamp of the event, in msecs form start of the epoch. void newEvent(int onEvent, int code, int value, int eventTime); -private slots: +private Q_SLOTS: /// Called every time underlying event file produces an event. void onNewEvent(int eventType, int code, int value, const trikKernel::TimeVal &eventTime); diff --git a/trikControl/src/exceptions/incorrectDeviceConfigurationException.h b/trikControl/src/exceptions/incorrectDeviceConfigurationException.h index fe6af4ccc..ffd79692f 100644 --- a/trikControl/src/exceptions/incorrectDeviceConfigurationException.h +++ b/trikControl/src/exceptions/incorrectDeviceConfigurationException.h @@ -22,7 +22,8 @@ namespace trikControl { /// Exception for semantically incorrect device config, for example, trying to init MxN color sensor with negative /// grid size. -class IncorrectDeviceConfigurationException : public trikKernel::TrikRuntimeException +class IncorrectDeviceConfigurationException // clazy:exclude=copyable-polymorphic + : public trikKernel::TrikRuntimeException { public: /// Constructor. diff --git a/trikControl/src/exceptions/incorrectStateChangeException.h b/trikControl/src/exceptions/incorrectStateChangeException.h index 7de2bc1b6..440d0dd99 100644 --- a/trikControl/src/exceptions/incorrectStateChangeException.h +++ b/trikControl/src/exceptions/incorrectStateChangeException.h @@ -23,7 +23,8 @@ namespace trikControl { /// Exception for incorrect device state change, for example, from "off" to "stopping". -class IncorrectStateChangeException : public trikKernel::TrikRuntimeException +class IncorrectStateChangeException // clazy:exclude=copyable-polymorphic + : public trikKernel::TrikRuntimeException { public: /// Constructor. @@ -32,7 +33,7 @@ class IncorrectStateChangeException : public trikKernel::TrikRuntimeException /// @param to - status to which we tried to change. IncorrectStateChangeException(const QString &deviceName, DeviceInterface::Status from, DeviceInterface::Status to) : trikKernel::TrikRuntimeException(QString("%1: incorrect device state change from \"%2\" to \"%3\"") - .arg(deviceName).arg(statusToString(from)).arg(statusToString(to))) + .arg(deviceName, statusToString(from), statusToString(to))) { } @@ -41,7 +42,7 @@ class IncorrectStateChangeException : public trikKernel::TrikRuntimeException /// @param from - status from which we tried to change. IncorrectStateChangeException(const QString &deviceName, DeviceInterface::Status from) : trikKernel::TrikRuntimeException(QString("%1 : incorrect attempt to reset failure from \"%2\"") - .arg(deviceName).arg(statusToString(from))) + .arg(deviceName, statusToString(from))) { } diff --git a/trikControl/src/fifoworker.cpp b/trikControl/src/fifoworker.cpp index a3e62dfb9..63e6bf037 100644 --- a/trikControl/src/fifoworker.cpp +++ b/trikControl/src/fifoworker.cpp @@ -117,7 +117,7 @@ void trikControl::FifoWorker::onNewLine(const QString &line) QWriteLocker w(&mCurrentLock); mCurrentLine = line; w.unlock(); - emit newLine(mCurrentLine); + Q_EMIT newLine(mCurrentLine); } void trikControl::FifoWorker::onNewData(const QVector &data) @@ -129,7 +129,7 @@ void trikControl::FifoWorker::onNewData(const QVector &data) mCurrentData.clear(); } w.unlock(); - emit newData(mCurrentData); + Q_EMIT newData(mCurrentData); } void trikControl::FifoWorker::onReadError() diff --git a/trikControl/src/fifoworker.h b/trikControl/src/fifoworker.h index e7f3d5dcf..7de45689e 100644 --- a/trikControl/src/fifoworker.h +++ b/trikControl/src/fifoworker.h @@ -43,7 +43,7 @@ class FifoWorker : public QObject, public DeviceInterface Status status() const override; -public slots: +public Q_SLOTS: /// Work with DeviceState and connections. void init(); /// Reads line from this FIFO file, returning all available data as string. @@ -59,13 +59,13 @@ public slots: /// Blocks the Thread with QSemaphore until init() method releases it. void waitUntilInited(); -signals: +Q_SIGNALS: /// Emitted once per each text line that arrives to FIFO. void newLine(const QString &data); /// Emitted when new bytes have arrived to FIFO file. void newData(const QVector &data); -private slots: +private Q_SLOTS: void onNewLine(const QString &line); void onNewData(const QVector &data); void onReadError(); diff --git a/trikControl/src/gamepad.cpp b/trikControl/src/gamepad.cpp index 041ed3dc1..4a765e58e 100644 --- a/trikControl/src/gamepad.cpp +++ b/trikControl/src/gamepad.cpp @@ -79,7 +79,7 @@ bool Gamepad::disconnect() if (wasConnected) { mConnected = false; reset(); - emit disconnected(); + Q_EMIT disconnected(); } return wasConnected; } @@ -88,7 +88,7 @@ void Gamepad::onNewData(const QString &data) { if (!isConnected()) { mConnected = true; - emit connected(); + Q_EMIT connected(); } const QStringList cmd = data.split(" ", QString::SkipEmptyParts); @@ -145,13 +145,13 @@ void Gamepad::onNewData(const QString &data) void Gamepad::handlePadUp(int padId) { mPads[padId].isPressed = false; - emit padUp(padId); + Q_EMIT padUp(padId); } void Gamepad::handleWheel(int percent) { mWheelPercent = percent; - emit wheelEvent(percent); + Q_EMIT wheelEvent(percent); } void Gamepad::handlePad(int padId, int x, int y) @@ -159,7 +159,7 @@ void Gamepad::handlePad(int padId, int x, int y) mPads[padId].isPressed = true; mPads[padId].x = x; mPads[padId].y = y; - emit pad(padId, x, y); + Q_EMIT pad(padId, x, y); } void Gamepad::handleButton(int button, int pressed) @@ -179,7 +179,7 @@ void Gamepad::handleButton(int button, int pressed) tmr->start(); - emit Gamepad::button(button, pressed); + Q_EMIT Gamepad::button(button, pressed); } void Gamepad::handleKeepalive(int waitForMs) @@ -194,7 +194,7 @@ void Gamepad::handleKeepalive(int waitForMs) void Gamepad::handleCustom(const QString &message) { mLastCustomMessage = message; - emit custom(message); + Q_EMIT custom(message); } void Gamepad::onButtonStateClearTimerTimeout() diff --git a/trikControl/src/gamepad.h b/trikControl/src/gamepad.h index b207a1676..93934e8cc 100644 --- a/trikControl/src/gamepad.h +++ b/trikControl/src/gamepad.h @@ -43,7 +43,7 @@ class Gamepad : public GamepadInterface, public DeviceInterface Status status() const override; -public slots: +public Q_SLOTS: void reset() override; bool buttonWasPressed(int buttonNumber) override; @@ -62,7 +62,7 @@ public slots: bool disconnect() override; -private slots: +private Q_SLOTS: void onNewData(const QString &data); void onButtonStateClearTimerTimeout(); diff --git a/trikControl/src/graphicsWidget.cpp b/trikControl/src/graphicsWidget.cpp index 0a84042b7..31dde7bd6 100644 --- a/trikControl/src/graphicsWidget.cpp +++ b/trikControl/src/graphicsWidget.cpp @@ -39,13 +39,13 @@ GraphicsWidget::~GraphicsWidget() void GraphicsWidget::showCommand() { show(); - emit shown(); + Q_EMIT shown(); } void GraphicsWidget::hideCommand() { hide(); - emit hidden(); + Q_EMIT hidden(); } void GraphicsWidget::paintEvent(QPaintEvent *paintEvent) diff --git a/trikControl/src/guiWorker.h b/trikControl/src/guiWorker.h index b00b91bd0..0f38f70a5 100644 --- a/trikControl/src/guiWorker.h +++ b/trikControl/src/guiWorker.h @@ -45,7 +45,7 @@ class GuiWorker : public QObject /// Returns a widget on which everything is drawn. DisplayWidgetInterface &graphicsWidget(); -public slots: +public Q_SLOTS: /// Shows image with given filename on display. Image is scaled to fill the screen and is cached on first read /// for better performance. void showImage(const QString &fileName); diff --git a/trikControl/src/gyroSensor.cpp b/trikControl/src/gyroSensor.cpp index 191ab501e..27d880f1f 100644 --- a/trikControl/src/gyroSensor.cpp +++ b/trikControl/src/gyroSensor.cpp @@ -213,7 +213,7 @@ void GyroSensor::countTilt(const QVector &gyroData, trikKernel::TimeVal t) mResult[6] = -euler.y(); locker.unlock(); - emit newData(mResult, t); + Q_EMIT newData(mResult, t); } } @@ -245,7 +245,7 @@ void GyroSensor::countCalibrationParameters() setCalibrationValues(mCalibrationValues); mIsCalibrated = true; - emit calibrationFinished(); + Q_EMIT calibrationFinished(); } void GyroSensor::sumAccelerometer(const QVector &accelerometerData, const trikKernel::TimeVal &t) diff --git a/trikControl/src/gyroSensor.h b/trikControl/src/gyroSensor.h index 97b6ca582..8cf8824c8 100644 --- a/trikControl/src/gyroSensor.h +++ b/trikControl/src/gyroSensor.h @@ -69,7 +69,7 @@ class GyroSensor : public GyroSensorInterface Q_SLOT void setCalibrationValues(const QVector &values) override; -private slots: +private Q_SLOTS: /// Counts current angle velocities (3-axis) in mdps, current tilts (3-axis) in mdps /// and packed time of current event. void countTilt(const QVector &gyroData, trikKernel::TimeVal t); diff --git a/trikControl/src/i2cDevice.h b/trikControl/src/i2cDevice.h index 8b3dd862a..a03d85d43 100644 --- a/trikControl/src/i2cDevice.h +++ b/trikControl/src/i2cDevice.h @@ -32,7 +32,7 @@ class I2cDevice : public I2cDeviceInterface Status status() const override; -public slots: +public Q_SLOTS: /// Sends data to current device, if it is connected. void send(int reg, int value) override; diff --git a/trikControl/src/irCamera.cpp b/trikControl/src/irCamera.cpp index 7442be44d..dee947288 100644 --- a/trikControl/src/irCamera.cpp +++ b/trikControl/src/irCamera.cpp @@ -106,20 +106,20 @@ int IrCamera::readSensor(int m, int n) const void IrCamera::onNewImage(QVector image) { mImage.swap(image); - emit imageUpdated(); + Q_EMIT imageUpdated(); } void IrCamera::onNewSensorData(QVector grid) { mSensorData.swap(grid); - emit sensorUpdated(); + Q_EMIT sensorUpdated(); } void IrCamera::onStop() { mImage.fill(0); mSensorData.fill(-1); - emit stopped(); + Q_EMIT stopped(); } IrCamera::Status IrCamera::status() const diff --git a/trikControl/src/irCamera.h b/trikControl/src/irCamera.h index f14e121f0..389b4b99e 100644 --- a/trikControl/src/irCamera.h +++ b/trikControl/src/irCamera.h @@ -61,7 +61,7 @@ public Q_SLOTS: Status status() const override; -private slots: +private Q_SLOTS: /// Process new image from IrCameraWorker. void onNewImage(QVector image); diff --git a/trikControl/src/irCameraWorker.cpp b/trikControl/src/irCameraWorker.cpp index c999322b9..60e658d07 100644 --- a/trikControl/src/irCameraWorker.cpp +++ b/trikControl/src/irCameraWorker.cpp @@ -87,7 +87,7 @@ void IrCameraWorkerMLX90640::stop() { if (mState.isReady()) { mState.stop(); - emit stopped(); + Q_EMIT stopped(); mState.off(); } } @@ -143,7 +143,7 @@ void IrCameraWorkerMLX90640::processFrame() } } } - emit newImage(mImage); + Q_EMIT newImage(mImage); auto heightsDivMod = std::div(IMG_HEIGHT, mSensorHeight); auto widthsDivMod = std::div(IMG_WIDTH, mSensorWidth); @@ -162,7 +162,7 @@ void IrCameraWorkerMLX90640::processFrame() in = 0; } } - emit newSensorData(mSensorData); + Q_EMIT newSensorData(mSensorData); QTimer::singleShot(0, this, &IrCameraWorkerMLX90640::processFrame); } diff --git a/trikControl/src/irCameraWorker.h b/trikControl/src/irCameraWorker.h index 0d2537543..4aa229868 100644 --- a/trikControl/src/irCameraWorker.h +++ b/trikControl/src/irCameraWorker.h @@ -43,7 +43,7 @@ class IrCameraWorkerMLX90640: public QObject /// Stops frames capturing. void stop(); -signals: +Q_SIGNALS: /// Emitted when new image provided by worker. void newImage(QVector); @@ -53,7 +53,7 @@ class IrCameraWorkerMLX90640: public QObject /// Emitted when frames capturing successfully stopped. void stopped(); -private slots: +private Q_SLOTS: /// Reads new frame with raw data from IR camera. void processFrame(); diff --git a/trikControl/src/keys.cpp b/trikControl/src/keys.cpp index 4b18a71dd..7859420bb 100644 --- a/trikControl/src/keys.cpp +++ b/trikControl/src/keys.cpp @@ -81,7 +81,7 @@ bool Keys::isPressed(int code) void Keys::changeButtonState(int code, int value) { mKeysPressed[code] = value; - emit buttonStateChanged(); + Q_EMIT buttonStateChanged(); } int Keys::buttonCode(bool wait) diff --git a/trikControl/src/keys.h b/trikControl/src/keys.h index 7a3a3ebb8..bba435c3b 100644 --- a/trikControl/src/keys.h +++ b/trikControl/src/keys.h @@ -48,7 +48,7 @@ class Keys : public KeysInterface Status status() const override; -public slots: +public Q_SLOTS: void reset() override; bool wasPressed(int code) override; @@ -57,11 +57,11 @@ public slots: int buttonCode(bool wait = true) override; -signals: +Q_SIGNALS: /// Emitted when a button's state changed. void buttonStateChanged(); -private slots: +private Q_SLOTS: void changeButtonState(int code, int value); private: diff --git a/trikControl/src/keysWorker.cpp b/trikControl/src/keysWorker.cpp index 974130650..49724b3e0 100644 --- a/trikControl/src/keysWorker.cpp +++ b/trikControl/src/keysWorker.cpp @@ -45,7 +45,7 @@ void KeysWorker::init() void KeysWorker::reset() { mLock.lockForWrite(); - emit stopWaiting(); + Q_EMIT stopWaiting(); mWasPressed.clear(); mButtonCode = 0; mButtonValue = 0; @@ -85,7 +85,7 @@ void KeysWorker::readKeysEvent(int eventType, int code, int value mLock.unlock(); } - emit buttonPressed(mButtonCode, mButtonValue); + Q_EMIT buttonPressed(mButtonCode, mButtonValue); mButtonCode = 0; mButtonValue = 0; diff --git a/trikControl/src/keysWorker.h b/trikControl/src/keysWorker.h index f8973b827..94ecba2f0 100644 --- a/trikControl/src/keysWorker.h +++ b/trikControl/src/keysWorker.h @@ -44,14 +44,14 @@ class KeysWorker : public QObject /// Clear data about previous key pressures. void reset(); -public slots: +public Q_SLOTS: /// Returns true if a key with given code was pressed. bool wasPressed(int code); -private slots: +private Q_SLOTS: void readKeysEvent(int eventType, int code, int value, const trikKernel::TimeVal &eventTime); -signals: +Q_SIGNALS: /// Triggered when button state changed (pressed or released). /// @param code - key code. /// @param value - key state. diff --git a/trikControl/src/led.h b/trikControl/src/led.h index 100d5f062..4af54aa93 100644 --- a/trikControl/src/led.h +++ b/trikControl/src/led.h @@ -46,7 +46,7 @@ class Led : public LedInterface Status status() const override; -public slots: +public Q_SLOTS: void red() override; void green() override; diff --git a/trikControl/src/lidarWorker.h b/trikControl/src/lidarWorker.h index 14cab24dd..8c9344b35 100644 --- a/trikControl/src/lidarWorker.h +++ b/trikControl/src/lidarWorker.h @@ -52,7 +52,7 @@ class LidarWorker : public QObject, public DeviceInterface /// Returning all available raw data. Q_INVOKABLE QVector readRaw() const; -private slots: +private Q_SLOTS: /// Called when there is new data on serial port void readData(); diff --git a/trikControl/src/lineSensor.cpp b/trikControl/src/lineSensor.cpp index b9ea8279f..62f0172ee 100644 --- a/trikControl/src/lineSensor.cpp +++ b/trikControl/src/lineSensor.cpp @@ -107,5 +107,5 @@ QVector LineSensor::getDetectParameters() const void LineSensor::onStopped() { - emit stopped(); + Q_EMIT stopped(); } diff --git a/trikControl/src/lineSensor.h b/trikControl/src/lineSensor.h index 3e5ee5795..f1c8981c4 100644 --- a/trikControl/src/lineSensor.h +++ b/trikControl/src/lineSensor.h @@ -51,18 +51,20 @@ class LineSensor : public LineSensorInterface Status status() const override; -public slots: + Q_INVOKABLE QVector read() override; + + Q_INVOKABLE QVector getDetectParameters() const override; + +public Q_SLOTS: void init(bool showOnDisplay) override; void detect() override; - QVector read() override; - void stop() override; - QVector getDetectParameters() const override; +private Q_SLOTS: -private slots: + /// emit Stopped signal void onStopped(); private: diff --git a/trikControl/src/lineSensorWorker.h b/trikControl/src/lineSensorWorker.h index 7ea30eadf..b4f9b257c 100644 --- a/trikControl/src/lineSensorWorker.h +++ b/trikControl/src/lineSensorWorker.h @@ -42,7 +42,7 @@ class LineSensorWorker : public AbstractVirtualSensorWorker ~LineSensorWorker() override; -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. void init(bool showOnDisplay); diff --git a/trikControl/src/objectSensor.cpp b/trikControl/src/objectSensor.cpp index 6247c8faf..0e901cbeb 100644 --- a/trikControl/src/objectSensor.cpp +++ b/trikControl/src/objectSensor.cpp @@ -35,7 +35,8 @@ ObjectSensor::ObjectSensor(const QString &port, const trikKernel::Configurer &co mObjectSensorWorker.reset(new ObjectSensorWorker(script, inputFile, outputFile, toleranceFactor, mState , hardwareAbstraction)); mObjectSensorWorker->moveToThread(&mWorkerThread); - connect(mObjectSensorWorker.data(), SIGNAL(stopped()), this, SLOT(onStopped()), Qt::DirectConnection); + connect(mObjectSensorWorker.data(), &AbstractVirtualSensorWorker::stopped + , this, &ObjectSensor::onStopped, Qt::DirectConnection); QLOG_INFO() << "Starting ObjectSensor worker thread" << &mWorkerThread; @@ -105,5 +106,5 @@ QVector ObjectSensor::getDetectParameters() const void ObjectSensor::onStopped() { - emit stopped(); + Q_EMIT stopped(); } diff --git a/trikControl/src/objectSensor.h b/trikControl/src/objectSensor.h index fad910640..1f2259dd9 100644 --- a/trikControl/src/objectSensor.h +++ b/trikControl/src/objectSensor.h @@ -48,7 +48,7 @@ class ObjectSensor : public ObjectSensorInterface Status status() const override; -public slots: +public Q_SLOTS: void init(bool showOnDisplay) override; void detect() override; @@ -59,7 +59,7 @@ public slots: QVector getDetectParameters() const override; -private slots: +private Q_SLOTS: void onStopped(); private: diff --git a/trikControl/src/objectSensorWorker.h b/trikControl/src/objectSensorWorker.h index 9842c93a3..e67c6b22f 100644 --- a/trikControl/src/objectSensorWorker.h +++ b/trikControl/src/objectSensorWorker.h @@ -41,7 +41,7 @@ class ObjectSensorWorker : public AbstractVirtualSensorWorker ~ObjectSensorWorker() override; -public slots: +public Q_SLOTS: /// Initializes a camera. /// @param showOnDisplay - true if we want an image from a camera to be drawn on robot display. void init(bool showOnDisplay); diff --git a/trikControl/src/powerMotor.cpp b/trikControl/src/powerMotor.cpp index 11ab1c57a..1162669f3 100644 --- a/trikControl/src/powerMotor.cpp +++ b/trikControl/src/powerMotor.cpp @@ -97,7 +97,7 @@ void PowerMotor::brake(int durationMs) if (durationMs <= 0) brake(); setPower(0x7f, false); - QTimer::singleShot(durationMs, this, SLOT(powerOff())); + QTimer::singleShot(durationMs, this, &PowerMotor::powerOff); } void PowerMotor::setPeriod(int period) diff --git a/trikControl/src/powerMotor.h b/trikControl/src/powerMotor.h index cc7e822e4..2e86f2814 100644 --- a/trikControl/src/powerMotor.h +++ b/trikControl/src/powerMotor.h @@ -49,7 +49,7 @@ class PowerMotor : public MotorInterface int maxControl() const override; -public slots: +public Q_SLOTS: void setPower(int power, bool constrain = true) override; int power() const override; diff --git a/trikControl/src/pwmCapture.h b/trikControl/src/pwmCapture.h index 223cb892a..dcb6e5cd9 100644 --- a/trikControl/src/pwmCapture.h +++ b/trikControl/src/pwmCapture.h @@ -50,7 +50,7 @@ class PwmCapture : public PwmCaptureInterface long maxValue() const override; -public slots: +public Q_SLOTS: /// Returns three readings of PWM signal frequency. QVector frequency() override; diff --git a/trikControl/src/rangeSensor.h b/trikControl/src/rangeSensor.h index 493c4afab..f4128529e 100644 --- a/trikControl/src/rangeSensor.h +++ b/trikControl/src/rangeSensor.h @@ -56,11 +56,11 @@ class RangeSensor : public SensorInterface int maxValue() const override; -signals: +Q_SIGNALS: /// Emitted when new data is received from a sensor. void newData(int distance, int rawDistance, const trikKernel::TimeVal &eventTime); -public slots: +public Q_SLOTS: /// Initializes sensor and begins receiving events from it. void init(); diff --git a/trikControl/src/rangeSensorWorker.cpp b/trikControl/src/rangeSensorWorker.cpp index cfc38ed3a..7a1580652 100644 --- a/trikControl/src/rangeSensorWorker.cpp +++ b/trikControl/src/rangeSensorWorker.cpp @@ -113,7 +113,7 @@ void RangeSensorWorker::onNewEvent(int eventType, int code, int value, const tri break; case evSyn: locker.unlock(); - emit newData(mDistance, mRawDistance, eventTime); + Q_EMIT newData(mDistance, mRawDistance, eventTime); break; default: QLOG_ERROR() << "Unknown event in range sensor event file:" << eventType << code << value; diff --git a/trikControl/src/rangeSensorWorker.h b/trikControl/src/rangeSensorWorker.h index 049f8a96e..016bb2d4d 100644 --- a/trikControl/src/rangeSensorWorker.h +++ b/trikControl/src/rangeSensorWorker.h @@ -42,11 +42,11 @@ class RangeSensorWorker : public QObject ~RangeSensorWorker() override; -signals: +Q_SIGNALS: /// Emitted when new data is received from a sensor. void newData(int distance, int rawDistance, const trikKernel::TimeVal &eventTime); -public slots: +public Q_SLOTS: /// Initializes sensor and begins receiving events from it. void init(); @@ -59,7 +59,7 @@ public slots: /// Stops sensor until init() will be called again. void stop(); -private slots: +private Q_SLOTS: /// Updates current reading when new value is ready in event file. void onNewEvent(int eventType, int code, int value, const trikKernel::TimeVal &eventTime); diff --git a/trikControl/src/servoMotor.h b/trikControl/src/servoMotor.h index e9697a00c..320bfd926 100644 --- a/trikControl/src/servoMotor.h +++ b/trikControl/src/servoMotor.h @@ -53,7 +53,7 @@ class ServoMotor : public MotorInterface int maxControl() const override; -public slots: +public Q_SLOTS: int power() const override; /// Returns currently set frequency of PWM signal supplied to the motor. diff --git a/trikControl/src/soundSensor.h b/trikControl/src/soundSensor.h index cc2d84dcc..8a3753d83 100644 --- a/trikControl/src/soundSensor.h +++ b/trikControl/src/soundSensor.h @@ -48,7 +48,7 @@ class SoundSensor : public SoundSensorInterface Status status() const override; -public slots: +public Q_SLOTS: void init(bool showOnDisplay) override; void detect() override; diff --git a/trikControl/src/soundSensorWorker.h b/trikControl/src/soundSensorWorker.h index 3a3387a3e..d6173afd2 100644 --- a/trikControl/src/soundSensorWorker.h +++ b/trikControl/src/soundSensorWorker.h @@ -39,7 +39,7 @@ class SoundSensorWorker : public AbstractVirtualSensorWorker ~SoundSensorWorker() override; -public slots: +public Q_SLOTS: /// Initializes an ALSA. /// @param showOnDisplay - true if we want an image from a DSP to be drawn on robot display. void init(bool showOnDisplay); diff --git a/trikControl/src/tonePlayer.h b/trikControl/src/tonePlayer.h index f024a0419..69aa6e5b2 100644 --- a/trikControl/src/tonePlayer.h +++ b/trikControl/src/tonePlayer.h @@ -31,7 +31,7 @@ class TonePlayer : public QObject /// Constructor TonePlayer(); -public slots: +public Q_SLOTS: /// Play sound void play(int freqHz, int durationMs); @@ -49,7 +49,7 @@ public slots: static constexpr int SAMPLE_RATE = 16000; static constexpr int SAMPLE_SIZE = 16; -public slots: +public Q_SLOTS: /// Stop playing void stop(); }; diff --git a/trikControl/src/vectorSensor.h b/trikControl/src/vectorSensor.h index 0cb605056..741d382da 100644 --- a/trikControl/src/vectorSensor.h +++ b/trikControl/src/vectorSensor.h @@ -41,14 +41,13 @@ class VectorSensor : public VectorSensorInterface /// @param port - port on which this sensor is configured. /// @param configurer - configurer object containing preparsed XML files with sensor parameters. VectorSensor(const QString &deviceName, const trikKernel::Configurer &configurer - , const trikHal::HardwareAbstractionInterface &hardwareAbstraction, const QString &port); + , const trikHal::HardwareAbstractionInterface &hardwareAbstraction, const QString &port); ~VectorSensor() override; Status status() const override; -public slots: - QVector read() const override; + Q_INVOKABLE QVector read() const override; private: /// Device state, shared with worker. diff --git a/trikControl/src/vectorSensorWorker.cpp b/trikControl/src/vectorSensorWorker.cpp index 9ccc64a57..c889b01e9 100644 --- a/trikControl/src/vectorSensorWorker.cpp +++ b/trikControl/src/vectorSensorWorker.cpp @@ -101,7 +101,7 @@ void VectorSensorWorker::onNewEvent(int eventType, int code, int value, const tr QWriteLocker locker(&mReadingLock); mReading.swap(mReadingUnsynced); locker.unlock(); - emit newData(mReading, eventTime); + Q_EMIT newData(mReading, eventTime); break; } default: diff --git a/trikControl/src/vectorSensorWorker.h b/trikControl/src/vectorSensorWorker.h index 0294f2274..fe531c762 100644 --- a/trikControl/src/vectorSensorWorker.h +++ b/trikControl/src/vectorSensorWorker.h @@ -47,15 +47,15 @@ class VectorSensorWorker : public QObject /// Execute init() after worker thread started. void init(); -signals: +Q_SIGNALS: /// Emitted when new sensor reading is ready. void newData(QVector reading, const trikKernel::TimeVal &eventTime); -public slots: +public Q_SLOTS: /// Returns current raw reading of a sensor. QVector read(); -private slots: +private Q_SLOTS: /// Updates current reading when new value is ready in event file. void onNewEvent(int eventType, int code, int value, const trikKernel::TimeVal &eventTime); diff --git a/trikGui/abstractIndicator.h b/trikGui/abstractIndicator.h index 4612e4ae4..2037d4b9d 100644 --- a/trikGui/abstractIndicator.h +++ b/trikGui/abstractIndicator.h @@ -42,7 +42,7 @@ class AbstractIndicator : public QWidget #endif } -public slots: +public Q_SLOTS: /// Rereads sensor and updates widget contents. virtual void renew() = 0; }; diff --git a/trikGui/accelerometerWidget.h b/trikGui/accelerometerWidget.h index 1d8af9a70..723d1062c 100644 --- a/trikGui/accelerometerWidget.h +++ b/trikGui/accelerometerWidget.h @@ -37,7 +37,7 @@ class AccelerometerWidget : public AbstractIndicator /// @param parent - parent of this widget in Qt widget parent-child system. explicit AccelerometerWidget(trikControl::VectorSensorInterface *accelerometer, QWidget *parent = 0); -public slots: +public Q_SLOTS: void renew() override; private: diff --git a/trikGui/autoRunner.cpp b/trikGui/autoRunner.cpp index 631e0b998..c8c826137 100644 --- a/trikGui/autoRunner.cpp +++ b/trikGui/autoRunner.cpp @@ -30,7 +30,7 @@ AutoRunner::AutoRunner(Controller &controller) if (autorunFileInfo.exists() && autorunFileInfo.isReadable()) { /// Timer is needed to wait for trikControl to initialize. /// @todo Make underlying components emit signal when they are ready for script execution. - QTimer::singleShot(1000, this, SLOT(doLaunch())); + QTimer::singleShot(1000, this, &AutoRunner::doLaunch); } } diff --git a/trikGui/autoRunner.h b/trikGui/autoRunner.h index 6e6c61945..c13c8af64 100644 --- a/trikGui/autoRunner.h +++ b/trikGui/autoRunner.h @@ -22,7 +22,7 @@ namespace trikGui { class Controller; /// Launches "autorun.js" file in "scripts" directory if it exists. -class AutoRunner : QObject +class AutoRunner : public QObject { Q_OBJECT @@ -31,7 +31,7 @@ class AutoRunner : QObject /// @param parent - parent of this widget in Qt widget parent-child system. explicit AutoRunner(Controller &controller); -private slots: +private Q_SLOTS: void doLaunch(); private: diff --git a/trikGui/backgroundWidget.cpp b/trikGui/backgroundWidget.cpp index 6d3ed63e8..dc3759856 100644 --- a/trikGui/backgroundWidget.cpp +++ b/trikGui/backgroundWidget.cpp @@ -50,7 +50,7 @@ BackgroundWidget::BackgroundWidget( mStatusBarLayout.addWidget(&mMailboxIndicator); mStatusBarLayout.addWidget(&mCommunicatorIndicator); mStatusBarLayout.addWidget(&mWiFiIndicator); - addMainWidget(mStartWidget); + addMainWidget(&mStartWidget); mBrickDisplayWidgetWrapper.reset(new LazyMainWidgetWrapper(mController.brick().graphicsWidget())); addLazyWidget(*mBrickDisplayWidgetWrapper); mMainWidgetsLayout.addWidget(&mRunningWidget); @@ -86,47 +86,47 @@ BackgroundWidget::~BackgroundWidget() disconnect(&mMainWidgetsLayout, 0, 0, 0); } -void BackgroundWidget::resetWidgetLayout(MainWidget &widget) +void BackgroundWidget::resetWidgetLayout(MainWidget *widget) { + Q_ASSERT(widget); // If the widget has layout, remove its margins because main widgets layout has its own margins. - QLayout *layout = widget.layout(); - if (layout != nullptr) { + if (auto *layout = widget->layout()) { layout->setContentsMargins(0, 0, 0, 0); } } -void BackgroundWidget::addMainWidget(MainWidget &widget) +void BackgroundWidget::addMainWidget(MainWidget *widget) { resetWidgetLayout(widget); - mMainWidgetIndex.push(mMainWidgetsLayout.addWidget(&widget)); + mMainWidgetIndex.push(mMainWidgetsLayout.addWidget(widget)); mMainWidgetsLayout.setCurrentIndex(mMainWidgetIndex.top()); - connect(&widget, &MainWidget::newWidget, this, &BackgroundWidget::addMainWidget); + connect(widget, &MainWidget::newWidget, this, &BackgroundWidget::addMainWidget); } -void BackgroundWidget::addRunningWidget(MainWidget &widget) +void BackgroundWidget::addRunningWidget(MainWidget *widget) { resetWidgetLayout(widget); - mMainWidgetsLayout.addWidget(&widget); + mMainWidgetsLayout.addWidget(widget); } void BackgroundWidget::addLazyWidget(LazyMainWidget &widget) { - resetWidgetLayout(widget); + resetWidgetLayout(&widget); mMainWidgetsLayout.addWidget(&widget); connect(&widget, &LazyMainWidget::showMe, this, &BackgroundWidget::showMainWidget); connect(&widget, &LazyMainWidget::hideMe, this, &BackgroundWidget::hideGraphicsWidget); } -void BackgroundWidget::showMainWidget(MainWidget &widget) +void BackgroundWidget::showMainWidget(MainWidget *widget) { - if (&widget == mBrickDisplayWidgetWrapper.data()) { + if (widget == mBrickDisplayWidgetWrapper.data()) { expandMainWidget(); } - const int index = mMainWidgetsLayout.indexOf(&widget); + const int index = mMainWidgetsLayout.indexOf(widget); if (index >= 0) { mMainWidgetsLayout.setCurrentIndex(index); } diff --git a/trikGui/backgroundWidget.h b/trikGui/backgroundWidget.h index 450dd78a7..1ff4293b9 100644 --- a/trikGui/backgroundWidget.h +++ b/trikGui/backgroundWidget.h @@ -60,14 +60,14 @@ class BackgroundWidget : public QWidget ~BackgroundWidget() override; -private slots: +private Q_SLOTS: /// Add a widget to main widgets layout and show it. /// @param widget - reference to the widget. - void addMainWidget(trikGui::MainWidget &widget); + void addMainWidget(MainWidget *widget); /// Add a RunningWidget to main widgets layout and show it. /// @param widget - reference to the widget. - void addRunningWidget(trikGui::MainWidget &widget); + void addRunningWidget(MainWidget *widget); /// Add a GraphicsWidget to main widgets layout and show RunningWidget. /// @param widget - reference to the widget. @@ -81,7 +81,7 @@ private slots: /// Show a widget which is contained in main widgets layout. /// @param widget - reference to the widget. - void showMainWidget(trikGui::MainWidget &widget); + void showMainWidget(trikGui::MainWidget *widget); /// Show a RunningWidget which is contained in main widgets layout. void showRunningWidget(const QString &fileName, int scriptId); @@ -99,7 +99,7 @@ private slots: private: /// Remove widget margins. /// @param widget - reference to the widget. - void resetWidgetLayout(MainWidget &widget); + void resetWidgetLayout(MainWidget *widget); /// Makes current main widget be shown as something like fullscreen, without layout margins. void expandMainWidget(); diff --git a/trikGui/batteryIndicator.h b/trikGui/batteryIndicator.h index 363907aa2..8216946a2 100644 --- a/trikGui/batteryIndicator.h +++ b/trikGui/batteryIndicator.h @@ -39,7 +39,7 @@ class BatteryIndicator : public QLabel /// @param parent - parent of this widget in terms of Qt parent-child widget relations. explicit BatteryIndicator(trikControl::BrickInterface &brick, QWidget *parent = 0); -private slots: +private Q_SLOTS: void renew(); private: diff --git a/trikGui/cameraWidget.h b/trikGui/cameraWidget.h index dda1d98e7..846a53a85 100644 --- a/trikGui/cameraWidget.h +++ b/trikGui/cameraWidget.h @@ -35,7 +35,7 @@ class CameraWidget : public AbstractIndicator /// Constructor for Camera Widget in testing menu explicit CameraWidget(trikControl::BrickInterface &brick, QWidget *parent = nullptr); -public slots: +public Q_SLOTS: void renew() override; protected: diff --git a/trikGui/commandSettingsWidget.cpp b/trikGui/commandSettingsWidget.cpp index d5a7b18d8..fbbc924d1 100644 --- a/trikGui/commandSettingsWidget.cpp +++ b/trikGui/commandSettingsWidget.cpp @@ -36,11 +36,11 @@ CommandSettingsWidget::CommandSettingsWidget(const QString &title, const int dig setLayout(&mLayout); mContinueButton.setAutoFillBackground(true); - connect(&mContinueButton, SIGNAL(upPressed()), this, SLOT(focus())); - connect(&mContinueButton, SIGNAL(downPressed()), this, SLOT(focus())); + connect(&mContinueButton, &ConnectButton::upPressed, this, &CommandSettingsWidget::focus); + connect(&mContinueButton, &ConnectButton::downPressed, this, &CommandSettingsWidget::focus); - connect(&mValueSelector, SIGNAL(upPressed()), this, SLOT(focus())); - connect(&mValueSelector, SIGNAL(downPressed()), this, SLOT(focus())); + connect(&mValueSelector, &NumberSelectionWidget::upPressed, this, &CommandSettingsWidget::focus); + connect(&mValueSelector, &NumberSelectionWidget::downPressed, this, &CommandSettingsWidget::focus); } QString CommandSettingsWidget::menuEntry() diff --git a/trikGui/commandSettingsWidget.h b/trikGui/commandSettingsWidget.h index 243f37da6..3fb0347df 100644 --- a/trikGui/commandSettingsWidget.h +++ b/trikGui/commandSettingsWidget.h @@ -59,7 +59,7 @@ class CommandSettingsWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Called by child widgets when they need to move input focus up or down. void focus(); diff --git a/trikGui/commandsListWidget.cpp b/trikGui/commandsListWidget.cpp index d55c7bde7..5d61bbac2 100644 --- a/trikGui/commandsListWidget.cpp +++ b/trikGui/commandsListWidget.cpp @@ -95,7 +95,7 @@ void CommandsListWidget::keyPressEvent(QKeyEvent *event) case 3: { const QString title(tr("Choose waiting time (ms):")); CommandSettingsWidget commandSettingsWidget(title, 5); - emit newWidget(commandSettingsWidget); + Q_EMIT newWidget(&commandSettingsWidget); commandSettingsWidget.exec(); const int value = commandSettingsWidget.value(); @@ -168,7 +168,7 @@ void CommandsListWidget::motorBehaviour() { const QString title(tr("Choose motors power (%): ")); CommandSettingsWidget commandSettingsWidget(title, 2); - emit newWidget(commandSettingsWidget); + Q_EMIT newWidget(&commandSettingsWidget); commandSettingsWidget.exec(); mValue = mCommands.currentItem()->text(); @@ -187,7 +187,7 @@ void CommandsListWidget::motorBehaviour() void CommandsListWidget::sensorBehaviour(const QString &port, bool isEncoder) { SensorSettingsWidget sensorSettingsWidget(port, isEncoder); - emit newWidget(sensorSettingsWidget); + Q_EMIT newWidget(&sensorSettingsWidget); sensorSettingsWidget.exec(); mValue = mCommands.currentItem()->text(); diff --git a/trikGui/commandsListWidget.h b/trikGui/commandsListWidget.h index fb13aee5b..41a99ccfb 100644 --- a/trikGui/commandsListWidget.h +++ b/trikGui/commandsListWidget.h @@ -61,7 +61,7 @@ class CommandsListWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Defines behaviour for commands "Motor Forward" and "Motor Backward". void motorBehaviour(); diff --git a/trikGui/communicationSettingsWidget.h b/trikGui/communicationSettingsWidget.h index e8b9b1e7c..72cc9b04d 100644 --- a/trikGui/communicationSettingsWidget.h +++ b/trikGui/communicationSettingsWidget.h @@ -48,13 +48,13 @@ class CommunicationSettingsWidget : public TrikGuiDialog /// String that shall appear in menu for this widget. static QString menuEntry(); -public slots: +public Q_SLOTS: void renewFocus() override; protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Called when 'Connect' button is pressed, initiates connection to leader robot. void onConnectButtonClicked(); diff --git a/trikGui/connectButton.cpp b/trikGui/connectButton.cpp index abc91cfca..259dafaff 100644 --- a/trikGui/connectButton.cpp +++ b/trikGui/connectButton.cpp @@ -23,11 +23,11 @@ void ConnectButton::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case Qt::Key_Up: { - emit upPressed(); + Q_EMIT upPressed(); return; } case Qt::Key_Down: { - emit downPressed(); + Q_EMIT downPressed(); return; } default: { diff --git a/trikGui/connectButton.h b/trikGui/connectButton.h index d66f0e890..1f224f042 100644 --- a/trikGui/connectButton.h +++ b/trikGui/connectButton.h @@ -29,7 +29,7 @@ class ConnectButton : public QPushButton { Q_OBJECT -signals: +Q_SIGNALS: /// Since key presses for Up and Down buttons are not propagated properly to parent widget on robot, we need to /// emulate them by signals. void upPressed(); diff --git a/trikGui/controller.cpp b/trikGui/controller.cpp index 22fb06b96..0dfabbb86 100644 --- a/trikGui/controller.cpp +++ b/trikGui/controller.cpp @@ -130,7 +130,7 @@ void Controller::runScript(const QString &script) void Controller::abortExecution() { - emit hideScriptWidgets(); + Q_EMIT hideScriptWidgets(); mScriptRunner->abort(); // Now script engine will stop (after some time maybe) and send "completed" signal, which will be caught and @@ -168,16 +168,16 @@ bool Controller::gamepadConnectionStatus() const void Controller::updateCommunicatorStatus() { - emit communicatorStatusChanged(communicatorConnectionStatus()); + Q_EMIT communicatorStatusChanged(communicatorConnectionStatus()); } void Controller::scriptExecutionCompleted(const QString &error, int scriptId) { if (error.isEmpty()) { - emit hideRunningWidget(scriptId); + Q_EMIT hideRunningWidget(scriptId); } else { mCommunicator->sendMessage("error: " + error); - emit showError(error, scriptId); + Q_EMIT showError(error, scriptId); } mBrick->reset(); @@ -191,7 +191,7 @@ void Controller::scriptExecutionCompleted(const QString &error, int scriptId) void Controller::scriptExecutionFromFileStarted(const QString &fileName, int scriptId) { - emit showRunningWidget(fileName, scriptId); + Q_EMIT showRunningWidget(fileName, scriptId); } void Controller::directScriptExecutionStarted(int scriptId) diff --git a/trikGui/controller.h b/trikGui/controller.h index 6e7e668aa..6b0a7da3a 100644 --- a/trikGui/controller.h +++ b/trikGui/controller.h @@ -69,11 +69,11 @@ class Controller : public QObject /// Returns gamepad connection status. bool gamepadConnectionStatus() const; -public slots: +public Q_SLOTS: /// Cancels execution of current program. void abortExecution(); -signals: +Q_SIGNALS: /// Emitted when a new script starts and therefore a running widget must be shown with the script's name. void showRunningWidget(const QString &fileName, int scriptId); @@ -112,7 +112,7 @@ public slots: /// Emitted when Mailbox server's status changes. void mailboxStatusChanged(bool connected); -private slots: +private Q_SLOTS: void scriptExecutionCompleted(const QString &error, int scriptId); void scriptExecutionFromFileStarted(const QString &fileName, int scriptId); diff --git a/trikGui/digitSelector.cpp b/trikGui/digitSelector.cpp index 3592da234..246b033cb 100644 --- a/trikGui/digitSelector.cpp +++ b/trikGui/digitSelector.cpp @@ -35,26 +35,26 @@ void DigitSelector::keyPressEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Up: { if (!mEditingMode) { - emit upPressed(); + Q_EMIT upPressed(); return; } int digit = text().toInt(); digit = (digit + 1) % 10; setText(QString::number(digit)); - emit valueChanged(digit); + Q_EMIT valueChanged(digit); return; } case Qt::Key_Down: { if (!mEditingMode) { - emit downPressed(); + Q_EMIT downPressed(); return; } int digit = text().toInt(); digit = (digit - 1 + 10) % 10; setText(QString::number(digit)); - emit valueChanged(digit); + Q_EMIT valueChanged(digit); return; } default: { diff --git a/trikGui/digitSelector.h b/trikGui/digitSelector.h index 81071aa81..67869c350 100644 --- a/trikGui/digitSelector.h +++ b/trikGui/digitSelector.h @@ -37,7 +37,7 @@ class DigitSelector : public QLineEdit /// @param height - height of a digit. DigitSelector(bool &editingMode, int height); -signals: +Q_SIGNALS: /// Digit is changed by user. void valueChanged(int newValue); diff --git a/trikGui/encoderIndicator.h b/trikGui/encoderIndicator.h index 965f52987..5f1334390 100644 --- a/trikGui/encoderIndicator.h +++ b/trikGui/encoderIndicator.h @@ -46,7 +46,7 @@ class EncoderIndicator : public AbstractIndicator /// @param parent - parent of this widget in Qt widget parent-child system. EncoderIndicator(const QString &port, trikControl::EncoderInterface &encoder, QWidget *parent = 0); -public slots: +public Q_SLOTS: void renew() override; private: diff --git a/trikGui/fileManagerWidget.h b/trikGui/fileManagerWidget.h index d99a9cbe2..eb3987f18 100644 --- a/trikGui/fileManagerWidget.h +++ b/trikGui/fileManagerWidget.h @@ -69,7 +69,7 @@ class FileManagerWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: void onDirectoryLoaded(const QString &path); void renewCurrentIndex(); void onSelectionChanged(QModelIndex current, QModelIndex previous); diff --git a/trikGui/gamepadIndicator.cpp b/trikGui/gamepadIndicator.cpp index 0d9b25bb3..b61afe552 100644 --- a/trikGui/gamepadIndicator.cpp +++ b/trikGui/gamepadIndicator.cpp @@ -22,8 +22,8 @@ GamepadIndicator::GamepadIndicator(Controller &controller, QWidget *parent) : QLabel(parent) , mController(controller) { - connect(&mController, SIGNAL(gamepadDisconnected()), this, SLOT(setOff())); - connect(&mController, SIGNAL(gamepadConnected()), this, SLOT(setOn())); + connect(&mController, &Controller::gamepadDisconnected, this, &GamepadIndicator::setOff); + connect(&mController, &Controller::gamepadConnected, this, &GamepadIndicator::setOn); } void GamepadIndicator::setOn() diff --git a/trikGui/gamepadIndicator.h b/trikGui/gamepadIndicator.h index eba7c4305..24a2d3e76 100644 --- a/trikGui/gamepadIndicator.h +++ b/trikGui/gamepadIndicator.h @@ -29,7 +29,7 @@ class GamepadIndicator : public QLabel /// @param controller is used to get the current gamepad info explicit GamepadIndicator(Controller &controller, QWidget *parent = 0); -public slots: +public Q_SLOTS: /// Updates the status to 'connect'. void setOn(); diff --git a/trikGui/gyroscopeIndicator.h b/trikGui/gyroscopeIndicator.h index ec1211a13..c9c9bd018 100644 --- a/trikGui/gyroscopeIndicator.h +++ b/trikGui/gyroscopeIndicator.h @@ -37,7 +37,7 @@ class GyroscopeIndicator : public AbstractIndicator /// @param parent - parent of this widget in Qt widget parent-child system. explicit GyroscopeIndicator(trikControl::GyroSensorInterface *gyroscope, QWidget *parent = 0); -public slots: +public Q_SLOTS: void renew() override; private: diff --git a/trikGui/informationWidget.h b/trikGui/informationWidget.h index c0df58b4c..01177c971 100644 --- a/trikGui/informationWidget.h +++ b/trikGui/informationWidget.h @@ -36,7 +36,7 @@ class InformationWidget : public TrikGuiDialog /// String that shall appear in menu for this widget. static QString menuEntry(); -public slots: +public Q_SLOTS: void renewFocus() override {} private: diff --git a/trikGui/lazyMainWidget.h b/trikGui/lazyMainWidget.h index a905a9cdd..99e6fbd79 100644 --- a/trikGui/lazyMainWidget.h +++ b/trikGui/lazyMainWidget.h @@ -37,9 +37,9 @@ class LazyMainWidget : public MainWidget /// @param parent - parent of that widget in terms of Qt parent/child widget relations. LazyMainWidget(QWidget *parent = 0) : MainWidget (parent) {} -signals: +Q_SIGNALS: /// Emitted when the widget wants it to be shown. - void showMe(trikGui::MainWidget &widget); + void showMe(trikGui::MainWidget *widget); /// Emitted when the widget wants it to be hidden. void hideMe(); diff --git a/trikGui/lazyMainWidgetWrapper.cpp b/trikGui/lazyMainWidgetWrapper.cpp index dc076f63a..c305aa4fe 100644 --- a/trikGui/lazyMainWidgetWrapper.cpp +++ b/trikGui/lazyMainWidgetWrapper.cpp @@ -21,8 +21,8 @@ using namespace trikGui; LazyMainWidgetWrapper::LazyMainWidgetWrapper(trikControl::DisplayWidgetInterface *wrappedWidget, QWidget *parent) : LazyMainWidget(parent), mWrappedWidget(wrappedWidget), mLayout(new QHBoxLayout(this)) { - connect(wrappedWidget, SIGNAL(shown()), this, SLOT(emitShowMe())); - connect(wrappedWidget, SIGNAL(hidden()), this, SIGNAL(hideMe())); + connect(wrappedWidget, &trikControl::DisplayWidgetInterface::shown, this, &LazyMainWidgetWrapper::emitShowMe); + connect(wrappedWidget, &trikControl::DisplayWidgetInterface::hidden, this, &LazyMainWidget::hideMe); mLayout->addWidget(mWrappedWidget); } @@ -40,5 +40,5 @@ LazyMainWidgetWrapper::~LazyMainWidgetWrapper() void LazyMainWidgetWrapper::emitShowMe() { - emit showMe(*this); + Q_EMIT showMe(this); } diff --git a/trikGui/lazyMainWidgetWrapper.h b/trikGui/lazyMainWidgetWrapper.h index d7ca5c55f..657ef17f9 100644 --- a/trikGui/lazyMainWidgetWrapper.h +++ b/trikGui/lazyMainWidgetWrapper.h @@ -42,7 +42,7 @@ class LazyMainWidgetWrapper : public LazyMainWidget ~LazyMainWidgetWrapper() override; void renewFocus() override; -private slots: +private Q_SLOTS: /// Helper slot to re-emit a signal with correct parameter (life without Qt5 is pain). void emitShowMe(); diff --git a/trikGui/mainWidget.h b/trikGui/mainWidget.h index 715b1e153..a2d9d03eb 100644 --- a/trikGui/mainWidget.h +++ b/trikGui/mainWidget.h @@ -42,8 +42,8 @@ class MainWidget : public QWidget /// Set focus properly on this widget or one of its children. virtual void renewFocus() = 0; -signals: +Q_SIGNALS: /// Emitted when the widget created a new one and wants it to be shown. - void newWidget(trikGui::MainWidget &widget); + void newWidget(trikGui::MainWidget *widget); }; } diff --git a/trikGui/motorsWidget.cpp b/trikGui/motorsWidget.cpp index e1926ff3c..d369d5fbb 100644 --- a/trikGui/motorsWidget.cpp +++ b/trikGui/motorsWidget.cpp @@ -65,7 +65,7 @@ MotorsWidget::MotorsWidget(trikControl::BrickInterface &brick this->setLayout(outerLayout); mScrollArea->setWidget(leversWidget); - QTimer::singleShot(0, this, SLOT(fixLeversPosition())); + QTimer::singleShot(0, this, &MotorsWidget::fixLeversPosition); } MotorsWidget::~MotorsWidget() diff --git a/trikGui/motorsWidget.h b/trikGui/motorsWidget.h index 9cd35a32c..bb34621d2 100644 --- a/trikGui/motorsWidget.h +++ b/trikGui/motorsWidget.h @@ -68,7 +68,7 @@ class MotorsWidget : public TrikGuiDialog private: void ensureFocusedWidgetVisible(); -private slots: +private Q_SLOTS: /// Hack to work around odd QScrollArea behavior which incorrectly positions inner widget when there is no need for /// vertical scrollbar. void fixLeversPosition(); diff --git a/trikGui/networkWidget.h b/trikGui/networkWidget.h index c39ba4052..bf1f8d915 100644 --- a/trikGui/networkWidget.h +++ b/trikGui/networkWidget.h @@ -29,7 +29,7 @@ class NetworkWidget : public QWidget /// Constructor explicit NetworkWidget(QWidget *parent = 0); -private slots: +private Q_SLOTS: void updateIP(); void updateHostname(); void updateHullNumber(); diff --git a/trikGui/numberSelectionWidget.cpp b/trikGui/numberSelectionWidget.cpp index bcec01c06..05ca7a96c 100644 --- a/trikGui/numberSelectionWidget.cpp +++ b/trikGui/numberSelectionWidget.cpp @@ -130,6 +130,7 @@ void NumberSelectionWidget::focusInEvent(QFocusEvent *event) QList NumberSelectionWidget::lineEdits() const { QList result; + result.reserve(mLayout.count()); for (int i = 0; i < mLayout.count(); ++i) { const auto digitSelector = dynamic_cast(mLayout.itemAt(i)->widget()); if (digitSelector) { @@ -142,5 +143,5 @@ QList NumberSelectionWidget::lineEdits() const void NumberSelectionWidget::onValueChanged() { - emit valueChanged(value()); + Q_EMIT valueChanged(value()); } diff --git a/trikGui/numberSelectionWidget.h b/trikGui/numberSelectionWidget.h index 6b79dda3e..11d75bd02 100644 --- a/trikGui/numberSelectionWidget.h +++ b/trikGui/numberSelectionWidget.h @@ -52,7 +52,7 @@ class NumberSelectionWidget : public QWidget /// True, if widget or one of its children has keyboard input focus. bool hasFocusInside(); -signals: +Q_SIGNALS: /// Emitted when number is changed by user. void valueChanged(int newValue); @@ -68,7 +68,7 @@ class NumberSelectionWidget : public QWidget void keyPressEvent(QKeyEvent *event) override; void focusInEvent(QFocusEvent *event) override; -private slots: +private Q_SLOTS: void onValueChanged(); private: diff --git a/trikGui/openSocketIndicator.h b/trikGui/openSocketIndicator.h index bae4207c9..a63120da7 100644 --- a/trikGui/openSocketIndicator.h +++ b/trikGui/openSocketIndicator.h @@ -33,7 +33,7 @@ class OpenSocketIndicator : public QLabel /// @param status - initial connection status OpenSocketIndicator(const QString &openFilePic, bool status, QWidget *parent = 0); -public slots: +public Q_SLOTS: /// Changes status of indicator to a given value. void changeStatus(bool status); diff --git a/trikGui/programmingWidget.cpp b/trikGui/programmingWidget.cpp index 560e909c1..f9267cdd9 100644 --- a/trikGui/programmingWidget.cpp +++ b/trikGui/programmingWidget.cpp @@ -110,7 +110,7 @@ void ProgrammingWidget::addCommand() { const QString text(mCommands.currentItem()->text()); CommandsListWidget commandsListWidget(mController, text); - emit newWidget(commandsListWidget); + Q_EMIT newWidget(&commandsListWidget); commandsListWidget.exec(); const QString value(commandsListWidget.value()); diff --git a/trikGui/programmingWidget.h b/trikGui/programmingWidget.h index c122b8f3e..038e35e47 100644 --- a/trikGui/programmingWidget.h +++ b/trikGui/programmingWidget.h @@ -60,7 +60,7 @@ class ProgrammingWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Adds command to the execution list. void addCommand(); diff --git a/trikGui/pwmCaptureIndicator.h b/trikGui/pwmCaptureIndicator.h index d49a4f27f..207956e4e 100644 --- a/trikGui/pwmCaptureIndicator.h +++ b/trikGui/pwmCaptureIndicator.h @@ -39,7 +39,7 @@ class PwmCaptureIndicator : public AbstractIndicator /// @param parent - parent of this widget in Qt widget parent-child system. PwmCaptureIndicator(const QString &port, trikControl::PwmCaptureInterface &pwmCapture, QWidget *parent = nullptr); -public slots: +public Q_SLOTS: void renew() override; private: diff --git a/trikGui/runningWidget.h b/trikGui/runningWidget.h index c15ddc119..f90ebf79e 100644 --- a/trikGui/runningWidget.h +++ b/trikGui/runningWidget.h @@ -57,7 +57,7 @@ class RunningWidget : public MainWidget void renewFocus() override; -signals: +Q_SIGNALS: /// Emitted when running widget wants to hide itself. void hideMe(int scriptId); diff --git a/trikGui/sensorIndicator.h b/trikGui/sensorIndicator.h index 6de6dea6a..72517ae03 100644 --- a/trikGui/sensorIndicator.h +++ b/trikGui/sensorIndicator.h @@ -39,7 +39,7 @@ class SensorIndicator : public AbstractIndicator /// @param parent - parent of this widget in Qt widget parent-child system. SensorIndicator(const QString &port, trikControl::SensorInterface &sensor, QWidget *parent = nullptr); -public slots: +public Q_SLOTS: void renew() override; private: diff --git a/trikGui/sensorLever.h b/trikGui/sensorLever.h index 8c911fb19..14cb6d396 100644 --- a/trikGui/sensorLever.h +++ b/trikGui/sensorLever.h @@ -47,7 +47,7 @@ class SensorLever : public QWidget void paintEvent(QPaintEvent *) override; -private slots: +private Q_SLOTS: /// Sets the distance which is necessary to trigger sensor. /// @param distance - required distance. void setDistance(int distance); diff --git a/trikGui/sensorSettingsWidget.cpp b/trikGui/sensorSettingsWidget.cpp index b39c8c35a..e95f25491 100644 --- a/trikGui/sensorSettingsWidget.cpp +++ b/trikGui/sensorSettingsWidget.cpp @@ -49,8 +49,8 @@ SensorSettingsWidget::SensorSettingsWidget(const QString &port, bool isEncoder, mContinueButton->setAutoFillBackground(true); mLayout.addWidget(mContinueButton.data()); - connect(mContinueButton.data(), SIGNAL(upPressed()), this, SLOT(focus())); - connect(mContinueButton.data(), SIGNAL(downPressed()), this, SLOT(focus())); + connect(mContinueButton.data(), &ConnectButton::upPressed, this, &SensorSettingsWidget::focus); + connect(mContinueButton.data(), &ConnectButton::downPressed, this, &SensorSettingsWidget::focus); setLayout(&mLayout); } @@ -109,5 +109,5 @@ QString SensorSettingsWidget::createScript() } return QString(" while (!(brick.%1(%2).read() %3 %4)) {\n" - " script.wait(10);\n }\n").arg(name).arg(mPort).arg(sign).arg(mLever->distance()); + " script.wait(10);\n }\n").arg(name, mPort, sign, QString::number(mLever->distance())); } diff --git a/trikGui/sensorSettingsWidget.h b/trikGui/sensorSettingsWidget.h index 3dfecb7e0..b2e3f85a4 100644 --- a/trikGui/sensorSettingsWidget.h +++ b/trikGui/sensorSettingsWidget.h @@ -64,7 +64,7 @@ class SensorSettingsWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Called by child widgets when they need to move input focus up or down. void focus(); diff --git a/trikGui/startWidget.cpp b/trikGui/startWidget.cpp index 08d31ed5e..0e1a7aac4 100644 --- a/trikGui/startWidget.cpp +++ b/trikGui/startWidget.cpp @@ -131,89 +131,89 @@ void StartWidget::launch() if (currentItemText == FileManagerWidget::menuEntry()) { /// @todo Why widgets are created every time? FileManagerWidget fileManagerWidget(mController, mFileManagerRoot); - emit newWidget(fileManagerWidget); + Q_EMIT newWidget(&fileManagerWidget); result = fileManagerWidget.exec(); } else if (currentItemText == WiFiModeWidget::menuEntry()) { WiFiModeWidget wiFiModeWidget(mController.wiFi()); - emit newWidget(wiFiModeWidget); + Q_EMIT newWidget(&wiFiModeWidget); result = wiFiModeWidget.exec(); } else if (currentItemText == ProgrammingWidget::menuEntry()) { ProgrammingWidget programmingWidget(mController); - emit newWidget(programmingWidget); + Q_EMIT newWidget(&programmingWidget); result = programmingWidget.exec(); } else if (currentItemText == MotorsWidget::menuEntry(MotorInterface::Type::powerMotor)) { MotorsWidget motorsWidget(mController.brick(), MotorInterface::Type::powerMotor); - emit newWidget(motorsWidget); + Q_EMIT newWidget(&motorsWidget); result = motorsWidget.exec(); } else if (currentItemText == MotorsWidget::menuEntry(MotorInterface::Type::servoMotor)) { MotorsWidget motorsWidget(mController.brick(), MotorInterface::Type::servoMotor); - emit newWidget(motorsWidget); + Q_EMIT newWidget(&motorsWidget); result = motorsWidget.exec(); } else if (currentItemText == tr("Analog sensors")) { ports = (mController.brick()).sensorPorts(trikControl::SensorInterface::Type::analogSensor); ports.sort(); SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::analogOrDigitalSensor); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("PWM Capture")) { ports = (mController.brick()).pwmCapturePorts(); ports.sort(); SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::pwmCapture); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("Digital sensors")) { ports = (mController.brick()).sensorPorts(trikControl::SensorInterface::Type::digitalSensor); ports.sort(); SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::analogOrDigitalSensor); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("Encoders")) { ports = (mController.brick()).encoderPorts(); ports.sort(); SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::encoder); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("Gyroscope")) { SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::gyroscope); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("Accelerometer")) { SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::accelerometer); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == tr("Camera")) { SensorsWidget sensorsWidget(mController.brick(), ports, SensorsWidget::SensorType::camera); - emit newWidget(sensorsWidget); + Q_EMIT newWidget(&sensorsWidget); result = sensorsWidget.exec(); } else if (currentItemText == CommunicationSettingsWidget::menuEntry()) { if (mController.mailbox()) { CommunicationSettingsWidget communicationSettingsWidget(*mController.mailbox()); - emit newWidget(communicationSettingsWidget); + Q_EMIT newWidget(&communicationSettingsWidget); result = communicationSettingsWidget.exec(); } else { Q_ASSERT(!"Mailbox is disabled but commmunications widget still tries to be shown"); } } else if (currentItemText == InformationWidget::menuEntry()) { InformationWidget versionWidget; - emit newWidget(versionWidget); + Q_EMIT newWidget(&versionWidget); result = versionWidget.exec(); } else if (currentItemText == SystemSettingsWidget::menuEntry()) { SystemSettingsWidget systemSettingsWidget(mFileManagerRoot); connect(&systemSettingsWidget, &SystemSettingsWidget::currentFilesDirPath , this, &StartWidget::changeFileManagerRoot); - emit newWidget(systemSettingsWidget); + Q_EMIT newWidget(&systemSettingsWidget); result = systemSettingsWidget.exec(); } else if (currentItemText == LanguageSelectionWidget::menuEntry()) { LanguageSelectionWidget languageSelectionWidget; - emit newWidget(languageSelectionWidget); + Q_EMIT newWidget(&languageSelectionWidget); result = languageSelectionWidget.exec(); } diff --git a/trikGui/startWidget.h b/trikGui/startWidget.h index 2701d03db..56df9f1d8 100644 --- a/trikGui/startWidget.h +++ b/trikGui/startWidget.h @@ -61,7 +61,7 @@ class StartWidget : public MainWidget void renewFocus() override; -private slots: +private Q_SLOTS: /// Change current FilesManegerRoot void changeFileManagerRoot(MainWidget::FileManagerRootType const& path); diff --git a/trikGui/systemSettingsWidget.cpp b/trikGui/systemSettingsWidget.cpp index b2d931fa0..c607b3513 100644 --- a/trikGui/systemSettingsWidget.cpp +++ b/trikGui/systemSettingsWidget.cpp @@ -117,8 +117,8 @@ void SystemSettingsWidget::emitCheckedDirPath() { QRadioButton const* const current = qobject_cast(mButtonGroup.checkedButton()); if (current == mOnlyScriptsButton) { - emit currentFilesDirPath(MainWidget::FileManagerRootType::scriptsDir); + Q_EMIT currentFilesDirPath(MainWidget::FileManagerRootType::scriptsDir); } else { - emit currentFilesDirPath(MainWidget::FileManagerRootType::allFS); + Q_EMIT currentFilesDirPath(MainWidget::FileManagerRootType::allFS); } } diff --git a/trikGui/systemSettingsWidget.h b/trikGui/systemSettingsWidget.h index bc2cc48a4..3c1ac0c99 100644 --- a/trikGui/systemSettingsWidget.h +++ b/trikGui/systemSettingsWidget.h @@ -49,10 +49,10 @@ class SystemSettingsWidget : public TrikGuiDialog /// String that shall appear in menu for this widget. static QString menuEntry(); -public slots: +public Q_SLOTS: void renewFocus() override; -signals: +Q_SIGNALS: /// Emitted when we want to save current FilesManagerRoot void currentFilesDirPath(MainWidget::FileManagerRootType const& path); diff --git a/trikGui/trikGuiApplication.h b/trikGui/trikGuiApplication.h index 1da9d2e6d..391c2f65a 100644 --- a/trikGui/trikGuiApplication.h +++ b/trikGui/trikGuiApplication.h @@ -35,7 +35,7 @@ class TrikGuiApplication : public QApplication bool notify(QObject *receiver, QEvent *event) override; -private slots: +private Q_SLOTS: /// Temporary measure for some demo models which do not use QWS to draw their graphics, so we need to update /// all GUI to remove clutter on a screen. void refreshWidgets(); diff --git a/trikGui/updateWidget.h b/trikGui/updateWidget.h index 2addea350..37200fa96 100644 --- a/trikGui/updateWidget.h +++ b/trikGui/updateWidget.h @@ -48,7 +48,7 @@ class UpdateWidget : public TrikGuiDialog int exec() override; -public slots: +public Q_SLOTS: void renewFocus() override; private: diff --git a/trikGui/wiFiClientWidget.h b/trikGui/wiFiClientWidget.h index 603376cf9..a8ce5f20e 100644 --- a/trikGui/wiFiClientWidget.h +++ b/trikGui/wiFiClientWidget.h @@ -85,7 +85,7 @@ class WiFiClientWidget : public TrikGuiDialog protected: void keyPressEvent(QKeyEvent *event) override; -private slots: +private Q_SLOTS: /// Called when information about networks in range is changed in WiFi controller. void onNetworksInfoUpdated(); diff --git a/trikGui/wiFiIndicator.h b/trikGui/wiFiIndicator.h index 4502cee8c..8bc7b9987 100644 --- a/trikGui/wiFiIndicator.h +++ b/trikGui/wiFiIndicator.h @@ -29,7 +29,7 @@ class WiFiIndicator : public QLabel /// @param controller is used to get the current network info explicit WiFiIndicator(Controller &controller, QWidget *parent = 0); -private slots: +private Q_SLOTS: /// Updates the status to 'connected'. void setOn(); diff --git a/trikGui/wiFiInitWidget.cpp b/trikGui/wiFiInitWidget.cpp index 1b0bfc0fc..dba5b862c 100644 --- a/trikGui/wiFiInitWidget.cpp +++ b/trikGui/wiFiInitWidget.cpp @@ -121,7 +121,7 @@ void WiFiInitWidget::onProcessFinished(int, QProcess::ExitStatus exitStatus) } case QProcess::CrashExit: { TrikGuiMessageBox messageBox; - emit newWidget(messageBox); + Q_EMIT newWidget(&messageBox); messageBox.exec(tr("Network initialization" "\n" "failed")); diff --git a/trikGui/wiFiInitWidget.h b/trikGui/wiFiInitWidget.h index 906e55b98..16143ba7d 100644 --- a/trikGui/wiFiInitWidget.h +++ b/trikGui/wiFiInitWidget.h @@ -69,7 +69,7 @@ class WiFiInitWidget : public MainWidget QLabel mBreakMessage; QProcess mProcess; -private slots: +private Q_SLOTS: void onProcessFinished(int, QProcess::ExitStatus exitStatus); void onProcessError(QProcess::ProcessError error); }; diff --git a/trikGui/wiFiModeWidget.cpp b/trikGui/wiFiModeWidget.cpp index 8ff43c3b6..9fa9f813d 100644 --- a/trikGui/wiFiModeWidget.cpp +++ b/trikGui/wiFiModeWidget.cpp @@ -87,7 +87,7 @@ void WiFiModeWidget::setMode(Mode mode) if (currentMode != mode) { WiFiInitWidget wiFiInitWidget; - emit newWidget(wiFiInitWidget); + Q_EMIT newWidget(&wiFiInitWidget); if (wiFiInitWidget.init(mode) == WiFiInitWidget::Result::fail) { QLOG_ERROR() << "Failed to init WiFi widget in mode" << currentModeText; return; @@ -102,14 +102,14 @@ void WiFiModeWidget::setMode(Mode mode) mWiFi.reinit(); } WiFiClientWidget wiFiClientWidget(mWiFi); - emit newWidget(wiFiClientWidget); + Q_EMIT newWidget(&wiFiClientWidget); returnValue = wiFiClientWidget.exec(); break; } case Mode::accessPoint: { mWiFi.dispose(); WiFiAPWidget wiFiAPWidget; - emit newWidget(wiFiAPWidget); + Q_EMIT newWidget(&wiFiAPWidget); returnValue = wiFiAPWidget.exec(); break; } diff --git a/trikHal/include/trikHal/IIOFileInterface.h b/trikHal/include/trikHal/IIOFileInterface.h index 11bf49423..bc5aa215a 100644 --- a/trikHal/include/trikHal/IIOFileInterface.h +++ b/trikHal/include/trikHal/IIOFileInterface.h @@ -47,7 +47,7 @@ class TRIKHAL_EXPORT IIOFileInterface : public QObject /// Returns true if a file is opened. virtual bool isOpened() const = 0; -signals: +Q_SIGNALS: void newData(QVector, const trikKernel::TimeVal &eventTime); }; } diff --git a/trikHal/include/trikHal/eventFileInterface.h b/trikHal/include/trikHal/eventFileInterface.h index 0867834f0..b205294eb 100644 --- a/trikHal/include/trikHal/eventFileInterface.h +++ b/trikHal/include/trikHal/eventFileInterface.h @@ -42,7 +42,7 @@ class TRIKHAL_EXPORT EventFileInterface : public QObject /// Returns true if a file is opened. virtual bool isOpened() const = 0; -signals: +Q_SIGNALS: /// Emitted when there is new event in an event file. /// @param eventType - low-level type of an event. /// @param code - low-level event code. diff --git a/trikHal/include/trikHal/fifoInterface.h b/trikHal/include/trikHal/fifoInterface.h index ea494b478..046e2a928 100644 --- a/trikHal/include/trikHal/fifoInterface.h +++ b/trikHal/include/trikHal/fifoInterface.h @@ -37,7 +37,7 @@ class TRIKHAL_EXPORT FifoInterface : public QObject /// Returns file name of a FIFO file. virtual QString fileName() = 0; -signals: +Q_SIGNALS: /// Emitted when new data is read from FIFO. void newData(QVector data); /// Emitted for each line from FIFO. diff --git a/trikHal/src/trik/trikEventFile.cpp b/trikHal/src/trik/trikEventFile.cpp index 87976572d..c1562b594 100644 --- a/trikHal/src/trik/trikEventFile.cpp +++ b/trikHal/src/trik/trikEventFile.cpp @@ -118,7 +118,7 @@ void TrikEventFile::readFile() == static_cast(sizeof(event))) { trikKernel::TimeVal eventTime(event.time.tv_sec, event.time.tv_usec); - emit newEvent(event.type, event.code, event.value, eventTime); + Q_EMIT newEvent(event.type, event.code, event.value, eventTime); } if (0 <= size && size < static_cast(sizeof(event))) { diff --git a/trikHal/src/trik/trikEventFile.h b/trikHal/src/trik/trikEventFile.h index d46727a09..1933bc963 100644 --- a/trikHal/src/trik/trikEventFile.h +++ b/trikHal/src/trik/trikEventFile.h @@ -42,7 +42,7 @@ class TrikEventFile : public EventFileInterface QString fileName() const override; bool isOpened() const override; -private slots: +private Q_SLOTS: /// Tries to open event file and if opened successfully stops waiting event loop. void tryOpenEventFile(); diff --git a/trikHal/src/trik/trikFifo.cpp b/trikHal/src/trik/trikFifo.cpp index c7a2aa2c2..a8185df6d 100644 --- a/trikHal/src/trik/trikFifo.cpp +++ b/trikHal/src/trik/trikFifo.cpp @@ -94,13 +94,13 @@ void TrikFifo::readFile() if (bytesRead < 0) { if (errno != EAGAIN) { QLOG_ERROR() << "FIFO read failed: " << strerror(errno) << "in" << mFileName; - emit readError(); + Q_EMIT readError(); } mSocketNotifier->setEnabled(true); return; } bytes.resize(bytesRead); - emit newData(bytes); + Q_EMIT newData(bytes); mBuffer += QByteArray(reinterpret_cast(bytes.data()), bytes.size()); if (mBuffer.contains("\n")) { QStringList lines = mBuffer.split('\n', QString::KeepEmptyParts); @@ -109,7 +109,7 @@ void TrikFifo::readFile() lines.removeLast(); for (auto &&line : lines) { - emit newLine(line); + Q_EMIT newLine(line); } } diff --git a/trikHal/src/trik/trikFifo.h b/trikHal/src/trik/trikFifo.h index 3d7d6c8ee..be9aee3b0 100644 --- a/trikHal/src/trik/trikFifo.h +++ b/trikHal/src/trik/trikFifo.h @@ -39,7 +39,7 @@ class TrikFifo : public FifoInterface bool close() override; QString fileName() override; -private slots: +private Q_SLOTS: /// Called when there is new data on a FIFO. void readFile(); diff --git a/trikHal/src/trik/trikIIOFile.cpp b/trikHal/src/trik/trikIIOFile.cpp index aba3f73c5..d6862da15 100644 --- a/trikHal/src/trik/trikIIOFile.cpp +++ b/trikHal/src/trik/trikIIOFile.cpp @@ -26,11 +26,12 @@ trikHal::trik::TrikIIOFile::TrikIIOFile(const QString &fileName, const QString & : mFileName(fileName) { if (scanType == "be:s14/16>>2") { - mScanType = ScanType::Accel; + mScanType = ScanType::Accel; } else if (scanType == "le:s16/16>>0") { - mScanType = ScanType::Gyro; + mScanType = ScanType::Gyro; } else { - mScanType = ScanType::Undefined; + mScanType = ScanType::Undefined; + QLOG_ERROR() << "Unknown scan type" << scanType << "for iio device" << mFileName; } } @@ -44,7 +45,7 @@ bool trikHal::trik::TrikIIOFile::open() QLOG_INFO() << "Openning" << mFileName; mIIOFileDescriptor = ::open(mFileName.toStdString().c_str(), O_NONBLOCK | O_RDONLY | O_CLOEXEC); if (mIIOFileDescriptor == -1) { - QLOG_ERROR() << QString("%1: open failed: %2").arg(mFileName).arg(strerror(errno)); + QLOG_ERROR() << QString("%1: open failed: %2").arg(mFileName, strerror(errno)); return false; } @@ -69,7 +70,7 @@ bool trikHal::trik::TrikIIOFile::close() } if (::close(mIIOFileDescriptor) != 0) { - QLOG_ERROR() << QString("%1: close failed: %2").arg(mFileName).arg(strerror(errno)); + QLOG_ERROR() << QString("%1: close failed: %2").arg(mFileName, strerror(errno)); return false; } @@ -93,35 +94,33 @@ void trikHal::trik::TrikIIOFile::readFile() uint8_t buffer[16]; if (::read(mIIOFileDescriptor, &buffer, sizeof(buffer)) == -1) { - QLOG_ERROR() << QString("%1: read failed: %2").arg(mFileName).arg(strerror(errno)); + QLOG_ERROR() << QString("%1: read failed: %2").arg(mFileName, strerror(errno)); } else { uint64_t timestamp; memcpy(×tamp, &buffer[8], sizeof(timestamp)); const uint64_t timestamp_mcsec = timestamp / 1000; trikKernel::TimeVal eventTime(timestamp_mcsec / 1000000, timestamp_mcsec % 1000000); - QVector sensorValues; - if (mScanType == ScanType::Accel) { - sensorValues = { - static_cast((buffer[0] << 8) | buffer[1]) >> 2, - static_cast((buffer[2] << 8) | buffer[3]) >> 2, - static_cast((buffer[4] << 8) | buffer[5]) >> 2, - }; - } else if (mScanType == ScanType::Gyro) { - sensorValues = { - static_cast((buffer[1] << 8) | buffer[0]), - static_cast((buffer[3] << 8) | buffer[2]), - static_cast((buffer[5] << 8) | buffer[4]), - }; - } else { - size_t len = sizeof(buffer) / sizeof(buffer[0]); - for (size_t i = 0; i < len; i++) { - sensorValues.append(static_cast(buffer[i])); - } - QLOG_ERROR() << "Unknown scan type for iio device"; - } - - emit newData(std::move(sensorValues), eventTime); + QVector sensorValues; + if (mScanType == ScanType::Accel) { + sensorValues = { + static_cast((buffer[0] << 8) | buffer[1]) >> 2, + static_cast((buffer[2] << 8) | buffer[3]) >> 2, + static_cast((buffer[4] << 8) | buffer[5]) >> 2, + }; + } else if (mScanType == ScanType::Gyro) { + sensorValues = { + static_cast((buffer[1] << 8) | buffer[0]), + static_cast((buffer[3] << 8) | buffer[2]), + static_cast((buffer[5] << 8) | buffer[4]), + }; + } else { + size_t len = sizeof(buffer) / sizeof(buffer[0]); + sensorValues.resize(len); + std::copy(buffer, buffer + len, sensorValues.begin()); + } + + Q_EMIT newData(std::move(sensorValues), eventTime); } mSocketNotifier->setEnabled(true); diff --git a/trikHal/src/trik/trikIIOFile.h b/trikHal/src/trik/trikIIOFile.h index 6729899aa..c44f27c54 100644 --- a/trikHal/src/trik/trikIIOFile.h +++ b/trikHal/src/trik/trikIIOFile.h @@ -40,7 +40,7 @@ class TrikIIOFile : public IIOFileInterface QString fileName() const override; bool isOpened() const override; -private slots: +private Q_SLOTS: /// Called when there is a new event in a file. void readFile(); diff --git a/trikHal/src/trik/trikV4l2VideoDevice.cpp b/trikHal/src/trik/trikV4l2VideoDevice.cpp index ca5867b32..584c348ae 100644 --- a/trikHal/src/trik/trikV4l2VideoDevice.cpp +++ b/trikHal/src/trik/trikV4l2VideoDevice.cpp @@ -371,7 +371,7 @@ void TrikV4l2VideoDevice::readFrameData(int fd) { QLOG_INFO() << "V4l2 captured 0 bytes, reset internal frame buffer"; decltype(mFrame)().swap(mFrame); } - emit dataReady(); + Q_EMIT dataReady(); } // WARN: Do not enable notifier until we store process data from mFrame variable! } diff --git a/trikHal/src/trik/trikV4l2VideoDevice.h b/trikHal/src/trik/trikV4l2VideoDevice.h index 9ceaf9289..8bf2acd3c 100644 --- a/trikHal/src/trik/trikV4l2VideoDevice.h +++ b/trikHal/src/trik/trikV4l2VideoDevice.h @@ -41,11 +41,11 @@ class TrikV4l2VideoDevice: public QObject /// Get last frame const QVector & getFrame() const { return mFrame; } -signals: +Q_SIGNALS: /// Signal when photo was made void dataReady(); -public slots: +public Q_SLOTS: /// Read data from v4l2 buffers /// @param fd - file descriptor void readFrameData(int fd); diff --git a/trikKernel/include/trikKernel/exceptions/failedToOpenFileException.h b/trikKernel/include/trikKernel/exceptions/failedToOpenFileException.h index b8fdf4ad0..2e9149398 100644 --- a/trikKernel/include/trikKernel/exceptions/failedToOpenFileException.h +++ b/trikKernel/include/trikKernel/exceptions/failedToOpenFileException.h @@ -23,15 +23,16 @@ namespace trikKernel { /// Exception that is thrown when file opening operation failed. -class TRIKKERNEL_EXPORT FailedToOpenFileException : public TrikRuntimeException +class TRIKKERNEL_EXPORT FailedToOpenFileException // clazy:exclude=copyable-polymorphic + : public TrikRuntimeException { public: /// Constructor. /// @param file - file that is failed to open. explicit FailedToOpenFileException(const QFile &file) : TrikRuntimeException(QString("Failed to open %1 %2") - .arg(QFileInfo(file).absoluteFilePath()) - .arg((file.openMode() & QIODevice::WriteOnly ? "for writing" : "for reading"))) + .arg(QFileInfo(file).absoluteFilePath() + , (file.openMode() & QIODevice::WriteOnly ? "for writing" : "for reading"))) , mFile(file) { } diff --git a/trikKernel/include/trikKernel/exceptions/failedToParseXmlException.h b/trikKernel/include/trikKernel/exceptions/failedToParseXmlException.h index 0c757e9cb..46fa58bbc 100644 --- a/trikKernel/include/trikKernel/exceptions/failedToParseXmlException.h +++ b/trikKernel/include/trikKernel/exceptions/failedToParseXmlException.h @@ -24,7 +24,8 @@ namespace trikKernel { /// Exception that is thrown when XML file is corrupt and "setContent" method of QDomDocument has failed. -class TRIKKERNEL_EXPORT FailedToParseXmlException : public TrikRuntimeException +class TRIKKERNEL_EXPORT FailedToParseXmlException // clazy:exclude=copyable-polymorphic + : public TrikRuntimeException { public: /// Constructor. diff --git a/trikKernel/include/trikKernel/exceptions/internalErrorException.h b/trikKernel/include/trikKernel/exceptions/internalErrorException.h index f62c5db6b..57dda9858 100644 --- a/trikKernel/include/trikKernel/exceptions/internalErrorException.h +++ b/trikKernel/include/trikKernel/exceptions/internalErrorException.h @@ -21,7 +21,8 @@ namespace trikKernel { /// Exception that is thrown when something is wrong with implementation of trikRuntime. -class InternalErrorException : public TrikRuntimeException +class InternalErrorException // clazy:exclude=copyable-polymorphic + : public TrikRuntimeException { public: /// Constructor. diff --git a/trikKernel/include/trikKernel/exceptions/malformedConfigException.h b/trikKernel/include/trikKernel/exceptions/malformedConfigException.h index ace599726..f7ece4de1 100644 --- a/trikKernel/include/trikKernel/exceptions/malformedConfigException.h +++ b/trikKernel/include/trikKernel/exceptions/malformedConfigException.h @@ -24,7 +24,8 @@ namespace trikKernel { /// Exception that is thrown when something is wrong with runtime configuration files. -class TRIKKERNEL_EXPORT MalformedConfigException : public TrikRuntimeException +class TRIKKERNEL_EXPORT MalformedConfigException // clazy:exclude=copyable-polymorphic + : public TrikRuntimeException { public: /// Constructor. diff --git a/trikKernel/include/trikKernel/exceptions/trikRuntimeException.h b/trikKernel/include/trikKernel/exceptions/trikRuntimeException.h index 09e1ad167..e117a2dff 100644 --- a/trikKernel/include/trikKernel/exceptions/trikRuntimeException.h +++ b/trikKernel/include/trikKernel/exceptions/trikRuntimeException.h @@ -22,7 +22,7 @@ namespace trikKernel { /// Base class for all exceptions in TRIKRuntime. -class TrikRuntimeException : public std::runtime_error +class TrikRuntimeException : public std::runtime_error // clazy:exclude=copyable-polymorphic { public: /// Constructor diff --git a/trikKernel/src/configurer.cpp b/trikKernel/src/configurer.cpp index 8ddc2d737..b5087adff 100644 --- a/trikKernel/src/configurer.cpp +++ b/trikKernel/src/configurer.cpp @@ -76,13 +76,13 @@ QString Configurer::attributeByDevice(const QString &deviceClass, const QString } throw MalformedConfigException( - QString("Unknown attribute '%1' of device '%2'").arg(attributeName).arg(deviceClass)); + QString("Unknown attribute '%1' of device '%2'").arg(attributeName, deviceClass)); } QString Configurer::getDefaultOrException(QString *defaultValue, const QString &error) const { if (defaultValue){ - return *defaultValue; + return *defaultValue; } throw MalformedConfigException(error); } @@ -119,12 +119,12 @@ QString Configurer::attributeByPort(const QString &port, const QString &attribut if (!device.portSpecificAttributes.contains(port)) { return getDefaultOrException(defaultValue, QString("Device type '%1' is not allowed on port %2.") - .arg(deviceType).arg(port)); + .arg(deviceType, port)); } } else { return getDefaultOrException(defaultValue, QString("Device type '%1' has device class '%2' which is not listed in 'deviceClasses' section.") - .arg(deviceType).arg(deviceClass)); + .arg(deviceType, deviceClass)); } } @@ -142,7 +142,7 @@ QString Configurer::attributeByPort(const QString &port, const QString &attribut } return getDefaultOrException(defaultValue, QString("Unknown attribute '%1' of device '%2' on port '%3'") - .arg(attributeName).arg(deviceType).arg(port)); + .arg(attributeName, deviceType, port)); } bool Configurer::isEnabled(const QString &deviceName) const @@ -166,7 +166,7 @@ QStringList Configurer::ports() const QString Configurer::deviceType(const QString &port) const { if (!mModelConfiguration.contains(port)) { - throw MalformedConfigException(QString("Port '%1' is not configured").arg(port)); + throw MalformedConfigException(QString("Port '%1' is not configured").arg(port)); } const QString &deviceType = mModelConfiguration.value(port).deviceType; @@ -187,8 +187,7 @@ QString Configurer::deviceClass(const QString &port) const if (!mDevices.contains(deviceType)) { throw MalformedConfigException(QString("Port '%1' is configured to use unknown device class '%2'") - .arg(port) - .arg(deviceType)); + .arg(port, deviceType)); } return deviceType; diff --git a/trikKernel/src/deinitializationHelper.cpp b/trikKernel/src/deinitializationHelper.cpp index e543eb3df..e921ca56a 100644 --- a/trikKernel/src/deinitializationHelper.cpp +++ b/trikKernel/src/deinitializationHelper.cpp @@ -23,7 +23,7 @@ DeinitializationHelper::~DeinitializationHelper() { QEventLoop loop; QTimer t; - QObject::connect(&t, SIGNAL(timeout()), &loop, SLOT(quit()), Qt::DirectConnection); + QObject::connect(&t, &QTimer::timeout, &loop, &QEventLoop::quit, Qt::DirectConnection); t.setSingleShot(true); t.start(0); loop.exec(); diff --git a/trikNetwork/include/trikNetwork/connection.h b/trikNetwork/include/trikNetwork/connection.h index d0c5c0e58..ef5ed5b0f 100644 --- a/trikNetwork/include/trikNetwork/connection.h +++ b/trikNetwork/include/trikNetwork/connection.h @@ -94,7 +94,7 @@ class TRIKNETWORK_EXPORT Connection : public QObject /// It is used to get flag for determine the situation when connection->thread() is running, but the connection is invalid bool getIsStarted() const; -signals: +Q_SIGNALS: /// Emitted after connection becomes closed. void disconnected(trikNetwork::Connection *self); @@ -111,7 +111,7 @@ class TRIKNETWORK_EXPORT Connection : public QObject /// @param port - target port. void init(const QHostAddress &ip, int port); -private slots: +private Q_SLOTS: /// New data is ready on a socket. void onReadyRead(); diff --git a/trikNetwork/include/trikNetwork/mailboxInterface.h b/trikNetwork/include/trikNetwork/mailboxInterface.h index fc952a822..723cb1bec 100644 --- a/trikNetwork/include/trikNetwork/mailboxInterface.h +++ b/trikNetwork/include/trikNetwork/mailboxInterface.h @@ -57,7 +57,7 @@ class TRIKNETWORK_EXPORT MailboxInterface : public QObject /// Sets hull number of this robot and connects to robot by IP and port. virtual void joinNetwork(const QString &ip, int port, int hullNumber) = 0; -public slots: +public Q_SLOTS: /// Connects to robot by IP and port. virtual void connect(const QString &ip, int port) = 0; @@ -85,7 +85,7 @@ public slots: /// Returns hull number of this robot. virtual int myHullNumber() const = 0; -signals: +Q_SIGNALS: /// Emitted when new message is received from a robot with given hull number. Note that if receive() and /// handler for newMessage() is used simultaneously, message will be delivered twice --- first for receive(), then /// to handler (or handlers). diff --git a/trikNetwork/include/trikNetwork/trikServer.h b/trikNetwork/include/trikNetwork/trikServer.h index 6f006c321..1ef99b0e2 100644 --- a/trikNetwork/include/trikNetwork/trikServer.h +++ b/trikNetwork/include/trikNetwork/trikServer.h @@ -49,11 +49,11 @@ class TRIKNETWORK_EXPORT TrikServer : public QTcpServer /// Track the status to the main init void preinitConnection(Connection * const connection); -public slots: +public Q_SLOTS: /// Broadcasts message across all opened connections. void sendMessage(const QString &message); -signals: +Q_SIGNALS: /// Emitted when we get the first connection established. void connected(); @@ -78,7 +78,7 @@ public slots: /// by startConnection() call but not finished to open yet, it will not be found. Connection *connection(const QHostAddress &ip) const; -private slots: +private Q_SLOTS: /// Called when connection thread finishes. void onConnectionClosed(trikNetwork::Connection *connection); diff --git a/trikNetwork/src/connection.cpp b/trikNetwork/src/connection.cpp index 3de4fc78b..a90459f2e 100644 --- a/trikNetwork/src/connection.cpp +++ b/trikNetwork/src/connection.cpp @@ -63,7 +63,7 @@ void Connection::init(const QHostAddress &ip, int port) return; } - emit connected(this); + Q_EMIT connected(this); } void Connection::send(const QByteArray &data) @@ -267,7 +267,7 @@ void Connection::doDisconnect() QLOG_INFO() << "Connection" << mSocket->socketDescriptor() << "disconnected."; - emit disconnected(this); + Q_EMIT disconnected(this); } void Connection::restartKeepalive() diff --git a/trikNetwork/src/mailbox.cpp b/trikNetwork/src/mailbox.cpp index 5f3296723..2bc3abd5d 100644 --- a/trikNetwork/src/mailbox.cpp +++ b/trikNetwork/src/mailbox.cpp @@ -111,7 +111,7 @@ void Mailbox::clearQueue() void Mailbox::stopWaiting() { - emit stopWaitingSignal(); + Q_EMIT stopWaitingSignal(); } bool Mailbox::isEnabled() @@ -190,5 +190,5 @@ void Mailbox::updateConnectionStatus() int activeConnections; QMetaObject::invokeMethod(mWorker.data(), [this, &activeConnections](){ activeConnections = mWorker->activeConnections();}, Qt::BlockingQueuedConnection); - emit connectionStatusChanged(activeConnections > 0); + Q_EMIT connectionStatusChanged(activeConnections > 0); } diff --git a/trikNetwork/src/mailbox.h b/trikNetwork/src/mailbox.h index d6dfe250a..ff0087dc3 100644 --- a/trikNetwork/src/mailbox.h +++ b/trikNetwork/src/mailbox.h @@ -63,7 +63,7 @@ class Mailbox : public MailboxInterface Q_INVOKABLE void joinNetwork(const QString &ip, int port = -1, int hullNumber = -1) override; -public slots: +public Q_SLOTS: void connect(const QString &ip, int port) override; void connect(const QString &ip) override; @@ -80,11 +80,11 @@ public slots: void setHullNumber(int myHullNumber) override; -signals: +Q_SIGNALS: /// Used to interrupt waiting for new message. void stopWaitingSignal(); -private slots: +private Q_SLOTS: void updateConnectionStatus(); private: diff --git a/trikNetwork/src/mailboxConnection.cpp b/trikNetwork/src/mailboxConnection.cpp index 6e846166e..c2d700a4a 100644 --- a/trikNetwork/src/mailboxConnection.cpp +++ b/trikNetwork/src/mailboxConnection.cpp @@ -68,7 +68,7 @@ void MailboxConnection::processData(const QByteArray &rawData) if (!serverPortOk || !hullNumberOk) { error(data); } else { - emit newConnection(peerAddress(), peerPort(), serverPort, hullNumber); + Q_EMIT newConnection(peerAddress(), peerPort(), serverPort, hullNumber); } } } else if (data.startsWith(connectionCommand)) { @@ -80,7 +80,7 @@ void MailboxConnection::processData(const QByteArray &rawData) if (!serverPortOk || !hullNumberOk) { error(data); } else { - emit connectionInfo(QHostAddress(parsedString[1]), serverPort, hullNumber); + Q_EMIT connectionInfo(QHostAddress(parsedString[1]), serverPort, hullNumber); } } } else if (data.startsWith(selfCommand)) { @@ -92,12 +92,12 @@ void MailboxConnection::processData(const QByteArray &rawData) if (!hullNumberOk) { error(data); } else { - emit connectionInfo(peerAddress(), peerPort(), hullNumber); + Q_EMIT connectionInfo(peerAddress(), peerPort(), hullNumber); } } } else if (data.startsWith(dataCommand)) { auto parsedString = data; parsedString.remove(0, dataCommand.length()); - emit newData(peerAddress(), peerPort(), parsedString.toUtf8()); + Q_EMIT newData(peerAddress(), peerPort(), parsedString.toUtf8()); } } diff --git a/trikNetwork/src/mailboxConnection.h b/trikNetwork/src/mailboxConnection.h index 9edbcf023..f43a51757 100644 --- a/trikNetwork/src/mailboxConnection.h +++ b/trikNetwork/src/mailboxConnection.h @@ -39,7 +39,7 @@ class MailboxConnection : public Connection /// Send our hull number. Used in response for connection request. Q_INVOKABLE void sendSelfInfo(int hullNumber); -signals: +Q_SIGNALS: /// Emitted when "register" command is received. /// @param ip - remote robot IP. /// @param clientPort - remote robot client port (peer port), for reuse of this new connection. diff --git a/trikNetwork/src/mailboxServer.cpp b/trikNetwork/src/mailboxServer.cpp index 60b155070..451388af0 100644 --- a/trikNetwork/src/mailboxServer.cpp +++ b/trikNetwork/src/mailboxServer.cpp @@ -323,7 +323,7 @@ void MailboxServer::onNewData(const QHostAddress &ip, int port, const QByteArray mMessagesQueue.enqueue(data); mMessagesQueueLock.unlock(); - emit newMessage(senderHullNumber, QString(data)); + Q_EMIT newMessage(senderHullNumber, QString(data)); } bool MailboxServer::hasMessages() diff --git a/trikNetwork/src/mailboxServer.h b/trikNetwork/src/mailboxServer.h index 2c1516379..95f830289 100644 --- a/trikNetwork/src/mailboxServer.h +++ b/trikNetwork/src/mailboxServer.h @@ -88,11 +88,11 @@ class MailboxServer : public TrikServer Q_INVOKABLE void joinNetwork(const QString &ip = "", int port = -1, int hullNumber = -1); -signals: +Q_SIGNALS: /// Emitted when new message was received from a robot with given hull number. void newMessage(int senderHullNumber, const QString &message); -private slots: +private Q_SLOTS: void onNewConnection(const QHostAddress &ip, int connectedPort, int serverPort, int hullNumber); void onConnectionInfo(const QHostAddress &ip, int serverPort, int hullNumber, int connectedPort = -1); void onNewData(const QHostAddress &ip, int port, const QByteArray &data); diff --git a/trikNetwork/src/trikServer.cpp b/trikNetwork/src/trikServer.cpp index f246e8cb2..fc5731b07 100644 --- a/trikNetwork/src/trikServer.cpp +++ b/trikNetwork/src/trikServer.cpp @@ -29,7 +29,7 @@ TrikServer::TrikServer(const std::function &connectionFactory) mConnections.insert(c->thread(), c); if (isFirstConnection) { /// @todo: Emit "connected" signal only when socket is actually connected. - emit connected(); + Q_EMIT connected(); } }); } @@ -96,7 +96,7 @@ void TrikServer::startConnection(Connection * const connectionWorker) connect(connectionThread, &QThread::started, this, [this, connectionWorker]() { QMetaObject::invokeMethod(connectionWorker, [=](){ connectionWorker->setIsStarted(true); - emit connectionWorker->readyForConnect(); + Q_EMIT connectionWorker->readyForConnect(); }); Q_EMIT startedConnection(connectionWorker); }); @@ -159,6 +159,6 @@ void TrikServer::onConnectionClosed(Connection *connection) QLOG_ERROR() << "Unable to stop thread" << thread; } if (mConnections.isEmpty()) { - emit disconnected(); + Q_EMIT disconnected(); } } diff --git a/trikRun/trikRunMain.cpp b/trikRun/trikRunMain.cpp index 37e3d3237..83a9a0221 100644 --- a/trikRun/trikRunMain.cpp +++ b/trikRun/trikRunMain.cpp @@ -41,6 +41,7 @@ int main(int argc, char *argv[]) { QStringList params; + params.reserve(argc); for (int i = 1; i < argc; ++i) { params << QString(argv[i]); } diff --git a/trikScriptRunner/generated_cpp/pytrikcontrol/pytrikcontrol0.h b/trikScriptRunner/generated_cpp/pytrikcontrol/pytrikcontrol0.h index 21540be0e..8b1ee9ca5 100644 --- a/trikScriptRunner/generated_cpp/pytrikcontrol/pytrikcontrol0.h +++ b/trikScriptRunner/generated_cpp/pytrikcontrol/pytrikcontrol0.h @@ -56,7 +56,7 @@ class PythonQtWrapper_trikControl : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: }; @@ -72,7 +72,7 @@ inline float py_q_readVoltage() { return this->readVoltage(); } class PythonQtWrapper_trikControl__BatteryInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__BatteryInterface(trikControl::BatteryInterface* obj) { delete obj; } float py_q_readRawDataVoltage(trikControl::BatteryInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__BatteryInterface*)theWrappedObject)->py_q_readRawDataVoltage());} float py_q_readVoltage(trikControl::BatteryInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__BatteryInterface*)theWrappedObject)->py_q_readVoltage());} @@ -85,7 +85,7 @@ void delete_trikControl__BatteryInterface(trikControl::BatteryInterface* obj) { class PythonQtWrapper_trikControl__BrickFactory : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: trikControl::BrickFactory* new_trikControl__BrickFactory(); void delete_trikControl__BrickFactory(trikControl::BrickFactory* obj) { delete obj; } trikControl::BrickInterface* static_trikControl__BrickFactory_create(const QString& configFilesPath = ".", const QString& mediaPath = "."); @@ -137,7 +137,7 @@ inline void py_q_stopEventDevice(const QString& deviceFile) { this->stopEventDe class PythonQtWrapper_trikControl__BrickInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__BrickInterface(trikControl::BrickInterface* obj) { delete obj; } trikControl::VectorSensorInterface* py_q_accelerometer(trikControl::BrickInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__BrickInterface*)theWrappedObject)->py_q_accelerometer());} trikControl::BatteryInterface* py_q_battery(trikControl::BrickInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__BrickInterface*)theWrappedObject)->py_q_battery());} @@ -185,7 +185,7 @@ void delete_trikControl__BrickInterface(trikControl::BrickInterface* obj) { dele class PythonQtWrapper_trikControl__CameraDeviceInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__CameraDeviceInterface(trikControl::CameraDeviceInterface* obj) { delete obj; } }; @@ -203,7 +203,7 @@ inline void py_q_stop() { this->stop(); } class PythonQtWrapper_trikControl__ColorSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__ColorSensorInterface(trikControl::ColorSensorInterface* obj) { delete obj; } void py_q_init(trikControl::ColorSensorInterface* theWrappedObject, bool showOnDisplay){ (((PythonQtPublicPromoter_trikControl__ColorSensorInterface*)theWrappedObject)->py_q_init(showOnDisplay));} QVector py_q_read(trikControl::ColorSensorInterface* theWrappedObject, int m, int n){ return (((PythonQtPublicPromoter_trikControl__ColorSensorInterface*)theWrappedObject)->py_q_read(m, n));} @@ -225,7 +225,7 @@ class PythonQtWrapper_trikControl__DeviceInterface : public QObject Q_ENUMS(Status ) enum class Status{ permanentFailure = static_cast(trikControl::DeviceInterface::Status::permanentFailure), temporaryFailure = static_cast(trikControl::DeviceInterface::Status::temporaryFailure), off = static_cast(trikControl::DeviceInterface::Status::off), starting = static_cast(trikControl::DeviceInterface::Status::starting), ready = static_cast(trikControl::DeviceInterface::Status::ready), stopping = static_cast(trikControl::DeviceInterface::Status::stopping)}; -public slots: +public Q_SLOTS: void delete_trikControl__DeviceInterface(trikControl::DeviceInterface* obj) { delete obj; } trikControl::DeviceInterface::Status static_trikControl__DeviceInterface_combine(const trikControl::DeviceInterface& underlying, const trikControl::DeviceInterface::Status& dependent); trikControl::DeviceInterface::Status status(trikControl::DeviceInterface* theWrappedObject) const; @@ -259,7 +259,7 @@ inline void py_q_showImage(const QString& fileName) { this->showImage(fileName) class PythonQtWrapper_trikControl__DisplayInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__DisplayInterface(trikControl::DisplayInterface* obj) { delete obj; } void py_q_addLabel(trikControl::DisplayInterface* theWrappedObject, const QString& text, int x, int y, int fontSize = -1){ (((PythonQtPublicPromoter_trikControl__DisplayInterface*)theWrappedObject)->py_q_addLabel(text, x, y, fontSize));} void py_q_clear(trikControl::DisplayInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__DisplayInterface*)theWrappedObject)->py_q_clear());} @@ -287,7 +287,7 @@ void delete_trikControl__DisplayInterface(trikControl::DisplayInterface* obj) { class PythonQtWrapper_trikControl__DisplayWidgetInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: trikControl::DisplayWidgetInterface* new_trikControl__DisplayWidgetInterface(); void delete_trikControl__DisplayWidgetInterface(trikControl::DisplayWidgetInterface* obj) { delete obj; } }; @@ -306,7 +306,7 @@ inline void py_q_reset() { this->reset(); } class PythonQtWrapper_trikControl__EncoderInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__EncoderInterface(trikControl::EncoderInterface* obj) { delete obj; } int py_q_read(trikControl::EncoderInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__EncoderInterface*)theWrappedObject)->py_q_read());} int py_q_readRawData(trikControl::EncoderInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__EncoderInterface*)theWrappedObject)->py_q_readRawData());} @@ -320,7 +320,7 @@ void delete_trikControl__EncoderInterface(trikControl::EncoderInterface* obj) { class PythonQtWrapper_trikControl__EventCodeInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: trikControl::EventCodeInterface* new_trikControl__EventCodeInterface(); void delete_trikControl__EventCodeInterface(trikControl::EventCodeInterface* obj) { delete obj; } }; @@ -337,7 +337,7 @@ inline trikControl::EventInterface* py_q_onEvent(int eventType) { return this- class PythonQtWrapper_trikControl__EventDeviceInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__EventDeviceInterface(trikControl::EventDeviceInterface* obj) { delete obj; } trikControl::EventInterface* py_q_onEvent(trikControl::EventDeviceInterface* theWrappedObject, int eventType){ return (((PythonQtPublicPromoter_trikControl__EventDeviceInterface*)theWrappedObject)->py_q_onEvent(eventType));} }; @@ -354,7 +354,7 @@ inline trikControl::EventCodeInterface* py_q_code(int code) { return this->cod class PythonQtWrapper_trikControl__EventInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__EventInterface(trikControl::EventInterface* obj) { delete obj; } trikControl::EventCodeInterface* py_q_code(trikControl::EventInterface* theWrappedObject, int code){ return (((PythonQtPublicPromoter_trikControl__EventInterface*)theWrappedObject)->py_q_code(code));} }; @@ -373,7 +373,7 @@ inline QString py_q_read() { return this->read(); } class PythonQtWrapper_trikControl__FifoInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__FifoInterface(trikControl::FifoInterface* obj) { delete obj; } bool py_q_hasData(trikControl::FifoInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__FifoInterface*)theWrappedObject)->py_q_hasData());} bool py_q_hasLine(trikControl::FifoInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__FifoInterface*)theWrappedObject)->py_q_hasLine());} @@ -400,7 +400,7 @@ inline int py_q_wheel() const { return this->wheel(); } class PythonQtWrapper_trikControl__GamepadInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__GamepadInterface(trikControl::GamepadInterface* obj) { delete obj; } bool py_q_buttonIsPressed(trikControl::GamepadInterface* theWrappedObject, int buttonNumber){ return (((PythonQtPublicPromoter_trikControl__GamepadInterface*)theWrappedObject)->py_q_buttonIsPressed(buttonNumber));} bool py_q_buttonWasPressed(trikControl::GamepadInterface* theWrappedObject, int buttonNumber){ return (((PythonQtPublicPromoter_trikControl__GamepadInterface*)theWrappedObject)->py_q_buttonWasPressed(buttonNumber));} @@ -429,7 +429,7 @@ inline void py_q_setCalibrationValues(const QVector& values) { this->setC class PythonQtWrapper_trikControl__GyroSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__GyroSensorInterface(trikControl::GyroSensorInterface* obj) { delete obj; } void py_q_calibrate(trikControl::GyroSensorInterface* theWrappedObject, int msec){ (((PythonQtPublicPromoter_trikControl__GyroSensorInterface*)theWrappedObject)->py_q_calibrate(msec));} QVector py_q_getCalibrationValues(trikControl::GyroSensorInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__GyroSensorInterface*)theWrappedObject)->py_q_getCalibrationValues());} @@ -451,7 +451,7 @@ inline void py_q_send(int reg, int value) { this->send(reg, value); } class PythonQtWrapper_trikControl__I2cDeviceInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__I2cDeviceInterface(trikControl::I2cDeviceInterface* obj) { delete obj; } int read(trikControl::I2cDeviceInterface* theWrappedObject, int reg); int py_q_read(trikControl::I2cDeviceInterface* theWrappedObject, int reg){ return (((PythonQtPublicPromoter_trikControl__I2cDeviceInterface*)theWrappedObject)->py_q_read(reg));} @@ -473,7 +473,7 @@ inline void py_q_stop() { this->stop(); } class PythonQtWrapper_trikControl__IrCameraInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__IrCameraInterface(trikControl::IrCameraInterface* obj) { delete obj; } void py_q_init(trikControl::IrCameraInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__IrCameraInterface*)theWrappedObject)->py_q_init());} int py_q_readSensor(trikControl::IrCameraInterface* theWrappedObject, int m, int n) const{ return (((PythonQtPublicPromoter_trikControl__IrCameraInterface*)theWrappedObject)->py_q_readSensor(m, n));} @@ -495,7 +495,7 @@ inline bool py_q_wasPressed(int code) { return this->wasPressed(code); } class PythonQtWrapper_trikControl__KeysInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__KeysInterface(trikControl::KeysInterface* obj) { delete obj; } int py_q_buttonCode(trikControl::KeysInterface* theWrappedObject, bool wait = true){ return (((PythonQtPublicPromoter_trikControl__KeysInterface*)theWrappedObject)->py_q_buttonCode(wait));} bool py_q_isPressed(trikControl::KeysInterface* theWrappedObject, int code){ return (((PythonQtPublicPromoter_trikControl__KeysInterface*)theWrappedObject)->py_q_isPressed(code));} @@ -518,7 +518,7 @@ inline void py_q_red() { this->red(); } class PythonQtWrapper_trikControl__LedInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__LedInterface(trikControl::LedInterface* obj) { delete obj; } void py_q_green(trikControl::LedInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__LedInterface*)theWrappedObject)->py_q_green());} void py_q_off(trikControl::LedInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__LedInterface*)theWrappedObject)->py_q_off());} @@ -533,7 +533,7 @@ void delete_trikControl__LedInterface(trikControl::LedInterface* obj) { delete o class PythonQtWrapper_trikControl__LidarInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__LidarInterface(trikControl::LidarInterface* obj) { delete obj; } }; @@ -553,7 +553,7 @@ inline void py_q_stop() { this->stop(); } class PythonQtWrapper_trikControl__LineSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__LineSensorInterface(trikControl::LineSensorInterface* obj) { delete obj; } void py_q_detect(trikControl::LineSensorInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__LineSensorInterface*)theWrappedObject)->py_q_detect());} QVector py_q_getDetectParameters(trikControl::LineSensorInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__LineSensorInterface*)theWrappedObject)->py_q_getDetectParameters());} @@ -577,7 +577,7 @@ inline void py_q_up() { this->up(); } class PythonQtWrapper_trikControl__MarkerInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__MarkerInterface(trikControl::MarkerInterface* obj) { delete obj; } void py_q_down(trikControl::MarkerInterface* theWrappedObject, const QString& color){ (((PythonQtPublicPromoter_trikControl__MarkerInterface*)theWrappedObject)->py_q_down(color));} bool py_q_isDown(trikControl::MarkerInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__MarkerInterface*)theWrappedObject)->py_q_isDown());} @@ -606,7 +606,7 @@ class PythonQtWrapper_trikControl__MotorInterface : public QObject Q_ENUMS(Type ) enum class Type{ powerMotor = static_cast(trikControl::MotorInterface::Type::powerMotor), servoMotor = static_cast(trikControl::MotorInterface::Type::servoMotor)}; -public slots: +public Q_SLOTS: void delete_trikControl__MotorInterface(trikControl::MotorInterface* obj) { delete obj; } void py_q_brake(trikControl::MotorInterface* theWrappedObject, int durationMs = 500){ (((PythonQtPublicPromoter_trikControl__MotorInterface*)theWrappedObject)->py_q_brake(durationMs));} int maxControl(trikControl::MotorInterface* theWrappedObject) const; @@ -635,7 +635,7 @@ inline void py_q_stop() { this->stop(); } class PythonQtWrapper_trikControl__ObjectSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__ObjectSensorInterface(trikControl::ObjectSensorInterface* obj) { delete obj; } void py_q_detect(trikControl::ObjectSensorInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__ObjectSensorInterface*)theWrappedObject)->py_q_detect());} QVector py_q_getDetectParameters(trikControl::ObjectSensorInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__ObjectSensorInterface*)theWrappedObject)->py_q_getDetectParameters());} @@ -660,7 +660,7 @@ inline long py_q_minValue() const { return this->minValue(); } class PythonQtWrapper_trikControl__PwmCaptureInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__PwmCaptureInterface(trikControl::PwmCaptureInterface* obj) { delete obj; } long py_q_duty(trikControl::PwmCaptureInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__PwmCaptureInterface*)theWrappedObject)->py_q_duty());} long py_q_dutyRaw(trikControl::PwmCaptureInterface* theWrappedObject){ return (((PythonQtPublicPromoter_trikControl__PwmCaptureInterface*)theWrappedObject)->py_q_dutyRaw());} @@ -689,7 +689,7 @@ class PythonQtWrapper_trikControl__SensorInterface : public QObject Q_ENUMS(Type ) enum class Type{ analogSensor = static_cast(trikControl::SensorInterface::Type::analogSensor), digitalSensor = static_cast(trikControl::SensorInterface::Type::digitalSensor), specialSensor = static_cast(trikControl::SensorInterface::Type::specialSensor)}; -public slots: +public Q_SLOTS: void delete_trikControl__SensorInterface(trikControl::SensorInterface* obj) { delete obj; } int maxValue(trikControl::SensorInterface* theWrappedObject) const; int py_q_maxValue(trikControl::SensorInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__SensorInterface*)theWrappedObject)->py_q_maxValue());} @@ -715,7 +715,7 @@ inline void py_q_volume(int volCoeff) { this->volume(volCoeff); } class PythonQtWrapper_trikControl__SoundSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__SoundSensorInterface(trikControl::SoundSensorInterface* obj) { delete obj; } void py_q_detect(trikControl::SoundSensorInterface* theWrappedObject){ (((PythonQtPublicPromoter_trikControl__SoundSensorInterface*)theWrappedObject)->py_q_detect());} void py_q_init(trikControl::SoundSensorInterface* theWrappedObject, bool showOnDisplay){ (((PythonQtPublicPromoter_trikControl__SoundSensorInterface*)theWrappedObject)->py_q_init(showOnDisplay));} @@ -736,7 +736,7 @@ inline QVector py_q_read() const { return this->read(); } class PythonQtWrapper_trikControl__VectorSensorInterface : public QObject { Q_OBJECT public: -public slots: +public Q_SLOTS: void delete_trikControl__VectorSensorInterface(trikControl::VectorSensorInterface* obj) { delete obj; } QVector py_q_read(trikControl::VectorSensorInterface* theWrappedObject) const{ return (((PythonQtPublicPromoter_trikControl__VectorSensorInterface*)theWrappedObject)->py_q_read());} }; diff --git a/trikScriptRunner/include/trikScriptRunner/trikJavaScriptRunner.h b/trikScriptRunner/include/trikScriptRunner/trikJavaScriptRunner.h index a26c889ac..f0941479e 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikJavaScriptRunner.h +++ b/trikScriptRunner/include/trikScriptRunner/trikJavaScriptRunner.h @@ -53,14 +53,14 @@ class TRIKSCRIPTRUNNER_EXPORT TrikJavaScriptRunner : public TrikScriptRunnerInte bool wasError() override { return false; } -public slots: +public Q_SLOTS: void run(const QString &script, const QString &fileName = "") override; void runDirectCommand(const QString &command) override; void abort() override; void brickBeep() override; void setWorkingDirectory(const QString &workingDir) override; -private slots: +private Q_SLOTS: void onScriptStart(int scriptId); private: diff --git a/trikScriptRunner/include/trikScriptRunner/trikPythonRunner.h b/trikScriptRunner/include/trikScriptRunner/trikPythonRunner.h index 012adc762..27ef43426 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikPythonRunner.h +++ b/trikScriptRunner/include/trikScriptRunner/trikPythonRunner.h @@ -52,7 +52,7 @@ class TRIKSCRIPTRUNNER_EXPORT TrikPythonRunner : public TrikScriptRunnerInterfac QStringList knownMethodNames() const override; bool wasError() override; -public slots: +public Q_SLOTS: void run(const QString &script, const QString &fileName = "") override; void runDirectCommand(const QString &command) override; void abort() override; diff --git a/trikScriptRunner/include/trikScriptRunner/trikScriptControlInterface.h b/trikScriptRunner/include/trikScriptRunner/trikScriptControlInterface.h index 021943812..2032275b5 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikScriptControlInterface.h +++ b/trikScriptRunner/include/trikScriptRunner/trikScriptControlInterface.h @@ -67,7 +67,7 @@ class TRIKSCRIPTRUNNER_EXPORT TrikScriptControlInterface : public QObject /// Counts time interval between two packed data of time using TimeVal Q_INVOKABLE virtual int timeInterval(int packedTimeLeft, int packedTimeRight) = 0; -public slots: +public Q_SLOTS: /// Starts event loop for script. virtual void run() = 0; @@ -77,7 +77,7 @@ public slots: /// Resets script execution state, clearing all flags and stopping all timers. virtual void reset() = 0; -signals: +Q_SIGNALS: /// Emitted when script requested system to abort execution. void quitSignal(); diff --git a/trikScriptRunner/include/trikScriptRunner/trikScriptRunner.h b/trikScriptRunner/include/trikScriptRunner/trikScriptRunner.h index 17886c6b1..de93709cf 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikScriptRunner.h +++ b/trikScriptRunner/include/trikScriptRunner/trikScriptRunner.h @@ -65,10 +65,10 @@ class TRIKSCRIPTRUNNER_EXPORT TrikScriptRunner : public TrikScriptRunnerInterfac QStringList knownMethodNames() const override; /// Execute script with a corresponding engine of specified type void run(const QString &script, ScriptType stype, const QString &fileName = ""); -signals: +Q_SIGNALS: /// Broadcasts message to all opened mailboxes. void sendMailboxMessage(QString msg); -public slots: +public Q_SLOTS: /// See corresponding TrikScriptRunnerInterface method void run(const QString &script, const QString &fileName = "") override; /// See corresponding TrikScriptRunnerInterface method diff --git a/trikScriptRunner/include/trikScriptRunner/trikScriptRunnerInterface.h b/trikScriptRunner/include/trikScriptRunner/trikScriptRunnerInterface.h index 9116e7fac..361dde77e 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikScriptRunnerInterface.h +++ b/trikScriptRunner/include/trikScriptRunner/trikScriptRunnerInterface.h @@ -126,7 +126,7 @@ class TRIKSCRIPTRUNNER_EXPORT TrikScriptRunnerInterface : public QObject /// Get status of last direct command/script virtual bool wasError() = 0; -public slots: +public Q_SLOTS: /// Executes given script asynchronously. If some script is already executing, it will be aborted. /// For event-driven mode (where script has brick.run() command) script counts as finished /// when it requests to quit by itself or was aborted. When script is finished, completed() signal will be emitted. @@ -159,7 +159,7 @@ public slots: /// Set working directory -- path to all project files virtual void setWorkingDirectory(const QString &workingDir) = 0; -signals: +Q_SIGNALS: /// Emitted when current script completes execution (for event-driven mode it means that script requested to quit /// or was aborted). /// @param error - localized error message if any error occured during script execution or empty string diff --git a/trikScriptRunner/include/trikScriptRunner/trikVariablesServer.h b/trikScriptRunner/include/trikScriptRunner/trikVariablesServer.h index 3da926f51..9ab6cdfbd 100644 --- a/trikScriptRunner/include/trikScriptRunner/trikVariablesServer.h +++ b/trikScriptRunner/include/trikScriptRunner/trikVariablesServer.h @@ -28,17 +28,17 @@ class TRIKSCRIPTRUNNER_EXPORT TrikVariablesServer : public QObject /// Constructor TrikVariablesServer(); -signals: +Q_SIGNALS: /// Emitted when there is a new connection with a HTTP-request of variables values /// @param propertyName - name of variables prefix, i.e prefix "web" for variable "web.light" void getVariables(const QString &propertyName); -public slots: +public Q_SLOTS: /// Sends HTTP response with JSON data about variables /// @param json - JSON container for variables values void sendHTTPResponse(const QJsonObject &json); -private slots: +private Q_SLOTS: /// Appends new connection for handling it void onNewConnection(); diff --git a/trikScriptRunner/src/pythonEngineWorker.cpp b/trikScriptRunner/src/pythonEngineWorker.cpp index ec2756b7e..82a390ee9 100644 --- a/trikScriptRunner/src/pythonEngineWorker.cpp +++ b/trikScriptRunner/src/pythonEngineWorker.cpp @@ -108,7 +108,7 @@ void PythonEngineWorker::init() QLOG_INFO() << "Running with python:" << Py_GetVersion(); if (strncmp(PY_VERSION, Py_GetVersion(), 4)) { auto const &e = QString("Incompatible Python runtime detected. Expecting version %1, but found %2") - .arg(PY_VERSION).arg(Py_GetVersion()); + .arg(PY_VERSION, Py_GetVersion()); throw trikKernel::InternalErrorException(e); } constexpr auto varName = "TRIK_PYTHONPATH"; @@ -141,7 +141,7 @@ void PythonEngineWorker::init() mProgramName = Py_DecodeLocale("trikPythonRuntime", nullptr); Py_SetProgramName(mProgramName); - if (!qgetenv("TRIK_PYTHON_DEBUG").isEmpty()) { + if (qEnvironmentVariableIsSet("TRIK_PYTHON_DEBUG")) { Py_VerboseFlag = 3; Py_InspectFlag = 1; Py_DebugFlag = 2; @@ -193,7 +193,7 @@ void PythonEngineWorker::init() PythonQt::setEnableThreadSupport(true); PythonQtGILScope _; PythonQt::init(PythonQt::RedirectStdOut | PythonQt::ExternalModule - | PythonQt::PythonAlreadyInitialized, "TRIK_PQT"); + | PythonQt::PythonAlreadyInitialized, "TRIK_PQT"); connect(PythonQt::self(), &PythonQt::pythonStdErr, this, &PythonEngineWorker::updateErrorMessage); connect(PythonQt::self(), &PythonQt::pythonStdOut, this, [this](const QString& str){ QTimer::singleShot(0, this, [this, str](){ Q_EMIT this->textInStdOut(str);}); @@ -365,7 +365,7 @@ void PythonEngineWorker::run(const QString &script, const QFileInfo &scriptFile) void PythonEngineWorker::doRun(const QString &script, const QFileInfo &scriptFile) { - emit startedScript("", 0); + Q_EMIT startedScript("", 0); mErrorMessage.clear(); /// When starting script execution (by any means), clear button states. mBrick->keys()->reset(); @@ -373,7 +373,7 @@ void PythonEngineWorker::doRun(const QString &script, const QFileInfo &scriptFil auto ok = recreateContext(); QCoreApplication::processEvents(); if (!ok) { - emit completed(mErrorMessage,0); + Q_EMIT completed(mErrorMessage,0); return; } @@ -393,9 +393,9 @@ void PythonEngineWorker::doRun(const QString &script, const QFileInfo &scriptFil releaseContext(); QCoreApplication::processEvents(); //dispatch events before emitting the signal if (wasError) { - emit completed(mErrorMessage, 0); + Q_EMIT completed(mErrorMessage, 0); } else { - emit completed("", 0); + Q_EMIT completed("", 0); } } @@ -407,7 +407,7 @@ void PythonEngineWorker::runDirect(const QString &command) void PythonEngineWorker::doRunDirect(const QString &command) { - emit startedDirectScript(0); + Q_EMIT startedDirectScript(0); if (PythonQt::self()->hadError()) { PythonQt::self()->clearError(); mErrorMessage.clear(); @@ -417,9 +417,9 @@ void PythonEngineWorker::doRunDirect(const QString &command) QCoreApplication::processEvents(); auto wasError = PythonQt::self()->hadError(); if (wasError) { - emit completed(mErrorMessage, 0); + Q_EMIT completed(mErrorMessage, 0); } else { - emit completed("", 0); + Q_EMIT completed("", 0); } } diff --git a/trikScriptRunner/src/pythonEngineWorker.h b/trikScriptRunner/src/pythonEngineWorker.h index 42ead6b0b..7f7295bdd 100644 --- a/trikScriptRunner/src/pythonEngineWorker.h +++ b/trikScriptRunner/src/pythonEngineWorker.h @@ -63,7 +63,7 @@ class TRIKSCRIPTRUNNER_EXPORT PythonEngineWorker : public QObject /// Blocks the Thread with QSemaphore until init() method releases it. void waitUntilInited(); -signals: +Q_SIGNALS: /// Emitted when current script execution is completed or is aborted by reset() call. /// @param error - localized error message or empty string. /// @param scriptId - unique identifier of a script completed @@ -80,7 +80,7 @@ class TRIKSCRIPTRUNNER_EXPORT PythonEngineWorker : public QObject /// Some message to send, for example, from stdout void textInStdOut(const QString&); -public slots: +public Q_SLOTS: /// Starts script evaluation, emits startedScript() signal and returns. Script will be executed asynchronously. /// completed() signal is emitted upon script abortion or completion. /// It is a caller's responsibility to ensure that PythonEngineWorker is in ready state before a call to run() @@ -111,7 +111,7 @@ public slots: /// Can be safely called from other threads. void brickBeep(); -private slots: +private Q_SLOTS: /// Abort script execution. void onScriptRequestingToQuit(); diff --git a/trikScriptRunner/src/scriptEngineWorker.cpp b/trikScriptRunner/src/scriptEngineWorker.cpp index 0458b437c..70c71ca70 100644 --- a/trikScriptRunner/src/scriptEngineWorker.cpp +++ b/trikScriptRunner/src/scriptEngineWorker.cpp @@ -183,7 +183,7 @@ void ScriptEngineWorker::stopScript() // Instead of deleteLater() we use zero timer QTimer::singleShot(0, this, [this]() { mDirectScriptsEngine.reset(); }); - emit completed(msg, mScriptId); + Q_EMIT completed(msg, mScriptId); } mState = ready; @@ -222,7 +222,7 @@ void ScriptEngineWorker::doRun(const QString &script) const QString error = mThreading.errorMessage(); QLOG_INFO() << "ScriptEngineWorker: evaluation ended with message" << error; QCoreApplication::processEvents(); - emit completed(error, mScriptId); + Q_EMIT completed(error, mScriptId); } void ScriptEngineWorker::runDirect(const QString &command, int scriptId) @@ -266,7 +266,7 @@ void ScriptEngineWorker::startScriptEvaluation(int scriptId) QLOG_INFO() << "ScriptEngineWorker: starting script" << scriptId << ", thread:" << QThread::currentThread(); mState = starting; mScriptId = scriptId; - emit startedScript(mScriptId); + Q_EMIT startedScript(mScriptId); } void ScriptEngineWorker::evalExternalFile(const QString & filepath, QScriptEngine * const engine) @@ -278,11 +278,11 @@ void ScriptEngineWorker::evalExternalFile(const QString & filepath, QScriptEngin const auto & message = engine->uncaughtException().toString(); const auto & backtrace = engine->uncaughtExceptionBacktrace().join("\n"); const auto & error = tr("Line %1: %2").arg(QString::number(line), message) + "\nBacktrace"+ backtrace; - emit completed(error, mScriptId); + Q_EMIT completed(error, mScriptId); QLOG_ERROR() << "Uncaught exception with error" << error; } } else { - emit completed(tr("File %1 not found").arg(filepath), mScriptId); + Q_EMIT completed(tr("File %1 not found").arg(filepath), mScriptId); QLOG_ERROR() << "File for eval not found, path:" << filepath; } } diff --git a/trikScriptRunner/src/scriptEngineWorker.h b/trikScriptRunner/src/scriptEngineWorker.h index f15ce6c6c..73421246a 100644 --- a/trikScriptRunner/src/scriptEngineWorker.h +++ b/trikScriptRunner/src/scriptEngineWorker.h @@ -79,7 +79,7 @@ class TRIKSCRIPTRUNNER_EXPORT ScriptEngineWorker : public QObject /// (useful when used from outside of the TrikRuntime). QStringList knownMethodNames() const; -signals: +Q_SIGNALS: /// Emitted when current script execution is completed or is aborted by reset() call. /// @param error - localized error message or empty string. /// @param scriptId - unique identifier of a script completed @@ -97,7 +97,7 @@ class TRIKSCRIPTRUNNER_EXPORT ScriptEngineWorker : public QObject /// @param json - JSON container for variables values void variablesReady(const QJsonObject &data); -public slots: +public Q_SLOTS: /// Starts script evaluation, emits startedScript() signal and returns. Script will be executed asynchronously. /// completed() signal is emitted upon script abortion or completion. /// It is a caller's responsibility to ensure that ScriptEngineWorker is in ready state before a call to run() @@ -124,7 +124,7 @@ public slots: /// Set default directory for includes (not a working dir, actually...) void setWorkingDir(const QString &workingDir); -private slots: +private Q_SLOTS: /// Abort script execution. void onScriptRequestingToQuit(); diff --git a/trikScriptRunner/src/scriptExecutionControl.cpp b/trikScriptRunner/src/scriptExecutionControl.cpp index dadbd306e..c37ed30f8 100644 --- a/trikScriptRunner/src/scriptExecutionControl.cpp +++ b/trikScriptRunner/src/scriptExecutionControl.cpp @@ -42,7 +42,7 @@ ScriptExecutionControl::~ScriptExecutionControl() void ScriptExecutionControl::reset() { mInEventDrivenMode = false; - emit stopWaiting(); + Q_EMIT stopWaiting(); for (auto &&timer : mTimers) { QMetaObject::invokeMethod(timer, &QTimer::stop, Qt::QueuedConnection); timer->deleteLater(); @@ -61,7 +61,7 @@ QObject* ScriptExecutionControl::timer(int milliseconds) static inline int waitWithTimerType(ScriptExecutionControl *sec, int ms, Qt::TimerType tt) { QEventLoop loop; - QObject::connect(sec, &ScriptExecutionControl::stopWaiting, &loop, std::bind(&QEventLoop::exit, &loop, -1)); + QObject::connect(sec, &TrikScriptControlInterface::stopWaiting, &loop, std::bind(&QEventLoop::exit, &loop, -1)); QTimer t; t.setTimerType(tt); QObject::connect(&t, &QTimer::timeout, &loop, &QEventLoop::quit); @@ -155,7 +155,7 @@ bool ScriptExecutionControl::isInEventDrivenMode() const void ScriptExecutionControl::quit() { - emit quitSignal(); + Q_EMIT quitSignal(); } void ScriptExecutionControl::system(const QString &command, bool synchronously) diff --git a/trikScriptRunner/src/scriptExecutionControl.h b/trikScriptRunner/src/scriptExecutionControl.h index 384783e1d..80da70106 100644 --- a/trikScriptRunner/src/scriptExecutionControl.h +++ b/trikScriptRunner/src/scriptExecutionControl.h @@ -72,7 +72,7 @@ class TRIKSCRIPTRUNNER_EXPORT ScriptExecutionControl : public TrikScriptControlI /// Counts time interval between two packed data of time using TimeVal Q_INVOKABLE int timeInterval(int packedTimeLeft, int packedTimeRight) override; -public slots: +public Q_SLOTS: /// Starts event loop for script. void run() override; @@ -82,7 +82,10 @@ public slots: /// Resets script execution state, clearing all flags and stopping all timers. void reset() override; -signals: + + // NOTE: If this incorrectly overriden signals removed, JS test expose the problem: + // quitSignal and stopWaiting are not delivered to the recivers. Very strange. +Q_SIGNALS: /// Emitted when script requested system to abort execution. void quitSignal(); diff --git a/trikScriptRunner/src/scriptThread.cpp b/trikScriptRunner/src/scriptThread.cpp index 8dce896a9..e4ae08572 100644 --- a/trikScriptRunner/src/scriptThread.cpp +++ b/trikScriptRunner/src/scriptThread.cpp @@ -69,7 +69,7 @@ void ScriptThread::abort() if (isEvaluating()) { mEngine->abortEvaluation(); } - emit stopRunning(); + Q_EMIT stopRunning(); } QString ScriptThread::id() const @@ -98,6 +98,6 @@ void ScriptThread::onGetVariables(const QString &propertyName) it.next(); json[it.name()] = it.value().toString(); } - emit variablesReady(json); + Q_EMIT variablesReady(json); } } diff --git a/trikScriptRunner/src/scriptThread.h b/trikScriptRunner/src/scriptThread.h index ae1c02256..eeba7d6bb 100644 --- a/trikScriptRunner/src/scriptThread.h +++ b/trikScriptRunner/src/scriptThread.h @@ -48,7 +48,7 @@ class TRIKSCRIPTRUNNER_EXPORT ScriptThread : public QThread /// @returns true if the script engine is evaluating a script at the moment bool isEvaluating() const; -signals: +Q_SIGNALS: /// Emitted when event loop must be stopped. void stopRunning(); @@ -56,7 +56,7 @@ class TRIKSCRIPTRUNNER_EXPORT ScriptThread : public QThread /// @param json - JSON container for variables values void variablesReady(const QJsonObject &json); -public slots: +public Q_SLOTS: /// Catch variables values from current script execution /// @param propertyName - name of variables prefix, i.e prefix "web" for variable "web.light" void onGetVariables(const QString &propertyName); diff --git a/trikScriptRunner/src/threading.cpp b/trikScriptRunner/src/threading.cpp index 48951bddb..d2e4aef21 100644 --- a/trikScriptRunner/src/threading.cpp +++ b/trikScriptRunner/src/threading.cpp @@ -206,7 +206,7 @@ void Threading::threadFinished(const QString &id) } if (mThreads.isEmpty()) { - emit finished(); + Q_EMIT finished(); } } diff --git a/trikScriptRunner/src/threading.h b/trikScriptRunner/src/threading.h index b86a86414..bd4e0de5f 100644 --- a/trikScriptRunner/src/threading.h +++ b/trikScriptRunner/src/threading.h @@ -81,7 +81,7 @@ class TRIKSCRIPTRUNNER_EXPORT Threading : public QObject /// Release thread initialization semaphore on thread initialization void releaseThreadInitializationSemaphore() { mThreadInitializationSemaphore.release(1); } -signals: +Q_SIGNALS: /// Signals that all threads have finished. void finished(); diff --git a/trikScriptRunner/src/trikJavaScriptRunner.cpp b/trikScriptRunner/src/trikJavaScriptRunner.cpp index 02e3c93c9..b368f0d93 100644 --- a/trikScriptRunner/src/trikJavaScriptRunner.cpp +++ b/trikScriptRunner/src/trikJavaScriptRunner.cpp @@ -129,9 +129,9 @@ void TrikJavaScriptRunner::abort() void TrikJavaScriptRunner::onScriptStart(int scriptId) { if (scriptId != -1 && mScriptFileNames.contains(scriptId)) { - emit startedScript(mScriptFileNames[scriptId], scriptId); + Q_EMIT startedScript(mScriptFileNames[scriptId], scriptId); } else { - emit startedDirectScript(scriptId); + Q_EMIT startedDirectScript(scriptId); } } diff --git a/trikScriptRunner/src/trikScriptRunner.cpp b/trikScriptRunner/src/trikScriptRunner.cpp index 5054f6ce6..dba2ffbfc 100644 --- a/trikScriptRunner/src/trikScriptRunner.cpp +++ b/trikScriptRunner/src/trikScriptRunner.cpp @@ -45,7 +45,7 @@ TrikScriptRunner::TrikScriptRunner(trikControl::BrickInterface &brick REGISTER_DEVICES_WITH_TEMPLATE(REGISTER_METATYPE) if (mailbox) { connect(mailbox, &MailboxInterface::newMessage, this, [this](int senderNumber, QString message){ - emit sendMailboxMessage(QString("mail: sender: %1 contents: %2") + Q_EMIT sendMailboxMessage(QString("mail: sender: %1 contents: %2") .arg(senderNumber) .arg(message) ); diff --git a/trikScriptRunner/src/trikVariablesServer.cpp b/trikScriptRunner/src/trikVariablesServer.cpp index c2d764a36..c136ab6b3 100644 --- a/trikScriptRunner/src/trikVariablesServer.cpp +++ b/trikScriptRunner/src/trikVariablesServer.cpp @@ -71,6 +71,6 @@ void TrikVariablesServer::processHTTPRequest() const QStringList words = cleanString.split(QRegExp("\\s+"), QString::SkipEmptyParts); if (words[1] == "/web/") { - emit getVariables("web"); + Q_EMIT getVariables("web"); } } diff --git a/trikWiFi/include/trikWiFi/trikWiFi.h b/trikWiFi/include/trikWiFi/trikWiFi.h index 6d69a52dc..4db7a91fe 100644 --- a/trikWiFi/include/trikWiFi/trikWiFi.h +++ b/trikWiFi/include/trikWiFi/trikWiFi.h @@ -73,7 +73,7 @@ class TRIKWIFI_EXPORT TrikWiFi : public QObject /// Return signal strength of current Wi-Fi connection SignalStrength signalStrength(); -signals: +Q_SIGNALS: /// Emitted when scanning for available networks initiated by scan() is finished and results are available /// and ready to be obtained by scanResults() method. void scanFinished(); diff --git a/trikWiFi/src/trikWiFiWorker.cpp b/trikWiFi/src/trikWiFiWorker.cpp index f1abc064a..9ca0aebac 100644 --- a/trikWiFi/src/trikWiFiWorker.cpp +++ b/trikWiFi/src/trikWiFiWorker.cpp @@ -56,7 +56,8 @@ void TrikWiFiWorker::reinit() const int monitorFileDesc = mMonitorInterface->fileDescriptor(); if (monitorFileDesc >= 0) { mMonitorFileSocketNotifier.reset(new QSocketNotifier(monitorFileDesc, QSocketNotifier::Read)); - QObject::connect(mMonitorFileSocketNotifier.data(), SIGNAL(activated(int)), this, SLOT(receiveMessages())); + QObject::connect(mMonitorFileSocketNotifier.data(), &QSocketNotifier::activated + , this, &TrikWiFiWorker::receiveMessages); } else { QLOG_ERROR() << "Can not get monitor file descriptor"; } @@ -91,20 +92,20 @@ void TrikWiFiWorker::connect(const QString &ssid) if (networkId == -1) { // wpa_supplicant failed for some reason. - emit error("connect"); + Q_EMIT error("connect"); return; } QString reply; int result = mControlInterface->request("DISCONNECT", reply); if (result < 0 || reply != "OK\n") { - emit error("connect"); + Q_EMIT error("connect"); return; } result = mControlInterface->request("SELECT_NETWORK " + QString::number(networkId), reply); if (result < 0 || reply != "OK\n") { - emit error("connect"); + Q_EMIT error("connect"); return; } } @@ -116,7 +117,7 @@ void TrikWiFiWorker::disconnect() QString reply; const int result = mControlInterface->request("DISCONNECT", reply); if (result != 0 || reply != "OK\n") { - emit error("disconnect"); + Q_EMIT error("disconnect"); } } @@ -127,7 +128,7 @@ void TrikWiFiWorker::scanRequest() mIgnoreScanResults = false; const int result = mControlInterface->request("SCAN", reply); if (result != 0 || reply != "OK\n") { - emit error("scanRequest"); + Q_EMIT error("scanRequest"); } } @@ -137,7 +138,7 @@ void TrikWiFiWorker::statusRequest() QString reply; if (mControlInterface->request(command, reply) < 0) { - emit error("statusRequest"); + Q_EMIT error("statusRequest"); return; } @@ -153,7 +154,7 @@ void TrikWiFiWorker::statusRequest() } mStatus.sync(); - emit statusReady(); + Q_EMIT statusReady(); } Status TrikWiFiWorker::statusResult() @@ -167,7 +168,7 @@ void TrikWiFiWorker::processScanResults() mIgnoreScanResults = true; - forever { + Q_FOREVER { const QString command = "BSS " + QString::number(index++); QString reply; @@ -207,7 +208,7 @@ void TrikWiFiWorker::processScanResults() mScanResult.sync(); mScanResult->clear(); - emit scanFinished(); + Q_EMIT scanFinished(); } QList TrikWiFiWorker::scanResult() @@ -220,7 +221,7 @@ void TrikWiFiWorker::listKnownNetworks() QString reply; const int result = mControlInterface->request("LIST_NETWORKS", reply); if (result < 0 || reply.isEmpty() || reply.startsWith("FAIL")) { - emit error("listNetworksRequest"); + Q_EMIT error("listNetworksRequest"); return; } @@ -258,9 +259,9 @@ void TrikWiFiWorker::processMessage(const QString &message) dhcpProcess.start("udhcpc", {"-i", "wlan0"}); dhcpProcess.waitForFinished(3000); statusRequest(); - emit connected(); + Q_EMIT connected(); } else if (message.contains("CTRL-EVENT-DISCONNECTED")) { - emit disconnected(mPlannedDisconnect ? DisconnectReason::planned : DisconnectReason::unplanned); + Q_EMIT disconnected(mPlannedDisconnect ? DisconnectReason::planned : DisconnectReason::unplanned); } } diff --git a/trikWiFi/src/trikWiFiWorker.h b/trikWiFi/src/trikWiFiWorker.h index 4ee89f28e..9c51c41be 100644 --- a/trikWiFi/src/trikWiFiWorker.h +++ b/trikWiFi/src/trikWiFiWorker.h @@ -69,7 +69,7 @@ class TrikWiFiWorker : public QObject /// Returns a list of currently known available WiFi networks. Use scanRequest() method to refresh. QList scanResult(); -signals: +Q_SIGNALS: /// Emitted when scanning for available networks initiated by scan() is finished and results are available /// and ready to be obtained by scanResults method. void scanFinished(); @@ -87,7 +87,7 @@ class TrikWiFiWorker : public QObject /// Emitted when something goes wrong. void error(const QString &message); -private slots: +private Q_SLOTS: /// Slot that processes messages from wpa_supplicant. void receiveMessages();