Skip to content

Commit 8e2d22c

Browse files
committed
Update shared components
1 parent f8adbe5 commit 8e2d22c

122 files changed

Lines changed: 1618 additions & 1262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE AppUtils)
152152

153153
# MobileUI
154154
add_subdirectory(thirdparty/MobileUI)
155-
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE MobileUI)
155+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE MobileUI MobileUI_plugin)
156156

157157
# MobileSharing
158158
add_subdirectory(thirdparty/MobileSharing)
159159
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE MobileSharing)
160160

161161
# ComponentLibrary
162162
add_subdirectory(thirdparty/ComponentLibrary)
163-
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ComponentLibraryplugin)
163+
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ComponentLibrary_plugin)
164164

165165
if(USE_ZXINGCPP)
166166
# build zxing-cpp

qml/DesktopApplication.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ ApplicationWindow {
172172
}
173173
}
174174
Shortcut {
175-
sequence: StandardKey.Preferences
175+
sequences: [StandardKey.Preferences]
176176
onActivated: appContent.state = "settings"
177177
}
178178
Shortcut {
@@ -191,9 +191,9 @@ ApplicationWindow {
191191
acceptedButtons: Qt.BackButton | Qt.ForwardButton
192192
onClicked: (mouse) => {
193193
if (mouse.button === Qt.BackButton) {
194-
backAction()
194+
appWindow.backAction()
195195
} else if (mouse.button === Qt.ForwardButton) {
196-
forwardAction()
196+
appWindow.forwardAction()
197197
}
198198
}
199199
}

qml/MobileApplication.qml

Lines changed: 16 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -31,145 +31,23 @@ Window {
3131
property int screenOrientation: Screen.primaryOrientation
3232
property int screenOrientationFull: Screen.orientation
3333

34-
property int screenPaddingStatusbar: 0
35-
property int screenPaddingNavbar: 0
36-
37-
property int screenPaddingTop: 0
38-
property int screenPaddingLeft: 0
39-
property int screenPaddingRight: 0
40-
property int screenPaddingBottom: 0
41-
42-
Connections {
43-
target: Screen
44-
function onOrientationChanged() { mobileUI.handleSafeAreas_withDelays() }
45-
}
46-
Connections {
47-
target: Theme
48-
function onCurrentThemeChanged() { mobileUI.handleSafeAreas_withDelays() }
49-
}
50-
51-
Timer {
52-
id: rotateTimer1
53-
interval: 50
54-
running: false
55-
repeat: false
56-
onTriggered: { mobileUI.handleSafeAreas() }
57-
}
58-
Timer {
59-
id: rotateTimer2
60-
interval: 256
61-
running: false
62-
repeat: false
63-
onTriggered: { mobileUI.handleSafeAreas() }
64-
}
65-
Timer {
66-
id: rotateTimer3
67-
interval: 512
68-
running: false
69-
repeat: false
70-
onTriggered: { mobileUI.handleSafeAreas() }
34+
property int screenPaddingStatusbar: MobileUI.statusbarHeight
35+
property int screenPaddingNavbar: MobileUI.navbarHeight
36+
37+
property int screenPaddingTop: MobileUI.safeAreaTop
38+
property int screenPaddingLeft: MobileUI.safeAreaLeft
39+
property int screenPaddingRight: MobileUI.safeAreaRight
40+
property int screenPaddingBottom: MobileUI.safeAreaBottom
41+
42+
Binding {
43+
target: MobileUI
44+
property: "statusbarTheme"
45+
value: { return (appContent.state === "ScreenBarcodeReader") ? MobileUI.Dark : Theme.themeStatusbar }
7146
}
72-
Timer {
73-
id: rotateTimer4
74-
interval: 1000
75-
running: false
76-
repeat: false
77-
onTriggered: { mobileUI.handleSafeAreas() }
78-
}
79-
80-
MobileUI {
81-
id: mobileUI
82-
83-
statusbarColor: "transparent"
84-
statusbarTheme: (appContent.state === "ScreenBarcodeReader") ? MobileUI.Dark : Theme.themeStatusbar
85-
86-
navbarColor: "transparent"
87-
navbarTheme: (appContent.state === "ScreenBarcodeReader") ? MobileUI.Dark : Theme.themeStatusbar
88-
89-
Component.onCompleted: {
90-
mobileUI.handleSafeAreas_withDelays()
91-
}
92-
93-
function handleSafeAreas_withDelays() {
94-
handleSafeAreas()
95-
rotateTimer1.start()
96-
rotateTimer2.start()
97-
rotateTimer3.start()
98-
rotateTimer4.start()
99-
}
100-
101-
function handleSafeAreas() {
102-
// safe areas handling is a work in progress /!\
103-
// safe areas are only taken into account when using maximized geometry / full screen mode
104-
105-
mobileUI.refreshUI() // hack
106-
107-
mobileUI.statusbarTheme = Theme.themeStatusbar // hack
108-
109-
if (appWindow.visibility === Window.FullScreen ||
110-
appWindow.flags & Qt.MaximizeUsingFullscreenGeometryHint) {
111-
112-
screenPaddingStatusbar = mobileUI.statusbarHeight
113-
screenPaddingNavbar = mobileUI.navbarHeight
114-
115-
screenPaddingTop = mobileUI.safeAreaTop
116-
screenPaddingLeft = mobileUI.safeAreaLeft
117-
screenPaddingRight = mobileUI.safeAreaRight
118-
screenPaddingBottom = mobileUI.safeAreaBottom
119-
120-
// hacks
121-
if (Qt.platform.os === "android") {
122-
if (appWindow.visibility === Window.FullScreen) {
123-
screenPaddingStatusbar = 0
124-
screenPaddingNavbar = 0
125-
}
126-
if (appWindow.flags & Qt.MaximizeUsingFullscreenGeometryHint) {
127-
if (mobileUI.isPhone) {
128-
if (Screen.orientation === Qt.LandscapeOrientation) {
129-
screenPaddingLeft = screenPaddingStatusbar
130-
screenPaddingRight = screenPaddingNavbar
131-
screenPaddingNavbar = 0
132-
} else if (Screen.orientation === Qt.InvertedLandscapeOrientation) {
133-
screenPaddingLeft = screenPaddingNavbar
134-
screenPaddingRight = screenPaddingStatusbar
135-
screenPaddingNavbar = 0
136-
}
137-
}
138-
}
139-
}
140-
// hacks
141-
if (Qt.platform.os === "ios") {
142-
if (appWindow.visibility === Window.FullScreen) {
143-
screenPaddingStatusbar = 0
144-
}
145-
}
146-
} else {
147-
screenPaddingStatusbar = 0
148-
screenPaddingNavbar = 0
149-
screenPaddingTop = 0
150-
screenPaddingLeft = 0
151-
screenPaddingRight = 0
152-
screenPaddingBottom = 0
153-
}
154-
/*
155-
console.log("> handleSafeAreas()")
156-
console.log("- window mode: " + appWindow.visibility)
157-
console.log("- window flags: " + appWindow.flags)
158-
console.log("- screen dpi: " + Screen.devicePixelRatio)
159-
console.log("- screen width: " + Screen.width)
160-
console.log("- screen width avail: " + Screen.desktopAvailableWidth)
161-
console.log("- screen height: " + Screen.height)
162-
console.log("- screen height avail: " + Screen.desktopAvailableHeight)
163-
console.log("- screen orientation (full): " + Screen.orientation)
164-
console.log("- screen orientation (primary): " + Screen.primaryOrientation)
165-
console.log("- screenSizeStatusbar: " + screenPaddingStatusbar)
166-
console.log("- screenSizeNavbar: " + screenPaddingNavbar)
167-
console.log("- screenPaddingTop: " + screenPaddingTop)
168-
console.log("- screenPaddingLeft: " + screenPaddingLeft)
169-
console.log("- screenPaddingRight: " + screenPaddingRight)
170-
console.log("- screenPaddingBottom: " + screenPaddingBottom)
171-
*/
172-
}
47+
Binding {
48+
target: MobileUI
49+
property: "navbarTheme"
50+
value: { return (appContent.state === "ScreenBarcodeReader") ? MobileUI.Dark : Theme.themeStatusbar }
17351
}
17452

17553
MobileHeader {

qml/ScreenBarcodeReader.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import QtQuick.Dialogs
99
import QtPositioning
1010
import QtMultimedia
1111

12-
import ComponentLibrary
1312
import QmlMobileScanner
13+
import ComponentLibrary
14+
import MobileUI
1415

1516
Loader {
1617
id: screenBarcodeReader
@@ -21,7 +22,7 @@ Loader {
2122
function loadScreen() {
2223
appContent.state = "ScreenBarcodeReader"
2324

24-
mobileUI.setScreenAlwaysOn(true)
25+
MobileUI.setScreenAlwaysOn(true)
2526

2627
screenBarcodeReader.active = true
2728

thirdparty/AppUtils/CMakeLists.txt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
cmake_minimum_required(VERSION 3.20)
22

3-
project(AppUtils LANGUAGES CXX)
3+
#project(AppUtils LANGUAGES CXX)
4+
5+
# To avoid CMake Warnings, you should add Qt6 'CorePrivate' or 'CoreGui', as needed,
6+
# to your root level find_package()
47

58
set(CMAKE_CXX_STANDARD 14)
69
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7-
set(QT_NO_PRIVATE_MODULE_WARNING ON)
810
set(CMAKE_AUTOMOC ON)
911

12+
set(QT_NO_PRIVATE_MODULE_WARNING ON)
13+
1014
################################################################################
1115

1216
# Optional stuff
@@ -23,7 +27,7 @@ option(UTILS_NOTIFICATIONS_ENABLED "iOS notification handling" OFF)
2327

2428
# Generic dependencies
2529
find_package(Qt6 6.6 REQUIRED COMPONENTS Core Gui Qml Quick)
26-
set(CORE_LIBRARIES Qt::Core Qt::Gui Qt::Qml Qt::Quick)
30+
set(CORE_LIBRARIES Qt6::Core Qt6::Gui Qt6::Qml Qt6::Quick)
2731

2832
# Generic sources
2933
set(CORE_SOURCES
@@ -55,10 +59,10 @@ if(UTILS_QT_RHI)
5559

5660
if(Qt6Gui_VERSION VERSION_GREATER_EQUAL 6.10.0)
5761
find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
58-
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt::GuiPrivate) # to get RHI infos
62+
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt6::GuiPrivate) # to get RHI infos
5963
else()
6064
find_package(Qt6 REQUIRED COMPONENTS Gui)
61-
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt::GuiPrivate)
65+
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt6::GuiPrivate)
6266
endif()
6367
endif()
6468

@@ -69,16 +73,21 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
6973
utils_os_linux.h)
7074

7175
find_package(Qt6 REQUIRED COMPONENTS DBus)
72-
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} Qt::DBus)
76+
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} Qt6::DBus)
7377
endif()
7478

7579
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
7680
set(PLATFORM_SOURCES ${PLATFORM_SOURCES}
7781
utils_os_android.cpp
7882
utils_os_android.h)
7983

80-
find_package(Qt6 REQUIRED COMPONENTS CorePrivate)
81-
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} Qt::CorePrivate)
84+
if(Qt6Core_VERSION VERSION_GREATER_EQUAL 6.10.0)
85+
find_package(Qt6 REQUIRED COMPONENTS CorePrivate)
86+
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt6::CorePrivate)
87+
else()
88+
find_package(Qt6 REQUIRED COMPONENTS Core)
89+
set(CORE_LIBRARIES ${CORE_LIBRARIES} Qt6::CorePrivate)
90+
endif()
8291
endif()
8392

8493
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@@ -127,9 +136,13 @@ endif()
127136

128137
################################################################################
129138

130-
add_library(AppUtils OBJECT ${CORE_SOURCES} ${PLATFORM_SOURCES})
139+
add_library(AppUtils STATIC ${CORE_SOURCES} ${PLATFORM_SOURCES})
131140
add_library(AppUtils::AppUtils ALIAS AppUtils)
132141

133142
target_compile_definitions(AppUtils PUBLIC APP_NAME=\"${APP_NAME}\" APP_VERSION=\"${APP_VERSION}\")
134-
target_link_libraries(AppUtils PRIVATE ${CORE_LIBRARIES} ${PLATFORM_LIBRARIES})
143+
144+
target_link_libraries(AppUtils PUBLIC ${CORE_LIBRARIES} ${PLATFORM_LIBRARIES})
145+
135146
target_include_directories(AppUtils PUBLIC ${CMAKE_CURRENT_LIST_DIR})
147+
148+
################################################################################

thirdparty/AppUtils/utils_app.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ bool UtilsApp::isQColorLight(const QColor &color)
274274

275275
bool UtilsApp::isOsThemeDark()
276276
{
277-
const QStyleHints *styleHints = static_cast<QGuiApplication*>qApp->styleHints();
277+
const QStyleHints *styleHints = static_cast<QGuiApplication *>qApp->styleHints();
278278
return (styleHints && styleHints->colorScheme() == Qt::ColorScheme::Dark);
279279
}
280280

@@ -361,6 +361,13 @@ void UtilsApp::openAndroidLocationSettings()
361361
#endif
362362
}
363363

364+
void UtilsApp::openAndroidAlarms()
365+
{
366+
#if defined(Q_OS_ANDROID)
367+
UtilsAndroid::openAlarmClock();
368+
#endif
369+
}
370+
364371
/* ************************************************************************** */
365372

366373
bool UtilsApp::checkMobileBluetoothPermission()

thirdparty/AppUtils/utils_app.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class UtilsApp : public QObject
9797
static Q_INVOKABLE void openAndroidAppInfo(const QString &packageName);
9898
static Q_INVOKABLE void openAndroidStorageSettings(const QString &packageName);
9999
static Q_INVOKABLE void openAndroidLocationSettings();
100+
static Q_INVOKABLE void openAndroidAlarms();
100101

101102
static Q_INVOKABLE void vibrate(int ms);
102103

thirdparty/AppUtils/utils_log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class UtilsLog : public QObject
3434
{
3535
Q_OBJECT
3636

37-
Q_PROPERTY(QString debugLog READ getDebugLog NOTIFY debuglogUpdated)
37+
Q_PROPERTY(QString debugLog READ getDebugLog NOTIFY debugLogUpdated)
3838

3939
bool m_logging = false;
4040
QString m_logPath;
@@ -50,7 +50,7 @@ class UtilsLog : public QObject
5050
~UtilsLog();
5151

5252
Q_SIGNALS:
53-
void debuglogUpdated();
53+
void debugLogUpdated();
5454

5555
public:
5656
static UtilsLog *getInstance(const bool enabled = true);

thirdparty/AppUtils/utils_os_android.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,41 @@ void UtilsAndroid::openApplicationInfo(const QString &packageName)
869869

870870
/* ************************************************************************** */
871871

872+
void UtilsAndroid::openAlarmClock()
873+
{
874+
//qDebug() << "> openAlarmClock()";
875+
QJniObject activity = QNativeInterface::QAndroidApplication::context();
876+
if (!activity.isValid())
877+
return;
878+
879+
// Build the Intent
880+
QJniObject intentClass = QJniObject::fromString("android/provider/AlarmClock");
881+
QJniObject action = QJniObject::getStaticObjectField<jstring>(
882+
"android/provider/AlarmClock",
883+
"ACTION_SHOW_ALARMS"
884+
);
885+
886+
QJniObject intent("android/content/Intent",
887+
"(Ljava/lang/String;)V",
888+
action.object<jstring>());
889+
890+
// Add FLAG_ACTIVITY_NEW_TASK
891+
jint flag = QJniObject::getStaticField<jint>(
892+
"android/content/Intent",
893+
"FLAG_ACTIVITY_NEW_TASK"
894+
);
895+
intent.callObjectMethod("addFlags",
896+
"(I)Landroid/content/Intent;",
897+
flag);
898+
899+
// Start the activity
900+
activity.callMethod<void>("startActivity",
901+
"(Landroid/content/Intent;)V",
902+
intent.object());
903+
}
904+
905+
/* ************************************************************************** */
906+
872907
void UtilsAndroid::openStorageSettings(const QString &packageName)
873908
{
874909
//qDebug() << "> openStorageSettings(" << packageName << ")";

0 commit comments

Comments
 (0)