Skip to content

Commit 412354c

Browse files
committed
Add a warning dialog if ASCOM version is outdated but telescope preconfigured.
1 parent 482c982 commit 412354c

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

plugins/TelescopeControl/src/common/ASCOMSupport.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@ bool ASCOMSupport::isASCOMSupported()
3232
{
3333
#ifdef Q_OS_WIN
3434

35+
int majorVersion = getASCOMMajorVersion();
36+
37+
// Check ASCOM Platform version to be 6 or greater. We apparently need 7 for Qt6!
38+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
39+
if (majorVersion >= 7)
40+
#else
41+
if (majorVersion >= 6)
42+
#endif
43+
{
44+
return true;
45+
}
46+
47+
return false;
48+
49+
#else // Q_OS_WIN
50+
return false;
51+
#endif // Q_OS_WIN
52+
}
53+
54+
int ASCOMSupport::getASCOMMajorVersion()
55+
{
56+
#ifdef Q_OS_WIN
57+
3558
VARIANT v1;
3659
HRESULT hResult;
3760
BOOL initResult;
@@ -44,7 +67,7 @@ bool ASCOMSupport::isASCOMSupported()
4467
if (FAILED(hResult) || !initResult) {
4568
return false;
4669
}
47-
70+
4871
hResult = OlePropertyGet(utilDispatch, &v1, const_cast<wchar_t*>(LPlatformVersion));
4972
QString version = QString::fromStdWString(v1.bstrVal);
5073
QString majorVersion = "";
@@ -54,22 +77,13 @@ bool ASCOMSupport::isASCOMSupported()
5477
if (versionMatch.hasMatch())
5578
{
5679
majorVersion = versionMatch.captured(1).trimmed();
80+
return majorVersion.toInt();
5781
}
5882

59-
// Check ASCOM Platform version to be 6 or greater. We apparently need 7 for Qt6!
60-
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
61-
if (majorVersion.toInt() >= 7)
62-
#else
63-
if (majorVersion.toInt() >= 6)
64-
#endif
65-
{
66-
return true;
67-
}
68-
69-
return false;
83+
return 0;
7084

7185
#else // Q_OS_WIN
72-
return false;
86+
return 0;
7387
#endif // Q_OS_WIN
7488
}
7589

plugins/TelescopeControl/src/common/ASCOMSupport.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ASCOMSupport final : public QObject
3131

3232
public:
3333
static bool isASCOMSupported();
34+
static int getASCOMMajorVersion();
3435

3536
ASCOMSupport(QObject* parent = nullptr);
3637

plugins/TelescopeControl/src/gui/TelescopeDialog.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#include <QSettings>
4040
#include <QStandardItem>
4141
#include <QRegularExpression>
42+
#if defined(Q_OS_WIN)
43+
#include "../common/ASCOMSupport.hpp"
44+
#include <QMessageBox>
45+
#endif
4246

4347

4448
TelescopeDialog::TelescopeDialog(const QString &dialogName, QObject *parent)
@@ -108,6 +112,11 @@ void TelescopeDialog::createDialogContent()
108112
connect(gui, SIGNAL(flagUseKineticScrollingChanged(bool)), this, SLOT(enableKineticScrolling(bool)));
109113
}
110114

115+
#ifdef Q_OS_WIN
116+
if ((ASCOMSupport::getASCOMMajorVersion() > 0) && (ASCOMSupport::getASCOMMajorVersion() < 7))
117+
QMessageBox::warning(nullptr, q_("Outdated ASCOM!"), q_("Your ASCOM is below version 7. Upgrade to avoid problems!") );
118+
#endif
119+
111120
//Inherited connect
112121
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
113122
connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);

0 commit comments

Comments
 (0)