diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b061d2e7f8a0dc8d6bbea32a706741c8a11a5b3..20882fc693458e2da020e72976083593e8560ff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set(MINGW_MSVCR_LIBRARY msvcrt CACHE STRING "Mingw MSVC runtime import library") add_subdirectory(libs/backward-cpp) # Qt5 and its modules -find_package(Qt5 REQUIRED COMPONENTS Widgets SerialPort PrintSupport 3DCore 3DExtras 3DRender 3DInput) +find_package(Qt6 REQUIRED COMPONENTS Widgets SerialPort PrintSupport 3DCore 3DExtras 3DRender 3DInput) add_executable(skywardhub # Primary files @@ -97,13 +97,13 @@ add_executable(skywardhub ) target_include_directories(skywardhub PRIVATE src/shared) target_link_libraries(skywardhub PUBLIC - Qt5::Widgets - Qt5::SerialPort - Qt5::PrintSupport - Qt5::3DCore - Qt5::3DExtras - Qt5::3DRender - Qt5::3DInput + Qt::Widgets + Qt::SerialPort + Qt::PrintSupport + Qt::3DCore + Qt::3DExtras + Qt::3DRender + Qt::3DInput Mavlink::Mavlink ) diff --git a/src/main.cpp b/src/main.cpp index 590a72e2d33541c2b67e4c208ec4e54ed5939b50..c8241e5418b80b2c57ce28548e40a22401558b20 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,7 @@ #include <Core/SkywardHubCore.h> #include <QApplication> +#include <QDebug> #include <QFile> #include "Core/CrashLogger.h" @@ -27,6 +28,9 @@ int main(int argc, char *argv[]) { QApplication application(argc, argv); + qDebug() << "WARNING: Hi mom!"; + qWarning() << "WARNING: Hi mom!"; + // Set application theme QFile styleSheet(":/assets/styles/global.qss"); styleSheet.open(QFile::ReadOnly); diff --git a/src/shared/Components/ErrorDisplayer/Error.cpp b/src/shared/Components/ErrorDisplayer/Error.cpp index 3162295745cd221c9e9016307db2aa10ac3a84bc..9cea81cb6bd4a65a16ece8a2b41a523d8d6fda32 100644 --- a/src/shared/Components/ErrorDisplayer/Error.cpp +++ b/src/shared/Components/ErrorDisplayer/Error.cpp @@ -31,7 +31,7 @@ Error::Error(ErrorDisplayer* _displayer, QString _title, QString _description, type = _type; layout.setSpacing(0); - layout.setMargin(0); + layout.setContentsMargins(0, 0, 0, 0); // setMaximumHeight(100); setMaximumWidth(250); @@ -116,7 +116,7 @@ void Error::mouseReleaseEvent(QMouseEvent* e) void Error::paintEvent(QPaintEvent* event) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); QWidget::paintEvent(event); diff --git a/src/shared/Components/ToggleButton/ToggleButton.cpp b/src/shared/Components/ToggleButton/ToggleButton.cpp index 38fe4ac66cf8418173915c2adcd93779e28a6a02..3b85354926ad8baba544123aa16c02f9ef465bae 100644 --- a/src/shared/Components/ToggleButton/ToggleButton.cpp +++ b/src/shared/Components/ToggleButton/ToggleButton.cpp @@ -103,7 +103,7 @@ void ToggleButton::changeState(bool state) } } -void ToggleButton::enterEvent(QEvent* e) +void ToggleButton::enterEvent(QEnterEvent* e) { setCursor(Qt::PointingHandCursor); QAbstractButton::enterEvent(e); diff --git a/src/shared/Components/ToggleButton/ToggleButton.h b/src/shared/Components/ToggleButton/ToggleButton.h index 66121855298d363087c8ef7e6200ca2f6eca711f..b4975f3aa25cb80e52f3dd2c5c7a0057160205e9 100644 --- a/src/shared/Components/ToggleButton/ToggleButton.h +++ b/src/shared/Components/ToggleButton/ToggleButton.h @@ -54,7 +54,7 @@ signals: protected: void paintEvent(QPaintEvent*) override; void mouseReleaseEvent(QMouseEvent*) override; - void enterEvent(QEvent*) override; + void enterEvent(QEnterEvent*) override; void changeState(bool state); private: diff --git a/src/shared/Core/Message/Field.cpp b/src/shared/Core/Message/Field.cpp index 75d53204a2227cb68a619aa43a2a0a124fce394f..05e1f69d058965ffa101a22d652530b99f107504 100644 --- a/src/shared/Core/Message/Field.cpp +++ b/src/shared/Core/Message/Field.cpp @@ -18,7 +18,7 @@ #include "Field.h" -#include <QRegExp> +#include <QRegularExpression> Field::Field() : type(Type::EMPTY) {} @@ -103,10 +103,10 @@ QString Field::toString() const QString str = QString::number(floatingPoint, 'f', 8); // Remove any number of trailing 0's - str.remove(QRegExp("0+$")); + str.remove(QRegularExpression("0+$")); // If the last character is just a '.' then remove it - str.remove(QRegExp("\\.$")); + str.remove(QRegularExpression("\\.$")); return str; } diff --git a/src/shared/Core/Message/Topic.cpp b/src/shared/Core/Message/Topic.cpp index e665063cfc77dac2e7113b7f388ad272280964b3..5691418800c2091547f7b9aac444bbda86086fc6 100644 --- a/src/shared/Core/Message/Topic.cpp +++ b/src/shared/Core/Message/Topic.cpp @@ -18,7 +18,7 @@ #include "Topic.h" -#include <QRegExp> +#include <QRegularExpression> Topic::Topic() : topic("") {} @@ -70,7 +70,8 @@ Topic Topic::getPrefix() const bool Topic::isValid() const { - return topic.contains(QRegExp("^[A-Za-z0-9$_]+(\\/[A-Za-z0-9$_]+)*$")); + return topic.contains( + QRegularExpression("^[A-Za-z0-9$_]+(\\/[A-Za-z0-9$_]+)*$")); } bool Topic::isWildcard() const diff --git a/src/shared/Core/QCustomPlot/QCustomPlot.h b/src/shared/Core/QCustomPlot/QCustomPlot.h index 45b1a36db20d35a9f0603712035363d5c64082bf..7979ee302bec1499849e9c8af3d04dc373a10a61 100644 --- a/src/shared/Core/QCustomPlot/QCustomPlot.h +++ b/src/shared/Core/QCustomPlot/QCustomPlot.h @@ -160,29 +160,9 @@ class QCPPolarGraph; It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject. */ -#ifndef Q_MOC_RUN namespace QCP { -#else -class QCP -{ // when in moc-run, make it look like a class, so we get Q_GADGET, - // Q_ENUMS/Q_FLAGS features in namespace - Q_GADGET - Q_ENUMS(ExportPen) - Q_ENUMS(ResolutionUnit) - Q_ENUMS(SignDomain) - Q_ENUMS(MarginSide) - Q_FLAGS(MarginSides) - Q_ENUMS(AntialiasedElement) - Q_FLAGS(AntialiasedElements) - Q_ENUMS(PlottingHint) - Q_FLAGS(PlottingHints) - Q_ENUMS(Interaction) - Q_FLAGS(Interactions) - Q_ENUMS(SelectionRectMode) - Q_ENUMS(SelectionType) -public: -#endif +Q_NAMESPACE /*! Defines the different units in which the image resolution can be specified in @@ -445,6 +425,20 @@ enum SelectionType ///< selected }; +Q_ENUM_NS(ExportPen) +Q_ENUM_NS(ResolutionUnit) +Q_ENUM_NS(SignDomain) +Q_ENUM_NS(MarginSide) +Q_FLAG_NS(MarginSides) +Q_ENUM_NS(AntialiasedElement) +Q_FLAG_NS(AntialiasedElements) +Q_ENUM_NS(PlottingHint) +Q_FLAG_NS(PlottingHints) +Q_ENUM_NS(Interaction) +Q_FLAG_NS(Interactions) +Q_ENUM_NS(SelectionRectMode) +Q_ENUM_NS(SelectionType) + /*! \internal Returns whether the specified \a value is considered an invalid data value for @@ -522,25 +516,13 @@ inline int getMarginValue(const QMargins &margins, QCP::MarginSide side) return 0; } -extern const QMetaObject - staticMetaObject; // in moc-run we create a static meta object for QCP - // "fake" object. This line is the link to it via - // QCP::staticMetaObject in normal operation as namespace - } // end of namespace QCP Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) -Q_DECLARE_METATYPE(QCP::ExportPen) -Q_DECLARE_METATYPE(QCP::ResolutionUnit) -Q_DECLARE_METATYPE(QCP::SignDomain) -Q_DECLARE_METATYPE(QCP::MarginSide) -Q_DECLARE_METATYPE(QCP::AntialiasedElement) -Q_DECLARE_METATYPE(QCP::PlottingHint) -Q_DECLARE_METATYPE(QCP::Interaction) -Q_DECLARE_METATYPE(QCP::SelectionRectMode) -Q_DECLARE_METATYPE(QCP::SelectionType) +// no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as +// metatype automatically /* end of 'src/global.h' */ diff --git a/src/shared/Core/SkywardHubCore.cpp b/src/shared/Core/SkywardHubCore.cpp index daa743efe2b4525183d051aa111b970546ec077b..bb032ceba1e4e526684b10c15a2b55a233078956 100644 --- a/src/shared/Core/SkywardHubCore.cpp +++ b/src/shared/Core/SkywardHubCore.cpp @@ -27,6 +27,7 @@ #include <QCloseEvent> #include <QDir> +#include <QGuiApplication> #include <QMessageBox> SkywardHubCore& SkywardHubCore::getInstance() @@ -136,7 +137,12 @@ void SkywardHubCore::addWindowFromXml(XmlObject settings) { Window* newWindow = new Window(settings); newWindow->show(); - newWindow->activateWindow(); + + if (QGuiApplication::platformName() != "wayland") + { + newWindow->activateWindow(); + } + newWindow->setStyleSheet(activeThemeStyleSheet); windowsList.push_back(newWindow); diff --git a/src/shared/Core/XmlObject.cpp b/src/shared/Core/XmlObject.cpp index dc6b504be33bcb55d56daba44594e250b04109eb..759217f62f47a89be5be259e101d4338b0623fb7 100644 --- a/src/shared/Core/XmlObject.cpp +++ b/src/shared/Core/XmlObject.cpp @@ -43,14 +43,15 @@ bool XmlObject::loadFromFile(const QString& filePath) return result; } -bool XmlObject::writeToFile(const QString& filePath, const QString& codec) const +bool XmlObject::writeToFile(const QString& filePath, + const QStringConverter::Encoding& encoding) const { bool result = false; QFile file(filePath); if (file.open(QIODevice::WriteOnly)) { QTextStream textStream(&file); - textStream.setCodec(codec.toUtf8()); + textStream.setEncoding(encoding); textStream << this->toXml(); file.close(); result = true; @@ -194,9 +195,9 @@ void XmlObject::swapChildAt(int i, int j) QString XmlObject::getChildObjectValue(const QString& objectName) { - auto result = std::find_if(childList.begin(), childList.end(), - [&](XmlObject child) - { return child.getObjectName() == objectName; }); + auto result = + std::find_if(childList.begin(), childList.end(), [&](XmlObject child) + { return child.getObjectName() == objectName; }); if (result != childList.end()) return result->getTextValue(); diff --git a/src/shared/Core/XmlObject.h b/src/shared/Core/XmlObject.h index f8cf20b638f96b9c26761719588e1a9ae5c6e338..cd115a2961e6d76b355d9e4fe6c22b076e911fd0 100644 --- a/src/shared/Core/XmlObject.h +++ b/src/shared/Core/XmlObject.h @@ -31,7 +31,8 @@ public: bool loadFromFile(const QString& filePath); bool writeToFile(const QString& filePath, - const QString& codec = "UTF-8") const; + const QStringConverter::Encoding& encoding = + QStringConverter::Encoding::Utf8) const; QString toXml() const; void fromXml(const QString& txt); diff --git a/src/shared/Modules/CompactCommandPad/CommandSelector.cpp b/src/shared/Modules/CompactCommandPad/CommandSelector.cpp index 24497f54ce7717ee724948c67d748ac13a866861..e05a361e5b8d95f2ebc5d3e7fef97cc3d199c4b9 100644 --- a/src/shared/Modules/CompactCommandPad/CommandSelector.cpp +++ b/src/shared/Modules/CompactCommandPad/CommandSelector.cpp @@ -38,7 +38,7 @@ XmlObject CommandSelector::toXmlObject(XmlObject& obj) bool ok; long timeout = continuosTimeoutEdit->text().toUInt(&ok); if (ok) - obj.addAttribute("timeout", QString() + timeout); + obj.addAttribute("timeout", QString("%1").arg(timeout)); auto key = messagesListComboBox->currentText(); if (formElements.contains(key)) @@ -59,7 +59,7 @@ void CommandSelector::fromXmlObject(const XmlObject& obj) timeout = str.toUInt(&ok); if (ok) - continuosTimeoutEdit->setText(QString() + timeout); + continuosTimeoutEdit->setText(QString("%1").arg(timeout)); if (obj.hasAttribute("message_id")) { @@ -102,8 +102,7 @@ void CommandSelector::setupUi() continuosCheck->setText("Continuos Send"); outerLayout->addWidget(continuosCheck); QObject::connect( - continuosCheck, &QCheckBox::stateChanged, - [this]() + continuosCheck, &QCheckBox::stateChanged, [this]() { continuosTimeoutEdit->setHidden(!continuosCheck->isChecked()); }); continuosTimeoutEdit = new QLineEdit(); diff --git a/src/shared/Modules/Mavlink/BaseMavlinkModule.h b/src/shared/Modules/Mavlink/BaseMavlinkModule.h index d7911d1022f2198163167981423f0463bba1132d..77a2c75f37133e2628a3903aec37783441aae406 100644 --- a/src/shared/Modules/Mavlink/BaseMavlinkModule.h +++ b/src/shared/Modules/Mavlink/BaseMavlinkModule.h @@ -28,8 +28,6 @@ #include "MavlinkCodec.h" #include "Ports/MavlinkPort.h" -Q_DECLARE_METATYPE(Message); - namespace Ui { class BaseMavlinkModule; @@ -86,4 +84,4 @@ private: int msgArrived = 0; static int ACTIVE_MAVLINK_MODULES; -}; \ No newline at end of file +}; diff --git a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp index 78ea1c8bea75f687035b0b919a53d7e5af2f380f..d06812799b9cb1c4923682e5eb85b83416e75c8d 100644 --- a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp +++ b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp @@ -19,11 +19,11 @@ #include "OrientationVisualizer.h" #include <QBoxLayout> +#include <Qt3DCore/QAttribute> +#include <Qt3DCore/QBuffer> #include <Qt3DExtras/QConeMesh> #include <Qt3DExtras/QPhongMaterial> #include <Qt3DExtras/Qt3DWindow> -#include <Qt3DRender/QAttribute> -#include <Qt3DRender/QBuffer> #include <Qt3DRender/QCamera> OrientationVisualizer::OrientationVisualizer() diff --git a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h index 062b3ea4bf75f65fdd33d591117e39fa33344f3e..07817d26fc63073fa86b9f55c9c07750ee863628 100644 --- a/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h +++ b/src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h @@ -21,11 +21,13 @@ #include <Modules/Module.h> #include <Qt3DRender/qpointlight.h> +#include <QGeometry> #include <QMesh> #include <QSizePolicy> #include <QSortPolicy> #include <QVector3D> #include <Qt3DCore/QAspectEngine> +#include <Qt3DCore/QBuffer> #include <Qt3DCore/QEntity> #include <Qt3DCore/QTransform> #include <Qt3DExtras/QConeMesh> @@ -40,11 +42,8 @@ #include <Qt3DExtras/QTorusMesh> #include <Qt3DExtras/Qt3DWindow> #include <Qt3DInput/QInputAspect> -#include <Qt3DRender/QAttribute> -#include <Qt3DRender/QBuffer> #include <Qt3DRender/QCamera> #include <Qt3DRender/QCameraLens> -#include <Qt3DRender/QGeometry> #include <Qt3DRender/QGeometryRenderer> #include <Qt3DRender/QRenderAspect> diff --git a/src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp b/src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp index 7be4f30fbfee0ab866173d302f8f741b90eb17ff..768eb5eff5c6fc2f9e01605a7c6cbf7f312ca7cc 100644 --- a/src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp +++ b/src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp @@ -38,13 +38,11 @@ OutgoingMessagesViewerModule::OutgoingMessagesViewerModule() MessageBroker::getInstance().subscribe( Filter::fromString(SkywardHubStrings::mavlink_received_msg_ACK_topic), - this, - [this](const Message& message, const Filter& filter) + this, [this](const Message& message, const Filter& filter) { handleAck(message); }); MessageBroker::getInstance().subscribe( Filter::fromString(SkywardHubStrings::mavlink_received_msg_NACK_topic), - this, - [this](const Message& message, const Filter& filter) + this, [this](const Message& message, const Filter& filter) { handleNack(message); }); MessageBroker::getInstance().subscribe( Filter::fromString(SkywardHubStrings::mavlink_received_msg_WACK_topic),