diff --git a/CMakeLists.txt b/CMakeLists.txt index 7286190..528b34f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,8 @@ include(KDECompilerSettings NO_POLICY_SCOPE) ## CMake settings: include(KDECMakeSettings) -## Find Qt 5: -find_package(Qt6 +## Find Qt: +find_package(Qt6 "6.7" REQUIRED COMPONENTS Core @@ -38,6 +38,11 @@ find_package(Qt6 LinguistTools ) +# Set policies for Qt: +if(QT_KNOWN_POLICY_QTP0001) + qt_policy(SET QTP0001 NEW) +endif() + ## Add subdirectories: add_subdirectory(branding) add_subdirectory(data) diff --git a/src/live-welcome/CMakeLists.txt b/src/live-welcome/CMakeLists.txt index 8de9210..3e2be3f 100644 --- a/src/live-welcome/CMakeLists.txt +++ b/src/live-welcome/CMakeLists.txt @@ -1,23 +1,26 @@ -# Translations -file(GLOB LiveWelcome_TRANSLATIONS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*_*.ts") -qt6_add_translation(LiveWelcome_QM_FILES ${LiveWelcome_TRANSLATIONS}) -install(FILES ${LiveWelcome_QM_FILES} - DESTINATION "${KDE_INSTALL_DATADIR}/liri-live-welcome/translations") - -set(SOURCES +qt6_add_executable(LiveWelcome + MANUAL_FINALIZATION main.cpp runner.cpp runner.h - io.liri.LiveWelcome.desktop ) +set_target_properties(LiveWelcome PROPERTIES OUTPUT_NAME "liri-live-welcome") -qt_add_resources(SOURCES live-welcome.qrc) -qt6_add_executable(LiveWelcome - MANUAL_FINALIZATION - ${SOURCES} - ${LiveWelcome_QM_FILES} +set_source_files_properties(qml/Main.qml PROPERTIES + QT_RESOURCE_ALIAS Main.qml +) +qt6_add_qml_module(LiveWelcome + URI io.liri.LiveWelcome + VERSION 1.0 + QML_FILES qml/Main.qml ) -set_target_properties(LiveWelcome PROPERTIES OUTPUT_NAME "liri-live-welcome") +file(GLOB ts_files "${CMAKE_CURRENT_SOURCE_DIR}/translations/*_*.ts") +qt6_add_translations(LiveWelcome + TS_FILE_BASE "liri-live-welcome" + TS_FILE_DIR "translations" + TS_FILES ${ts_files} + RESOURCE_PREFIX "/qt/qml/io/liri/LiveWelcome/i18n" +) target_compile_definitions(LiveWelcome PRIVATE VERSION="${PROJECT_VERSION}") diff --git a/src/live-welcome/live-welcome.qrc b/src/live-welcome/live-welcome.qrc deleted file mode 100644 index 69145a8..0000000 --- a/src/live-welcome/live-welcome.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/main.qml - - diff --git a/src/live-welcome/main.cpp b/src/live-welcome/main.cpp index 2e6eaa9..f7f7626 100644 --- a/src/live-welcome/main.cpp +++ b/src/live-welcome/main.cpp @@ -31,49 +31,10 @@ #include "runner.h" -static void loadQtTranslations() -{ -#ifndef QT_NO_TRANSLATION - QString locale = QLocale::system().name(); - - // Load Qt translations - QTranslator *qtTranslator = new QTranslator(qApp); - if (qtTranslator->load(QStringLiteral("qt_%1").arg(locale), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { - qApp->installTranslator(qtTranslator); - } else { - delete qtTranslator; - } -#endif -} - -static void loadTranslations() -{ -#ifndef QT_NO_TRANSLATION - QString locale = QLocale::system().name(); - - // Find the translations directory - const QString path = QStringLiteral("liri-live-welcome/translations"); - const QString translationsDir = - QStandardPaths::locate(QStandardPaths::GenericDataLocation, - path, - QStandardPaths::LocateDirectory); - - // Load shell translations - QTranslator *appTranslator = new QTranslator(qGuiApp); - if (appTranslator->load(QStringLiteral("%1/liri-live-welcome_%2").arg(translationsDir, locale))) { - QCoreApplication::installTranslator(appTranslator); - } else if (locale == QStringLiteral("C") || - locale.startsWith(QStringLiteral("en"))) { - // English is the default, it's translated anyway - delete appTranslator; - } -#endif -} +using namespace Qt::StringLiterals; int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - // Setup application QGuiApplication app(argc, argv); app.setApplicationName(QStringLiteral("Live Welcome")); @@ -84,13 +45,23 @@ int main(int argc, char *argv[]) QQuickStyle::setStyle(QStringLiteral("Material")); - // Load translations - loadQtTranslations(); - loadTranslations(); +#ifndef QT_NO_TRANSLATION + // Load Qt translations + QTranslator qtTranslator; + if (qtTranslator.load(QLocale(), "qt"_L1, "_"_L1, + QLibraryInfo::path(QLibraryInfo::TranslationsPath))) + app.installTranslator(&qtTranslator); + + // Load translations from resources + QTranslator translator; + if (translator.load(QLocale(), "liri-live-welcome"_L1, "_"_L1, ":/qt/qml/io/liri/LiveWelcome/i18n"_L1)) + QCoreApplication::installTranslator(&translator); +#endif // Load UI - QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + QQmlApplicationEngine engine; engine.rootContext()->setContextProperty(QStringLiteral("Runner"), new Runner(&engine)); + engine.loadFromModule("io.liri.LiveWelcome", "Main"); return app.exec(); } diff --git a/src/live-welcome/qml/main.qml b/src/live-welcome/qml/Main.qml similarity index 78% rename from src/live-welcome/qml/main.qml rename to src/live-welcome/qml/Main.qml index 0b98694..d0e079f 100644 --- a/src/live-welcome/qml/main.qml +++ b/src/live-welcome/qml/Main.qml @@ -21,13 +21,12 @@ * $END_LICENSE$ ***************************************************************************/ -import QtQuick 2.0 -import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 -import Fluid.Controls 1.0 as FluidControls +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls.Material +import Fluid as Fluid -ApplicationWindow { +Fluid.ApplicationWindow { title: qsTr("Welcome to Liri OS") width: 600 height: 400 @@ -42,8 +41,8 @@ ApplicationWindow { anchors.fill: parent spacing: 0 - FluidControls.Placeholder { - icon.source: FluidControls.Utils.iconUrl("hardware/computer") + Fluid.Placeholder { + icon.source: Fluid.Utils.iconUrl("hardware/computer") text: qsTr("Welcome to Liri OS") subText: qsTr("You are currently running Liri OS from live media.\nYou can install Liri OS now, or launch \"Install to Hard Drive\" later.") @@ -56,14 +55,14 @@ ApplicationWindow { Layout.fillHeight: true } - FluidControls.ListItem { - icon.source: FluidControls.Utils.iconUrl("action/exit_to_app") + Fluid.ListItem { + icon.source: Fluid.Utils.iconUrl("action/exit_to_app") text: qsTr("Try Liri OS") onClicked: Qt.quit() } - FluidControls.ListItem { - icon.source: FluidControls.Utils.iconUrl("file/file_download") + Fluid.ListItem { + icon.source: Fluid.Utils.iconUrl("file/file_download") text: qsTr("Install to Hard Drive") onClicked: { Runner.run(); diff --git a/src/live-welcome/src/live-welcome/translations/liri-live-welcome.ts b/src/live-welcome/src/live-welcome/translations/liri-live-welcome.ts deleted file mode 100644 index 6401616..0000000 --- a/src/live-welcome/src/live-welcome/translations/liri-live-welcome.ts +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/live-welcome/translations/liri-live-welcome.ts b/src/live-welcome/translations/liri-live-welcome_en.ts similarity index 72% rename from src/live-welcome/translations/liri-live-welcome.ts rename to src/live-welcome/translations/liri-live-welcome_en.ts index 6b7f588..fadf835 100644 --- a/src/live-welcome/translations/liri-live-welcome.ts +++ b/src/live-welcome/translations/liri-live-welcome_en.ts @@ -4,24 +4,24 @@ main - - + + Welcome to Liri OS - + You are currently running Liri OS from live media. You can install Liri OS now, or launch "Install to Hard Drive" later. - + Try Liri OS - + Install to Hard Drive diff --git a/src/live-welcome/translations/liri-live-welcome_it.ts b/src/live-welcome/translations/liri-live-welcome_it.ts index 22dd913..d545124 100644 --- a/src/live-welcome/translations/liri-live-welcome_it.ts +++ b/src/live-welcome/translations/liri-live-welcome_it.ts @@ -2,25 +2,25 @@ main - - + + Welcome to Liri OS Benvenuto a Liri OS - + You are currently running Liri OS from live media. You can install Liri OS now, or launch "Install to Hard Drive" later. Stai utilizzando Liri OS da una live. Puoi installare Liri OS adesso, oppure lanciare "Installa su disco" piú tardi. - + Try Liri OS Prova Liri OS - + Install to Hard Drive Installa su disco