File indexing completed on 2024-05-05 07:42:54
0001 /* 0002 SPDX-FileCopyrightText: 2003 Jasem Mutlaq <mutlaqja@ikarustech.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 0006 0007 */ 0008 0009 #pragma once 0010 0011 #include "indicommon.h" 0012 #include <indiproperty.h> 0013 0014 #include <QWidget> 0015 0016 #include <memory> 0017 0018 namespace INDI 0019 { 0020 class Property; 0021 } 0022 0023 class INDI_G; 0024 class INDI_E; 0025 0026 class QAbstractButton; 0027 class QButtonGroup; 0028 class QCheckBox; 0029 class QComboBox; 0030 class QHBoxLayout; 0031 class QPushButton; 0032 class QSpacerItem; 0033 class QVBoxLayout; 0034 0035 class KLed; 0036 class KSqueezedTextLabel; 0037 0038 /** 0039 * @class INDI_P 0040 * INDI_P represents a single INDI property (Switch, Text, Number, Light, or BLOB). It handles building the GUI and updating the property status and/or value as new data 0041 * arrive from INDI Serve. It also sends any changes in the property value back to INDI server via the ClientManager. 0042 * 0043 * @author Jasem Mutlaq 0044 */ 0045 class INDI_P : public QWidget 0046 { 0047 Q_OBJECT 0048 public: 0049 INDI_P(INDI_G *ipg, INDI::Property prop); 0050 0051 /* Draw state LED */ 0052 void updateStateLED(); 0053 0054 /* Update menu gui */ 0055 void updateMenuGUI(); 0056 0057 void initGUI(); 0058 0059 void buildSwitchGUI(); 0060 void buildMenuGUI(); 0061 void buildTextGUI(); 0062 void buildNumberGUI(); 0063 void buildLightGUI(); 0064 void buildBLOBGUI(); 0065 0066 /** Setup the 'set' button in the property */ 0067 void setupSetButton(const QString &caption); 0068 0069 /** 0070 * @brief newTime Display dialog to set UTC date and time to the driver. 0071 */ 0072 void newTime(); 0073 0074 PGui getGUIType() const 0075 { 0076 return guiType; 0077 } 0078 0079 INDI_G *getGroup() const 0080 { 0081 return pg; 0082 } 0083 0084 const QString &getName() const 0085 { 0086 return name; 0087 } 0088 0089 void addWidget(QWidget *w); 0090 void addLayout(QHBoxLayout *layout); 0091 0092 INDI_E *getElement(const QString &elementName) const; 0093 0094 QList<INDI_E *> getElements() const 0095 { 0096 return elementList; 0097 } 0098 bool isRegistered() const; 0099 const INDI::Property getProperty() const 0100 { 0101 return dataProp; 0102 } 0103 0104 public slots: 0105 void processSetButton(); 0106 void newSwitch(QAbstractButton *button); 0107 void newSwitch(int index); 0108 void newSwitch(const QString &name); 0109 void resetSwitch(); 0110 0111 void sendBlob(); 0112 void sendSwitch(); 0113 void sendText(); 0114 0115 void setBLOBOption(int state); 0116 0117 private: 0118 /// Parent group 0119 INDI_G *pg { nullptr }; 0120 INDI::Property dataProp; 0121 QCheckBox *enableBLOBC { nullptr }; 0122 /// Label widget 0123 KSqueezedTextLabel* labelW { nullptr }; 0124 /// Set button 0125 QPushButton* setB { nullptr }; 0126 /// Status LED 0127 KLed* ledStatus { nullptr }; 0128 /// GUI type 0129 PGui guiType; 0130 /// Horizontal spacer 0131 QSpacerItem *horSpacer { nullptr }; 0132 /// Horizontal container 0133 QHBoxLayout *PHBox { nullptr }; 0134 /// Vertical container 0135 QVBoxLayout *PVBox { nullptr }; 0136 /// Group button for radio and check boxes (Elements) 0137 QButtonGroup *groupB { nullptr }; 0138 /// Combo box for menu 0139 QComboBox* menuC { nullptr }; 0140 QString name; 0141 /// List of elements 0142 QList<INDI_E *> elementList; 0143 };