Skip to content

Commit

Permalink
Various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Nov 25, 2024
1 parent 9af22fb commit d8a02bd
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/android/src/io/emeric/utils/QGpsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static boolean checkGpsEnabled(final Context context) {

final int locationMode;
try {
// This constant was deprecated in API level 28.
// This constant was deprecated in API level 28.
locationMode = Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
Expand Down
107 changes: 107 additions & 0 deletions thirdparty/AppUtils/AppUtils.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

# Optional stuff (for macOS)
#CONFIG += UTILS_DOCK_ENABLED

# Optional stuff (for iOS)
#CONFIG += UTILS_WIFI_ENABLED
#CONFIG += UTILS_NOTIFICATIONS_ENABLED

# Generic utils
SOURCES += $${PWD}/utils_app.cpp \
$${PWD}/utils_bits.cpp \
$${PWD}/utils_clipboard.cpp \
$${PWD}/utils_fpsmonitor.cpp \
$${PWD}/utils_language.cpp \
$${PWD}/utils_log.cpp \
$${PWD}/utils_maths.cpp \
$${PWD}/utils_screen.cpp \
$${PWD}/utils_sysinfo.cpp \
$${PWD}/utils_wifi.cpp

HEADERS += $${PWD}/utils_app.h \
$${PWD}/utils_bits.h \
$${PWD}/utils_clipboard.h \
$${PWD}/utils_fpsmonitor.h \
$${PWD}/utils_language.h \
$${PWD}/utils_log.h \
$${PWD}/utils_maths.h \
$${PWD}/utils_screen.h \
$${PWD}/utils_sysinfo.h \
$${PWD}/utils_versionchecker.h \
$${PWD}/utils_wifi.h

INCLUDEPATH += $${PWD}

versionAtLeast(QT_VERSION, 6.6) {
QT += gui-private # to get RHI info
}

# Linux OS utils
linux:!android {
QT += dbus

SOURCES += $${PWD}/utils_os_linux.cpp
HEADERS += $${PWD}/utils_os_linux.h
}

# macOS utils
macx {
LIBS += -framework IOKit
SOURCES += $${PWD}/utils_os_macos.mm
HEADERS += $${PWD}/utils_os_macos.h

# macOS dock click handler (optional)
UTILS_DOCK_ENABLED {
DEFINES += UTILS_DOCK_ENABLED
LIBS += -framework AppKit
SOURCES += $${PWD}/utils_os_macos_dock.mm
HEADERS += $${PWD}/utils_os_macos_dock.h
}
}

# Windows OS utils
win32 {
DEFINES += _USE_MATH_DEFINES
SOURCES += $${PWD}/utils_os_windows.cpp
HEADERS += $${PWD}/utils_os_windows.h
}

# Android OS utils
android {
DEFINES += UTILS_NOTIFICATIONS_ENABLED UTILS_WIFI_ENABLED

versionAtLeast(QT_VERSION, 6.0) {
QT += core-private

SOURCES += $${PWD}/utils_os_android_qt6.cpp
HEADERS += $${PWD}/utils_os_android.h
} else {
QT += androidextras

SOURCES += $${PWD}/utils_os_android_qt5.cpp
HEADERS += $${PWD}/utils_os_android.h
}
}

# iOS utils
ios {
LIBS += -framework UIKit
SOURCES += $${PWD}/utils_os_ios.mm
HEADERS += $${PWD}/utils_os_ios.h

# iOS notifications (optional)
UTILS_NOTIFICATIONS_ENABLED {
DEFINES += UTILS_NOTIFICATIONS_ENABLED
LIBS += -framework UserNotifications
SOURCES += $${PWD}/utils_os_ios_notif.mm
HEADERS += $${PWD}/utils_os_ios_notif.h
}

# iOS WiFi SSID (optional)
UTILS_WIFI_ENABLED {
DEFINES += UTILS_WIFI_ENABLED
LIBS += -framework SystemConfiguration
SOURCES += $${PWD}/utils_os_ios_wifi.mm
HEADERS += $${PWD}/utils_os_ios_wifi.h
}
}
5 changes: 5 additions & 0 deletions thirdparty/AppUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ set(CMAKE_AUTOMOC ON)

################################################################################

# Optional stuff (for macOS)
#set(UTILS_DOCK_ENABLED true)

# Optional stuff (for iOS)
#set(UTILS_WIFI_ENABLED true)
#set(UTILS_NOTIFICATIONS_ENABLED true)

Expand All @@ -28,6 +31,8 @@ set(CORE_SOURCES
utils_app.h
utils_bits.cpp
utils_bits.h
utils_clipboard.cpp
utils_clipboard.h
utils_fpsmonitor.cpp
utils_fpsmonitor.h
utils_language.cpp
Expand Down
8 changes: 4 additions & 4 deletions thirdparty/AppUtils/utils_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class UtilsWiFi: public QObject
Q_PROPERTY(bool permissionOS READ hasPermissionOS NOTIFY permissionsChanged)

QString m_currentSSID;
QString getCurrentSSID() { return m_currentSSID; }

bool m_permOS = false;
bool hasPermissionOS() const { return m_permOS; }

void refreshWiFi_internal();

Expand All @@ -65,10 +63,12 @@ private slots:
public:
static UtilsWiFi *getInstance();

Q_INVOKABLE void refreshWiFi();
QString getCurrentSSID() { return m_currentSSID; }

Q_INVOKABLE bool checkLocationPermissions();
Q_INVOKABLE void requestLocationPermissions();

Q_INVOKABLE void refreshWiFi();
bool hasPermissionOS() const { return m_permOS; }
};

/* ************************************************************************** */
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/ComponentLibrary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if (TARGET Qt::Location)
maps/MapScale.qml
)
else()
message(NOTICE "Skipping the mapping components from ComponentLibrary as Qt6::Location is not used.")
message(STATUS "Skipping the mapping components from ComponentLibrary as Qt6::Location is not used.")
endif()

list(APPEND MODULE_QML_FILES
Expand Down

0 comments on commit d8a02bd

Please sign in to comment.