Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions 3rd-party/cove/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 1 addition & 3 deletions 3rd-party/cove/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 2 additions & 3 deletions 3rd-party/qtsingleapplication/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2012-2015 Kai Pastor
# Copyright 2012-2015, 2017, 2019, 2026 Kai Pastor
#
# This file is part of OpenOrienteering.
#
Expand All @@ -16,8 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.

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 "")
Expand Down
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 2 additions & 7 deletions doc/manual/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/core/app_permissions_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <algorithm>
#include <QtAndroid>
#include <QHash>


namespace AppPermissions
Expand Down
12 changes: 6 additions & 6 deletions src/core/objects/text_object.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -470,15 +470,15 @@ 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;
}
}
if (part_end < part_start)
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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/objects/text_object.h
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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));
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/symbols/text_symbol.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#if defined(Q_OS_ANDROID)
# include <QtAndroid>
# include <QDesktopWidget>
# include <QScreen>
# include <QTimer>
# include <QUrl>
#endif
Expand Down Expand Up @@ -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;

Expand Down
34 changes: 19 additions & 15 deletions src/gui/widgets/pie_menu.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -24,9 +24,9 @@
#include <QtMath>
#include <QAction>
#include <QApplication>
#include <QDesktopWidget>
#include <QMouseEvent>
#include <QPainter>
#include <QScreen>
#include <QStyleOptionMenuItem>

#include "settings.h"
Expand Down Expand Up @@ -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);

Expand Down
10 changes: 7 additions & 3 deletions src/gui/widgets/symbol_tooltip.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -25,14 +25,14 @@
#include <QtGlobal>
#include <QApplication>
#include <QCursor>
#include <QDesktopWidget>
#include <QHideEvent>
#include <QLabel>
#include <QLatin1Char>
#include <QLatin1String>
#include <QPainter>
#include <QPalette>
#include <QPoint>
#include <QScreen>
#include <QShortcut>
#include <QShowEvent>
#include <QSize>
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions src/util/mapper_service_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifdef Q_OS_ANDROID
#include <QtAndroid>
#include <QtAndroidExtras/QAndroidJniObject>
#include <QHash>
#include <QString>
#endif

#include "gui/main_window.h"
Expand Down