Skip to content

Commit

Permalink
Port to Qt 6
Browse files Browse the repository at this point in the history
  • Loading branch information
plfiorini committed Sep 16, 2024
1 parent 73241a0 commit d5bf13c
Show file tree
Hide file tree
Showing 69 changed files with 739 additions and 868 deletions.
72 changes: 42 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,70 @@
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.19)

project("AppCenter"
VERSION "0.1.0"
DESCRIPTION "Software center"
LANGUAGES CXX C
)

## Shared macros and functions:
if(NOT LIRI_LOCAL_ECM)
find_package(LiriCMakeShared "2.0.0" REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}")
## Only build on the appropriate platforms.
if(NOT UNIX OR ANDROID)
message(NOTICE "\"${CMAKE_PROJECT_NAME}\" can be build only on UNIX-like systems, Android excluded")
return()
endif()

## Add some paths to check for CMake modules:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

## Set C++ standard:
set(CMAKE_CXX_STANDARD 17)
## ECM:
find_package(ECM 5.245.0 REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

## Set minimum versions required.
set(QT_MIN_VERSION "5.10.0")
## Installation directories:
include(KDEInstallDirs)

## Liri specific setup common for all modules:
include(LiriSetup)
## Compiler settings:
set(KDE_SKIP_NULLPTR_WARNINGS_SETTINGS TRUE)
include(KDECompilerSettings NO_POLICY_SCOPE)

## 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()
## CMake settings:
include(KDECMakeSettings)

## Find Qt 5.
find_package(Qt5 "${QT_MIN_VERSION}"
CONFIG REQUIRED
COMPONENTS
Core
DBus
Concurrent
Gui
Qml
Quick
QuickControls2
LinguistTools
)
## QML module:
include(ECMQmlModule)

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

## Enable C++17:
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## Treat warnings as errors:
add_compile_options(-Wall -Wextra -Werror)

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

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

## Features:
include(features.cmake)

## 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/framework)
add_subdirectory(src/app)
add_subdirectory(src/notifier)
add_subdirectory(src/imports/appcenter)
if(LINUX AND NOT ANDROID)
if(LINUX AND NOT ANDROID AND TARGET PkgConfig::Flatpak)
add_subdirectory(src/plugins/flatpak)
endif()
add_subdirectory(src/plugins/odrs)
4 changes: 2 additions & 2 deletions cmake/FindFlatpak.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: BSD-3-Clause

find_package(PkgConfig)
find_package(PkgConfig REQUIRED)

pkg_check_modules(Flatpak flatpak REQUIRED IMPORTED_TARGET)
pkg_check_modules(Flatpak flatpak>=0.11.8 REQUIRED IMPORTED_TARGET)
53 changes: 53 additions & 0 deletions features.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
# SPDX-License-Identifier: BSD-3-Clause

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

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

## Find Qt:
find_package(Qt6 "${QT_MIN_VERSION}"
REQUIRED
COMPONENTS
Core
Core5Compat
DBus
Concurrent
Gui
Qml
QmlIntegration
Quick
QuickControls2
LinguistTools
)

## Silence old policy warnings:
qt6_policy(SET QTP0004 OLD)

## Find AppStreamQt:
find_package(AppStreamQt REQUIRED)

## Find Flatpak:
option(FEATURE_appcenter_flatpak "Flatpak support" ON)
if(FEATURE_appcenter_flatpak)
find_package(Flatpak QUIET)
set_package_properties(Flatpak PROPERTIES
TYPE RECOMMENDED
PURPOSE "Flatpak support"
)
if(NOT TARGET PkgConfig::Flatpak)
message(WARNING "You need Flatpak for AppCenter::Flatpak")
set(FEATURE_appcenter_flatpak OFF)
endif()
endif()
add_feature_info("AppCenter::Flatpak" FEATURE_appcenter_flatpak "Build support for Flatpak")
set(FEATURE_appcenter_flatpak "$<IF:${FEATURE_appcenter_flatpak},1,0>")

#### Features

## Features summary:
if(NOT LIRI_SUPERBUILD)
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
endif()
81 changes: 55 additions & 26 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
# Translations
file(GLOB LiriAppCenter_TRANSLATIONS "${CMAKE_SOURCE_DIR}/translations/app/*_*.ts")
qt5_add_translation(LiriAppCenter_QM_FILES ${LiriAppCenter_TRANSLATIONS})
install(FILES ${LiriAppCenter_QM_FILES}
DESTINATION "${INSTALL_DATADIR}/liri-appcenter/translations")
#file(GLOB LiriAppCenter_TRANSLATIONS "${CMAKE_SOURCE_DIR}/translations/app/*_*.ts")
#qt5_add_translation(LiriAppCenter_QM_FILES ${LiriAppCenter_TRANSLATIONS})
#install(FILES ${LiriAppCenter_QM_FILES}
# DESTINATION "${INSTALL_DATADIR}/liri-appcenter/translations")

liri_add_executable(LiriAppCenter
OUTPUT_NAME
"liri-appcenter"
SOURCES
main.cpp
${LiriAppCenter_QM_FILES}
RESOURCES
appcenter.qrc
DEFINES
qt6_add_executable(LiriAppCenter MANUAL_FINALIZATION main.cpp)
set_target_properties(LiriAppCenter PROPERTIES OUTPUT_NAME "liri-appcenter")
qt6_finalize_target(LiriAppCenter)

target_compile_definitions(LiriAppCenter
PRIVATE
APPCENTER_VERSION="${PROJECT_VERSION}"
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
APPCENTER_VERSION="${PROJECT_VERSION}"
APPDATA
"${CMAKE_CURRENT_SOURCE_DIR}/io.liri.AppCenter.appdata.xml"
DESKTOP
"${CMAKE_CURRENT_SOURCE_DIR}/io.liri.AppCenter.desktop"
LIBRARIES
Qt5::Core
Qt5::Gui
Qt5::Qml
Qt5::Quick
Qt5::QuickControls2
GUI
)

liri_finalize_executable(LiriAppCenter)
target_link_libraries(LiriAppCenter
PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Qml
Qt6::Quick
Qt6::QuickControls2
)

qt6_add_qml_module(LiriAppCenter
URI io.liri.AppCenter
VERSION 1.0
QML_FILES
qml/AddSourceDialog.qml
qml/AllAppsTab.qml
qml/AppPage.qml
qml/InstalledAppsTab.qml
qml/Main.qml
qml/SourcesTab.qml
qml/UpdatesTab.qml
qml/app/Buttons.qml
qml/app/Details.qml
qml/app/Header.qml
qml/app/HeaderRatings.qml
qml/app/Icon.qml
qml/app/Info.qml
qml/app/RatingsReviews.qml
qml/app/Review.qml
qml/app/Screenshots.qml
qml/app/Transaction.qml
qml/pages/AddReviewPage.qml
qml/pages/ReviewsPage.qml
qml/ratings/RatingNumber.qml
qml/ratings/RatingStar.qml
qml/ratings/StarIcon.qml
qml/ratings/StarRatings.qml
)

install(TARGETS LiriAppCenter DESTINATION ${KDE_INSTALL_BINDIR})

install(FILES "io.liri.AppCenter.appdata.xml"
DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES "io.liri.AppCenter.desktop"
DESTINATION ${KDE_INSTALL_APPDIR})
27 changes: 0 additions & 27 deletions src/app/appcenter.qrc

This file was deleted.

24 changes: 16 additions & 8 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <QTranslator>
#include <QtQuickControls2/QQuickStyle>

using namespace Qt::StringLiterals;

#if 0
static void loadQtTranslations()
{
#ifndef QT_NO_TRANSLATION
Expand Down Expand Up @@ -50,27 +53,32 @@ static void loadAppTranslations()
}
#endif
}
#endif

int main(int argc, char *argv[])
{
// Set the X11 WML_CLASS so X11 desktops can find the desktop file
qputenv("RESOURCE_NAME", QByteArrayLiteral("io.liri.AppCenter"));

QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QGuiApplication app(argc, argv);
app.setApplicationName(QLatin1String("App Center"));
app.setOrganizationDomain(QLatin1String("liri.io"));
app.setOrganizationName(QLatin1String("Liri"));
app.setDesktopFileName(QLatin1String("io.liri.AppCenter.desktop"));
app.setApplicationName("App Center"_L1);
app.setOrganizationDomain("liri.io"_L1);
app.setOrganizationName("Liri"_L1);
app.setDesktopFileName("io.liri.AppCenter"_L1);

QQuickStyle::setStyle(QLatin1String("Material"));
QQuickStyle::setStyle("Material"_L1);

#if 0
// Load translations
loadQtTranslations();
loadAppTranslations();
#endif

QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/qml/main.qml")));
QQmlApplicationEngine engine;
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
engine.loadFromModule("io.liri.AppCenter", "Main");

return app.exec();
}
9 changes: 5 additions & 4 deletions src/app/qml/AddSourceDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick
import QtQuick.Controls
import Fluid as Fluid

Dialog {
Fluid.Dialog {
id: addSourceDialog

signal failed(string errorMessage)
Expand All @@ -28,7 +29,7 @@ Dialog {
addSourceDialog.failed(qsTr("Failed to retrieve source"));
}

TextField {
Fluid.TextField {
id: urlField
anchors.left: parent.left
anchors.top: parent.top
Expand Down
Loading

0 comments on commit d5bf13c

Please sign in to comment.