9#include "clientmanager.h"
10#include "deviceinfo.h"
11#include "indidevice.h"
14#include "fitsviewer/fitsviewer.h"
15#include "ksnotification.h"
17#include <KActionCollection>
20#include <QApplication>
27extern const char *libindi_strings_context;
33 if (_GUIManager ==
nullptr)
35 _GUIManager =
new GUIManager(
42void GUIManager::release()
45 _GUIManager =
nullptr;
51 if (Options::independentWindowINDI())
63 mainLayout->setContentsMargins(10, 10, 10, 10);
64 mainLayout->setSpacing(10);
68 mainLayout->addWidget(mainTabWidget);
72 setWindowTitle(
i18nc(
"@title:window",
"INDI Control Panel"));
83 mainLayout->addLayout(buttonLayout);
86 connect(clearB, SIGNAL(clicked()),
this, SLOT(clearLog()));
88 resize(Options::iNDIWindowWidth(), Options::iNDIWindowHeight());
92 showINDIPanel->
setChecked(Options::showINDIwindowInitially());
95GUIManager::~GUIManager()
97 for (
auto oneClient : qAsConst(clients))
98 oneClient->disconnect(
this);
119 QAction *showINDIPanel =
124 Options::setINDIWindowWidth(
width());
125 Options::setINDIWindowHeight(
height());
149void GUIManager::updateStatus(
bool toggle_behavior)
151 QAction *showINDIPanel =
154 if (guidevices.count() == 0)
156 KSNotification::error(
i18n(
"No INDI devices currently running. To run devices, "
157 "please select devices from the "
158 "Device Manager in the devices menu."));
165 showINDIPanel->
setEnabled(getDevices().size() > 0);
184 for (
auto oneGUIDevice : guidevices)
186 if (oneGUIDevice->name() == deviceName)
193void GUIManager::clearLog()
195 INDI_D *dev = findGUIDevice(
196 mainTabWidget->tabText(mainTabWidget->currentIndex()).remove(QChar(
'&')));
199 dev->clearMessageLog();
205 connect(cm, &ClientManager::newINDIDevice,
this, &GUIManager::buildDevice);
206 connect(cm, &ClientManager::removeINDIDevice,
this, &GUIManager::removeDevice);
211 clients.removeOne(cm);
213 QMutableListIterator<INDI_D *> it(guidevices);
216 INDI_D *gdv = it.next();
218 if (gdv->getClientManager() == cm)
220 for (
int i = 0; i < mainTabWidget->count(); i++)
222 if (mainTabWidget->tabText(i).remove(
'&') == QString(gdv->name()))
224 mainTabWidget->removeTab(i);
234 if (clients.size() == 0)
238void GUIManager::removeDevice(
const QString &name)
240 INDI_D *dp = findGUIDevice(name);
245 if (dp->getClientManager())
251 if (mainTabWidget->count() != guidevices.count())
254 for (
int i = 0; i < mainTabWidget->count(); i++)
256 if (mainTabWidget->tabText(i).remove(
'&') == name)
258 mainTabWidget->removeTab(i);
263 guidevices.removeOne(dp);
266 if (guidevices.isEmpty())
268 QAction *showINDIPanel =
277 Q_ASSERT_X(cm, __FUNCTION__,
"Client manager is not valid.");
279 INDI_D *gdm =
new INDI_D(mainTabWidget, di->getBaseDevice(), cm);
281 connect(cm, &ClientManager::newINDIProperty, gdm, &INDI_D::buildProperty);
282 connect(cm, &ClientManager::removeINDIProperty, gdm, &INDI_D::removeProperty);
283 connect(cm, &ClientManager::updateINDIProperty, gdm, &INDI_D::updateProperty);
284 connect(cm, &ClientManager::newINDIMessage, gdm, &INDI_D::updateMessageLog);
287 for (
auto &oneProperty : di->getBaseDevice().getProperties())
288 gdm->buildProperty(oneProperty);
290 auto deviceName = di->getDeviceName();
291 auto index = mainTabWidget->
count();
292 for (
int i = 0; i < mainTabWidget->count(); i++)
294 if (mainTabWidget->tabText(i) > deviceName)
301 mainTabWidget->insertTab(index, gdm, di->getDeviceName());
302 guidevices.insert(index, gdm);
ClientManager manages connection to INDI server, creation of devices, and receiving/sending propertie...
DeviceInfo is simple class to hold DriverInfo and INDI::BaseDevice associated with a particular devic...
GUIManager creates the INDI Control Panel upon receiving a new device.
INDI_D represents an INDI GUI Device.
Q_INVOKABLE QAction * action(const QString &name) const
static KStars * Instance()
virtual KActionCollection * actionCollection() const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void insertStretch(int index, int stretch)
QCoreApplication * instance()
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
T qobject_cast(QObject *object)
QObject * sender() const const
qsizetype count() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void msleep(unsigned long msecs)