diff --git a/3rd-party/cove/CMakeLists.txt b/3rd-party/cove/CMakeLists.txt
index 329ca9137..efb03c025 100644
--- a/3rd-party/cove/CMakeLists.txt
+++ b/3rd-party/cove/CMakeLists.txt
@@ -1,8 +1,6 @@
project(Cove)
-find_package(Qt5Core ${Qt5Core_VERSION} REQUIRED)
-find_package(Qt5Widgets ${Qt5Core_VERSION} REQUIRED)
-find_package(Qt5Concurrent ${Qt5Core_VERSION} REQUIRED)
+find_package(${Mapper_QT} ${Mapper_QT_VERSION} COMPONENTS Core Widgets Concurrent REQUIRED)
set(CMAKE_CXX_STANDARD 14)
diff --git a/3rd-party/cove/tests/CMakeLists.txt b/3rd-party/cove/tests/CMakeLists.txt
index f946678fc..5d1163c3f 100644
--- a/3rd-party/cove/tests/CMakeLists.txt
+++ b/3rd-party/cove/tests/CMakeLists.txt
@@ -1,6 +1,4 @@
-find_package(Qt5Core ${Qt5Core_VERSION} REQUIRED)
-find_package(Qt5Gui ${Qt5Core_VERSION} REQUIRED)
-find_package(Qt5Test ${Qt5Core_VERSION} REQUIRED)
+find_package(${Mapper_QT} ${Mapper_QT_VERSION} COMPONENTS Core Gui Test REQUIRED)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
diff --git a/3rd-party/qtsingleapplication/CMakeLists.txt b/3rd-party/qtsingleapplication/CMakeLists.txt
index 01d078773..154d7860a 100644
--- a/3rd-party/qtsingleapplication/CMakeLists.txt
+++ b/3rd-party/qtsingleapplication/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2012-2015 Kai Pastor
+# Copyright 2012-2015, 2017, 2019, 2026 Kai Pastor
#
# This file is part of OpenOrienteering.
#
@@ -16,8 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with OpenOrienteering. If not, see .
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Network REQUIRED)
+find_package(${Mapper_QT} ${Mapper_QT_VERSION} COMPONENTS Widgets Network REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_CLANG_TIDY "")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 900941f3b..3f11a3230 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -227,12 +227,14 @@ if(Mapper_USE_GDAL)
find_package(GDAL MODULE REQUIRED)
endif()
-find_package(Qt5Core 5.5 REQUIRED)
-add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050500)
-if (ANDROID AND "${Qt5Core_VERSION}" VERSION_LESS 5.12.1)
- message(FATAL_ERROR "At least Qt 5.12.1 is required to build for Android")
-elseif ("${Qt5Core_VERSION}" VERSION_LESS 5.8.0)
- add_definitions("-D'Q_FALLTHROUGH()=(void)0'")
+set(Mapper_QT "Qt5" CACHE STRING "Qt version and prefix")
+mark_as_advanced(Mapper_QT)
+find_package("${Mapper_QT}" REQUIRED COMPONENTS Core Widgets)
+add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050c00)
+
+set(Mapper_QT_VERSION "${${Mapper_QT}_VERSION}")
+if (Mapper_QT_VERSION VERSION_LESS "5.12.1")
+ message(FATAL_ERROR "At least Qt 5.12.1 is required to build")
endif()
include("TestBigEndian")
diff --git a/doc/manual/CMakeLists.txt b/doc/manual/CMakeLists.txt
index 56470b02f..ef870c680 100644
--- a/doc/manual/CMakeLists.txt
+++ b/doc/manual/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright 2012, 2013, 2014 Thomas Schöps
-# Copyright 2012-2019 Kai Pastor
+# Copyright 2012-2020, 2026 Kai Pastor
#
# This file is part of OpenOrienteering.
#
@@ -143,12 +143,7 @@ if(Mapper_MANUAL_QTHELP)
# Qt Help generation
#
- find_package(Qt5Core REQUIRED)
- if (Qt5Core_VERSION VERSION_LESS 5.12)
- set(qcollectiongenerator_name qcollectiongenerator)
- else()
- set(qcollectiongenerator_name qhelpgenerator)
- endif()
+ set(qcollectiongenerator_name qhelpgenerator)
# Qt provides a broken Qt5::qcollectiongenerator when crosscompiling.
if (CMAKE_CROSSCOMPILING AND NOT TARGET Qt5::qcollectiongenerator)
diff --git a/src/core/app_permissions_android.cpp b/src/core/app_permissions_android.cpp
index 775af68bf..607dbf924 100644
--- a/src/core/app_permissions_android.cpp
+++ b/src/core/app_permissions_android.cpp
@@ -22,6 +22,7 @@
#include
#include
+#include
namespace AppPermissions
diff --git a/src/core/objects/text_object.cpp b/src/core/objects/text_object.cpp
index cb9cc4198..cc296e697 100644
--- a/src/core/objects/text_object.cpp
+++ b/src/core/objects/text_object.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2012, 2013 Thomas Schöps
- * Copyright 2012-2019, 2025 Kai Pastor
+ * Copyright 2012-2019, 2025, 2026 Kai Pastor
*
* This file is part of OpenOrienteering.
*
@@ -43,12 +43,12 @@ int TextObjectPartInfo::getIndex(double pos_x) const
while (right != left)
{
int middle = (left + right) / 2;
- double x = part_x + metrics.width(part_text.left(middle));
+ double x = part_x + metrics.horizontalAdvance(part_text.left(middle));
if (pos_x >= x)
{
if (middle >= right)
return right;
- double next = part_x + metrics.width(part_text.left(middle + 1));
+ double next = part_x + metrics.horizontalAdvance(part_text.left(middle + 1));
if (pos_x < next)
if (pos_x < (x + next) / 2)
return middle;
@@ -61,7 +61,7 @@ int TextObjectPartInfo::getIndex(double pos_x) const
{
if (middle <= 0)
return 0;
- double prev = part_x + metrics.width(part_text.left(middle - 1));
+ double prev = part_x + metrics.horizontalAdvance(part_text.left(middle - 1));
if (pos_x > prev)
if (pos_x > (x + prev) / 2)
return middle;
@@ -470,7 +470,7 @@ void TextObject::prepareLineInfos() const
// Shrink the part and the line
part_end = new_part_end;
part = text.mid(part_start, part_end - part_start);
- part_width = metrics.width(part);
+ part_width = metrics.horizontalAdvance(part);
line_end = part_end;
}
}
@@ -478,7 +478,7 @@ void TextObject::prepareLineInfos() const
break;
// Add the current part
- part_infos.push_back( { part, part_start, part_end, part_x, metrics.width(part), metrics } );
+ part_infos.push_back( { part, part_start, part_end, part_x, metrics.horizontalAdvance(part), metrics } );
// Advance to next part position
part_start = part_end + 1;
diff --git a/src/core/objects/text_object.h b/src/core/objects/text_object.h
index cdb244089..e31fbda74 100644
--- a/src/core/objects/text_object.h
+++ b/src/core/objects/text_object.h
@@ -1,6 +1,6 @@
/*
* Copyright 2012, 2013 Thomas Schöps
- * Copyright 2012-2019, 2025 Kai Pastor
+ * Copyright 2012-2019, 2025, 2026 Kai Pastor
*
* This file is part of OpenOrienteering.
*
@@ -327,7 +327,7 @@ class TextObject : public Object // clazy:exclude=copyable-polymorphic
inline
double TextObjectPartInfo::getX(int index) const
{
- return part_x + metrics.width(part_text.left(index - start_index));
+ return part_x + metrics.horizontalAdvance(part_text.left(index - start_index));
}
diff --git a/src/core/symbols/text_symbol.cpp b/src/core/symbols/text_symbol.cpp
index 6580c9a9b..215425453 100644
--- a/src/core/symbols/text_symbol.cpp
+++ b/src/core/symbols/text_symbol.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2012, 2013 Thomas Schöps
- * Copyright 2012-2022 Kai Pastor
+ * Copyright 2012-2022, 2026 Kai Pastor
*
* This file is part of OpenOrienteering.
*
@@ -324,7 +324,7 @@ void TextSymbol::updateQFont()
qfont.setHintingPreference(QFont::PreferNoHinting);
qfont.setKerning(kerning);
metrics = QFontMetricsF(qfont);
- qfont.setLetterSpacing(QFont::AbsoluteSpacing, metrics.width(QString(QLatin1String{" "})) * character_spacing);
+ qfont.setLetterSpacing(QFont::AbsoluteSpacing, metrics.horizontalAdvance(QString(QLatin1String{" "})) * character_spacing);
qfont.setStyleStrategy(QFont::ForceOutline);
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index a430d3ae2..de0a190fc 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -41,7 +41,7 @@
#if defined(Q_OS_ANDROID)
# include
-# include
+# include
# include
# include
#endif
@@ -765,7 +765,9 @@ void MainWindow::loadWindowSettings()
{
#if defined(Q_OS_ANDROID)
// Always show the window on the whole available area on Android
- resize(QApplication::desktop()->availableGeometry().size());
+ // Qt 5.14 adds QWidget::screen().
+ if (auto* screen = qApp->screenAt(geometry().center()))
+ resize(screen->availableGeometry().size());
#else
QSettings settings;
diff --git a/src/gui/widgets/pie_menu.cpp b/src/gui/widgets/pie_menu.cpp
index 0905ae82a..74a5d2136 100644
--- a/src/gui/widgets/pie_menu.cpp
+++ b/src/gui/widgets/pie_menu.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2012, 2013 Thomas Schöps
- * Copyright 2014 Thomas Schöps, Kai Pastor
+ * Copyright 2012-2014 Thomas Schöps
+ * Copyright 2013, 2014, 2016-2019, 2026 Kai Pastor
*
* This file is part of OpenOrienteering.
*
@@ -24,9 +24,9 @@
#include
#include
#include
-#include
#include
#include
+#include
#include
#include "settings.h"
@@ -162,18 +162,22 @@ void PieMenu::popup(const QPoint& pos)
{
updateCachedState(); // We need the current total_radius.
- QPoint cursor_pos = QCursor::pos();
- QRect screen_rect = qApp->desktop()->availableGeometry(cursor_pos);
-
- if (cursor_pos.x() > screen_rect.right() - total_radius)
- cursor_pos.setX(screen_rect.right() - total_radius);
- else if (cursor_pos.x() < total_radius)
- cursor_pos.setX(total_radius);
-
- if (cursor_pos.y() > screen_rect.bottom() - total_radius)
- cursor_pos.setY(screen_rect.bottom() - total_radius);
- else if (cursor_pos.y() < total_radius)
- cursor_pos.setY(total_radius);
+ auto* screen = qApp->screenAt(pos);
+ if (screen)
+ {
+ QPoint cursor_pos = QCursor::pos();
+ QRect screen_rect = screen->availableGeometry();
+
+ if (cursor_pos.x() > screen_rect.right() - total_radius)
+ cursor_pos.setX(screen_rect.right() - total_radius);
+ else if (cursor_pos.x() < total_radius)
+ cursor_pos.setX(total_radius);
+
+ if (cursor_pos.y() > screen_rect.bottom() - total_radius)
+ cursor_pos.setY(screen_rect.bottom() - total_radius);
+ else if (cursor_pos.y() < total_radius)
+ cursor_pos.setY(total_radius);
+ }
setGeometry(pos.x() - total_radius, pos.y() - total_radius, 2 * total_radius, 2 * total_radius);
diff --git a/src/gui/widgets/symbol_tooltip.cpp b/src/gui/widgets/symbol_tooltip.cpp
index 3d8782126..74243a8de 100644
--- a/src/gui/widgets/symbol_tooltip.cpp
+++ b/src/gui/widgets/symbol_tooltip.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2012, 2013 Thomas Schöps
- * Copyright 2017 Kai Pastor
+ * Copyright 2014, 2016-2019, 2026 Kai Pastor
*
* This file is part of OpenOrienteering.
*
@@ -25,7 +25,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -33,6 +32,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -139,8 +139,12 @@ void SymbolToolTip::paintEvent(QPaintEvent* event)
void SymbolToolTip::adjustPosition(bool mobile_mode)
{
+ auto* screen = qApp->screenAt(QCursor::pos());
+ if (!screen)
+ return;
+
auto size = this->size();
- auto desktop = QApplication::desktop()->screenGeometry(QCursor::pos());
+ auto desktop = screen->availableGeometry();
const int margin = 3;
bool has_room_to_left = (icon_rect.left() - size.width() - margin >= desktop.left());
diff --git a/src/util/mapper_service_proxy.cpp b/src/util/mapper_service_proxy.cpp
index b006db2c6..a4970f597 100644
--- a/src/util/mapper_service_proxy.cpp
+++ b/src/util/mapper_service_proxy.cpp
@@ -25,6 +25,8 @@
#ifdef Q_OS_ANDROID
#include
#include
+#include
+#include
#endif
#include "gui/main_window.h"