File indexing completed on 2024-04-21 14:46:04
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jasem Mutlaq 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QList> 0010 #include <QWidget> 0011 0012 class QCloseEvent; 0013 class QHideEvent; 0014 class QPushButton; 0015 class QShowEvent; 0016 class QString; 0017 class QTabWidget; 0018 class QVBoxLayout; 0019 0020 class INDI_D; 0021 0022 class ClientManager; 0023 class DeviceInfo; 0024 0025 /** 0026 * @class GUIManager 0027 * GUIManager creates the INDI Control Panel upon receiving a new device. Each device is displayed 0028 * on a separate tab. The device and property GUI creation is performed dynamically via introspection. As new properties 0029 * arrive from the ClientManager, they get created in the GUI. 0030 * 0031 * @author Jasem Mutlaq 0032 */ 0033 class GUIManager : public QWidget 0034 { 0035 Q_OBJECT 0036 public: 0037 static GUIManager *Instance(); 0038 static void release(); 0039 0040 void updateStatus(bool toggle_behavior); 0041 0042 INDI_D *findGUIDevice(const QString &deviceName); 0043 0044 void addClient(ClientManager *cm); 0045 void removeClient(ClientManager *cm); 0046 0047 QList<INDI_D *> getDevices() 0048 { 0049 return guidevices; 0050 } 0051 0052 int size() 0053 { 0054 return guidevices.size(); 0055 } 0056 0057 protected: 0058 void closeEvent(QCloseEvent *) override; 0059 void hideEvent(QHideEvent *) override; 0060 void showEvent(QShowEvent *) override; 0061 0062 private: 0063 /***************************************************************** 0064 * GUI stuff 0065 ******************************************************************/ 0066 QVBoxLayout *mainLayout; 0067 QTabWidget *mainTabWidget; 0068 QPushButton *clearB; 0069 QPushButton *closeB; 0070 GUIManager(QWidget *parent = nullptr); 0071 ~GUIManager() override; 0072 0073 static GUIManager *_GUIManager; 0074 QList<ClientManager *> clients; 0075 QList<INDI_D *> guidevices; 0076 0077 public slots: 0078 void changeAlwaysOnTop(Qt::ApplicationState state); 0079 void clearLog(); 0080 void buildDevice(DeviceInfo *di); 0081 void removeDevice(const QString &name); 0082 };