diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e638fd8..015bb19 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,49 +1,50 @@ set(kirigami2gallery_SRCS main.cpp + InfoData.cpp ) qt5_add_resources(RESOURCES resources.qrc) if (CMAKE_SYSTEM_NAME STREQUAL "Android") find_package(KF5Kirigami2 ${KF5_DEP_VERSION}) set(kirigami2gallery_EXTRA_LIBS Qt5::AndroidExtras #FIXME: we shouldn't have to link to it but otherwise the lib won't be packaged on Android Qt5::QuickControls2 KF5::Kirigami2) endif() find_program(kpackagetool_cmd kpackagetool5) if (kpackagetool_cmd) set(component org.kde.kirigami2.gallery) set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml") message(STATUS "${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/data --appstream-metainfo-output ${APPDATAFILE}") execute_process( COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/data --appstream-metainfo-output ${APPDATAFILE} ERROR_VARIABLE appstreamerror RESULT_VARIABLE result) if (NOT result EQUAL 0) message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}") else() if(appstreamerror) message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}") endif() # OPTIONAL because desktop files can be NoDisplay so they render no XML. install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL) endif() else() message(WARNING "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.") endif() add_executable(kirigami2gallery ${kirigami2gallery_SRCS} ${RESOURCES}) target_link_libraries(kirigami2gallery Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg ${kirigami2gallery_EXTRA_LIBS}) install(TARGETS kirigami2gallery ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES data/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.kirigami2.gallery.desktop) if (CMAKE_SYSTEM_NAME STREQUAL "Android") find_package(KF5Kirigami2 REQUIRED) kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-information dialog-positive dialog-warning dialog-error dialog-cancel document-decrypt system-run mail-reply-sender bookmarks folder media-record-symbolic add-placemark address-book-new-symbolic view-right-new view-right-close documentinfo) endif() diff --git a/src/InfoData.cpp b/src/InfoData.cpp new file mode 100644 index 0000000..10fbefd --- /dev/null +++ b/src/InfoData.cpp @@ -0,0 +1,84 @@ +#include "InfoData.h" +#include +#include +#include +#include +#include + +InfoData::InfoData(QObject *parent) + : QObject(parent) +{ + QString infoSheetData; + QFile file("://info-data.json"); + + if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { + infoSheetData = file.readAll(); + file.close(); + } + + QJsonObject jsonObject; + QJsonDocument data = QJsonDocument::fromJson(infoSheetData.toUtf8()); + + if (!data.isEmpty()) { + jsonObject = data.object(); + m_jsonMap = jsonObject.toVariantMap(); + } +} + +QString InfoData::component() const +{ + return m_component; +} + +QString InfoData::higUrl() const +{ + return m_higUrl; +} + +QString InfoData::sourceUrl() const +{ + return m_sourceUrl; +} + +QString InfoData::title() const +{ + return m_title; +} + +QString InfoData::text() const +{ + return m_text; +} + +void InfoData::setComponent(const QString &componentName) +{ + if (componentName != m_component) { + m_component = componentName; + emit componentChanged(); + m_jsonMap.contains(componentName) ? setComponentData() : clearComponentData(); + } +} + +void InfoData::clearComponentData() +{ + m_sourceUrl = QString(); + m_higUrl = QString(); + m_title = QString(); + m_text = QString(); +} + +void InfoData::setComponentData() +{ + QVariantMap componentVariant = qvariant_cast(m_jsonMap[m_component]); + + if (!componentVariant.isEmpty()) { + m_sourceUrl = componentVariant.contains("sourceUrl") ? componentVariant["sourceUrl"].toString() : QString(); + sourceUrlChanged(); + m_higUrl = componentVariant.contains("higUrl") ? componentVariant["higUrl"].toString() : QString(); + higUrlChanged(); + m_title = componentVariant.contains("title") ? componentVariant["title"].toString() : QString(); + titleChanged(); + m_text = componentVariant.contains("text") ? componentVariant["text"].toString() : QString(); + textChanged(); + } +} diff --git a/src/InfoData.h b/src/InfoData.h new file mode 100644 index 0000000..fb246ed --- /dev/null +++ b/src/InfoData.h @@ -0,0 +1,48 @@ +#ifndef INFODATA_H +#define INFODATA_H + +#include +#include +#include + +class InfoData : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString component READ component WRITE setComponent NOTIFY componentChanged) + Q_PROPERTY(QString higUrl READ higUrl NOTIFY higUrlChanged) + Q_PROPERTY(QString sourceUrl READ sourceUrl NOTIFY sourceUrlChanged) + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(QString text READ text NOTIFY textChanged) + +public: + InfoData(QObject *parent=0); + + QString component() const; + QString higUrl() const; + QString sourceUrl() const; + QString title() const; + QString text() const; + + void setComponent(const QString &componentName); + +signals: + void componentChanged(); + void higUrlChanged(); + void sourceUrlChanged(); + void titleChanged(); + void textChanged(); + +private: + void setComponentData(); + void clearComponentData(); + + QString m_component; + QString m_higUrl; + QString m_sourceUrl; + QString m_title; + QString m_text; + QVariantMap m_jsonMap; +}; + +#endif // INFODATA_H diff --git a/src/data/contents/ui/gallery/CardsLayoutGallery.qml b/src/data/contents/ui/gallery/CardsLayoutGallery.qml index a1aeb53..9681c01 100644 --- a/src/data/contents/ui/gallery/CardsLayoutGallery.qml +++ b/src/data/contents/ui/gallery/CardsLayoutGallery.qml @@ -1,231 +1,228 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.4 as Kirigami import "components" Kirigami.ScrollablePage { id: page title: qsTr("Cards Layout") actions.main: Kirigami.Action { iconName: "documentinfo" text: qsTr("Info") checkable: true onCheckedChanged: sheet.sheetOpen = checked; shortcut: "Alt+I" } InfoSheet { id: sheet - page: page - title: qsTr("Cards Layout") - higUrl: "https://hig.kde.org/components/editing/card.html" - sourceUrl: "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/CardsLayoutGallery.qml" - text: qsTr("The Kirigami types AbstractCard and Card are used to implement the popular Card pattern used on many mobile and web platforms that is used to display a collection of information or actions.\n Besides the Card components, Kirigami offers also 3 kinds of views and positioners to help to present cards with beautiful and responsive layouts.\n\nIn this page, CardsLayout is presented, which should be used when the cards are not instantiated by a model or by a model which has always very few items (In the case of a big model CardsListView or CardsGridview should be used instead). They are presented as a grid of two columns which will remain centered if the application is really wide, or become a single column if there is not enough space for two columns, such as a mobile phone screen.\nA CardsLayout should always be contained within a ColumnLayout.") + page: page + component: "CardsLayoutGallery" } ColumnLayout { Kirigami.CardsLayout { id: layout Kirigami.AbstractCard { Layout.fillHeight: true header: Kirigami.Heading { text: qsTr("AbstractCard") level: 2 } contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("An AbstractCard is the simplest form of card. It's just a rectangle with a shadow, which can contain any Item in it. It can also have items assigned to the Header or Footer properties. In this case a Kirigami.Heading is its header and a Label with WordWrap is the contentItem.") } } Kirigami.AbstractCard { showClickFeedback: true contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("This is an AbstractCard with a Label with WordWrap in it and nothing else, it's the simplest form Cards can be found in.\nAn AbstractCard can be clicked itself, with the usual onClicked signal handler and the showClickFeedback property can be used if the click should show any kind of visual feedback. It is recommended to set it to true if you plan to make the card reactive on any kind of click.") } onClicked: showPassiveNotification(qsTr("Card clicked")) } Kirigami.Card { actions: [ Kirigami.Action { text: qsTr("Action1") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action2") icon.name: "address-book-new-symbolic" } ] banner { source: "../banner.jpg" title: qsTr("Card") } contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("This is an instance of the Card type: it can optionally have an image, a title and an icon assigned to its banner group property, one or all of the properties together. A Card can also have Actions that will appear in the footer.") } } Kirigami.Card { actions: [ Kirigami.Action { text: qsTr("Action1") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action2") icon.name: "address-book-new-symbolic" }, Kirigami.Action { text: qsTr("Action3") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action4") icon.name: "address-book-new-symbolic" }, Kirigami.Action { text: qsTr("Action5") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action6") icon.name: "address-book-new-symbolic" } ] banner { source: "../banner.jpg" title: "Title Alignment" titleAlignment: Qt.AlignLeft | Qt.AlignBottom } contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("The title can be aligned to all corners or centered with a combination of Qt.Alignment flags.\n When there are too many actions, they go in an overflow menu.") } } Kirigami.Card { actions: [ Kirigami.Action { text: qsTr("Action1") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action2") icon.name: "address-book-new-symbolic" } ] hiddenActions: [ Kirigami.Action { text: qsTr("Action always hidden") icon.name: "add-placemark" } ] banner { iconSource: "applications-graphics" title: "Title only" } contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("The Banner can contain only the title and/or an icon, even if there is no banner image.") } } Kirigami.Card { banner.source: "../banner.jpg" header: Rectangle { color: Qt.rgba(0,0,0,0.3) implicitWidth: headerLayout.implicitWidth implicitHeight: headerLayout.implicitHeight - avatarIcon.height/2 ColumnLayout { id: headerLayout anchors { left: parent.left right: parent.right } Controls.Label { Layout.fillWidth: true padding: Kirigami.Units.largeSpacing color: "white" wrapMode: Text.WordWrap text: qsTr("It's possible to have custom contents overlapping the image, for cases where a more personalized design is needed.") } Rectangle { id: avatarIcon color: "steelblue" radius: width Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: Kirigami.Units.iconSizes.huge Layout.preferredHeight: Kirigami.Units.iconSizes.huge } } } contentItem: Controls.Label { wrapMode: Text.WordWrap topPadding: avatarIcon.height/2 text: qsTr("It's possible to customize the look and feel for Cards too, if the no padding behavior for headers is needed. This is usually discouraged in order to have greater consistency, but in some cases the design requires a more fancy layout, as shown in this example of a Card. If a custom header is used, the title and icon in the banner property shouldn't be used. If a custom footer is used (which is discouraged), actions shouldn't be used.") } footer: RowLayout { Controls.Label { Layout.fillWidth: true text: qsTr("Custom footer") } Controls.Button { text: qsTr("Ok") } } } Kirigami.Card { headerOrientation: Qt.Horizontal actions: [ Kirigami.Action { text: qsTr("Action1") icon.name: "add-placemark" }, Kirigami.Action { text: qsTr("Action2") icon.name: "address-book-new-symbolic" } ] banner { source: "../banner.jpg" title: "Title" } contentItem: Controls.Label { wrapMode: Text.WordWrap text: qsTr("A card can optionally have horizontal orientation.\n In this case will be wider than tall, so is fit to be used also in a ColumnLayout.\nIf you need to put it in a CardsLayout, it will have by default a columnSpan of 2 (which can be overridden).") } } } } } diff --git a/src/data/contents/ui/gallery/DrawerGallery.qml b/src/data/contents/ui/gallery/DrawerGallery.qml index 19d366b..c3609f4 100644 --- a/src/data/contents/ui/gallery/DrawerGallery.qml +++ b/src/data/contents/ui/gallery/DrawerGallery.qml @@ -1,182 +1,181 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.2 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.5 as Kirigami import "components" Kirigami.ScrollablePage { id: page title: qsTr("Overlay Sheets") actions{ main: Kirigami.Action { iconName: "documentinfo" text: qsTr("Info") checkable: true onCheckedChanged: sheet.sheetOpen = checked; shortcut: "Alt+I" } contextualActions: [ Kirigami.Action { text: qsTr("Action 1") iconName: "bookmarks" onTriggered: showPassiveNotification(qsTr("Action 1 clicked")) }, Kirigami.Action { text: qsTr("Disabled Action") iconName: "folder" enabled: false }, Kirigami.Action { text: qsTr("Action 3") onTriggered: showPassiveNotification(qsTr("Action 3 clicked")) } ] } //Close the drawer with the back button onBackRequested: { if (sheet.sheetOpen) { event.accepted = true; sheet.close(); } } InfoSheet { id: sheet - title: qsTr("Drawers") + page: page - sourceUrl: "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/DrawerGallery.qml" - text: qsTr("Drawers are bars anchored to an edge of the screen: left, right, top or bottom.\nOn the left edge they should contain controls and settings global for the whole app, and is strongly encouraged to use the default component GlobalDrawer and to have only one instance for the whole application.\nOn the right edge they should have context-dependent actions linked to the current Page. It is strongly suggested to use the default component ContextDrawer for this and to have only one instance for the whole application.\nDrawers can be modal(default) in which they block input in the rest of the application window, clicking on a darkened out area will dismiss the drawer.\nNon modal drawers will leave the rest of the application window functional and vertical(left and right edge) drawers will become sidebars.\nNon modal drawers can also be collapsible, switching from a full vertical sidebar to a more compact vertical toolbar.\nYou can test between different Drawer modes in the \"Global Drawer Mode...\" menu entry in the global drawer of this application running on Desktop systems.") + component: "DrawerGallery" } Kirigami.OverlayDrawer { id: modalBottomDrawer edge: Qt.BottomEdge contentItem: ColumnLayout { Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("A modal bottom drawer will span for the whole application window width and will darken the rest of the app. Clicking on a darkened will dismiss the drawer.") } Controls.Button { Layout.alignment: Qt.AlignRight text: qsTr("Close") onClicked: modalBottomDrawer.close() } } } Kirigami.OverlayDrawer { id: inlineBottomDrawer edge: Qt.BottomEdge modal: false contentItem: ColumnLayout { Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("An inline top drawer covers the whole application width but lets the uncovered pieces to still be interacted with.") } Controls.Button { Layout.alignment: Qt.AlignRight text: qsTr("Close") onClicked: inlineBottomDrawer.close() } } } Kirigami.OverlayDrawer { id: modalTopDrawer edge: Qt.TopEdge contentItem: ColumnLayout { Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("A modal top drawer will span for the whole application window width and will darken the rest of the app. Clicking on the darkened area will dismiss the drawer.") } Controls.Button { Layout.alignment: Qt.AlignRight text: qsTr("Close") onClicked: modalTopDrawer.close() } } } Kirigami.OverlayDrawer { id: inlineTopDrawer edge: Qt.TopEdge modal: false contentItem: ColumnLayout { Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("An inline bottom drawer covers the whole application width but lets the uncovered pieces to still be interacted with.") } Controls.Button { Layout.alignment: Qt.AlignRight text: qsTr("Close") onClicked: inlineTopDrawer.close() } } } ColumnLayout { width: page.width spacing: Kirigami.Units.smallSpacing Controls.Button { text: qsTr("Left Global Drawer") Layout.alignment: Qt.AlignHCenter onClicked: applicationWindow().globalDrawer.open() } Controls.Button { text: qsTr("Right Context Drawer") Layout.alignment: Qt.AlignHCenter visible: applicationWindow().contextDrawer onClicked: applicationWindow().contextDrawer.open() } Controls.Button { text: qsTr("Modal Bottom Drawer") Layout.alignment: Qt.AlignHCenter onClicked: modalBottomDrawer.open() } Controls.Button { text: "Inline Bottom Drawer" Layout.alignment: Qt.AlignHCenter onClicked: inlineBottomDrawer.open() } Controls.Button { text: qsTr("Modal Top Drawer") Layout.alignment: Qt.AlignHCenter onClicked: modalTopDrawer.open() } Controls.Button { text: "Inline Top Drawer" Layout.alignment: Qt.AlignHCenter onClicked: inlineTopDrawer.open() } } } diff --git a/src/data/contents/ui/gallery/FormLayoutGallery.qml b/src/data/contents/ui/gallery/FormLayoutGallery.qml index a7cc830..ecce519 100644 --- a/src/data/contents/ui/gallery/FormLayoutGallery.qml +++ b/src/data/contents/ui/gallery/FormLayoutGallery.qml @@ -1,103 +1,128 @@ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 import org.kde.kirigami 2.4 as Kirigami +import "components" Kirigami.ScrollablePage { + id: page title: "Form Layout" + actions.main: Kirigami.Action { + iconName: "documentinfo" + text: qsTr("Info") + checkable: true + onCheckedChanged: sheet.sheetOpen = checked; + shortcut: "Alt+I" + } + + //Close the drawer with the back button + onBackRequested: { + if (sheet.sheetOpen) { + event.accepted = true; + sheet.close(); + } + } + + InfoSheet { + id: sheet + + page: page + component: "FormLayoutGallery" + } + Kirigami.FormLayout { id: layout TextField { Kirigami.FormData.label: "Label:" } TextField { } TextField { Kirigami.FormData.label:"Lo&nger label:" } Kirigami.Separator { Kirigami.FormData.isSection: true } TextField { Kirigami.FormData.label: "After separator:" } ComboBox { Kirigami.FormData.label: "Combo:" model: ["First", "Second", "Third"] } CheckBox { checked: true text: "Option" } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: "Section title" } TextField { Kirigami.FormData.label: "Label:" } Item { width:1 height:1 Kirigami.FormData.isSection: true } TextField { Kirigami.FormData.label: "Section without line:" } Button { text: qsTr("Expanding Button") Layout.fillWidth: true } Item { width:1 height:1 Kirigami.FormData.isSection: true Kirigami.FormData.label: "Section with title without line" } TextField { Kirigami.FormData.label: "Title:" } TextField { Kirigami.FormData.label: "Checkable label" Kirigami.FormData.checkable: true enabled: Kirigami.FormData.checked } ColumnLayout { Layout.rowSpan: 3 Kirigami.FormData.label: "Label for radios:" Kirigami.FormData.buddyFor: firstRadio RadioButton { id: firstRadio checked: true text: "One" } RadioButton { text: "Two" } RadioButton { text: "Three" } } Button { text: item ? "Remove Field" : "Add Field" property TextField item onClicked: { if (item) { item.destroy(); } else { item = dyncomponent.createObject(layout); } } Component { id: dyncomponent TextField { Kirigami.FormData.label: "Generated Title:" } } } } } diff --git a/src/data/contents/ui/gallery/OverlaySheetGallery.qml b/src/data/contents/ui/gallery/OverlaySheetGallery.qml index 0658d5c..af66145 100644 --- a/src/data/contents/ui/gallery/OverlaySheetGallery.qml +++ b/src/data/contents/ui/gallery/OverlaySheetGallery.qml @@ -1,211 +1,212 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.5 as Kirigami import "components" Kirigami.ScrollablePage { id: page Layout.fillWidth: true //implicitWidth: Units.gridUnit * (Math.floor(Math.random() * 35) + 10) title: qsTr("Overlay Sheets") actions.main: Kirigami.Action { iconName: "documentinfo" text: qsTr("Info") checkable: true onCheckedChanged: sheet.sheetOpen = checked; shortcut: "Alt+I" } //Close the drawer with the back button onBackRequested: { if (sheet.sheetOpen) { event.accepted = true; sheet.close(); } } InfoSheet { id: sheet - title: qsTr("Overlay Sheets") - sourceUrl: "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/OverlaySheetGallery.qml" - text: qsTr("The OverlaySheet control is a kind of modal content which goes over the main application content (either just the page or the whole app area) which is supposed to be used to display long contents, which may be taller than the application window itself, in which case the content will be scrollable.\nThe visual metaphore of the control is a piece of paper that scrolling, covering the page of the application, which can be dismissed scrolling it away (or tapping any area outside it).") + + page: page + component: "OverlaySheetGallery" + } Kirigami.OverlaySheet { id: longSheet ColumnLayout { Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id risus id augue euismod accumsan. Nunc vestibulum placerat bibendum. Morbi commodo auctor varius. Donec molestie euismod ultrices. Sed facilisis augue nec eros auctor, vitae mattis quam rhoncus. Nam ut erat diam. Curabitur iaculis accumsan magna, eget fermentum massa scelerisque eu. Cras elementum erat non erat euismod accumsan. Vestibulum ac mi sed dui finibus pulvinar. Vivamus dictum, leo sed lobortis porttitor, nisl magna faucibus orci, sit amet euismod arcu elit eget est. Duis et vehicula nibh. In arcu sapien, laoreet sit amet porttitor non, rhoncus vel magna. Suspendisse imperdiet consectetur est nec ornare. Pellentesque bibendum sapien at erat efficitur vehicula. Morbi sed porta nibh. Vestibulum ut urna ut dolor sagittis mattis." } Controls.TextField { Layout.alignment: Qt.AlignHCenter } Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: " Morbi dictum, sapien at maximus pulvinar, sapien metus condimentum magna, quis lobortis nisi dui mollis turpis. Aliquam sit amet scelerisque dui. In sit amet tellus placerat, condimentum enim sed, hendrerit quam. Integer dapibus lobortis finibus. Suspendisse faucibus eros vitae ante posuere blandit. Nullam volutpat quam id diam hendrerit aliquam. Donec non sem at diam posuere convallis. Vivamus ut congue quam. Ut dictum fermentum sapien, eu ultricies est ornare ut. Nullam fringilla a libero vehicula faucibus. Donec euismod sodales nulla, in vehicula lectus posuere a. Donec nisi nulla, pulvinar eu porttitor vitae, varius eget ante. Nam rutrum eleifend elit, quis facilisis leo sodales vitae. Aenean accumsan a nulla at sagittis. Integer placerat tristique magna, vitae iaculis ante cursus sit amet. Sed facilisis mollis turpis nec tristique. Etiam quis feugiat odio. Vivamus sagittis at purus nec aliquam. Morbi neque dolor, elementum ac fermentum ac, auctor ut erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus non nibh sit amet quam luctus congue. Donec in eros varius, porta metus sed, sagittis lacus. Mauris dapibus lorem nisi, non eleifend massa tristique egestas. Curabitur nec blandit urna. Mauris rhoncus libero felis, commodo viverra ante consectetur vel. Donec dictum tincidunt orci, quis tristique urna. Quisque egestas, dui ac mollis dictum, purus velit elementum est, at pellentesque erat est fermentum purus. Nulla a quam tellus. Vestibulum a congue ligula. Quisque feugiat nulla et tortor sodales viverra. Maecenas dolor leo, elementum sed urna vel, posuere hendrerit metus. Mauris pellentesque, mi non luctus aliquam, leo nulla varius arcu, vel pulvinar enim enim nec nisl. Etiam sapien leo, venenatis eget justo at, pellentesque mollis tellus. Fusce consequat ullamcorper vulputate. Duis tellus nisi, dictum ut augue non, elementum congue ligula. Fusce in vehicula arcu. Nulla facilisi. Quisque a convallis sapien. Aenean pellentesque convallis egestas. Phasellus rhoncus, nulla in tempor maximus, arcu ex venenatis diam, sit amet egestas mi dolor non ante. " } Controls.Button { text: qsTr("Close") Layout.alignment: Qt.AlignHCenter onClicked: sheet.close() } } } Kirigami.OverlaySheet { id: headerFooterSheet header: Kirigami.Heading { text: qsTr("Title") } footer: RowLayout { Controls.Label { text: qsTr("Footer:") } Controls.TextField { Layout.fillWidth: true } } ColumnLayout { spacing: Kirigami.Units.largeSpacing * 5 Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("A sheet can have optional header and footer items which will not scroll away when the sheet overflows.") } Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id risus id augue euismod accumsan. Nunc vestibulum placerat bibendum. Morbi commodo auctor varius. Donec molestie euismod ultrices. Sed facilisis augue nec eros auctor, vitae mattis quam rhoncus. Nam ut erat diam. Curabitur iaculis accumsan magna, eget fermentum massa scelerisque eu. Cras elementum erat non erat euismod accumsan. Vestibulum ac mi sed dui finibus pulvinar. Vivamus dictum, leo sed lobortis porttitor, nisl magna faucibus orci, sit amet euismod arcu elit eget est. Duis et vehicula nibh. In arcu sapien, laoreet sit amet porttitor non, rhoncus vel magna. Suspendisse imperdiet consectetur est nec ornare. Pellentesque bibendum sapien at erat efficitur vehicula. Morbi sed porta nibh. Vestibulum ut urna ut dolor sagittis mattis.\nMorbi dictum, sapien at maximus pulvinar, sapien metus condimentum magna, quis lobortis nisi dui mollis turpis. Aliquam sit amet scelerisque dui. In sit amet tellus placerat, condimentum enim sed, hendrerit quam. Integer dapibus lobortis finibus. Suspendisse faucibus eros vitae ante posuere blandit. Nullam volutpat quam id diam hendrerit aliquam. Donec non sem at diam posuere convallis. Vivamus ut congue quam. Ut dictum fermentum sapien, eu ultricies est ornare ut.\nNullam fringilla a libero vehicula faucibus. Donec euismod sodales nulla, in vehicula lectus posuere a. Donec nisi nulla, pulvinar eu porttitor vitae, varius eget ante. Nam rutrum eleifend elit, quis facilisis leo sodales vitae. Aenean accumsan a nulla at sagittis. Integer placerat tristique magna, vitae iaculis ante cursus sit amet. Sed facilisis mollis turpis nec tristique. Etiam quis feugiat odio. Vivamus sagittis at purus nec aliquam.\nMorbi neque dolor, elementum ac fermentum ac, auctor ut erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus non nibh sit amet quam luctus congue. Donec in eros varius, porta metus sed, sagittis lacus. Mauris dapibus lorem nisi, non eleifend massa tristique egestas. Curabitur nec blandit urna. Mauris rhoncus libero felis, commodo viverra ante consectetur vel. Donec dictum tincidunt orci, quis tristique urna. Quisque egestas, dui ac mollis dictum, purus velit elementum est, at pellentesque erat est fermentum purus. Nulla a quam tellus. Vestibulum a congue ligula. Quisque feugiat nulla et tortor sodales viverra. Maecenas dolor leo, elementum sed urna vel, posuere hendrerit metus. Mauris pellentesque, mi non luctus aliquam, leo nulla varius arcu, vel pulvinar enim enim nec nisl.\nEtiam sapien leo, venenatis eget justo at, pellentesque mollis tellus. Fusce consequat ullamcorper vulputate. Duis tellus nisi, dictum ut augue non, elementum congue ligula. Fusce in vehicula arcu. Nulla facilisi. Quisque a convallis sapien. Aenean pellentesque convallis egestas. Phasellus rhoncus, nulla in tempor maximus, arcu ex venenatis diam, sit amet egestas mi dolor non ante." } } } Kirigami.OverlaySheet { id: fixedWidthSheet ColumnLayout { spacing: Kirigami.Units.largeSpacing * 5 Layout.preferredWidth: Kirigami.Units.gridUnit * 25 Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("A sheet will take the maximum available width in the page by default.\nHowever, if the main item sets an implicitWidth or Layout.preferredWidth, the sheet won't grow in width more than such given value.") } Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id risus id augue euismod accumsan. Nunc vestibulum placerat bibendum. Morbi commodo auctor varius. Donec molestie euismod ultrices. Sed facilisis augue nec eros auctor, vitae mattis quam rhoncus. Nam ut erat diam. Curabitur iaculis accumsan magna, eget fermentum massa scelerisque eu. Cras elementum erat non erat euismod accumsan. Vestibulum ac mi sed dui finibus pulvinar. Vivamus dictum, leo sed lobortis porttitor, nisl magna faucibus orci, sit amet euismod arcu elit eget est. Duis et vehicula nibh. In arcu sapien, laoreet sit amet porttitor non, rhoncus vel magna. Suspendisse imperdiet consectetur est nec ornare. Pellentesque bibendum sapien at erat efficitur vehicula. Morbi sed porta nibh. Vestibulum ut urna ut dolor sagittis mattis." } } } Kirigami.OverlaySheet { id: globalSheet parent: applicationWindow().overlay ColumnLayout { spacing: Kirigami.Units.largeSpacing * 5 Layout.preferredWidth: Kirigami.Units.gridUnit * 25 Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("A sheet by default will be over a single page, even if the app is in wide mode. By changing the sheet parent to applicationWindow().overlay it will display the sheet as an overlay on top of the whole application window.\nIn this case the sheet will cover the page Action buttons too.") } Controls.Label { Layout.fillWidth: true wrapMode: Text.WordWrap text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id risus id augue euismod accumsan. Nunc vestibulum placerat bibendum. Morbi commodo auctor varius. Donec molestie euismod ultrices. Sed facilisis augue nec eros auctor, vitae mattis quam rhoncus. Nam ut erat diam. Curabitur iaculis accumsan magna, eget fermentum massa scelerisque eu. Cras elementum erat non erat euismod accumsan. Vestibulum ac mi sed dui finibus pulvinar. Vivamus dictum, leo sed lobortis porttitor, nisl magna faucibus orci, sit amet euismod arcu elit eget est. Duis et vehicula nibh. In arcu sapien, laoreet sit amet porttitor non, rhoncus vel magna. Suspendisse imperdiet consectetur est nec ornare. Pellentesque bibendum sapien at erat efficitur vehicula. Morbi sed porta nibh. Vestibulum ut urna ut dolor sagittis mattis." } } } Kirigami.OverlaySheet { id: listViewSheet header: Kirigami.Heading { text: qsTr("Title") } footer: RowLayout { Controls.Label { text: qsTr("Footer:") } Controls.TextField { Layout.fillWidth: true Layout.alignment: Qt.AlignCenter } } ListView { model: 100 implicitWidth: Kirigami.Units.gridUnit * 30 delegate: Kirigami.BasicListItem { label: qsTr("Item in sheet ") + modelData } } } ColumnLayout { width: page.width spacing: Kirigami.Units.smallSpacing Controls.Button { text: qsTr("Very Long Sheet") Layout.alignment: Qt.AlignHCenter onClicked: longSheet.open() } Controls.Button { text: "Sheet With Header And Footer" Layout.alignment: Qt.AlignHCenter onClicked: headerFooterSheet.open() } Controls.Button { text: "Sheet With Fixed Width" Layout.alignment: Qt.AlignHCenter onClicked: fixedWidthSheet.open() } Controls.Button { text: "Global Sheet" Layout.alignment: Qt.AlignHCenter onClicked: globalSheet.open() } Controls.Button { text: "Sheet With List View" Layout.alignment: Qt.AlignHCenter onClicked: listViewSheet.open() } } } diff --git a/src/data/contents/ui/gallery/SelectionControlsGallery.qml b/src/data/contents/ui/gallery/SelectionControlsGallery.qml index 542542f..4b16d3b 100644 --- a/src/data/contents/ui/gallery/SelectionControlsGallery.qml +++ b/src/data/contents/ui/gallery/SelectionControlsGallery.qml @@ -1,180 +1,178 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.2 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.4 as Kirigami import "components" Kirigami.ScrollablePage { id: page actions.main: Kirigami.Action { iconName: "documentinfo" text: qsTr("Info") checkable: true onCheckedChanged: sheet.sheetOpen = checked; shortcut: "Alt+I" } Layout.fillWidth: true title: qsTr("Selection Controls") //Close the drawer with the back button onBackRequested: { if (sheet.sheetOpen) { event.accepted = true; sheet.close(); } } InfoSheet { id: sheet + page: page - title: qsTr("Selection Controls") - higUrl: "https://hig.kde.org/components/index.html#selection" - sourceUrl: "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/SelectionControlsGallery.qml" - text: qsTr("

Selection controls allow users to complete tasks that involve a choice or a selection.

Depending on the kind of choice that has to be made, the best control to use may be a Checkbox, a RadioButton, or a Switch.

  • Use checkboxes for non-exclusive options that have clear alternatives. Mutually exclusive options should use a set of radio buttons or a combo box.
  • Use radio buttons for a few mutually exclusive options. If there are more than five options (or if there is not enough space to arrange four or five options), use a combo box or list instead.
  • Use switches on Mobile, when immediately activating or deactivating something (ok/Apply buttons not needed).
") + component: "SelectionControlsGallery" } Controls.Dialog { id: checkListDialog modal: true focus: true x: (page.width - width) / 2 y: page.height / 2 - height width: Math.min(page.width - Kirigami.Units.gridUnit * 4, Kirigami.Units.gridUnit * 20) height: Kirigami.Units.gridUnit * 20 standardButtons: Controls.Dialog.Close title: qsTr("Checkable List Items") contentItem: Controls.ScrollView { ListView { model: 20 delegate: Controls.CheckDelegate { width: parent.width text: qsTr("Delegate") + " " + (modelData+1) } } Component.onCompleted: background.visible = true } } Controls.Dialog { id: radioListDialog modal: true focus: true x: (page.width - width) / 2 y: page.height / 2 - height width: Math.min(page.width - Kirigami.Units.gridUnit * 4, Kirigami.Units.gridUnit * 20) height: Kirigami.Units.gridUnit * 20 standardButtons: Controls.Dialog.Close title: qsTr("Radio List Items") contentItem: Controls.ScrollView { ListView { model: 20 delegate: Controls.RadioDelegate { width: parent.width text: qsTr("Delegate") + " " + (modelData+1) } } Component.onCompleted: background.visible = true } } Controls.Dialog { id: switchListDialog modal: true focus: true x: (page.width - width) / 2 y: page.height / 2 - height width: Math.min(page.width - Kirigami.Units.gridUnit * 4, Kirigami.Units.gridUnit * 20) height: Kirigami.Units.gridUnit * 20 standardButtons: Controls.Dialog.Close title: qsTr("Radio List Items") contentItem: Controls.ScrollView { ListView { model: 20 delegate: Controls.SwitchDelegate { width: parent.width text: qsTr("Delegate") + " " + (modelData+1) } } Component.onCompleted: background.visible = true } } Kirigami.FormLayout { Item { Kirigami.FormData.label: qsTr("Checkboxes") Kirigami.FormData.isSection: true } Controls.CheckBox { text: qsTr("Item selected") checked: true } Controls.CheckBox { text: qsTr("Item not selected") checked: false } Controls.Button { text: qsTr("Checkable List View") onClicked: checkListDialog.open() } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: qsTr("Radio buttons") } ColumnLayout { Controls.RadioButton { text: qsTr("Item selected") checked: true } Controls.RadioButton { text: qsTr("Item not selected") checked: false } } Controls.Button { text: qsTr("Radio List View") onClicked: radioListDialog.open() } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: qsTr("Switches") } Controls.Switch { text: qsTr("Item selected") checked: true } Controls.Switch { text: qsTr("Item not selected") checked: false } Controls.Button { text: qsTr("Switch List View") onClicked: switchListDialog.open() } } } diff --git a/src/data/contents/ui/gallery/components/InfoSheet.qml b/src/data/contents/ui/gallery/components/InfoSheet.qml index 38180ef..e9b73a3 100644 --- a/src/data/contents/ui/gallery/components/InfoSheet.qml +++ b/src/data/contents/ui/gallery/components/InfoSheet.qml @@ -1,60 +1,69 @@ /* * Copyright 2018 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 import org.kde.kirigami 2.4 as Kirigami +import Data 1.0 Kirigami.OverlaySheet { id: root property Kirigami.Page page - property url higUrl - property url sourceUrl + property url higUrl: infoData.higUrl + property url sourceUrl: infoData.sourceUrl property alias title: titleLabel.text property alias text: mainText.text + property alias component: infoData.component onSheetOpenChanged: page.actions.main.checked = sheetOpen header: Kirigami.Heading { id: titleLabel + + text: infoData.title Layout.fillWidth: true + + InfoData { + id: infoData + } } footer: RowLayout { Item { Layout.fillWidth: true } Controls.ToolButton { text: qsTr("HIG...") enabled: higUrl != "" onClicked: Qt.openUrlExternally(higUrl) } Controls.ToolButton { text: qsTr("Source code...") enabled: sourceUrl != "" onClicked: Qt.openUrlExternally(sourceUrl) } } Controls.Label { id: mainText + text: infoData.text property int implicitWidth: Kirigami.Units.gridUnit * 25 wrapMode: Text.WordWrap } } diff --git a/src/data/info-data.json b/src/data/info-data.json new file mode 100644 index 0000000..4c45e6d --- /dev/null +++ b/src/data/info-data.json @@ -0,0 +1,30 @@ +{ + "FormLayoutGallery": { + "title":"Form Layout", + "higUrl": "https://hig.kde.org/patterns/content/form.html", + "sourceUrl": "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/FormLayoutGallery.qml", + "text": "

A Form layout is used to help align and structure a layout containing many control and input fields


When to use


  • Use a Form layout when there are many related controls and input fields.
  • Form layouts are ideal for settings dialogs
" + }, + "SelectionControlsGallery" : { + "title" : "Selection Controls", + "higUrl": "https://hig.kde.org/components/index.html#selection", + "sourceUrl": "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/SelectionControlsGallery.qml", + "text":"

Selection controls allow users to complete tasks that involve a choice or a selection.

Depending on the kind of choice that has to be made, the best control to use may be a Checkbox, a RadioButton, or a Switch.

  • Use checkboxes for non-exclusive options that have clear alternatives. Mutually exclusive options should use a set of radio buttons or a combo box.
  • Use radio buttons for a few mutually exclusive options. If there are more than five options (or if there is not enough space to arrange four or five options), use a combo box or list instead.
  • Use switches on Mobile, when immediately activating or deactivating something (ok/Apply buttons not needed).
" + }, + "CardsLayoutGallery" : { + "title": "Cards Layout", + "higUrl": "https://hig.kde.org/components/editing/card.html", + "sourceUrl": "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/CardsLayoutGallery.qml", + "text": "The Kirigami types AbstractCard and Card are used to implement the popular Card pattern used on many mobile and web platforms that is used to display a collection of information or actions.
Besides the Card components, Kirigami offers also 3 kinds of views and positioners to help to present cards with beautiful and responsive layouts.

In this page, CardsLayout is presented, which should be used when the cards are not instantiated by a model or by a model which has always very few items (In the case of a big model CardsListView or CardsGridview should be used instead). They are presented as a grid of two columns which will remain centered if the application is really wide, or become a single column if there is not enough space for two columns, such as a mobile phone screen.
A CardsLayout should always be contained within a ColumnLayout." + }, + "DrawerGallery": { + "title": "Drawers", + "sourceUrl": "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/DrawerGallery.qml", + "text": "Drawers are bars anchored to an edge of the screen: left, right, top or bottom.
On the left edge they should contain controls and settings global for the whole app, and is strongly encouraged to use the default component GlobalDrawer and to have only one instance for the whole application.
On the right edge they should have context-dependent actions linked to the current Page. It is strongly suggested to use the default component ContextDrawer for this and to have only one instance for the whole application.
Drawers can be modal(default) in which they block input in the rest of the application window, clicking on a darkened out area will dismiss the drawer.
Non modal drawers will leave the rest of the application window functional and vertical(left and right edge) drawers will become sidebars.
Non modal drawers can also be collapsible, switching from a full vertical sidebar to a more compact vertical toolbar.
You can test between different Drawer modes in the \"Global Drawer Mode...\" menu entry in the global drawer of this application running on Desktop systems." + }, + "OverlaySheetGallery": { + "title": "Overlay Sheets", + "sourceUrl": "https://cgit.kde.org/kirigami-gallery.git/tree/src/data/contents/ui/gallery/OverlaySheetGallery.qml", + "text": "The OverlaySheet control is a kind of modal content which goes over the main application content (either just the page or the whole app area) which is supposed to be used to display long contents, which may be taller than the application window itself, in which case the content will be scrollable.
The visual metaphore of the control is a piece of paper that scrolling, covering the page of the application, which can be dismissed scrolling it away (or tapping any area outside it)." + } +} diff --git a/src/main.cpp b/src/main.cpp index bc60ee3..0e29253 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,82 +1,85 @@ /* * Copyright 2017 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef Q_OS_ANDROID #include #else #include #endif #include #include #include #include +#include "InfoData.h" #ifdef Q_OS_ANDROID #include // WindowManager.LayoutParams #define FLAG_TRANSLUCENT_STATUS 0x04000000 #define FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 0x80000000 // View #define SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 0x00002000 #endif Q_DECL_EXPORT int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //The desktop QQC2 style needs it to be a QApplication #ifdef Q_OS_ANDROID QGuiApplication app(argc, argv); #else QApplication app(argc, argv); #endif //Extra debug if needed //qputenv("QML_IMPORT_TRACE", "1"); QQmlApplicationEngine engine; + qmlRegisterType("Data", 1, 0, "InfoData"); + //we want different main files on desktop or mobile //very small difference as they as they are subclasses of the same thing if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE") && (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("1") || QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("true"))) { engine.load(QUrl(QStringLiteral("qrc:///contents/ui/mobileApp.qml"))); } else { engine.load(QUrl(QStringLiteral("qrc:///contents/ui/BaseApp.qml"))); } if (engine.rootObjects().isEmpty()) { return -1; } //HACK to color the system bar on Android, use qtandroidextras and call the appropriate Java methods #ifdef Q_OS_ANDROID QtAndroid::runOnAndroidThread([=]() { QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;"); window.callMethod("addFlags", "(I)V", FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.callMethod("clearFlags", "(I)V", FLAG_TRANSLUCENT_STATUS); window.callMethod("setStatusBarColor", "(I)V", QColor("#2196f3").rgba()); window.callMethod("setNavigationBarColor", "(I)V", QColor("#2196f3").rgba()); }); #endif return app.exec(); } diff --git a/src/resources.qrc b/src/resources.qrc index 7393f9c..d9bb9b5 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,33 +1,34 @@ ./data/contents/ui/MainPage.qml ./data/contents/ui/banner.jpg ./data/contents/ui/gallery/components/InfoSheet.qml ./data/contents/ui/gallery/NonScrollableGallery.qml ./data/contents/ui/gallery/ButtonGallery.qml ./data/contents/ui/gallery/OverlaySheetGallery.qml ./data/contents/ui/gallery/DrawerGallery.qml ./data/contents/ui/gallery/ProgressBarGallery.qml ./data/contents/ui/gallery/SelectionControlsGallery.qml ./data/contents/ui/gallery/SliderGallery.qml ./data/contents/ui/gallery/MultipleColumnsGallery.qml ./data/contents/ui/gallery/MiscGallery.qml ./data/contents/ui/gallery/ListViewGallery.qml ./data/contents/ui/gallery/ListViewHeaderItemsGallery.qml ./data/contents/ui/gallery/TabBarGallery.qml ./data/contents/ui/gallery/TextFieldGallery.qml ./data/contents/ui/gallery/ColorsGallery.qml ./data/contents/ui/gallery/CardsLayoutGallery.qml ./data/contents/ui/gallery/CardsListViewGallery.qml ./data/contents/ui/gallery/CardsGridViewGallery.qml ./data/contents/ui/gallery/InlineMessagesGallery.qml ./data/contents/ui/gallery/MetricsGallery.qml ./data/contents/ui/gallery/LayersGallery.qml ./data/contents/ui/gallery/FormLayoutGallery.qml ./data/contents/ui/gallery/ColorSetGallery.qml ./data/contents/ui/BaseApp.qml ./data/contents/ui/mobileApp.qml ./data/metadata.desktop qtquickcontrols2.conf + ./data/info-data.json