summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/CMakeLists.txt2
-rw-r--r--core/applicationstate.cpp15
-rw-r--r--core/applicationstate.h21
-rw-r--r--core/qthelper.cpp15
-rw-r--r--core/qthelper.h2
5 files changed, 40 insertions, 15 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index c55b5627d..17a2bd0c7 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -37,6 +37,8 @@ endif()
# compile the core library part in C, part in C++
set(SUBSURFACE_CORE_LIB_SRCS
+ applicationstate.cpp
+ applicationstate.h
checkcloudconnection.cpp
checkcloudconnection.h
cloudstorage.cpp
diff --git a/core/applicationstate.cpp b/core/applicationstate.cpp
new file mode 100644
index 000000000..a5adde8cf
--- /dev/null
+++ b/core/applicationstate.cpp
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "applicationstate.h"
+
+static ApplicationState appState = (ApplicationState)-1; // Set to an invalid value
+
+ApplicationState getAppState()
+{
+ return appState;
+}
+
+void setAppState(ApplicationState state)
+{
+ appState = state;
+}
+
diff --git a/core/applicationstate.h b/core/applicationstate.h
new file mode 100644
index 000000000..fbaf3e829
--- /dev/null
+++ b/core/applicationstate.h
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef APPLICATIONSTATE_H
+#define APPLICATIONSTATE_H
+
+// By using an enum class, the enum entries don't polute the global namespace.
+// Moreover, they are strongly typed. This means that they are not auto-converted
+// to integer types if e.g. used as array-indices.
+enum class ApplicationState {
+ Default,
+ EditDive,
+ PlanDive,
+ EditPlannedDive,
+ EditDiveSite,
+ FilterDive,
+ Count
+};
+
+ApplicationState getAppState();
+void setAppState(ApplicationState state);
+
+#endif
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 3abcec04a..65c55414d 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -12,6 +12,7 @@
#include "divecomputer.h"
#include "time.h"
#include "gettextfromc.h"
+#include "applicationstate.h"
#include "metadata.h"
#include <sys/time.h>
#include "exif.h"
@@ -1362,21 +1363,9 @@ extern "C" void parse_display_units(char *line)
qDebug() << line;
}
-static QByteArray currentApplicationState;
-
-QByteArray getCurrentAppState()
-{
- return currentApplicationState;
-}
-
-void setCurrentAppState(const QByteArray &state)
-{
- currentApplicationState = state;
-}
-
extern "C" bool in_planner()
{
- return currentApplicationState == "PlanDive" || currentApplicationState == "EditPlannedDive";
+ return getAppState() == ApplicationState::PlanDive || getAppState() == ApplicationState::EditPlannedDive;
}
extern "C" enum deco_mode decoMode()
diff --git a/core/qthelper.h b/core/qthelper.h
index 2a91df9ef..53b0cc59a 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -40,8 +40,6 @@ volume_t string_to_volume(const char *str, pressure_t workp);
fraction_t string_to_fraction(const char *str);
int getCloudURL(QString &filename);
bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
-QByteArray getCurrentAppState();
-void setCurrentAppState(const QByteArray &state);
void init_proxy();
QString getUUID();
extern const QStringList videoExtensionsList;