File indexing completed on 2024-12-08 04:16:50
0001 /* AtCore Test Client 0002 * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 * SPDX-FileCopyrightText: 2016-2018 Patrick José Pereira <patrickjp@kde.org> 0004 * SPDX-FileCopyrightText: 2016-2017 Lays Rodrigues <lays.rodrigues@kde.org> 0005 * SPDX-FileCopyrightText: 2016-2019 Chris Rizzitello <rizzitello@kde.org> 0006 * SPDX-FileCopyrightText: 2016 Tomaz Canabrava <tcanabrava@kde.org> 0007 */ 0008 0009 #pragma once 0010 0011 #include <QMainWindow> 0012 0013 #include "atcore.h" 0014 #include "commandwidget.h" 0015 #include "logwidget.h" 0016 #include "movementwidget.h" 0017 #include "plotwidget.h" 0018 #include "printwidget.h" 0019 #include "profilemanager.h" 0020 #include "sdwidget.h" 0021 #include "statuswidget.h" 0022 #include "temperaturewidget.h" 0023 0024 class SerialLayer; 0025 0026 class MainWindow : public QMainWindow 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit MainWindow(QWidget *parent = nullptr); 0032 ~MainWindow() override = default; 0033 0034 public slots: 0035 /** 0036 * @brief Check temperature 0037 * 0038 * @param sensorType : type of sensor 0039 * @param number : index of sensor 0040 * @param temp : temperature 0041 */ 0042 void checkTemperature(uint sensorType, uint number, float temp); 0043 0044 private slots: 0045 // ButtonEvents 0046 0047 /** 0048 * @brief Connect Button Clicked will connect or disconnect based on printer state 0049 */ 0050 void connectPBClicked(); 0051 0052 /** 0053 * @brief Print Button Clicked, can also pause /resue print based on printer state 0054 */ 0055 void printPBClicked(); 0056 0057 /** 0058 * @brief printerStateChanged Catch and proccess printer state commands 0059 * @param state: new printer state 0060 */ 0061 void printerStateChanged(AtCore::STATES state); 0062 0063 /** 0064 * @brief show/hide dock titlebars 0065 * @param checked: True if shown 0066 */ 0067 void toggleDockTitles(bool checked); 0068 0069 /** 0070 * @brief set enabled for connection option widgets (port, baud and fw selector) 0071 * @param enabled: true if enabled. 0072 */ 0073 void setConnectionWidgetsEnabled(bool enabled); 0074 /** 0075 * @brief Toggle disable state of dangerous docks 0076 * Command, Sd Card, Movement, Temperature Controls and Printing docks 0077 * @param disabled: True if items are disabled. 0078 */ 0079 void setDangeriousDocksDisabled(bool disabled); 0080 /** 0081 * @brief Called when atcore changes it temperature reporting mode 0082 * @param autoReport: True if using temperature auto reporting 0083 */ 0084 void updateAutoTemperatureReport(bool autoReport); 0085 0086 private: 0087 AtCore *core; 0088 // Define max number of fans 0089 static int fanCount; 0090 0091 void closeEvent(QCloseEvent *event) override; 0092 /** 0093 * @brief Locate serial port 0094 * 0095 */ 0096 void locateSerialPort(const QStringList &ports); 0097 0098 /** 0099 * @brief setupActions for KXMLGui 0100 */ 0101 void setupActions(); 0102 0103 /** 0104 * @brief Populate comboboxes 0105 */ 0106 void populateCBs(); 0107 0108 /** 0109 * @brief Gui Changes for when sd card mount status has changed. 0110 */ 0111 void sdChanged(bool mounted); 0112 0113 // UI Functions 0114 0115 /** 0116 * @brief Create The Menubar 0117 */ 0118 void initMenu(); 0119 0120 /** 0121 * @brief Create StatusBar 0122 */ 0123 void initStatusBar(); 0124 0125 /** 0126 * @brief Create Main Widgets. 0127 */ 0128 void initWidgets(); 0129 0130 // Private GUI Items 0131 // menuView is global to allow for docks to be added / removed. 0132 QMenu *menuView = nullptr; 0133 // Status Bar Items 0134 StatusWidget *statusWidget = nullptr; 0135 // Docks 0136 void makeLogDock(); 0137 QDockWidget *logDock = nullptr; 0138 LogWidget *logWidget = nullptr; 0139 0140 void makeTempTimelineDock(); 0141 QDockWidget *tempTimelineDock = nullptr; 0142 PlotWidget *plotWidget = nullptr; 0143 0144 void makeCommandDock(); 0145 QDockWidget *commandDock = nullptr; 0146 CommandWidget *commandWidget = nullptr; 0147 0148 void makePrintDock(); 0149 QDockWidget *printDock = nullptr; 0150 PrintWidget *printWidget = nullptr; 0151 0152 void makeConnectDock(); 0153 QDockWidget *connectDock = nullptr; 0154 QComboBox *comboPort = nullptr; 0155 QComboBox *comboProfile = nullptr; 0156 QPushButton *buttonConnect = nullptr; 0157 QCheckBox *cbReset = nullptr; 0158 QTimer *connectionTimer = nullptr; 0159 QSpinBox *sbTemperatureTimer = nullptr; 0160 void makeMoveDock(); 0161 QDockWidget *moveDock = nullptr; 0162 MovementWidget *movementWidget = nullptr; 0163 0164 void makeTempControlsDock(); 0165 QDockWidget *tempControlsDock = nullptr; 0166 TemperatureWidget *temperatureWidget = nullptr; 0167 0168 void makeSdDock(); 0169 QDockWidget *sdDock = nullptr; 0170 SdWidget *sdWidget = nullptr; 0171 0172 void makeProfileDock(); 0173 QDockWidget *profileDock = nullptr; 0174 ProfileManager *profileManager = nullptr; 0175 };