Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow Fluid changes #10

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
31 changes: 17 additions & 14 deletions src/live-welcome/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")

Expand Down
5 changes: 0 additions & 5 deletions src/live-welcome/live-welcome.qrc

This file was deleted.

59 changes: 15 additions & 44 deletions src/live-welcome/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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();
}
23 changes: 11 additions & 12 deletions src/live-welcome/qml/main.qml → src/live-welcome/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")

Expand All @@ -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();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<context>
<name>main</name>
<message>
<location filename="../qml/main.qml" line="31"/>
<location filename="../qml/main.qml" line="47"/>
<location filename="../qml/Main.qml" line="31"/>
<location filename="../qml/Main.qml" line="47"/>
<source>Welcome to Liri OS</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="48"/>
<location filename="../qml/Main.qml" line="48"/>
<source>You are currently running Liri OS from live media.
You can install Liri OS now, or launch &quot;Install to Hard Drive&quot; later.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="56"/>
<location filename="../qml/Main.qml" line="56"/>
<source>Try Liri OS</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/main.qml" line="62"/>
<location filename="../qml/Main.qml" line="62"/>
<source>Install to Hard Drive</source>
<translation type="unfinished"></translation>
</message>
Expand Down
10 changes: 5 additions & 5 deletions src/live-welcome/translations/liri-live-welcome_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
<context>
<name>main</name>
<message>
<location filename="../qml/main.qml" line="31"/>
<location filename="../qml/main.qml" line="47"/>
<location filename="../qml/Main.qml" line="31"/>
<location filename="../qml/Main.qml" line="47"/>
<source>Welcome to Liri OS</source>
<translation>Benvenuto a Liri OS</translation>
</message>
<message>
<location filename="../qml/main.qml" line="48"/>
<location filename="../qml/Main.qml" line="48"/>
<source>You are currently running Liri OS from live media.
You can install Liri OS now, or launch &quot;Install to Hard Drive&quot; later.</source>
<translation>Stai utilizzando Liri OS da una live.
Puoi installare Liri OS adesso, oppure lanciare &quot;Installa su disco&quot; piú tardi.</translation>
</message>
<message>
<location filename="../qml/main.qml" line="56"/>
<location filename="../qml/Main.qml" line="56"/>
<source>Try Liri OS</source>
<translation>Prova Liri OS</translation>
</message>
<message>
<location filename="../qml/main.qml" line="62"/>
<location filename="../qml/Main.qml" line="62"/>
<source>Install to Hard Drive</source>
<translation>Installa su disco</translation>
</message>
Expand Down
Loading