diff --git a/translations/trikRuntime_de.ts b/translations/trikRuntime_de.ts index fcf2a0b08..6481967bf 100644 --- a/translations/trikRuntime_de.ts +++ b/translations/trikRuntime_de.ts @@ -4,6 +4,7 @@ FileSystemFilter + Delete all... alles löschen @@ -11,30 +12,37 @@ LogWindow + Log window Protokollfenster + &Pause &Pause + &Save &Speichern + C&lear K&lar + &Copy &Kopieren + Level: Ebene: + &Auto scroll &Auto Scroll @@ -42,88 +50,110 @@ QObject + Trace + Debug + Info + Warning + Error + Fatal + Print this help text. + Ignore all locale options and use English language + Path to a directory where all configs for TRIK runtime are stored. Config files are system-config.xml (system-wide configuration of robot hardware for trikControl library) and model-config.xml (configuration of current model). + Path to a directory where core dump will be saved in case of creation. + Positional arguments: + Options + Flags + Graphical user interface, TRIK Studio runtime environment and script runner of a robot + File with script to execute + (optional of -js or -py option is specified) + JavaScript script to be executed directly from command line. + + Example: + Python script to be executed directly from command line. + Disable display support. When this flag is active, trikRun can work without QWS or even physical display + Runner of JavaScript and Python files. @@ -131,14 +161,17 @@ QsLogging::LogWindowModel + Time + Level + Message @@ -146,18 +179,22 @@ QsLogging::Window + &Pause &Pause + &Resume + Save log + Log file (*.log) @@ -165,10 +202,12 @@ trikGui::AccelerometerWidget + Accelerometer + Error @@ -176,10 +215,12 @@ trikGui::CameraWidget + Camera + Camera is not available @@ -187,10 +228,12 @@ trikGui::CommandSettingsWidget + Continue + Command Settings @@ -198,70 +241,87 @@ trikGui::CommandsListWidget + Choose command: + Play Tone + Smile + Sad Smile + Timer + Motor Forward + Motor Backward + Motors Stop + Wait for Light + Wait for Ultrasonic Distance + Wait for Infrared Distance + Wait for Encoder + Commands List + Choose waiting time (ms): + Delay %1 ms + < add command > + Choose motors power (%): @@ -269,30 +329,37 @@ trikGui::CommunicationSettingsWidget + <b>Comm settings</b> <b>Kommunikationseinstellungen</b> + (Press 'Enter' to edit) (Drücken Sie zum Bearbeiten die Eingabetaste.) + Hull number: Rumpfnummer: + Leader IP: Leader-IP: + (last two numbers) (letzte zwei Zahlen) + Connect Verbinden + Comm settings Kommunikationseinstellungen @@ -300,6 +367,7 @@ trikGui::Controller + direct command @@ -307,22 +375,28 @@ trikGui::FileManagerWidget + Delete all... alles löschen + File Manager + + Confirm deletion + Are you sure you want to delete file? + Are you sure you want to delete all files? @@ -330,10 +404,12 @@ trikGui::GyroscopeIndicator + Gyroscope + Error @@ -341,22 +417,27 @@ trikGui::InformationWidget + OS version + Not found + MAC address + Version + Unknown @@ -364,22 +445,27 @@ trikGui::LanguageSelectionWidget + Select language: + English + Language + Warning + GUI will now restart. Do you want to continue? @@ -387,10 +473,15 @@ trikGui::MotorLever + + + off + + on @@ -398,10 +489,12 @@ trikGui::MotorsWidget + Test power motors + Test servo motors @@ -409,14 +502,18 @@ trikGui::NetworkWidget + + Hull number: Rumpfnummer: + IP: + Name: @@ -424,22 +521,30 @@ trikGui::ProgrammingWidget + Add commands to list + + < add command > + + Run program + + Clear list + Programming @@ -447,10 +552,12 @@ trikGui::RunningWidget + Press Power to abort + Running @@ -458,20 +565,24 @@ trikGui::SensorSettingsWidget + Select tacho limit: + Select distance: + Continue + Sensor Settings @@ -479,42 +590,60 @@ trikGui::StartWidget + TRIK + + Testing + More... + + Analog sensors + + PWM Capture + + Digital sensors + + Encoders + + Gyroscope + + Accelerometer + + Camera @@ -522,18 +651,22 @@ trikGui::SystemSettingsWidget + Directory 'Files' is ... + full file system + only 'scripts' directory + System settings @@ -541,22 +674,27 @@ trikGui::UpdateWidget + Update is started... + Update + Update and Upgrade is successfully finished + Upgrade is failed + Update is failed @@ -564,30 +702,37 @@ trikGui::WiFiAPWidget + Network parameters + Name not found + Password not found + IP address not found + Name: + Password: + IP address: @@ -595,38 +740,48 @@ trikGui::WiFiClientWidget + IP: + Name: + Available networks: + connecting... + no connection + error + + Scanning... + Confirm connection + Are you sure you want to connect to open WiFi network? @@ -634,20 +789,24 @@ trikGui::WiFiInitWidget + Network initialization in process + Please wait + Press Escape for break + Network initialization failed @@ -656,18 +815,23 @@ failed trikGui::WiFiModeWidget + Choose mode: + + Wi-Fi client + Wi-Fi access point + Network Config @@ -675,10 +839,12 @@ failed trikScriptRunner::ScriptEngineWorker + Line %1: %2 + File %1 not found @@ -686,6 +852,7 @@ failed trikScriptRunner::ScriptThread + Line %1: %2 @@ -693,6 +860,7 @@ failed trikScriptRunner::Threading + Attempt to create a thread with an already occupied id %1 diff --git a/translations/trikRuntime_fr.ts b/translations/trikRuntime_fr.ts index 421be813a..1c59f37df 100644 --- a/translations/trikRuntime_fr.ts +++ b/translations/trikRuntime_fr.ts @@ -4,6 +4,7 @@ FileSystemFilter + Delete all... @@ -11,30 +12,37 @@ LogWindow + Log window + &Pause + &Save + C&lear + &Copy + Level: + &Auto scroll @@ -42,88 +50,110 @@ QObject + Trace + Debug + Info + Warning + Error + Fatal + Print this help text. + Ignore all locale options and use English language + Path to a directory where all configs for TRIK runtime are stored. Config files are system-config.xml (system-wide configuration of robot hardware for trikControl library) and model-config.xml (configuration of current model). + Path to a directory where core dump will be saved in case of creation. + Positional arguments: + Options + Flags + Graphical user interface, TRIK Studio runtime environment and script runner of a robot + File with script to execute + (optional of -js or -py option is specified) + JavaScript script to be executed directly from command line. + + Example: + Python script to be executed directly from command line. + Disable display support. When this flag is active, trikRun can work without QWS or even physical display + Runner of JavaScript and Python files. @@ -131,14 +161,17 @@ QsLogging::LogWindowModel + Time + Level + Message @@ -146,18 +179,22 @@ QsLogging::Window + &Pause + &Resume + Save log + Log file (*.log) @@ -165,10 +202,12 @@ trikGui::AccelerometerWidget + Accelerometer + Error @@ -176,10 +215,12 @@ trikGui::CameraWidget + Camera + Camera is not available @@ -187,10 +228,12 @@ trikGui::CommandSettingsWidget + Continue + Command Settings @@ -198,70 +241,87 @@ trikGui::CommandsListWidget + Choose command: + Play Tone + Smile + Sad Smile + Timer + Motor Forward + Motor Backward + Motors Stop + Wait for Light + Wait for Ultrasonic Distance + Wait for Infrared Distance + Wait for Encoder + Commands List + Choose waiting time (ms): + Delay %1 ms + < add command > + Choose motors power (%): @@ -269,30 +329,37 @@ trikGui::CommunicationSettingsWidget + <b>Comm settings</b> + (Press 'Enter' to edit) + Hull number: + Leader IP: + (last two numbers) + Connect + Comm settings @@ -300,6 +367,7 @@ trikGui::Controller + direct command @@ -307,22 +375,28 @@ trikGui::FileManagerWidget + Delete all... + File Manager + + Confirm deletion + Are you sure you want to delete file? + Are you sure you want to delete all files? @@ -330,10 +404,12 @@ trikGui::GyroscopeIndicator + Gyroscope + Error @@ -341,22 +417,27 @@ trikGui::InformationWidget + OS version + Not found + MAC address + Version + Unknown @@ -364,22 +445,27 @@ trikGui::LanguageSelectionWidget + Select language: + English + Language + Warning + GUI will now restart. Do you want to continue? @@ -387,10 +473,15 @@ trikGui::MotorLever + + + off + + on @@ -398,10 +489,12 @@ trikGui::MotorsWidget + Test power motors + Test servo motors @@ -409,14 +502,18 @@ trikGui::NetworkWidget + + Hull number: + IP: + Name: @@ -424,22 +521,30 @@ trikGui::ProgrammingWidget + Add commands to list + + < add command > + + Run program + + Clear list + Programming @@ -447,10 +552,12 @@ trikGui::RunningWidget + Press Power to abort + Running @@ -458,20 +565,24 @@ trikGui::SensorSettingsWidget + Select tacho limit: + Select distance: + Continue + Sensor Settings @@ -479,42 +590,60 @@ trikGui::StartWidget + TRIK + + Testing + More... + + Analog sensors + + PWM Capture + + Digital sensors + + Encoders + + Gyroscope + + Accelerometer + + Camera @@ -522,18 +651,22 @@ trikGui::SystemSettingsWidget + Directory 'Files' is ... + full file system + only 'scripts' directory + System settings @@ -541,22 +674,27 @@ trikGui::UpdateWidget + Update is started... + Update + Update and Upgrade is successfully finished + Upgrade is failed + Update is failed @@ -564,30 +702,37 @@ trikGui::WiFiAPWidget + Network parameters + Name not found + Password not found + IP address not found + Name: + Password: + IP address: @@ -595,38 +740,48 @@ trikGui::WiFiClientWidget + IP: + Name: + Available networks: + connecting... + no connection + error + + Scanning... + Confirm connection + Are you sure you want to connect to open WiFi network? @@ -634,20 +789,24 @@ trikGui::WiFiInitWidget + Network initialization in process + Please wait + Press Escape for break + Network initialization failed @@ -656,18 +815,23 @@ failed trikGui::WiFiModeWidget + Choose mode: + + Wi-Fi client + Wi-Fi access point + Network Config @@ -675,10 +839,12 @@ failed trikScriptRunner::ScriptEngineWorker + Line %1: %2 + File %1 not found @@ -686,6 +852,7 @@ failed trikScriptRunner::ScriptThread + Line %1: %2 @@ -693,6 +860,7 @@ failed trikScriptRunner::Threading + Attempt to create a thread with an already occupied id %1 diff --git a/translations/trikRuntime_ru.ts b/translations/trikRuntime_ru.ts index 4484ede06..c593c1815 100644 --- a/translations/trikRuntime_ru.ts +++ b/translations/trikRuntime_ru.ts @@ -4,6 +4,7 @@ FileSystemFilter + Delete all... Удалить всё... @@ -11,30 +12,37 @@ LogWindow + Log window Окно журнала + &Pause &Пауза + &Save &Сохранить + C&lear О&чистить + &Copy &Копировать + Level: Уровень: + &Auto scroll &Автопрокрутка @@ -42,18 +50,22 @@ QObject + Graphical user interface, TRIK Studio runtime environment and script runner of a robot Графический интерфейс, среда времени выполнения для TRIK Studio и исполнитель скриптов на роботе + Print this help text. Распечатать это сообщение. + Ignore all locale options and use English language Игнорировать настройки локали и использовать английский язык (Ignore all locale options and use English language) + Path to a directory where all configs for TRIK runtime are stored. Config files are system-config.xml (system-wide configuration of robot hardware for trikControl library) and model-config.xml (configuration of current model). @@ -62,18 +74,22 @@ model-config.xml (настройки конкретной модели). + Path to a directory where core dump will be saved in case of creation. Путь к папке, в которую будет сохранен core dump в случае создания. + Positional arguments: Позиционные аргументы: + Options Опции + Flags Флаги @@ -83,54 +99,68 @@ Скрипт, который надо исполнить прямо из командной строки. + File with script to execute Файл со скриптом, который надо исполнить + (optional of -js or -py option is specified) (этот параметр не надо указывать, если указан параметр -js или -py) + JavaScript script to be executed directly from command line. JavaScript cкрипт, который надо исполнить прямо из командной строки. + Python script to be executed directly from command line. Python cкрипт, который надо исполнить прямо из командной строки. + + Example: Пример: + Disable display support. When this flag is active, trikRun can work without QWS or even physical display Отключает поддержку дисплея. С этим флагом trikRun может работать без ключа -qws и даже без физического дисплея + Runner of JavaScript and Python files. Интерпретатор скриптов на JavaScript и Python для ТРИК. + Warning Внимание + Error Ошибка + Trace След + Debug Отладка + Info Инфо + Fatal Фатально @@ -138,14 +168,17 @@ QsLogging::LogWindowModel + Time Время + Level Уровень + Message Сообщение @@ -153,18 +186,22 @@ QsLogging::Window + &Pause &Пауза + &Resume &Возобновить + Save log Сохранить логи + Log file (*.log) Файл логов (*.log) @@ -172,10 +209,12 @@ trikGui::AccelerometerWidget + Accelerometer Акселерометр + Error Ошибка @@ -183,10 +222,12 @@ trikGui::CameraWidget + Camera Камера + Camera is not available Камера недоступна @@ -194,10 +235,12 @@ trikGui::CommandSettingsWidget + Continue Продолжить + Command Settings Настройки команды @@ -205,6 +248,7 @@ trikGui::CommandsListWidget + Choose command: Выберите команду: @@ -213,56 +257,69 @@ Очистить + Play Tone Играть звук + Smile Смайлик + Sad Smile Грустный смайлик + Timer Таймер + Motor Forward Моторы вперёд + Motor Backward Моторы назад + Motors Stop Моторы стоп + Wait for Light Ждать свет + Wait for Ultrasonic Distance Ждать УЗ датчик + Wait for Infrared Distance Ждать ИК датчик + Commands List Список команд + Choose waiting time (ms): Выберите время ожидания (в миллисекундах): + Delay %1 ms Задержка %1 мс @@ -275,14 +332,17 @@ Ждать + < add command > < новая команда > + Choose motors power (%): Выберите мощность моторов (в процентах): + Wait for Encoder Ждать энкодер @@ -290,22 +350,27 @@ trikGui::CommunicationSettingsWidget + <b>Comm settings</b> <b>Взаимодействие</b> + Hull number: Бортномер: + Leader IP: IP ведущего: + Connect Подключиться + Comm settings Взаимодействие @@ -314,10 +379,12 @@ 'Enter' для изменения + (Press 'Enter' to edit) ('Enter' для изменения) + (last two numbers) (последние два числа) @@ -325,6 +392,7 @@ trikGui::Controller + direct command команда с компьютера @@ -351,22 +419,28 @@ Удалить всё + Delete all... Удалить всё... + File Manager Файлы + + Confirm deletion Удаление + Are you sure you want to delete file? Вы уверены, что хотите удалить файл? + Are you sure you want to delete all files? Вы уверены, что хотите удалить все файлы? @@ -374,10 +448,12 @@ trikGui::GyroscopeIndicator + Gyroscope Гироскоп + Error Ошибка @@ -385,22 +461,27 @@ trikGui::InformationWidget + Not found Не найден + MAC address MAC-адрес + OS version Версия ОС + Version Версия ПО + Unknown Неизвестна @@ -408,22 +489,27 @@ trikGui::LanguageSelectionWidget + Select language: Выберите язык: + English English + Language Язык / Language + Warning Внимание + GUI will now restart. Do you want to continue? Контроллер сейчас перегрузится. Вы действительно хотите продолжить? @@ -431,10 +517,15 @@ trikGui::MotorLever + + + off выкл + + on вкл @@ -442,10 +533,12 @@ trikGui::MotorsWidget + Test power motors Силовые моторы + Test servo motors Сервоприводы @@ -453,14 +546,18 @@ trikGui::NetworkWidget + + Hull number: Бортномер: + IP: IP: + Name: Имя: @@ -468,23 +565,31 @@ trikGui::ProgrammingWidget + Add commands to list Добавьте команду в список + + < add command > < новая команда > + + Run program Запустить программу + Programming Программирование + + Clear list Очистить список @@ -502,10 +607,12 @@ чтобы выйти + Running Выполняется + Press Power to abort Нажмите кнопку Питание для выхода @@ -517,20 +624,24 @@ Выберите расстояние: + Continue Продолжить + Sensor Settings Настройки датчиков + Select distance: Выберите расстояние: + Select tacho limit: Выберите предел оборотов: @@ -544,42 +655,60 @@ Выход + TRIK ТРИК + + Testing Тестирование + More... Еще... + + Analog sensors Аналоговые датчики + + PWM Capture ШИМ захват + + Digital sensors Цифровые датчики + + Encoders Энкодеры + + Gyroscope Гироскоп + + Accelerometer Акселерометр + + Camera Камера @@ -587,18 +716,22 @@ trikGui::SystemSettingsWidget + Directory 'Files' is ... Папка 'Файлы' - это ... + System settings Настройки системы + full file system файловая система + only 'scripts' directory папка со скриптами @@ -606,22 +739,27 @@ trikGui::UpdateWidget + Update is started... Обновление начато... + Update Обновление ПО + Update is failed Во время обновления (update) произошла ошибка + Update and Upgrade is successfully finished Обновление успешно завершено + Upgrade is failed Во время обновления (upgrade) произошла ошибка @@ -644,30 +782,37 @@ trikGui::WiFiAPWidget + Network parameters Параметры сети + IP address: IP-адрес: + Name not found Имя не найдено + Password not found Пароль не найден + Name: Имя: + Password: Пароль: + IP address not found IP-адрес не найден @@ -675,38 +820,48 @@ trikGui::WiFiClientWidget + IP: IP: + Available networks: Доступные сети: + connecting... соединение... + no connection нет соединения + Name: Имя: + error ошибка + + Scanning... Поиск... + Confirm connection Подтверждение + Are you sure you want to connect to open WiFi network? Вы действительно хотите подключиться к незащищённой сети? @@ -714,17 +869,20 @@ trikGui::WiFiInitWidget + Please wait Пожалуйста, подождите + Network initialization in process Идёт инициализация сети + Network initialization failed Не удалось @@ -733,6 +891,7 @@ failed сети + Press Escape for break Чтобы прервать @@ -743,18 +902,23 @@ Escape trikGui::WiFiModeWidget + Choose mode: Выберите режим: + + Wi-Fi client Wi-Fi клиент + Wi-Fi access point Wi-Fi точка доступа + Network Config Сеть @@ -762,10 +926,12 @@ Escape trikScriptRunner::ScriptEngineWorker + Line %1: %2 Строка %1: %2 + File %1 not found Файл %1 не найден @@ -773,6 +939,7 @@ Escape trikScriptRunner::ScriptThread + Line %1: %2 Строка %1: %2 @@ -780,6 +947,7 @@ Escape trikScriptRunner::Threading + Attempt to create a thread with an already occupied id %1 Попытка создать поток с уже занятым идентификатором %1 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/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..5827e51cb 100644 --- a/trikControl/include/trikControl/gyroSensorInterface.h +++ b/trikControl/include/trikControl/gyroSensorInterface.h @@ -33,26 +33,27 @@ class TRIKCONTROL_EXPORT GyroSensorInterface : public VectorSensorInterface /// 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..882977d13 100644 --- a/trikControl/include/trikControl/irCameraInterface.h +++ b/trikControl/include/trikControl/irCameraInterface.h @@ -38,15 +38,16 @@ 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: /// Emitted when new image is ready. diff --git a/trikControl/include/trikControl/lineSensorInterface.h b/trikControl/include/trikControl/lineSensorInterface.h index a10c69e7c..e192eb278 100644 --- a/trikControl/include/trikControl/lineSensorInterface.h +++ b/trikControl/include/trikControl/lineSensorInterface.h @@ -34,7 +34,7 @@ class TRIKCONTROL_EXPORT LineSensorInterface : public QObject, public DeviceInte /// 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/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/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/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/objectSensor.cpp b/trikControl/src/objectSensor.cpp index 6247c8faf..8ef29fc7c 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; 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/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/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..c07d5649d 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 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..b3f181739 100644 --- a/trikGui/backgroundWidget.h +++ b/trikGui/backgroundWidget.h @@ -63,11 +63,11 @@ class BackgroundWidget : public QWidget private 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/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/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/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/lazyMainWidget.h b/trikGui/lazyMainWidget.h index a905a9cdd..ed76de806 100644 --- a/trikGui/lazyMainWidget.h +++ b/trikGui/lazyMainWidget.h @@ -39,7 +39,7 @@ class LazyMainWidget : public MainWidget 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/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/numberSelectionWidget.cpp b/trikGui/numberSelectionWidget.cpp index bcec01c06..ed00fcda1 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) { 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/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/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/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/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/src/trik/trikIIOFile.cpp b/trikHal/src/trik/trikIIOFile.cpp index aba3f73c5..bc05c463b 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()); + } + + emit newData(std::move(sensorValues), eventTime); } mSocketNotifier->setEnabled(true); 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..d5371dc11 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); t.setSingleShot(true); t.start(0); loop.exec(); 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/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/src/pythonEngineWorker.cpp b/trikScriptRunner/src/pythonEngineWorker.cpp index ec2756b7e..e00fc6a73 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);}); diff --git a/trikScriptRunner/src/scriptExecutionControl.h b/trikScriptRunner/src/scriptExecutionControl.h index 384783e1d..81d25ce21 100644 --- a/trikScriptRunner/src/scriptExecutionControl.h +++ b/trikScriptRunner/src/scriptExecutionControl.h @@ -82,16 +82,6 @@ public slots: /// Resets script execution state, clearing all flags and stopping all timers. void reset() override; -signals: - /// Emitted when script requested system to abort execution. - void quitSignal(); - - /// To be connected to quit() slot of local event loops that are used for waiting. - void stopWaiting(); - - /// Requests sending a message to a desktop. - void textInStdOut(const QString &text); - private: QList mTimers; // Has ownership. trikControl::BrickInterface *mBrick {}; //Does not have ownership diff --git a/trikWiFi/src/trikWiFiWorker.cpp b/trikWiFi/src/trikWiFiWorker.cpp index f1abc064a..f77acf3de 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"; }