diff --git a/CMakeLists.txt b/CMakeLists.txt index 82372af8417c126345c9ff31415d064163488196..45afe4c4697b6ab149285997af50bfc180b79f8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ find_package(Qt5 REQUIRED COMPONENTS ) add_executable(groundstation - src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.cpp src/shared/Components/ModulesPicker/ModulesPicker.cpp src/shared/Components/SaveConfigurationDialog/SaveConfigurationDialog.cpp src/shared/Components/SubscriptionsPanel/SubscriptionsPanel.cpp @@ -73,14 +72,8 @@ add_executable(groundstation src/shared/Modules/Mavlink/MavlinkCommandAdapter.cpp src/shared/Modules/Mavlink/MavlinkModule.cpp src/shared/Modules/Mavlink/MavlinkReader.cpp - src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.cpp src/shared/Modules/Mavlink/MavlinkWriter.cpp src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp - src/shared/Modules/SkywardHub/Deployer.cpp - src/shared/Modules/SkywardHub/DeployerPathPicker.cpp - src/shared/Modules/SkywardHub/PrefabDialog.cpp - src/shared/Modules/SkywardHub/PrefabViewElement.cpp - src/shared/Modules/SkywardHub/SkywardHubModule.cpp src/shared/Modules/Splitter/Splitter.cpp src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp src/shared/Modules/StateViewer/StateViewer.cpp diff --git a/SkywardHub.pro b/SkywardHub.pro index c5f3472aabce1eb94f5af97510dfac0dbd3c196f..44f2eedfa475a2c765fa2de5bc3d7ee90a47216f 100644 --- a/SkywardHub.pro +++ b/SkywardHub.pro @@ -26,11 +26,6 @@ SOURCES += \ src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.cpp \ src/shared/Modules/TimerController/TimerControllerModule.cpp \ src/shared/Modules/OrientationVisualizer/OrientationVisualizer.cpp \ - src/shared/Modules/SkywardHub/PrefabViewElement.cpp \ - src/shared/Modules/SkywardHub/PrefabDialog.cpp \ - src/shared/Modules/SkywardHub/DeployerPathPicker.cpp \ - src/shared/Modules/SkywardHub/Deployer.cpp \ - src/shared/Modules/SkywardHub/SkywardHubModule.cpp \ src/shared/Modules/StateViewer/StateViewer.cpp \ src/shared/Modules/FileStream/FileStreamModule.cpp \ src/shared/Modules/Graph/Graph.cpp \ @@ -52,7 +47,6 @@ SOURCES += \ src/shared/Modules/Mavlink/MavlinkReader.cpp \ src/shared/Modules/Mavlink/MavlinkCommandAdapter.cpp \ src/shared/Modules/Mavlink/MavlinkModule.cpp \ - src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.cpp \ src/shared/Core/EventHandler/EventHandler.cpp \ src/shared/Core/XmlObject.cpp \ src/shared/Core/QCustomPlot/QCustomPlot.cpp \ @@ -64,7 +58,6 @@ SOURCES += \ src/shared/Core/Message/Topic.cpp \ src/shared/Core/Message/Message.cpp \ src/shared/Core/ModulesManager/ModulesManager.cpp \ - src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.cpp \ src/shared/Components/FilterSelector/FilterSelector.cpp \ src/shared/Components/ModulesPicker/ModulesPicker.cpp \ src/shared/Components/SaveConfigurationDialog/SaveConfigurationDialog.cpp \ @@ -83,11 +76,6 @@ HEADERS += \ src/shared/Modules/TimerController/TimerControllerModule.h \ src/shared/Modules/ModuleInfo.h \ src/shared/Modules/OrientationVisualizer/OrientationVisualizer.h \ - src/shared/Modules/SkywardHub/SkywardHubModule.h \ - src/shared/Modules/SkywardHub/PrefabDialog.h \ - src/shared/Modules/SkywardHub/Deployer.h \ - src/shared/Modules/SkywardHub/DeployerPathPicker.h \ - src/shared/Modules/SkywardHub/PrefabViewElement.h \ src/shared/Modules/StateViewer/StatesList.h \ src/shared/Modules/StateViewer/StateViewer.h \ src/shared/Modules/FileStream/FileStreamModule.h \ @@ -107,7 +95,6 @@ HEADERS += \ src/shared/Modules/CompactCommandPad/SendThread.h \ src/shared/Modules/Tabs/TabsModule.h \ src/shared/Modules/Mavlink/MavlinkReader.h \ - src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.h \ src/shared/Modules/Mavlink/MavlinkWriter.h \ src/shared/Modules/Mavlink/MavlinkVersionHeader.h \ src/shared/Modules/Mavlink/MavlinkModule.h \ @@ -124,7 +111,6 @@ HEADERS += \ src/shared/Core/Message/Field.h \ src/shared/Core/Message/Topic.h \ src/shared/Core/ModulesManager/ModulesManager.h \ - src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.h \ src/shared/Components/FilterSelector/FilterSelector.h \ src/shared/Components/ModulesPicker/ModulesPicker.h \ src/shared/Components/SaveConfigurationDialog/SaveConfigurationDialog.h \ @@ -139,14 +125,9 @@ FORMS += \ src/shared/Modules/ValuesConverterViewer/ValuesViewerConfigPanel.ui \ src/shared/Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.ui \ src/shared/Modules/TimerController/TimerControllerModule.ui \ - src/shared/Modules/SkywardHub/SkywardHubModule.ui \ - src/shared/Modules/SkywardHub/PrefabViewElement.ui \ - src/shared/Modules/SkywardHub/PrefabDialog.ui \ - src/shared/Modules/SkywardHub/DeployerPathPicker.ui \ src/shared/Modules/FileStream/FileStreamModule.ui \ src/shared/Modules/Test/TestModule.ui \ src/shared/Modules/MainWindow/Window.ui \ - src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.ui \ src/shared/Components/ModulesPicker/ModulesPicker.ui \ src/shared/Components/SaveConfigurationDialog/SaveConfigurationDialog.ui \ diff --git a/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.cpp b/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.cpp deleted file mode 100644 index 285ef873c4ec5a78e4ab58ac68859059d3755250..0000000000000000000000000000000000000000 --- a/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "ContextMenuSeparator.h" - -ContextMenuSeparator::ContextMenuSeparator(QWidget *parent) - : QWidgetAction(parent) -{ - build(); -} - -ContextMenuSeparator::ContextMenuSeparator(const QString &txt, QWidget *parent) - : QWidgetAction(parent) -{ - setText(txt); - build(); -} - -ContextMenuSeparator::~ContextMenuSeparator() {} - -void ContextMenuSeparator::setHeight(int val) { label.setMaximumHeight(val); } - -void ContextMenuSeparator::setText(const QString &txt) { label.setText(txt); } - -void ContextMenuSeparator::build() -{ - setHeight(2); - // grayish style - label.setStyleSheet("background: #DBDBDB;"); - // possible alignment - label.setAlignment(Qt::AlignCenter); - setDefaultWidget(&label); -} diff --git a/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.h b/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.h deleted file mode 100644 index 46888c4ebe05b509c94407e5805fe8f0669cfedd..0000000000000000000000000000000000000000 --- a/src/shared/Components/ContextMenuSeparator/ContextMenuSeparator.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QLabel> -#include <QWidgetAction> - -class ContextMenuSeparator : public QWidgetAction -{ -public: - explicit ContextMenuSeparator(QWidget *parent = nullptr); - explicit ContextMenuSeparator(const QString &txt, - QWidget *parent = nullptr); - ~ContextMenuSeparator(); - void setHeight(int val); - void setText(const QString &txt); - -protected: - void build(); - -private: - QLabel label; -}; diff --git a/src/shared/Modules/DefaultModule/DefaultModule.cpp b/src/shared/Modules/DefaultModule/DefaultModule.cpp index a479afec9aacaed34275887e0bf4ccb1cc0f54ef..e779bb24b46ee1bf8c8612a5b39f3c521dce7b93 100644 --- a/src/shared/Modules/DefaultModule/DefaultModule.cpp +++ b/src/shared/Modules/DefaultModule/DefaultModule.cpp @@ -18,7 +18,6 @@ #include "DefaultModule.h" -#include <Components/ContextMenuSeparator/ContextMenuSeparator.h> #include <Core/ModulesManager/ModulesManager.h> #include <QCloseEvent> diff --git a/src/shared/Modules/Empty/EmptyModule.cpp b/src/shared/Modules/Empty/EmptyModule.cpp index 2bb3fb375e5f8eaa73be88eff3b2cf8f64f0cb30..ed9230ec895c7b44984d691016202452064fb121 100644 --- a/src/shared/Modules/Empty/EmptyModule.cpp +++ b/src/shared/Modules/Empty/EmptyModule.cpp @@ -24,7 +24,6 @@ #include <QMessageBox> #include <QPoint> -#include "Components/ContextMenuSeparator/ContextMenuSeparator.h" #include "ui_EmptyModule.h" EmptyModule::EmptyModule() : DefaultModule(), ui(new Ui::EmptyModule) diff --git a/src/shared/Modules/Graph/Graph.cpp b/src/shared/Modules/Graph/Graph.cpp index 9a3ee60c805ca68a7ef7429cd492a5b04d3444be..2fbb9ce7629c3871d1807f37faec98d1cff5fc29 100644 --- a/src/shared/Modules/Graph/Graph.cpp +++ b/src/shared/Modules/Graph/Graph.cpp @@ -18,7 +18,6 @@ #include "Graph.h" -#include <Components/ContextMenuSeparator/ContextMenuSeparator.h> #include <Components/SubscriptionsPanel/SubscriptionsPanel.h> #include <Core/MessageBroker/MessageBroker.h> diff --git a/src/shared/Modules/Mavlink/MavlinkModule.cpp b/src/shared/Modules/Mavlink/MavlinkModule.cpp index 9247f2f85f9743f4fd7584914e213a5c79fcfcb3..9d8b8d6471dd466cf1bef4a9078a684654036ea5 100644 --- a/src/shared/Modules/Mavlink/MavlinkModule.cpp +++ b/src/shared/Modules/Mavlink/MavlinkModule.cpp @@ -19,13 +19,11 @@ #include "MavlinkModule.h" #include <Core/MessageBroker/MessageBroker.h> +#include <Modules/SkywardHubStrings.h> #include <QDebug> #include <QSerialPortInfo> -#include "Components/ContextMenuSeparator/ContextMenuSeparator.h" -#include "Modules/SkywardHubStrings.h" - MavlinkModule::MavlinkModule(QWidget *parent) : DefaultModule(parent), mavlinkReader(this), serialPort(this) { diff --git a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.cpp b/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.cpp deleted file mode 100644 index e6637322a51e2f07c9b6e2fb1def2b030d78919c..0000000000000000000000000000000000000000 --- a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "MavlinkRocketMsgTestingModule.h" - -#include <Core/MessageBroker/MessageBroker.h> - -#include <QDebug> -#include <QMap> - -#include "Core/XmlObject.h" -#include "MavlinkCommandAdapter.h" -#include "MavlinkReader.h" -#include "MavlinkVersionHeader.h" -#include "ui_MavlinkRocketMsgTestingModule.h" - -MavlinkRocketMsgTestingModule::MavlinkRocketMsgTestingModule(QWidget* parent) - : DefaultModule(parent), ui(new Ui::MavlinkRocketMsgTestingModule) -{ - ui->setupUi(this); - defaultContextMenuSetup(); - init(); -} - -MavlinkRocketMsgTestingModule::~MavlinkRocketMsgTestingModule() -{ - delete ui; // This delete all the radiobutton -} - -void MavlinkRocketMsgTestingModule::init() -{ - ui->lineEdit_mavlinkInputFilePath->setText(defaultMavlinkFileName); - connect(ui->pushButton_sendMsg, &QPushButton::clicked, this, - &MavlinkRocketMsgTestingModule::onSendMsgClicked); - connect(ui->pushButton_loadInputFile, &QPushButton::clicked, this, - &MavlinkRocketMsgTestingModule::onLoadFileClicked); -} - -QWidget* MavlinkRocketMsgTestingModule::toWidget() { return this; } - -XmlObject MavlinkRocketMsgTestingModule::toXmlObject() -{ - return XmlObject(getName(ModuleId::MAVLINK_RCK_TESTING)); -} - -void MavlinkRocketMsgTestingModule::fromXmlObject(const XmlObject& xmlObject) -{ - Q_UNUSED(xmlObject); -} - -void MavlinkRocketMsgTestingModule::createNewButton(const QString& txt, - QLayout* container) -{ - QRadioButton* radiobutton = new QRadioButton(txt); - connectRadioButton(radiobutton); - container->addWidget(radiobutton); -} - -void MavlinkRocketMsgTestingModule::connectRadioButton( - QRadioButton* radiobutton) -{ - connect(radiobutton, &QRadioButton::clicked, this, - [this, radiobutton]() { this->onRadioButtonClicked(radiobutton); }); -} - -void MavlinkRocketMsgTestingModule::setSelectedMsg(const QString& msgName) -{ - if (currentMsgView != nullptr) - { - delete currentMsgView; - currentMsgView = nullptr; - } - - QList<XmlObject*> clickedMsg = mavlinkMsgDefinitionFile.deepSearchObjects( - [this, msgName](const XmlObject* obj) - { - QString name = obj->getAttribute(xmlFieldName); - if (name == msgName) - { - return true; - } - return false; - }); - - if (clickedMsg.count() == 1) - { - currentMsgView = new MsgView(clickedMsg[0], msgName); - ui->details_layout->insertWidget(0, currentMsgView->getView()); - } -} - -void MavlinkRocketMsgTestingModule::createViewFromXmlMessages( - QList<XmlObject*> messagesList) -{ - for (int i = 0; i < messagesList.count(); i++) - { - XmlObject* xmlObj = messagesList[i]; - QString msgType = xmlObj->getAttribute(xmlFieldType).trimmed(); - QGroupBox* gbox = getOrCreateGBox(msgType); - QString name = xmlObj->getAttribute(xmlFieldName).trimmed(); - if (name != "") - { - createNewButton(xmlObj->getAttribute(xmlFieldName), gbox->layout()); - } - } -} - -QGroupBox* MavlinkRocketMsgTestingModule::getOrCreateGBox(const QString& title) -{ - QGroupBox* gBox = nullptr; - if (title != "" && !viewGroupList.contains(title)) - { - gBox = new QGroupBox(title); - viewGroupList[title] = gBox; - ui->msg_layout->insertWidget(0, gBox); - gBox->setLayout(new QVBoxLayout()); - } - else if (viewGroupList.contains(title)) - { - gBox = viewGroupList[title]; - } - return gBox; -} - -QString MavlinkRocketMsgTestingModule::getCurrentTopic() const -{ - return ui->lineEdit_outputTopic->text(); -} - -void MavlinkRocketMsgTestingModule::onRadioButtonClicked( - QRadioButton* radiobutton) -{ - setSelectedMsg(radiobutton->text()); -} - -void MavlinkRocketMsgTestingModule::clearView() -{ - if (currentMsgView != nullptr) - { - delete currentMsgView; - currentMsgView = nullptr; - } - - QList<QGroupBox*> groupBox = viewGroupList.values(); - for (int i = 0; i < groupBox.count(); i++) - delete groupBox[i]; - - viewGroupList.clear(); -} - -void MavlinkRocketMsgTestingModule::onLoadFileClicked() -{ - clearView(); - - QString filePath = SkywardHubStrings::defaultConfigurationFolder + "/" + - ui->lineEdit_mavlinkInputFilePath->text().trimmed(); - if (mavlinkMsgDefinitionFile.loadFromFile(filePath)) - { - QList<XmlObject*> xmlMessages = - mavlinkMsgDefinitionFile.deepSearchObjects( - [this](const XmlObject* msg) - { - if (msg->getObjectName() == xmlChildName) - { - return true; - } - return false; - }); - - createViewFromXmlMessages(xmlMessages); - } -} - -XmlObject MavlinkRocketMsgTestingModule::msgToXml() const -{ - XmlObject xmlMsg; - if (currentMsgView != nullptr) - { - xmlMsg.setObjectName(currentMsgView->getName()); - auto fields = currentMsgView->getFields(); - QMapIterator<QString, QLineEdit*> i(fields); - while (i.hasNext()) - { - i.next(); - xmlMsg.addAttribute(i.key(), i.value()->text()); - } - } - return xmlMsg; -} - -void MavlinkRocketMsgTestingModule::onSendMsgClicked() -{ - if (currentMsgView != nullptr) - { - XmlObject xmlMsg = msgToXml(); - testMavlinkEncodeAndDecode(xmlMsg); - } -} - -bool MavlinkRocketMsgTestingModule::testMavlinkEncodeAndDecode( - const XmlObject& xmlMsg) -{ - // Test mavlink msg encoding - mavlink_message_t mavMsg; - bool ok = false; - ok = MavlinkCommandAdapter().produceMsgFromXml(xmlMsg, &mavMsg); - - // Test of buffer writing - // if(MavlinkCommandAdapter().produceMsgFromXml(xmlMsg, &mavMsg)){ - // unsigned char buff[sizeof(mavlink_message_t)+1]; - // int msg_len = mavlink_msg_to_send_buffer(buff, &mavMsg); - // ok = msg_len > 0; - // } - - // Test mavlink msg decoding - if (ok) - { - MavlinkReader mavlinkReader(nullptr); - Message msgProduced = mavlinkReader.generateMessage(mavMsg); - Topic currentTopic(getCurrentTopic().trimmed()); - getCore()->getMessageBroker()->publish(msgProduced); - } - return ok; -} - -// mavlink_message_t MavlinkRocketMsgTestingModule::genericPack(string funcName, -// char* params[]) -//{ -// mavlink_message_t result_msg; - -// if(!funcName.compare("mavlink_msg_sm_tm_pack")){ -// uint8_t system_id = (uint8_t)atoi(params[0]); -// ecc.. -// mavlink_msg_sm_tm_pack(system_id, ecc...); -// } -// else if(!funcName.compare("mavlink_msg_gps_tm_pack")){ -// param... -// mavlink_msg_gps_tm_pack(param...); -// } -// . -// . -// . - -// return result_msg; -//} - -// _______________________________________________ MsgView -// ___________________________________________________ - -MsgView::MsgView(const XmlObject* obj, QString name) : QObject() -{ - this->name = name; - bool ok; - id = obj->getAttribute(xmlFieldId).trimmed().toInt(&ok); - if (!ok) - { - id = 0; - } - - for (int i = 0; i < obj->childCount(); i++) - { - XmlObject fieldXml = obj->childAt(i); - if (fieldXml.getObjectName() == xmlFieldElementName) - { - // auto i = fieldXml.attributesIterator(); - // while(i.hasNext()){ - // auto pair = i.next(); - // } - QString fieldName = fieldXml.getAttribute(xmlFieldName); - QLineEdit* lineEdit = new QLineEdit(); - fields[fieldName] = lineEdit; - } - else if (fieldXml.getObjectName() == xmlFieldDescr) - { - description = fieldXml.getTextValue(); - } - } -} - -MsgView::~MsgView() { delete view; } - -QWidget* MsgView::getView() -{ - if (view == nullptr) - { - view = new QWidget(); - QVBoxLayout* layout = new QVBoxLayout(); - view->setLayout(layout); - - QLabel* nameLabel = new QLabel(name); - nameLabel->setAlignment(Qt::AlignmentFlag::AlignCenter); - layout->addWidget(nameLabel); - - QHBoxLayout* rowId = new QHBoxLayout(); - rowId->addWidget(new QLabel(xmlFieldId)); - QLabel* idLabel = new QLabel(QString::number(id)); - rowId->addWidget(idLabel); - rowId->setStretchFactor(idLabel, 1); - layout->addLayout(rowId); - layout->addWidget(new QLabel(description)); - - QMapIterator<QString, QLineEdit*> i(fields); - while (i.hasNext()) - { - i.next(); - QLabel* fieldNameLabel = new QLabel(i.key()); - QHBoxLayout* rowLayout = new QHBoxLayout(); - - rowLayout->addWidget(fieldNameLabel); - rowLayout->addWidget(i.value()); - layout->addLayout(rowLayout); - } - } - - return view; -} - -QString MsgView::getName() const { return name; } - -QMap<QString, QLineEdit*> MsgView::getFields() const { return fields; } diff --git a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.h b/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.h deleted file mode 100644 index a32b85fc1a87782b8c003ea95655e340dca9f622..0000000000000000000000000000000000000000 --- a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QGroupBox> -#include <QLineEdit> -#include <QRadioButton> - -#include "Modules/DefaultModule/DefaultModule.h" -#include "Modules/SkywardHubStrings.h" - -namespace Ui -{ -class MavlinkRocketMsgTestingModule; -} - -class MsgView : public QObject -{ - Q_OBJECT - -public: - MsgView(const XmlObject *obj, QString name); - ~MsgView(); - QWidget *getView(); - - QString getName() const; - - QMap<QString, QLineEdit *> getFields() const; - -private: - QString description; - QString name; - int id; - QMap<QString, QLineEdit *> fields; - QWidget *view = nullptr; - - QString xmlFieldId = "id"; - QString xmlFieldDescr = "description"; - QString xmlFieldElementName = "field"; - QString xmlFieldName = "name"; -}; - -class MavlinkRocketMsgTestingModule : public DefaultModule -{ - Q_OBJECT - -public: - explicit MavlinkRocketMsgTestingModule(QWidget *parent = nullptr); - ~MavlinkRocketMsgTestingModule(); - - QWidget *toWidget() override; - - XmlObject toXmlObject() override; - void fromXmlObject(const XmlObject &xmlObject) override; - -protected: - void init(); - void createNewButton(const QString &txt, QLayout *container); - void connectRadioButton(QRadioButton *radiobutton); - void setSelectedMsg(const QString &msgName); - void onSendMsgClicked(); - void onLoadFileClicked(); - bool testMavlinkEncodeAndDecode(const XmlObject &xmlMsg); - // mavlink_message_t genericPack(string funcName, char *params[]); - QString getCurrentTopic() const; - void createViewFromXmlMessages(QList<XmlObject *> messagesList); - QGroupBox *getOrCreateGBox(const QString &title); - void clearView(); - XmlObject msgToXml() const; - -protected slots: - void onRadioButtonClicked(QRadioButton *radiobutton); - -private: - Ui::MavlinkRocketMsgTestingModule *ui; - - MsgView *currentMsgView = nullptr; - - QString defaultMavlinkFileName = "mavlink.xml"; - QString xmlChildName = "message"; - QString xmlFieldType = "msg_type"; - QString xmlFieldName = "name"; - XmlObject mavlinkMsgDefinitionFile; - - QMap<QString, QGroupBox *> viewGroupList; -}; diff --git a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.ui b/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.ui deleted file mode 100644 index 019874545dcd23169f14bcd9a7f94ed0b355aaf0..0000000000000000000000000000000000000000 --- a/src/shared/Modules/Mavlink/MavlinkRocketMsgTestingModule.ui +++ /dev/null @@ -1,131 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MavlinkRocketMsgTestingModule</class> - <widget class="QWidget" name="MavlinkRocketMsgTestingModule"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>676</width> - <height>431</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Mavlink Rocket Messages Tester</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLineEdit" name="lineEdit_mavlinkInputFilePath"> - <property name="placeholderText"> - <string>Mavlink .xml file</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_loadInputFile"> - <property name="text"> - <string>Load File</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_outputTopic"> - <property name="placeholderText"> - <string>Output topic</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,2"> - <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>214</width> - <height>327</height> - </rect> - </property> - <layout class="QVBoxLayout" name="msg_layout"> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QScrollArea" name="scrollArea_2"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents_2"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>430</width> - <height>327</height> - </rect> - </property> - <layout class="QVBoxLayout" name="details_layout"> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>254</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_sendMsg"> - <property name="text"> - <string>Send</string> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/shared/Modules/ModuleInfo.h b/src/shared/Modules/ModuleInfo.h index ec455af182ef066a9e7b38b5c49c84350ed23481..f300c0acb3eaf602ea42e66a8537a593ef9265b8 100644 --- a/src/shared/Modules/ModuleInfo.h +++ b/src/shared/Modules/ModuleInfo.h @@ -26,7 +26,6 @@ enum ModuleId { EMPTY, SPLITTER, - SKYWARDHUB, COMMANDPAD, COMPACT_COMMAND_PAD, BROKERTEST, @@ -38,7 +37,6 @@ enum ModuleId ORIENTATION_VISUALIZER, STATEVIEWER, VALUESCONVERTERVIEWER, - MAVLINK_RCK_TESTING, TIMER_CONTROLLER, MODULETEST, TABS, diff --git a/src/shared/Modules/ModulesList.cpp b/src/shared/Modules/ModulesList.cpp index 38d1977f3820ea82c41436bd426dfa0f4ad57de2..d32058bd97cd0c686595a7f70135463fff2dc7a4 100644 --- a/src/shared/Modules/ModulesList.cpp +++ b/src/shared/Modules/ModulesList.cpp @@ -27,10 +27,8 @@ #include <Modules/Graph/Graph.h> #include <Modules/IncomingMessagesViewer/IncomingMessagesViewerModule.h> #include <Modules/Mavlink/MavlinkModule.h> -#include <Modules/Mavlink/MavlinkRocketMsgTestingModule.h> #include <Modules/OrientationVisualizer/OrientationVisualizer.h> #include <Modules/OutgoingMessagesViewer/OutgoingMessagesViewerModule.h> -#include <Modules/SkywardHub/SkywardHubModule.h> #include <Modules/Splitter/Splitter.h> #include <Modules/StateViewer/StateViewer.h> #include <Modules/Tabs/TabsModule.h> @@ -55,42 +53,31 @@ void ModulesList::createModuleList() ModuleInfo empty(ModuleId::EMPTY, "EmptyModule"); empty.setFactory([]() { return new EmptyModule(); }); - empty.addModuleSourceFiles("Modules/Empty/"); addModuleInfo(empty); ModuleInfo commandPad(ModuleId::COMMANDPAD, "CommandPad", ModuleCategory::UTILITY); commandPad.setFactory([]() { return new CommandPad(); }); - commandPad.addModuleSourceFiles("Modules/CommandPad/"); addModuleInfo(commandPad); ModuleInfo compactCommandPad(ModuleId::COMPACT_COMMAND_PAD, "compact_command_pad", ModuleCategory::UTILITY); compactCommandPad.setFactory([]() { return new CompactCommandPad(); }); - compactCommandPad.addModuleSourceFiles("Modules/CompactCommandPad/"); addModuleInfo(compactCommandPad); ModuleInfo splitter(ModuleId::SPLITTER, "Splitter"); splitter.setFactory([]() { return new Splitter(); }); - splitter.addModuleSourceFiles("Modules/Splitter/"); addModuleInfo(splitter); - ModuleInfo hub(ModuleId::SKYWARDHUB, "SkywardHub", ModuleCategory::HOME); - hub.setFactory([]() { return new SkywardHubModule(); }); - hub.addModuleSourceFiles("Modules/SkywardHub/"); - addModuleInfo(hub); - ModuleInfo testModule(ModuleId::BROKERTEST, "TestBroker", ModuleCategory::DEFAULT); testModule.setFactory([]() { return new TestModule(); }); - testModule.addModuleSourceFiles("Modules/Test/"); addModuleInfo(testModule); ModuleInfo graphModule(ModuleId::GRAPH, "Graph", ModuleCategory::DATAVISUAL); graphModule.setFactory([]() { return new Graph(); }); - graphModule.addModuleSourceFiles("Modules/Graph/"); addModuleInfo(graphModule); ModuleInfo outMsgViewer(ModuleId::OUTCOMINGMESSAGEVIEWER, @@ -98,39 +85,27 @@ void ModulesList::createModuleList() ModuleCategory::DATAVISUAL); outMsgViewer.setFactory([]() { return new OutgoingMessagesViewerModule(); }); - outMsgViewer.addModuleSourceFiles("Modules/OutgoingMessageViewer/"); addModuleInfo(outMsgViewer); ModuleInfo inMsgViewer(ModuleId::INCOMINGMESSAGESVIEWER, "IncomingMessagesViewer", ModuleCategory::DATAVISUAL); inMsgViewer.setFactory([]() { return new IncomingMessagesViewerModule(); }); - inMsgViewer.addModuleSourceFiles("Modules/IncomingMessageViewer/"); addModuleInfo(inMsgViewer); ModuleInfo mavlink(ModuleId::MAVLINK, "Mavlink", ModuleCategory::DATASOURCE); mavlink.setFactory([]() { return new MavlinkModule(); }); - mavlink.addModuleSourceFiles("Modules/Mavlink/"); addModuleInfo(mavlink); - ModuleInfo mvkRckTesting(ModuleId::MAVLINK_RCK_TESTING, - "MavlinkRocketMsgTesting", - ModuleCategory::DEFAULT); - mvkRckTesting.setFactory([]() - { return new MavlinkRocketMsgTestingModule(); }); - addModuleInfo(mvkRckTesting); - ModuleInfo fileStream(ModuleId::FILESTREAM, "FileStream", ModuleCategory::DATASOURCE); fileStream.setFactory([]() { return new FileStreamModule(); }); - fileStream.addModuleSourceFiles("Modules/FileStream/"); addModuleInfo(fileStream); ModuleInfo stateViewer(ModuleId::STATEVIEWER, "StateViewer", ModuleCategory::DATAVISUAL); stateViewer.setFactory([]() { return new StateViewerModule(); }); - stateViewer.addModuleSourceFiles("Modules/StateViewer/"); addModuleInfo(stateViewer); ModuleInfo valuesConverterViewer(ModuleId::VALUESCONVERTERVIEWER, @@ -138,8 +113,6 @@ void ModulesList::createModuleList() ModuleCategory::UTILITY); valuesConverterViewer.setFactory( []() { return new ValuesConverterViewerModule(); }); - valuesConverterViewer.addModuleSourceFiles( - "Modules/ValuesConverterViewer/"); addModuleInfo(valuesConverterViewer); ModuleInfo orientationVisualizer(ModuleId::ORIENTATION_VISUALIZER, @@ -147,19 +120,15 @@ void ModulesList::createModuleList() ModuleCategory::UTILITY); orientationVisualizer.setFactory([]() { return new OrientationVisualizer(); }); - orientationVisualizer.addModuleSourceFiles( - "Modules/OrientationVisualizer/"); addModuleInfo(orientationVisualizer); ModuleInfo timerController(ModuleId::TIMER_CONTROLLER, "TimerController", ModuleCategory::UTILITY); timerController.setFactory([]() { return new TimerControllerModule(); }); - timerController.addModuleSourceFiles("Modules/TimerController/"); addModuleInfo(timerController); ModuleInfo tabs(ModuleId::TABS, "Tabs", ModuleCategory::UTILITY); tabs.setFactory([]() { return new TabsModule(); }); - tabs.addModuleSourceFiles("Modules/Tabs/"); addModuleInfo(tabs); } diff --git a/src/shared/Modules/SkywardHub/Deployer.cpp b/src/shared/Modules/SkywardHub/Deployer.cpp deleted file mode 100644 index 3c5ecb9e750678050a75555c8b1d5b845b6b0c5b..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/Deployer.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "Deployer.h" - -#include <QDir> -#include <QFile> -#include <QMessageBox> -#include <QTextStream> - -Deployer::Deployer() {} - -bool Deployer::deploy(const QList<QString>& activeModules) -{ - setupModulesFiles(activeModules); - - if (!deployerPicker.pickDirectory()) - { - return false; - } - - proFilePath = deployerPicker.getProFilePathFolder(); - deployDir = deployerPicker.getDeploymentFolder(); - - if (!isDeployConfirmed()) - return false; - - makeDeployDir(); - copyPath(getSourceDir(), getNewSourceDir()); - produceNewProFile(); - produceNewModuleListFile(); - - system(qPrintable("cmd.exe /A /C " + writeBatFile())); - - return showResultMessage(); -} - -QString Deployer::getDeployReleaseFolder() const -{ - return deployDir + "/" + newCopyReleaseFolderName; -} - -void Deployer::setupModulesFiles(const QList<QString>& activeModules) -{ - modulesFiles.clear(); - modulesFiles.append("SOURCES"); - modulesFiles.append("HEADERS"); - modulesFiles.append("FORMS"); - - /* - * This are the mandatory files to include in the build. - * If you want to change this list, probablly you must edit also the - * ModulesManager in the Core. - * - * The files are listed in order of how much they are deep-rooted (radicati) - * in the system (so the first files are the most difficul to replace while - * the lastone is the easyest) - */ - - modulesFiles.append("Core/"); - modulesFiles.append("moduleinfo"); - modulesFiles.append("moduleslist"); - modulesFiles.append("SkywardHubStrings"); - modulesFiles.append("main.cpp"); - modulesFiles.append("Modules/Empty/"); - modulesFiles.append("Modules/DefaultModule/"); - modulesFiles.append("Modules/Splitter/"); - modulesFiles.append("Modules/MainWindow/"); - modulesFiles.append("Components/"); - - modulesFiles.append(activeModules); -} - -// _________________________________ PRO FILE -// ______________________________________________________ - -void Deployer::produceNewProFile() -{ - QString filePath = getNewProFilePath(); - QList<QString> proFile = loadFile(filePath); - QList<QString> newProFile = makeNewProFile(proFile); - writeFile(newProFile, filePath); -} - -QList<QString> Deployer::makeNewProFile(const QList<QString>& oldProFile) const -{ - QList<QString> newProFile; - - bool copy = true; - for (QString line : oldProFile) - { - if (line.contains(proFileEndCopyTag)) - { - copy = false; - } - else if (line.contains(proFileRestartCopyTag)) - { - copy = true; - } - - if (copy || line.isEmpty() || checkIfFilesIsActive(line)) - { - newProFile.append(line); - } - } - - return newProFile; -} - -bool Deployer::checkIfFilesIsActive(const QString& line) const -{ - for (QString file : modulesFiles) - { - if (line.contains(file)) - { - return true; - } - } - return false; -} - -// _____________________________ modules list.cpp FILE -// ______________________________________________________ - -void Deployer::produceNewModuleListFile() -{ - QString filePath = getModuleListFilePath(); - QList<QString> oldModulesFile = loadFile(filePath); - QList<QString> newModulesFile = makeNewModulesListFile(oldModulesFile); - writeFile(newModulesFile, filePath); -} - -QList<QString> Deployer::makeNewModulesListFile( - const QList<QString>& oldModulesListFile) const -{ - QList<QString> newFile; - - for (QString line : oldModulesListFile) - { - if (line.contains("#include")) - { - if (checkIfFilesIsActive(line)) - { - newFile.append(line); - } - } - else - { - newFile.append(line); - } - } - - return newFile; -} - -// _____________________________ BAT FILE -// ___________________________________________________________________ - -QString Deployer::writeBatFile() const -{ - QString batfile_header = "set PATH=" + mingw81_64_bin + ";" + - mingw810_64_bin + - ";%PATH%\n" - "cd /D " + - mingw81_64_bin + "\n"; - QString batfile_core = "cd " + deployDir + - "\n" - "qmake -config release " + - getNewProFilePath() + - "\n" - "mingw32-make.exe -f Makefile.Release\n" - "mingw32-make.exe -f Makefile.Release clean\n" - "windeployqt release/."; - - QString batfile_path = getNewSourceDir() + "\\deployer.bat"; - QFile file(batfile_path); - if (file.open(QIODevice::WriteOnly)) - { - QTextStream(&file) << batfile_header << batfile_core; - file.close(); - return batfile_path; - } - return ""; -} - -// __________________________________________________________________________________________________________ - -bool Deployer::isDeployCompletedSuccessfully() -{ - QDir dir(getDeployReleaseFolder()); - if (dir.exists() && !dir.isEmpty()) - return true; - - return false; -} - -bool Deployer::showResultMessage() -{ - QMessageBox confirmMsg; - - if (isDeployCompletedSuccessfully()) - { - confirmMsg.setText("Deploy completed successfully"); - confirmMsg.exec(); - return true; - } - else - { - QString text = "Deployment Error"; - QString infoMsg = - "Something went wrong. \n\nCheck if the new modules specify " - "correctly all the needed files."; - confirmMsg.warning(nullptr, text, infoMsg); - confirmMsg.setInformativeText(infoMsg); - return false; - } -} - -bool Deployer::isDeployConfirmed() -{ - QMessageBox msgBox; - msgBox.setWindowTitle("Deploy"); - QString infoMsg = "Do you want to deploy the following project: \n" + - proFilePath + "\n\nIn the following directory: \n" + - deployDir; - msgBox.setInformativeText(infoMsg); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Yes); - - if (msgBox.exec() == QMessageBox::Yes) - return true; - return false; -} - -void Deployer::copyPath(const QString& src, const QString& dst) -{ - QDir dir(src); - if (!dir.exists()) - return; - - foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) - { - QString dst_path = dst + QDir::separator() + d; - dir.mkpath(dst_path); - copyPath(src + QDir::separator() + d, dst_path); - } - - foreach (QString f, dir.entryList(QDir::Files)) - { - QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f); - } -} - -QList<QString> Deployer::loadFile(const QString& path) -{ - QList<QString> stringList; - QFile textFile(path); - if (textFile.open(QIODevice::ReadOnly)) - { - QTextStream textStream(&textFile); - while (!textStream.atEnd()) - { - stringList.append(textStream.readLine()); - } - textFile.close(); - } - return stringList; -} - -QString Deployer::getProFileName() const -{ - return QFileInfo(proFilePath).fileName(); -} - -QString Deployer::getSourceDir() const -{ - return QFileInfo(proFilePath).dir().absolutePath(); -} - -QString Deployer::getNewSourceDir() const -{ - return deployDir + "/" + newCopySourceFolderName; -} - -QString Deployer::getNewProFilePath() const -{ - return getNewSourceDir() + "/" + getProFileName(); -} - -QString Deployer::getModuleListFilePath() const -{ - return getNewSourceDir() + relativeModuleFilesPath; -} - -void Deployer::makeDeployDir() const -{ - QDir newDir(deployDir); - newDir.mkdir(newCopySourceFolderName); - // newDir.mkdir(newCopyReleaseFolderName); -} - -bool Deployer::writeFile(const QList<QString>& text, const QString& path) -{ - bool result = false; - QFile file(path); - if (file.open(QIODevice::WriteOnly)) - { - QTextStream writer(&file); - for (QString line : text) - { - writer << line << '\n'; - } - file.close(); - result = true; - } - return result; -} diff --git a/src/shared/Modules/SkywardHub/Deployer.h b/src/shared/Modules/SkywardHub/Deployer.h deleted file mode 100644 index 41536df7dcedd17df37e746d8d7066f5efb3462a..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/Deployer.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QList> -#include <QProcess> -#include <QString> - -#include "Core/XmlObject.h" -#include "DeployerPathPicker.h" - -class Deployer -{ -public: - Deployer(); - - bool deploy(const QList<QString> &activeModules); - QString getDeployReleaseFolder() const; - -protected: - QString writeBatFile() const; - void copyPath(const QString &src, const QString &dst); - - QList<QString> loadFile(const QString &path); - QString getProFileName() const; - QString getSourceDir() const; - QString getNewSourceDir() const; - QString getNewProFilePath() const; - QString getModuleListFilePath() const; - - void makeDeployDir() const; - - bool writeFile(const QList<QString> &text, const QString &path); - void setupModulesFiles(const QList<QString> &activeModules); - bool checkIfFilesIsActive(const QString &line) const; - - void produceNewProFile(); - QList<QString> makeNewProFile(const QList<QString> &oldProFile) const; - - void produceNewModuleListFile(); - QList<QString> makeNewModulesListFile( - const QList<QString> &oldModulesListFile) const; - - bool isDeployCompletedSuccessfully(); - bool showResultMessage(); - - bool isDeployConfirmed(); - -private: - QList<QString> modulesFiles; - QString mingw81_64_bin = "C:/Qt/5.15.1/mingw81_64/bin"; - QString mingw810_64_bin = "C:/Qt/Tools/mingw810_64/bin"; - QString relativeModuleFilesPath = "/Modules/moduleslist.cpp"; - - QString proFilePath = ""; - QString deployDir = ""; - QString newCopySourceFolderName = "source"; - QString newCopyReleaseFolderName = "release"; - - QString proFileRestartCopyTag = "qnx:"; - QString proFileEndCopyTag = "SOURCES"; - - DeployerPathPicker deployerPicker; -}; diff --git a/src/shared/Modules/SkywardHub/DeployerPathPicker.cpp b/src/shared/Modules/SkywardHub/DeployerPathPicker.cpp deleted file mode 100644 index 8f40542336c864d46e32b4b0d401a438e4cb6558..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/DeployerPathPicker.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "DeployerPathPicker.h" - -#include <QFileDialog> - -#include "ui_DeployerPathPicker.h" - -DeployerPathPicker::DeployerPathPicker(QWidget *parent) - : QDialog(parent), ui(new Ui::DeployerPathPicker) -{ - ui->setupUi(this); - // setAttribute(Qt::WA_DeleteOnClose, true); // WA_DeleteOnClose is - // set to true, so this widget will be deleted on close - - connect(ui->pushButton_selectDeployFolder, &QPushButton::clicked, this, - &DeployerPathPicker::onSelectDeployFolderClicked); - connect(ui->pushButton_selectProFilePath, &QPushButton::clicked, this, - &DeployerPathPicker::onSelectProFilePathClicked); - connect(ui->pushButton_confirm, &QPushButton::clicked, this, - &DeployerPathPicker::onConfirmButtonClicked); -} - -DeployerPathPicker::~DeployerPathPicker() { delete ui; } - -QString DeployerPathPicker::getDeploymentFolder() const -{ - return ui->textEdit_DeploymentFolder->toPlainText().trimmed(); -} - -QString DeployerPathPicker::getProFilePathFolder() const -{ - return ui->textEdit_proFilePath->toPlainText().trimmed(); -} - -void DeployerPathPicker::onSelectDeployFolderClicked() -{ - QString deployDir = QFileDialog::getExistingDirectory(); - setDeploymentFolder(deployDir); -} - -void DeployerPathPicker::onSelectProFilePathClicked() -{ - QString proFilePath = QFileDialog::getOpenFileName( - nullptr, "Select .pro file", "", "(*.pro)"); - setProFilePathFolder(proFilePath); -} - -void DeployerPathPicker::setDeploymentFolder(const QString &value) -{ - ui->textEdit_DeploymentFolder->setText(value); -} - -void DeployerPathPicker::setProFilePathFolder(const QString &value) -{ - ui->textEdit_proFilePath->setText(value); -} - -void DeployerPathPicker::onConfirmButtonClicked() -{ - QString deployDir = getDeploymentFolder(); - QString proFilePath = getProFilePathFolder(); - - if (deployDir.isEmpty() || proFilePath.isEmpty()) - { - setPickConfirmed(false); - } - setPickConfirmed(true); - this->close(); // In order to autodelete on close, WA_DeleteOnClose must be - // set to true. -} - -bool DeployerPathPicker::getPickConfirmed() const { return pickConfirmed; } - -void DeployerPathPicker::setPickConfirmed(bool value) { pickConfirmed = value; } - -bool DeployerPathPicker::pickDirectory() -{ - setPickConfirmed(false); - this->exec(); - return getPickConfirmed(); -} diff --git a/src/shared/Modules/SkywardHub/DeployerPathPicker.h b/src/shared/Modules/SkywardHub/DeployerPathPicker.h deleted file mode 100644 index 47f57880f965d1e4b6deca6d6ec38f46197a5f32..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/DeployerPathPicker.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QDialog> - -namespace Ui -{ -class DeployerPathPicker; -} - -class DeployerPathPicker : public QDialog -{ - Q_OBJECT - -public: - explicit DeployerPathPicker(QWidget *parent = nullptr); - ~DeployerPathPicker(); - - bool pickDirectory(); - - QString getDeploymentFolder() const; - QString getProFilePathFolder() const; - - bool getPickConfirmed() const; - void setPickConfirmed(bool value); - -protected slots: - void onSelectDeployFolderClicked(); - void onSelectProFilePathClicked(); - - void setDeploymentFolder(const QString &value); - void setProFilePathFolder(const QString &value); - void onConfirmButtonClicked(); - -private: - Ui::DeployerPathPicker *ui; - bool pickConfirmed; -}; diff --git a/src/shared/Modules/SkywardHub/DeployerPathPicker.ui b/src/shared/Modules/SkywardHub/DeployerPathPicker.ui deleted file mode 100644 index 37b5b260d90619085ea417b90a79a21ff4a05368..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/DeployerPathPicker.ui +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>DeployerPathPicker</class> - <widget class="QWidget" name="DeployerPathPicker"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>608</width> - <height>304</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="1"> - <widget class="QPushButton" name="pushButton_selectProFilePath"> - <property name="text"> - <string>Select</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QTextEdit" name="textEdit_DeploymentFolder"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Select the path to the .pro file of the Qt project you want to deploy</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QTextEdit" name="textEdit_proFilePath"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Select the deployment folder</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QPushButton" name="pushButton_selectDeployFolder"> - <property name="text"> - <string>Select</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="5" column="1"> - <widget class="QPushButton" name="pushButton_confirm"> - <property name="text"> - <string>Confirm</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/shared/Modules/SkywardHub/PrefabDialog.cpp b/src/shared/Modules/SkywardHub/PrefabDialog.cpp deleted file mode 100644 index f9d370c8d73afc63a1fe8fab983b49f0a845b08c..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabDialog.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "PrefabDialog.h" - -#include "ui_PrefabDialog.h" - -PrefabDialog::PrefabDialog(QWidget *parent) - : QDialog(parent), ui(new Ui::PrefabDialog) -{ - ui->setupUi(this); - this->setFixedHeight(800); - this->setMinimumWidth(800); - connect(ui->create_pushButton, &QPushButton::clicked, this, - &PrefabDialog::onCreate); - this->setStyleSheet("background-color: #212121 ;"); - QString groupboxStyle = - "QGroupBox {" - " border:1px solid #00bfff;" - " border-radius: 7px;" - " margin-top: 2ex;" - "}" - - "QGroupBox::title {" - " subcontrol-origin: margin;" - " subcontrol-position: top center;" - " padding-left: 10px;" - "padding-right: 10px;" - "color: #00bfff;" - "}"; - ui->title_groupBox->setStyleSheet(groupboxStyle); - ui->caption_groupBox->setStyleSheet(groupboxStyle); - ui->description_groupBox->setStyleSheet(groupboxStyle); - - QString lineeditStyle = - "QLineEdit" - "{" - " background-color: #2d2d2d;" - " padding: 2px;" - " border-style: solid;" - "border: 1px solid #00bfff;" - "border-radius: 3px;" - "color: #00bfff;" - "}"; - - ui->title_lineEdit->setStyleSheet(lineeditStyle); - ui->caption_lineEdit->setStyleSheet(lineeditStyle); - - QString palaintextStyle = - "QPlainTextEdit" - "{" - /*background-color: #201F1F;; - color: silver; - border-radius: 3px; - border: 1px solid #3A3939;*/ - - " background-color: #2d2d2d;" - " padding: 2px;" - " border-style: solid;" - "border: 1px solid #00bfff;" - "border-radius: 3px;" - "color: #00bfff;" - "}"; - ui->Desc_plainTextEdit->setStyleSheet(palaintextStyle); - - ui->create_pushButton->setStyleSheet( - "" - "QPushButton" - "{" - "background-color: none;" - "border: 2px solid #00bfff;" - "color: #00bfff;" - "border-radius: 3px;" - "}" - "QPushButton:hover" - "{" - "background-color: #474747;" - "border: 2px solid #00bfff;" - "color: #00bfff;" - "}" - "QPushButton:pressed { background-color: QLinearGradient( x1: 0, y1: " - "0, x2: 0, y2: 1, stop: 0 #506987, stop: 1 #00739a);}"); -} - -PrefabDialog::~PrefabDialog() { delete ui; } - -void PrefabDialog::onCreate() -{ - QString title = ui->title_lineEdit->text(); - QString caption = ui->caption_lineEdit->text(); - QString description = ui->Desc_plainTextEdit->toPlainText(); - emit newPrefabCreated(title, caption, description); - this->close(); -} diff --git a/src/shared/Modules/SkywardHub/PrefabDialog.h b/src/shared/Modules/SkywardHub/PrefabDialog.h deleted file mode 100644 index 206eadf4721e41bf547d7ed3a8ba2e86f61c1470..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabDialog.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QDialog> - -namespace Ui -{ -class PrefabDialog; -} - -class PrefabDialog : public QDialog -{ - Q_OBJECT - -public: - explicit PrefabDialog(QWidget *parent = nullptr); - ~PrefabDialog(); - -public slots: - void onCreate(); - -signals: - void newPrefabCreated(const QString &title, const QString &caption, - const QString &description); - -private: - Ui::PrefabDialog *ui; -}; diff --git a/src/shared/Modules/SkywardHub/PrefabDialog.ui b/src/shared/Modules/SkywardHub/PrefabDialog.ui deleted file mode 100644 index ddc35e3f0f913be409505fc80d58e7c04bfb44bf..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabDialog.ui +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PrefabDialog</class> - <widget class="QDialog" name="PrefabDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QGroupBox" name="title_groupBox"> - <property name="title"> - <string>Title</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QLineEdit" name="title_lineEdit"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="caption_groupBox"> - <property name="title"> - <string>Caption</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QLineEdit" name="caption_lineEdit"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="description_groupBox"> - <property name="title"> - <string>Description</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QPlainTextEdit" name="Desc_plainTextEdit"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="create_pushButton"> - <property name="text"> - <string>Create</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/shared/Modules/SkywardHub/PrefabViewElement.cpp b/src/shared/Modules/SkywardHub/PrefabViewElement.cpp deleted file mode 100644 index 5772499b5c74085777195f243f5543c66a0f6b47..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabViewElement.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "PrefabViewElement.h" - -#include "Modules/SkywardHubStrings.h" -#include "ui_PrefabViewElement.h" - -PrefabViewElement::PrefabViewElement(const QString &name, QWidget *parent) - : QWidget(parent), ui(new Ui::PrefabViewElement) -{ - ui->setupUi(this); - setName(name); - - connect(ui->pushButton_launch, &QPushButton::clicked, this, - &PrefabViewElement::onLaunchClicked); - connect(ui->pushButton_delete, &QPushButton::clicked, this, - &PrefabViewElement::onDeleteClicked); - connect(ui->pushButton_icon, &QPushButton::clicked, this, - &PrefabViewElement::onIconClicked); -} - -PrefabViewElement::~PrefabViewElement() { delete ui; } - -void PrefabViewElement::setName(const QString &value) -{ - name = value; - ui->label_name->setText(value); -} - -QString PrefabViewElement::getName() const { return name; } - -QString PrefabViewElement::getDesctiption() const { return desctiption; } - -void PrefabViewElement::setDesctiption(const QString &value) -{ - if (value.isEmpty()) - return; - - desctiption = value; - ui->label_desctiption->setText(value); -} - -QString PrefabViewElement::getPathToImg() const { return pathToImg; } - -void PrefabViewElement::setPathToImg(const QString &value) -{ - if (value.isEmpty()) - return; - - pathToImg = value; - QPixmap pixmap(value); - QIcon ButtonIcon(pixmap); - ui->pushButton_icon->setIcon(ButtonIcon); - ui->pushButton_icon->setIconSize(pixmap.rect().size()); - ui->pushButton_icon->setIconSize(QSize(512, 512)); -} - -XmlObject PrefabViewElement::getXml() const { return xml; } - -void PrefabViewElement::setXml(XmlObject &xml) -{ - this->xml = xml; - - setPathToImg( - xml.getAttribute(SkywardHubStrings::configurationIconPathAttribute)); - - QList<XmlObject *> descr = xml.deepSearchObjects( - SkywardHubStrings::configurationDescriptionAttribute); - - if (descr.count() >= 1) - { - setDesctiption(descr.first()->getTextValue()); - } -} - -void PrefabViewElement::addActiveModuleName(const QString &moduleName) -{ - if (containsModule(moduleName)) - return; - - activeModules.append(moduleName); -} - -void PrefabViewElement::removeActiveModuleName(const QString &moduleName) -{ - activeModules.removeAll(moduleName); -} - -bool PrefabViewElement::containsModule(const QString &moduleName) -{ - return activeModules.contains(moduleName); -} - -void PrefabViewElement::setDeleteButtonVisibility(bool visibility) -{ - ui->pushButton_delete->setVisible(visibility); -} - -void PrefabViewElement::setLaunchButtonText(const QString &txt) -{ - ui->pushButton_launch->setText(txt); -} - -void PrefabViewElement::setIconButtonVisibility(bool visibility) -{ - ui->pushButton_icon->setVisible(visibility); -} - -void PrefabViewElement::onIconClicked() { emit selected(this); } - -void PrefabViewElement::onLaunchClicked() { emit launchRequested(this); } - -void PrefabViewElement::onDeleteClicked() { emit deleteRequested(this); } - -QString PrefabViewElement::getFilePath() const { return filePath; } - -void PrefabViewElement::setFilePath(const QString &value) { filePath = value; } diff --git a/src/shared/Modules/SkywardHub/PrefabViewElement.h b/src/shared/Modules/SkywardHub/PrefabViewElement.h deleted file mode 100644 index a59b290e56fd01bce0798cc74dbb814e73e867e3..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabViewElement.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QWidget> - -#include "Core/XmlObject.h" - -namespace Ui -{ -class PrefabViewElement; -} - -class PrefabViewElement : public QWidget -{ - Q_OBJECT - -public: - explicit PrefabViewElement(const QString &name, QWidget *parent = nullptr); - ~PrefabViewElement(); - - void setName(const QString &value); - QString getName() const; - - QString getDesctiption() const; - void setDesctiption(const QString &value); - - QString getPathToImg() const; - void setPathToImg(const QString &value); - - XmlObject getXml() const; - void setXml(XmlObject &xml); - - void addActiveModuleName(const QString &moduleName); - void removeActiveModuleName(const QString &moduleName); - bool containsModule(const QString &moduleName); - - void setDeleteButtonVisibility(bool visibility); - void setLaunchButtonText(const QString &txt); - void setIconButtonVisibility(bool visibility); - - QString getFilePath() const; - void setFilePath(const QString &value); - -public slots: - void onIconClicked(); - void onLaunchClicked(); - void onDeleteClicked(); - -signals: - void selected(PrefabViewElement *prefabVElement); - void launchRequested(PrefabViewElement *prefabVElement); - void deleteRequested(PrefabViewElement *prefabVElement); - -private: - Ui::PrefabViewElement *ui; - - QString name; - QString desctiption; - QString pathToImg; - XmlObject xml; - QList<QString> activeModules; - QString filePath = ""; - - int height = 0; - int width = 0; -}; diff --git a/src/shared/Modules/SkywardHub/PrefabViewElement.ui b/src/shared/Modules/SkywardHub/PrefabViewElement.ui deleted file mode 100644 index 9ae13c6e2764f698f8e2f2f5a470dd5a1617cc35..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/PrefabViewElement.ui +++ /dev/null @@ -1,127 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PrefabViewElement</class> - <widget class="QWidget" name="PrefabViewElement"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>256</width> - <height>256</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>256</width> - <height>256</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>1024</width> - <height>1024</height> - </size> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>30</number> - </property> - <property name="topMargin"> - <number>30</number> - </property> - <property name="rightMargin"> - <number>30</number> - </property> - <property name="bottomMargin"> - <number>30</number> - </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,0,0"> - <property name="spacing"> - <number>20</number> - </property> - <item> - <widget class="QPushButton" name="pushButton_icon"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_name"> - <property name="text"> - <string>Name</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_desctiption"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>512</width> - <height>512</height> - </size> - </property> - <property name="text"> - <string>Short description</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="pushButton_delete"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_launch"> - <property name="text"> - <string>Launch </string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/shared/Modules/SkywardHub/SkywardHubModule.cpp b/src/shared/Modules/SkywardHub/SkywardHubModule.cpp deleted file mode 100644 index 37ce7888f6ca58563219e419f27baf1e3782d38e..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/SkywardHubModule.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#include "SkywardHubModule.h" - -#include <Core/ModulesManager/ModulesManager.h> - -#include <QDir> -#include <QGridLayout> -#include <QLabel> -#include <QPushButton> - -#include "Deployer.h" -#include "Modules/MainWindow/SkywardHubMainWindow.h" -#include "Modules/SkywardHubStrings.h" -#include "PrefabDialog.h" -#include "PrefabViewElement.h" -#include "QMessageBox" -#include "ui_SkywardHubModule.h" - -SkywardHubModule::SkywardHubModule(QWidget *parent) - : DefaultModule(parent), ui(new Ui::SkywardHubModule) -{ - ui->setupUi(this); - - defaultContextMenuSetup(); - fillCompleteModulesList(); - addEmptyPrefab(); - loadPrefabs(); - - connect(ui->pushButton_deploy, &QPushButton::clicked, this, - [this]() { onPrefabDeployRequested(selectedElement); }); -} - -SkywardHubModule::~SkywardHubModule() -{ - clearPrefab(); - delete emptyPrefab; - emptyPrefab = nullptr; - for (QCheckBox *c : completeModule_checkboxList) - { - delete c; - } - delete ui; -} - -void SkywardHubModule::fillCompleteModulesList() -{ - QList<QString> completeModuleNamesList = - ModulesManager::getModulesNamesList(); - - for (QString s : completeModuleNamesList) - { - QCheckBox *cBox = createPanelsCheckbox(s); - insertCheckBox(cBox); - connect(cBox, &QCheckBox::clicked, this, - [this, cBox]() { onCheckBoxClicked(cBox); }); - } -} - -void SkywardHubModule::loadPrefabs() -{ - clearPrefab(); - nextColumn = 0; - nextRow = 0; - - QString prefabsFolder = SkywardHubStrings::defaultPrefabsFolder; - - QDir directory(prefabsFolder); - QStringList prefabFiles = - directory.entryList(QStringList() << "*.xml", QDir::Files); - for (QString prefabName : prefabFiles) - { - XmlObject xml; - xml.loadFromFile(prefabsFolder + prefabName); - createAndInsertPrefabFromXml(xml, prefabsFolder + prefabName); - } -} - -void SkywardHubModule::updateActiveCheckboxList(PrefabViewElement *element) -{ - if (element == nullptr) - return; - - for (QCheckBox *cBox : completeModule_checkboxList) - { - bool isModuleActive = element->containsModule(cBox->text()); - cBox->setChecked(isModuleActive); - } -} - -void SkywardHubModule::initUsedModules(PrefabViewElement *element, - const XmlObject &root) const -{ - if (element == nullptr) - return; - - // Set as active the used modules - element->addActiveModuleName(root.getObjectName()); - for (int i = 0; i < root.childCount(); i++) - { - initUsedModules(element, root.childAt(i)); - } -} - -void SkywardHubModule::addEmptyPrefab() -{ - Module *module = getCore()->getModulesManager()->instantiateDefaultModule(); - if (module != nullptr) - { - XmlObject xmlconfig(SkywardHubStrings::configurationNameValue); - xmlconfig.addAttribute(SkywardHubStrings::configurationNameAttribute, - "Launch Empty Configuration"); - XmlObject emptyXml = module->toXmlObject(); - xmlconfig.addChild(emptyXml); - PrefabViewElement *prefabView = createNewPrefab(xmlconfig); - if (prefabView != nullptr) - { - initUsedModules(prefabView, xmlconfig); - prefabView->setDeleteButtonVisibility(false); - prefabView->setIconButtonVisibility(false); - prefabView->setLaunchButtonText("+"); - prefabView->setDesctiption( - "Create your custom configuration and then save it (Right " - "Click -> HubMenu -> Save)"); - emptyPrefab = prefabView; - connect(prefabView, &PrefabViewElement::launchRequested, this, - &SkywardHubModule::onPrefabLaunchRequested); - ui->layout_addNewConfig->addWidget(prefabView); - } - } -} - -void SkywardHubModule::createAndInsertPrefabFromXml(XmlObject &xml, - const QString &filePath) -{ - PrefabViewElement *prefabView = createNewPrefab(xml); - if (prefabView != nullptr) - { - prefabView->setFilePath(filePath); - initUsedModules(prefabView, xml); - addPrefab(prefabView); - insertPrefabInUi(prefabView); - } -} - -QCheckBox *SkywardHubModule::createPanelsCheckbox(const QString &text) -{ - QString check_stylesheet = - "" - "QCheckBox" - "{" - "background-color: none;" - "border: 3px solid transparent;" - "color: #00bfff;" - "}" - "QCheckBox:hover" - "{" - "background-color: #474747;" - // "border: 3px solid #00bfff;" - "border-top: 1px solid none;border-right: 3px solid #00bfff; " - "border-bottom: 1px solid none; border-left: 3px solid #00bfff;" - "color: #00bfff;" - "}" - "QCheckBox:checked { background-color: QLinearGradient( x1: 0, y1: 0, " - "x2: 1, y2: 0, stop: 0 #506987, stop: 1 #00739a);" - // "border: 2px solid #00bfff;" /*#3f839a - // #00739a*/ - "border-top: none;border-right: 3px solid #00bfff; border-bottom: " - "none; border-left: 3px solid #00bfff;}"; - - QCheckBox *checkBox = new QCheckBox(text); - checkBox->setStyleSheet(check_stylesheet); - return checkBox; -} - -void SkywardHubModule::insertCheckBox(QCheckBox *checkBox) -{ - ui->modules_layout->insertWidget(0, checkBox); - completeModule_checkboxList.append(checkBox); -} - -void SkywardHubModule::addPrefab(PrefabViewElement *element) -{ - prefabs.append(element); - connect(element, &PrefabViewElement::launchRequested, this, - &SkywardHubModule::onPrefabLaunchRequested); - connect(element, &PrefabViewElement::deleteRequested, this, - &SkywardHubModule::onPrefabDeleteRequested); - connect(element, &PrefabViewElement::selected, this, - &SkywardHubModule::onPrefabSelected); -} - -void SkywardHubModule::insertPrefabInUi(PrefabViewElement *element) -{ - // Insert the prefabView in the correct column - - if (nextColumn == maxColum) - { - nextColumn = 0; - nextRow++; - } - ui->gridLayout_prefab->addWidget(element, nextRow, nextColumn); - nextColumn++; -} - -void SkywardHubModule::clearPrefab() -{ - for (PrefabViewElement *p : prefabs) - { - delete p; - } - prefabs.clear(); - onPrefabSelected(nullptr); -} - -PrefabViewElement *SkywardHubModule::createNewPrefab(XmlObject &xmlPrefab) -{ - if (xmlPrefab.getObjectName() == SkywardHubStrings::configurationNameValue) - { - QString prefName = xmlPrefab.getAttribute( - SkywardHubStrings::configurationNameAttribute); - if (!prefName.isEmpty()) - { - PrefabViewElement *prefabView = new PrefabViewElement(prefName); - prefabView->setXml(xmlPrefab); - return prefabView; - } - } - return nullptr; -} - -void SkywardHubModule::dialogRequested() -{ - PrefabDialog dialog(this); - // connect(&dialog, &PrefabDialog::newPrefabCreated, this, - // &SkywardHubModule::createNewPrefab); - dialog.exec(); -} - -void SkywardHubModule::onPrefabSelected(PrefabViewElement *element) -{ - selectedElement = element; - updateActiveCheckboxList(selectedElement); - ui->plainTextEdit->clear(); - - if (element != nullptr) - { - ui->groupBox_selectedModule->setTitle(element->getName()); - ui->plainTextEdit->insertPlainText(element->getXml().toXml()); - } -} - -void SkywardHubModule::onPrefabLaunchRequested(PrefabViewElement *element) -{ - if (element != nullptr) - { - XmlObject xml = element->getXml(); - getCore()->getModulesManager()->setModules( - getCore()->getModulesManager()->loadModuleFromXml(xml)); - } -} - -void SkywardHubModule::onPrefabDeployRequested(PrefabViewElement *element) -{ - if (element == nullptr) - { - QMessageBox msgBox; - msgBox.setText("No configuration selected."); - msgBox.exec(); - return; - } - - Deployer deployer; - - QList<QString> modulesFiles; - QList<ModuleInfo> fullModuleList = - getCore()->getModulesManager()->getModulesInfo(); - - for (ModuleInfo mInfo : fullModuleList) - { - if (element->containsModule(mInfo.getModuleName())) - { - modulesFiles.append(mInfo.getModuleSourceFiles()); - } - } - - bool deployResult = deployer.deploy(modulesFiles); - - if (deployResult == false) - return; - - // Put the prefab config as default config - QString configPath = deployer.getDeployReleaseFolder() + "/" + - SkywardHubStrings::defaultConfigurationFolder; - if (!QDir(configPath).exists()) - { - QDir().mkdir(configPath); - } - configPath += "/" + SkywardHubStrings::defaultPrefabsFolderName; - if (!QDir(configPath).exists()) - { - QDir().mkdir(configPath); - } - element->getXml().writeToFile( - configPath + "/" + SkywardHubStrings::defaultConfigurationFileName); -} - -void SkywardHubModule::onPrefabDeleteRequested(PrefabViewElement *element) -{ - if (element == nullptr) - return; - - QMessageBox msgBox; - QString title = "Delete configuration"; - QString text = "Do you want to delete the following configuration?\n" + - element->getFilePath(); - if (msgBox.question(this, title, text) == QMessageBox::Yes) - { - QFile file(element->getFilePath()); - if (file.exists()) - { - file.remove(); - loadPrefabs(); - } - } -} - -void SkywardHubModule::onCheckBoxClicked(QCheckBox *cBox) -{ - if (cBox == nullptr || selectedElement == nullptr) - return; - - if (cBox->isChecked()) - { - selectedElement->addActiveModuleName(cBox->text()); - } - else - { - selectedElement->removeActiveModuleName(cBox->text()); - } -} - -QWidget *SkywardHubModule::toWidget() { return this; } - -XmlObject SkywardHubModule::toXmlObject() -{ - return XmlObject(getName(ModuleId::SKYWARDHUB)); -} - -void SkywardHubModule::fromXmlObject(const XmlObject &xmlObject) -{ - Q_UNUSED(xmlObject); -} diff --git a/src/shared/Modules/SkywardHub/SkywardHubModule.h b/src/shared/Modules/SkywardHub/SkywardHubModule.h deleted file mode 100644 index 64ac4ddae6f74facd83826105be7514e7adbdedf..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/SkywardHubModule.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of Skyward Hub. - * - * Skyward Hub is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * Skyward Hub is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * Skyward Hub. If not, see <https://www.gnu.org/licenses/>. - * - */ - -#pragma once - -#include <QCheckBox> -#include <QVBoxLayout> -#include <QWidget> - -#include "Modules/DefaultModule/DefaultModule.h" - -class PrefabViewElement; - -namespace Ui -{ -class SkywardHubModule; -} - -class SkywardHubModule : public DefaultModule -{ - Q_OBJECT - -public: - explicit SkywardHubModule(QWidget *parent = nullptr); - ~SkywardHubModule(); - - QWidget *toWidget() override; - - XmlObject toXmlObject() override; - void fromXmlObject(const XmlObject &xmlObject) override; - - QCheckBox *createPanelsCheckbox(const QString &txt); - void insertCheckBox(QCheckBox *checkBox); - -public slots: - PrefabViewElement *createNewPrefab(XmlObject &xmlPrefab); - void dialogRequested(); - - void onPrefabSelected(PrefabViewElement *element); - void onPrefabLaunchRequested(PrefabViewElement *element); - void onPrefabDeployRequested(PrefabViewElement *element); - void onPrefabDeleteRequested(PrefabViewElement *element); - void onCheckBoxClicked(QCheckBox *cBox); - -protected: - void fillCompleteModulesList(); - void loadPrefabs(); - void updateActiveCheckboxList(PrefabViewElement *element); - void initUsedModules(PrefabViewElement *element, - const XmlObject &root) const; - void addEmptyPrefab(); - void createAndInsertPrefabFromXml(XmlObject &xml, - const QString &filePath = ""); - void addPrefab(PrefabViewElement *element); - void insertPrefabInUi(PrefabViewElement *element); - void clearPrefab(); - -private: - Ui::SkywardHubModule *ui; - QList<QString> panelsList; - QList<QCheckBox *> completeModule_checkboxList; - - QList<PrefabViewElement *> prefabs; - PrefabViewElement *selectedElement = nullptr; - PrefabViewElement *emptyPrefab = nullptr; - int nextColumn = 0; - int nextRow = 0; - int maxColum = 5; -}; diff --git a/src/shared/Modules/SkywardHub/SkywardHubModule.ui b/src/shared/Modules/SkywardHub/SkywardHubModule.ui deleted file mode 100644 index 22c99adae0e4c9bfc5d98250688a32ac0b6b2b8d..0000000000000000000000000000000000000000 --- a/src/shared/Modules/SkywardHub/SkywardHubModule.ui +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>SkywardHubModule</class> - <widget class="QWidget" name="SkywardHubModule"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>782</width> - <height>579</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <item> - <widget class="QSplitter" name="splitter"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="childrenCollapsible"> - <bool>false</bool> - </property> - <widget class="QWidget" name="verticalLayoutWidget_2"> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="2,0,1"> - <item> - <widget class="QScrollArea" name="scrollArea_2"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents_2"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>553</width> - <height>351</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <layout class="QGridLayout" name="gridLayout_prefab"/> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>The following code represent the content of the configuration xml file.</string> - </property> - </widget> - </item> - <item> - <widget class="QPlainTextEdit" name="plainTextEdit"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="verticalLayoutWidget"> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1"> - <item> - <layout class="QVBoxLayout" name="layout_addNewConfig"/> - </item> - <item> - <widget class="QGroupBox" name="groupBox_selectedModule"> - <property name="title"> - <string>Modules</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>164</width> - <height>503</height> - </rect> - </property> - <layout class="QVBoxLayout" name="modules_layout"> - <item> - <widget class="QPushButton" name="pushButton_deploy"> - <property name="text"> - <string>Deploy</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>480</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="verticalLayoutWidget_3"> - <layout class="QVBoxLayout" name="verticalLayout_3"/> - </widget> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/shared/Modules/Splitter/Splitter.cpp b/src/shared/Modules/Splitter/Splitter.cpp index ace4cdaf8534b16926ae83fff9a829c4917c769e..3dfa5ed68f28dade3b3a871d292626380aea4ad7 100644 --- a/src/shared/Modules/Splitter/Splitter.cpp +++ b/src/shared/Modules/Splitter/Splitter.cpp @@ -18,7 +18,6 @@ #include "Splitter.h" -#include <Components/ContextMenuSeparator/ContextMenuSeparator.h> #include <Core/ModulesManager/ModulesManager.h> #include <QDebug> diff --git a/src/shared/Modules/Test/TestModule.cpp b/src/shared/Modules/Test/TestModule.cpp index 328c2f81c67890f17f94e3fbcd19ceaf441b6ae7..7bc640b6b6cf91acd0d70ec3219e260101b2a724 100644 --- a/src/shared/Modules/Test/TestModule.cpp +++ b/src/shared/Modules/Test/TestModule.cpp @@ -21,7 +21,6 @@ #include <Core/MessageBroker/MessageBroker.h> #include <Core/ModulesManager/ModulesManager.h> -#include "Components/ContextMenuSeparator/ContextMenuSeparator.h" #include "ui_TestModule.h" TestModule::TestModule(QWidget* parent)