diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,17 @@ cmake_minimum_required(VERSION 3.0) +find_package(ECM 5.0) + +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_PATH}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(FeatureSummary) + +find_package(Qt5 5.12 REQUIRED COMPONENTS Core Qml) +find_package(KF5 5.57 REQUIRED COMPONENTS I18n Declarative) + function(LANGUAGE_FROM_PO VAR pofile) get_filename_component(_lang ${pofile} DIRECTORY) get_filename_component(_lang ${_lang} NAME) @@ -55,3 +67,14 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/directory.jsonp DESTINATION /usr/share/ubiquity-slideshow/slides/) install(DIRECTORY ubiquity-slideshow DESTINATION /usr/share) + +add_subdirectory(calamares-qml-plugin) + +if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") + ki18n_install(po) +endif() + +file(GLOB QML_SRCS ubiquity-slideshow/slides/*.qml) +add_custom_target(QmlFiles ALL echo SOURCES ${QML_SRCS}) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/calamares-qml-plugin/CMakeLists.txt b/calamares-qml-plugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/calamares-qml-plugin/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(contextplugin SHARED plugin.cpp) +target_link_libraries(contextplugin + Qt5::Qml + KF5::Declarative + KF5::I18n +) + +install(TARGETS contextplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/neon/calamares/slideshow/context) +install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/neon/calamares/slideshow/context) diff --git a/calamares-qml-plugin/plugin.cpp b/calamares-qml-plugin/plugin.cpp new file mode 100644 --- /dev/null +++ b/calamares-qml-plugin/plugin.cpp @@ -0,0 +1,71 @@ +/* + Copyright 2019 Harald Sitter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of + the License or any later version accepted by the membership of + KDE e.V. (or its successor approved by the membership of KDE + e.V.), which shall act as a proxy defined in Section 14 of + version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include +#include + +#include +#include +#include + +// Simple plugin that does absolutely nothing other than make i18n available +// to QML with the slideshow translations as domain. +// i.e. use the same translations as used for the ubiquity html but in their +// gettext incarnation. +class ContextPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void initializeEngine(QQmlEngine *engine, const char *uri) override + { + QQmlExtensionPlugin::initializeEngine(engine, uri); + QQmlContext *context = engine->rootContext(); + + KDeclarative::KDeclarative d; + d.setTranslationDomain("ubiquity-slideshow-neon"); + d.setDeclarativeEngine(engine); + d.setupEngine(engine); + d.setupContext(); + + // Cala only sets the QLocale default but otherwise leaves + // everything unchanged. That means ki18n will not pick the + // correct reference as the "system" locale is still what it + // was. To solve this we'll build the language list manually. + QStringList ls; + for (auto &lang : QLocale().uiLanguages()) { + ls << lang.replace('-', '_'); + } + for (auto &lang : QLocale::system().uiLanguages()) { + ls << lang.replace('-', '_'); + } + KLocalizedString::setLanguages(ls); + } + + void registerTypes(const char *uri) override + { + qmlRegisterModule(uri, 1, 0); + } +}; + +#include "plugin.moc" diff --git a/calamares-qml-plugin/qmldir b/calamares-qml-plugin/qmldir new file mode 100644 --- /dev/null +++ b/calamares-qml-plugin/qmldir @@ -0,0 +1,2 @@ +module org.kde.neon.calamares.slideshow.context +plugin contextplugin diff --git a/ubiquity-slideshow/slides/UbiquitySlide.qml b/ubiquity-slideshow/slides/UbiquitySlide.qml new file mode 100644 --- /dev/null +++ b/ubiquity-slideshow/slides/UbiquitySlide.qml @@ -0,0 +1,82 @@ +/* + Copyright 2019 Harald Sitter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of + the License or any later version accepted by the membership of + KDE e.V. (or its successor approved by the membership of KDE + e.V.), which shall act as a proxy defined in Section 14 of + version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import QtQuick 2.0 +import QtQuick.Controls 2.5 +import QtQuick.XmlListModel 2.0 + +import calamares.slideshow 1.0 +import org.kde.kirigami 2.4 as Kirigami +import org.kde.neon.calamares.slideshow.context 1.0 + +Slide { + id: slide + anchors.fill: parent + + property string name + property string textColor + + // Extract the actual string out of the html. This requires all html + // pages to have a standard div/h2 nexting and is somewhat abusing + // the fact that xhtml and html are just about the same. + XmlListModel { + id: xmlModel + query: "/div" + source: slide.name + ".html" + + XmlRole { name: "title"; query: "h2/string()" } + XmlRole { name: "image"; query: "img/@src/string()" } + + onCountChanged:{ + var item = get(0) + background.source = item.image + header.text = i18n(item.title) + } + } + + Image { + id: background + anchors.fill: parent + // Cropping would be nicer IMO. but it severely messes with my size + // calculation + fillMode: Image.PreserveAspectFit + } + + Item { + id: headerContainer + x: (background.width - background.paintedWidth) / 2.0 + y: (background.height - background.paintedHeight) / 2.0 + width: background.paintedWidth + height: background.paintedHeight + + Kirigami.Heading { + id: header + + anchors.left: headerContainer.left + anchors.top: headerContainer.top + anchors.right: headerContainer.right + anchors.margins: Kirigami.Units.largeSpacing + + wrapMode: Text.Wrap + level: 1 + color: textColor + } + } +} diff --git a/ubiquity-slideshow/slides/index.qml b/ubiquity-slideshow/slides/index.qml new file mode 100644 --- /dev/null +++ b/ubiquity-slideshow/slides/index.qml @@ -0,0 +1,52 @@ +/* + Copyright 2019 Harald Sitter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3 of + the License or any later version accepted by the membership of + KDE e.V. (or its successor approved by the membership of KDE + e.V.), which shall act as a proxy defined in Section 14 of + version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import QtQuick 2.12 +import calamares.slideshow 1.0 + +Presentation +{ + id: presentation + + property string colorPaperWhite: "#fcfcfc" + property string colorCharcoalGrey: "#31363b" + + Rectangle { + SystemPalette { id: systemPalette } + + anchors.fill: parent + color: systemPalette.window + } + + Timer { + id: timer + interval: 5000 + running: false + repeat: true + onTriggered: presentation.goToNextSlide() + } + + UbiquitySlide { name: 'kde'; textColor: colorPaperWhite } + UbiquitySlide { name: 'neon'; textColor: colorPaperWhite } + UbiquitySlide { name: 'plasma'; textColor: colorCharcoalGrey } + UbiquitySlide { name: 'secure'; textColor: colorPaperWhite } + + Component.onCompleted: timer.running = true +}