Kstars

opsindi.cpp
1/*
2 SPDX-FileCopyrightText: 2003 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsindi.h"
8
9#include "ksnotification.h"
10#include "kstars.h"
11#include "Options.h"
12
13#include <KConfigDialog>
14
15#include <QCheckBox>
16#include <QComboBox>
17#include <QDesktopServices>
18#include <QFileDialog>
19#include <QPushButton>
20#include <QStringList>
21
22OpsINDI::OpsINDI() : QFrame(KStars::Instance())
23{
24 setupUi(this);
25
26 //Get a pointer to the KConfigDialog
27 m_ConfigDialog = KConfigDialog::exists("settings");
28
29 selectFITSDirB->setIcon(
30 QIcon::fromTheme("document-open-folder"));
32 selectDriversDirB->setIcon(
33 QIcon::fromTheme("document-open-folder"));
35 selectINDIHubB->setIcon(
36 QIcon::fromTheme("document-open"));
38
39#ifdef Q_OS_OSX
40 connect(kcfg_indiServerIsInternal, SIGNAL(clicked()), this, SLOT(toggleINDIInternal()));
41 kcfg_indiServerIsInternal->setToolTip(i18n("Internal or external INDI server?"));
42 connect(kcfg_indiDriversAreInternal, SIGNAL(clicked()), this, SLOT(toggleDriversInternal()));
43 kcfg_indiDriversAreInternal->setToolTip(i18n("Internal or external INDI drivers?"));
44
45 if (Options::indiServerIsInternal())
46 kcfg_indiServer->setEnabled(false);
47 if (Options::indiDriversAreInternal())
48 kcfg_indiDriversDir->setEnabled(false);
49
50#else
51 kcfg_indiServerIsInternal->setVisible(false);
52 kcfg_indiDriversAreInternal->setVisible(false);
53#endif
54
55 connect(selectFITSDirB, SIGNAL(clicked()), this, SLOT(saveFITSDirectory()));
56 connect(selectDriversDirB, SIGNAL(clicked()), this, SLOT(saveDriversDirectory()));
57 connect(showLogsB, SIGNAL(clicked()), this, SLOT(slotShowLogFiles()));
58 connect(kcfg_indiServer, SIGNAL(editingFinished()), this, SLOT(verifyINDIServer()));
59 connect(selectINDIHubB, &QPushButton::clicked, this, &OpsINDI::saveINDIHubAgent);
60
61#ifdef Q_OS_WIN
62 kcfg_indiServer->setEnabled(false);
63#endif
64}
65
66void OpsINDI::toggleINDIInternal()
67{
68 kcfg_indiServer->setEnabled(!kcfg_indiServerIsInternal->isChecked());
69 if (kcfg_indiServerIsInternal->isChecked())
70 kcfg_indiServer->setText("*Internal INDI Server*");
71 else
72 kcfg_indiServer->setText(KSUtils::getDefaultPath("indiServer"));
73}
74
75void OpsINDI::toggleDriversInternal()
76{
77 kcfg_indiDriversDir->setEnabled(!kcfg_indiDriversAreInternal->isChecked());
78 if (kcfg_indiDriversAreInternal->isChecked())
79 kcfg_indiDriversDir->setText("*Internal INDI Drivers*");
80 else
81 kcfg_indiDriversDir->setText(KSUtils::getDefaultPath("indiDriversDir"));
82
83 KSNotification::info(i18n("You need to restart KStars for this change to take effect."));
84}
85
86void OpsINDI::saveFITSDirectory()
87{
88 QString dir =
89 QFileDialog::getExistingDirectory(KStars::Instance(), i18nc("@title:window", "FITS Default Directory"), kcfg_fitsDir->text());
90
91 if (!dir.isEmpty())
92 kcfg_fitsDir->setText(dir);
93}
94
95void OpsINDI::saveDriversDirectory()
96{
97 QString dir = QFileDialog::getExistingDirectory(KStars::Instance(), i18nc("@title:window", "INDI Drivers Directory"),
98 kcfg_indiDriversDir->text());
99
100 if (!dir.isEmpty())
101 {
102 kcfg_indiDriversDir->setText(dir);
103 KSNotification::info(i18n("You need to restart KStars for this change to take effect."));
104 }
105}
106
107void OpsINDI::saveINDIHubAgent()
108{
109 QUrl url = QFileDialog::getOpenFileUrl(this, i18nc("@title:window", "Select INDIHub Agent"), QUrl(), "indihub-agent");
110 if (url.isEmpty())
111 return;
112
113 kcfg_INDIHubAgent->setText(url.toLocalFile());
114}
115
116void OpsINDI::slotShowLogFiles()
117{
118 QUrl path = QUrl::fromLocalFile(QDir::homePath() + "/.indi/logs");
119
121}
122
123void OpsINDI::verifyINDIServer()
124{
125 // Do not verify internal
126 if (kcfg_indiServerIsInternal->isChecked())
127 return;
128
130
131 if (indiserver.exists() && indiserver.isFile() && indiserver.baseName() == "indiserver")
132 return;
133
134 KSNotification::error(i18n("%1 is not a valid INDI server binary.", kcfg_indiServer->text()));
135}
static KConfigDialog * exists(const QString &name)
This is the main window for KStars.
Definition kstars.h:91
static KStars * Instance()
Definition kstars.h:123
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
KIOCORE_EXPORT QString dir(const QString &fileClass)
void clicked(bool checked)
bool openUrl(const QUrl &url)
QString homePath()
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, Options options)
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
QIcon fromTheme(const QString &name)
WA_LayoutUsesWidgetRect
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
bool isEmpty() const const
QString toLocalFile() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.