Skip to content

Commit

Permalink
Port to Qt 6 and use ECM
Browse files Browse the repository at this point in the history
Closes: #24
  • Loading branch information
plfiorini committed Dec 3, 2023
1 parent 5ebe982 commit af27d67
Show file tree
Hide file tree
Showing 37 changed files with 283 additions and 510 deletions.
76 changes: 50 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,78 @@
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.19)

project("LibLiri"
VERSION "0.9.0"
DESCRIPTION "Libraries for Liri apps and desktop environment"
LANGUAGES CXX C
)

## Only build on the appropriate platforms.
if(NOT UNIX OR CMAKE_SYSTEM_NAME MATCHES "Android")
message(NOTICE "Skipping the build as the condition \"UNIX OR Android\" is not met.")
return()
endif()

## ECM:
find_package(ECM 5.245.0 REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

## Installation directories:
include(KDEInstallDirs)

## Compiler settings:
set(KDE_SKIP_NULLPTR_WARNINGS_SETTINGS TRUE)
include(KDECompilerSettings NO_POLICY_SCOPE)

## CMake settings:
include(KDECMakeSettings)

## QML module:
include(ECMQmlModule)

## Shared macros and functions:
if(NOT LIRI_LOCAL_ECM)
find_package(LiriCMakeShared "2.0.0" REQUIRED NO_MODULE)
find_package(LiriCMakeShared "2.0.99" REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}")
endif()

## Set minimum versions required:
set(QT_MIN_VERSION "5.10.0")

## Liri specific setup common for all modules:
include(LiriSetup)

## Only build on the appropriate platforms.
if(NOT UNIX OR ANDROID)
message(NOTICE "Skipping the build as the condition \"UNIX OR ANDROID\" is not met.")
return()
endif()
## Features:
include(features.cmake)

## Find Qt 5:
find_package(Qt5 "${QT_MIN_VERSION}"
CONFIG REQUIRED
COMPONENTS
Core
Xml
DBus
Qml
Quick
Gui
)
## Project setup:
qt6_standard_project_setup(REQUIRES 6.6)

## Disable use of C++ API deprecated in Qt 5.15
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

## QML import path:
if(NOT QML_IMPORT_PATH)
set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE STRING "" FORCE)
endif()

## Add subdirectories:
add_subdirectory(src/core)
add_subdirectory(src/dbusservice)
add_subdirectory(src/imports/core)
add_subdirectory(src/imports/dbusservice)
add_subdirectory(src/imports/device)
add_subdirectory(src/imports/notifications)
add_subdirectory(src/localdevice)
add_subdirectory(src/models)
add_subdirectory(src/notifications)
add_subdirectory(src/notify)
add_subdirectory(src/xdg)
if(LIRI_BUILD_TESTING)
if(TARGET Liri::Core)
add_subdirectory(src/imports/core)
endif()
if(TARGET Liri::DBusService)
add_subdirectory(src/imports/dbusservice)
endif()
if(TARGET Liri::LocalDevice)
add_subdirectory(src/imports/device)
endif()
if(TARGET Liri::Notifications)
add_subdirectory(src/imports/notifications)
endif()
if(BUILD_TESTING)
if(TARGET Liri::Models)
add_subdirectory(tests/auto/core)
endif()
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ Library for Liri apps.

## Dependencies

Qt >= 5.8.0 with at least the following modules is required:
Qt >= 6.6.0 with at least the following modules is required:

* [qtbase](http://code.qt.io/cgit/qt/qtbase.git)
* [qtdeclarative](http://code.qt.io/cgit/qt/qtdeclarative.git)

The following modules and their dependencies are required:

* [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.10.0
* [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 1.0.0
* [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.19.0
* [extra-cmake-modules](https://invent.kde.org/frameworks/extra-cmake-modules) >= 5.245.0
* [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 2.0.99

## Installation

Expand Down
27 changes: 27 additions & 0 deletions features.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2023 Pier Luigi Fiorini <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause

## Enable feature summary at the end of the configure run:
include(FeatureSummary)

## Find Qt:
find_package(Qt6
REQUIRED
COMPONENTS
Core
Core5Compat
Xml
DBus
Qml
QmlIntegration
Quick
Gui
Test
)

#### Features

## Features summary:
if(NOT LIRI_SUPERBUILD)
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
endif()
13 changes: 4 additions & 9 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ liri_add_module(Core
DESCRIPTION
"Utilities for Liri apps"
SOURCES
kformat.cpp
kformat.h
kformatprivate.cpp
kformatprivate_p.h
DEFINES
#QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
kformat.cpp kformat.h
kformatprivate.cpp kformatprivate_p.h
PUBLIC_LIBRARIES
Qt5::Core
Qt6::Core
PKGCONFIG_DEPENDENCIES
Qt5Core
Qt6Core
)

liri_finalize_module(Core)
31 changes: 17 additions & 14 deletions src/dbusservice/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
set(SOURCES
dbusservice.cpp dbusservice.h dbusservice_p.h
)

qt6_add_dbus_adaptor(SOURCES
org.freedesktop.Application.xml
dbusservice.h
Liri::DBusService
)

liri_add_module(DBusService
DESCRIPTION
"D-Bus activation for Qt applications"
SOURCES
dbusservice.cpp
dbusservice.h
dbusservice_p.h
DBUS_ADAPTOR_SOURCES
org.freedesktop.Application.xml
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
${SOURCES}
PUBLIC_LIBRARIES
Qt5::Core
Qt5::DBus
Qt5::Gui
Qt6::Core
Qt6::DBus
Qt6::Gui
PKGCONFIG_DEPENDENCIES
Qt5Core
Qt5DBus
Qt5Gui
Qt6Core
Qt6DBus
Qt6Gui
)

liri_finalize_module(DBusService)
4 changes: 2 additions & 2 deletions src/dbusservice/dbusservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QtDBus/QDBusConnection>
#include <QtGui/QGuiApplication>

#include "application_adaptor.h"
#include "applicationadaptor.h"
#include "dbusservice.h"
#include "dbusservice_p.h"

Expand All @@ -42,7 +42,7 @@ QString DBusServicePrivate::getServiceName() const

if (desktopFileName.isEmpty()) {
const QString domain = QCoreApplication::organizationDomain();
const QStringList parts = domain.split(QLatin1Char('.'), QString::SkipEmptyParts);
const QStringList parts = domain.split(QLatin1Char('.'), Qt::SkipEmptyParts);

QString reverseDomain;
if (parts.isEmpty()) {
Expand Down
32 changes: 16 additions & 16 deletions src/imports/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
liri_add_qml_plugin(CoreQmlPlugin
MODULE_PATH
"Liri/Core"
ecm_add_qml_module(CoreQmlPlugin
URI
"Liri.Core"
VERSION
"1.0"
OUTPUT_NAME
"liricoreplugin"
SOURCES
formatter.cpp
formatter.h
plugin.cpp
QML_FILES
qmldir
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
PUBLIC_LIBRARIES
GENERATE_PLUGIN_SOURCE
)

target_sources(CoreQmlPlugin
PRIVATE
formatter.cpp formatter.h
)

target_link_libraries(CoreQmlPlugin
PUBLIC
Qt6::Core
Qt6::Qml
Liri::Core
)

liri_finalize_qml_plugin(CoreQmlPlugin)
ecm_finalize_qml_module(CoreQmlPlugin)
8 changes: 8 additions & 0 deletions src/imports/core/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ QString Formatter::formatRelativeDateTime(const QDateTime &dateTime,
{
return formatter.formatRelativeDateTime(dateTime, format);
}

Formatter *Formatter::create(QQmlEngine *engine, QJSEngine *jsEngine)
{
Q_UNUSED(engine)
Q_UNUSED(jsEngine)

return new Formatter();
}
10 changes: 8 additions & 2 deletions src/imports/core/formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

#pragma once

#include <QtCore/QLocale>
#include <QtCore/QObject>
#include <QLocale>
#include <QObject>
#include <QQmlEngine>

#include <LiriCore/kformat.h>

/**
Expand All @@ -36,6 +38,8 @@
class Formatter : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
public:
/**
* These binary units are used in KDE by the formatByteSize()
Expand Down Expand Up @@ -228,6 +232,8 @@ class Formatter : public QObject
Q_INVOKABLE QString formatRelativeDateTime(const QDateTime &dateTime,
QLocale::FormatType format) const;

static Formatter *create(QQmlEngine *engine, QJSEngine *jsEngine);

private:
KFormat formatter;
};
51 changes: 0 additions & 51 deletions src/imports/core/plugin.cpp

This file was deleted.

Loading

0 comments on commit af27d67

Please sign in to comment.