diff --git a/kirigami.qrc b/kirigami.qrc index 4f529f5d..d3c2313f 100644 --- a/kirigami.qrc +++ b/kirigami.qrc @@ -1,83 +1,86 @@ src/controls/AbstractApplicationWindow.qml src/controls/ContextDrawer.qml src/controls/Action.qml src/controls/Page.qml src/controls/PageRow.qml src/controls/AbstractListItem.qml src/controls/Theme.qml src/controls/AbstractCard.qml src/controls/templates/AbstractCard.qml src/controls/Card.qml src/controls/CardsLayout.qml src/controls/CardsListView.qml src/controls/CardsGridView.qml src/controls/ActionToolBar.qml src/controls/templates/InlineMessage.qml src/controls/InlineMessage.qml src/controls/ToolBarApplicationHeader.qml src/controls/private/PrivateActionToolButton.qml src/controls/private/RefreshableScrollView.qml src/controls/private/SwipeItemEventFilter.qml src/controls/private/PageActionPropertyGroup.qml src/controls/private/ActionIconGroup.qml src/controls/private/CornerShadow.qml src/controls/private/ActionButton.qml src/controls/private/DefaultListItemBackground.qml src/controls/private/BannerImage.qml src/controls/private/EdgeShadow.qml src/controls/private/globaltoolbar/AbstractPageHeader.qml src/controls/private/globaltoolbar/PageRowGlobalToolBarStyleGroup.qml src/controls/private/globaltoolbar/PageRowGlobalToolBarUI.qml src/controls/private/PrivateActionToolButton.qml src/controls/private/globaltoolbar/TitlesPageHeader.qml src/controls/private/globaltoolbar/ToolBarPageHeader.qml src/controls/private/globaltoolbar/BreadcrumbControl.qml src/controls/private/globaltoolbar/TabBarControl.qml src/controls/private/ActionsMenu.qml src/controls/private/ActionMenuItemQt59.qml src/controls/private/ActionMenuItemBase.qml src/controls/Separator.qml src/controls/OverlayDrawer.qml src/controls/OverlaySheet.qml src/controls/GlobalDrawer.qml src/controls/templates/AbstractListItem.qml src/controls/templates/private/MenuIcon.qml src/controls/templates/private/GenericDrawerIcon.qml src/controls/templates/private/PassiveNotification.qml src/controls/templates/private/ContextIcon.qml src/controls/templates/private/ScrollView.qml src/controls/templates/private/BackButton.qml src/controls/templates/private/IconPropertiesGroup.qml src/controls/templates/private/ForwardButton.qml src/controls/templates/OverlayDrawer.qml src/controls/templates/OverlaySheet.qml src/controls/templates/SwipeListItem.qml src/controls/templates/ApplicationHeader.qml src/controls/templates/AbstractApplicationHeader.qml src/controls/Units.qml src/controls/SwipeListItem.qml src/controls/ApplicationWindow.qml src/controls/AbstractApplicationItem.qml src/controls/ApplicationItem.qml src/controls/ApplicationHeader.qml src/controls/Heading.qml src/controls/ScrollablePage.qml + src/controls/AboutPage.qml + src/controls/UrlButton.qml + src/controls/LinkButton.qml src/controls/Label.qml src/controls/BasicListItem.qml src/controls/AbstractApplicationHeader.qml src/controls/FormLayout.qml src/controls/ListItemDragHandle.qml src/styles/Material/AbstractListItem.qml src/styles/Material/Theme.qml src/styles/Material/SwipeListItem.qml src/styles/Material/Label.qml src/styles/org.kde.desktop/AbstractListItem.qml src/styles/org.kde.desktop/Theme.qml src/styles/org.kde.desktop/Units.qml src/styles/org.kde.desktop/SwipeListItem.qml src/styles/org.kde.desktop/ApplicationWindow.qml src/styles/org.kde.desktop/AbstractApplicationHeader.qml diff --git a/src/controls/AboutPage.qml b/src/controls/AboutPage.qml new file mode 100644 index 00000000..882638ca --- /dev/null +++ b/src/controls/AboutPage.qml @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2018 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library/Lesser General Public License + * version 2, or (at your option) any later version, as published by the + * Free Software Foundation + * + * 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 Library/Lesser 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.1 +import QtQuick.Controls 2.4 as QQC2 +import QtQuick.Layouts 1.3 +import org.kde.kirigami 2.5 + +/** + * An about page that is ready to integrate in a kirigami app + * + * Allows to have a page that will show the copyright notice of the application + * together with the contributors and some information of which platform it's + * running on. + * + * @since 5.52 + * @since org.kde.kirigami 2.6 + */ +ScrollablePage +{ + id: page + /** + * An object with the same shape of KAboutData + * + * For example: + * @code + * aboutData: { + "displayName" : "KirigamiApp", + "productName" : "kirigami/app", + "componentName" : "kirigamiapp", + "shortDescription" : "A Kirigami example", + "homepage" : "", + "bugAddress" : "submit@bugs.kde.org", + "version" : "5.14.80", + "otherText" : "", + "authors" : [ + { + "name" : "...", + "task" : "", + "emailAddress" : "somebody@kde.org", + "webAddress" : "", + "ocsUsername" : "" + } + ], + "credits" : [], + "translators" : [], + "licenses" : [ + { + "name" : "GPL v2", + "text" : "long, boring, license text", + "spdx" : "GPL-2.0" + } + ], + "copyrightStatement" : "© 2010-2018 Plasma Development Team", + "desktopFileName" : "org.kde.kirigamiapp" + } + @endcode + * + * @see KAboutData + */ + property var aboutData + + title: i18n("About") + Component { + id: licencePage + ScrollablePage { + property alias text: content.text + QQC2.TextArea { + id: content + readOnly: true + } + } + } + + Component { + id: personDelegate + AbstractCard { + Layout.fillWidth: true + contentItem: RowLayout { + Layout.preferredHeight: Units.iconSizes.medium + Icon { + Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter + Layout.minimumWidth: Units.iconSizes.medium + Layout.maximumWidth: Units.iconSizes.medium + source: "user" //TODO: use ocs once we don't need to depend on attica, was using gravatar but it didn't feel right + fallback: "user" + } + QQC2.Label { + Layout.fillWidth: true + text: i18n("%1 <%2>", modelData.name, modelData.emailAddress) + } + } + } + } + + ColumnLayout { + GridLayout { + columns: 2 + Layout.fillWidth: true + Layout.preferredHeight: Units.iconSizes.huge + + Icon { + Layout.rowSpan: 2 + Layout.fillHeight: true + Layout.minimumWidth: height + Layout.rightMargin: Units.largeSpacing + source: page.aboutData.programLogo || page.aboutData.programIconName + } + Heading { + Layout.fillWidth: true + text: page.aboutData.displayName + " " + page.aboutData.version + } + Heading { + Layout.fillWidth: true + level: 2 + text: page.aboutData.shortDescription + } + } + + Separator { + Layout.fillWidth: true + } + + Heading { + text: i18n("Copyright") + } + QQC2.Label { + Layout.leftMargin: Units.gridUnit + text: aboutData.otherText + visible: text.length > 0 + } + QQC2.Label { + Layout.leftMargin: Units.gridUnit + text: aboutData.copyrightStatement + visible: text.length > 0 + } + UrlButton { + Layout.leftMargin: Units.gridUnit + url: aboutData.homepage + visible: url.length > 0 + } + + Repeater { + model: aboutData.licenses + delegate: RowLayout { + Layout.leftMargin: Units.gridUnit + QQC2.Label { text: i18n("License:" ) } + LinkButton { + text: modelData.name + onClicked: applicationWindow().pageStack.push(licencePage, { text: modelData.text, title: modelData.name } ) + } + } + } + + Heading { + text: i18n("Libraries in use") + visible: Settings.information + } + Repeater { + model: Settings.information + delegate: QQC2.Label { + Layout.leftMargin: Units.gridUnit + id: libraries + text: modelData + } + } + Heading { + Layout.fillWidth: true + text: i18n("Authors") + } + + Repeater { + model: aboutData.authors + delegate: personDelegate + } + Heading { + text: i18n("Credits") + visible: repCredits.count > 0 + } + Repeater { + id: repCredits + model: aboutData.translators + delegate: personDelegate + } + Heading { + text: i18n("Translators") + visible: repTranslators.count > 0 + } + Repeater { + id: repTranslators + model: aboutData.translators + delegate: personDelegate + } + } +} diff --git a/src/controls/LinkButton.qml b/src/controls/LinkButton.qml new file mode 100644 index 00000000..4d739d0f --- /dev/null +++ b/src/controls/LinkButton.qml @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2018 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library/Lesser General Public License + * version 2, or (at your option) any later version, as published by the + * Free Software Foundation + * + * 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 Library/Lesser 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.2 +import org.kde.kirigami 2.0 +import QtQuick.Controls 2.1 as QQC2 + +/** + * Shows a Button that looks like a link + * + * Uses the link color settings and allows to trigger an action when clicked. + * + * Maps to the Command Link in the HIG: + * https://hig.kde.org/components/navigation/commandlink.html + * + * @since 5.52 + * @since org.kde.kirigami 2.6 + */ +QQC2.Label { + id: control + + property Action action: null + property alias acceptedButtons: area.acceptedButtons + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.onPressAction: control.clicked(null) + + text: action ? action.text : "" + enabled: !action || action.enabled + onClicked: if (action) action.trigger() + + font.underline: control.enabled && area.containsMouse + color: enabled ? Theme.linkColor : Theme.textColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + + signal pressed(QtObject mouse) + signal clicked(QtObject mouse) + MouseArea { + id: area + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + + onClicked: control.clicked(mouse) + onPressed: control.pressed(mouse) + } +} diff --git a/src/controls/UrlButton.qml b/src/controls/UrlButton.qml new file mode 100644 index 00000000..bd6f036e --- /dev/null +++ b/src/controls/UrlButton.qml @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2018 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library/Lesser General Public License + * version 2, or (at your option) any later version, as published by the + * Free Software Foundation + * + * 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 Library/Lesser 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.2 +import org.kde.kirigami 2.0 as Kirigami +import QtQuick.Controls 2.1 as QQC2 + +/** + * A link button that contains a URL + * + * It will open the url by default, allow to copy it if triggered with the + * secondary mouse button. + * + * @since 5.52 + * @since org.kde.kirigami 2.6 + */ +LinkButton +{ + id: button + property string url + text: url + visible: text.length > 0 + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onPressed: if (mouse.button === Qt.RightButton) { + menu.popup() + } + onClicked: if (mouse.button !== Qt.RightButton) { + Qt.openUrlExternally(url) + } + + QQC2.Menu { + id: menu + QQC2.MenuItem { + text: i18n("Copy link address") + onClicked: app.copyTextToClipboard(button.url) + } + } +} diff --git a/src/kirigamiplugin.cpp b/src/kirigamiplugin.cpp index 41f96408..94e8f594 100644 --- a/src/kirigamiplugin.cpp +++ b/src/kirigamiplugin.cpp @@ -1,181 +1,186 @@ /* * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis * Copyright 2010 by 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. */ #include "kirigamiplugin.h" #include "enums.h" #include "desktopicon.h" #include "settings.h" #include "formlayoutattached.h" #include "mnemonicattached.h" #include "delegaterecycler.h" #include "scenepositionattached.h" #include #include #include #include #include "libkirigami/platformtheme.h" static QString s_selectedStyle; //Q_INIT_RESOURCE(kirigami); #ifdef KIRIGAMI_BUILD_TYPE_STATIC #include #endif QUrl KirigamiPlugin::componentUrl(const QString &fileName) const { foreach (const QString &style, m_stylesFallbackChain) { const QString candidate = QStringLiteral("styles/") + style + QLatin1Char('/') + fileName; if (QFile::exists(resolveFilePath(candidate))) { #ifdef KIRIGAMI_BUILD_TYPE_STATIC return QUrl(QStringLiteral("qrc:/org/kde/kirigami/styles/") + style + QLatin1Char('/') + fileName); #else return QUrl(resolveFileUrl(candidate)); #endif } } #ifdef KIRIGAMI_BUILD_TYPE_STATIC return QUrl(QStringLiteral("qrc:/org/kde/kirigami/") + fileName); #else return QUrl(resolveFileUrl(fileName)); #endif } void KirigamiPlugin::registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.kirigami")); const QString style = QQuickStyle::name(); //FIXME: How to decide when to do this? (when we are on a platform that needs its own icon set shipped if (QIcon::themeName().isEmpty()) { QIcon::setThemeSearchPaths({resolveFilePath(QStringLiteral(".")), QStringLiteral(":/icons")}); QIcon::setThemeName(QStringLiteral("breeze-internal")); } #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) //org.kde.desktop.plasma is a couple of files that fall back to desktop by purpose if ((style.isEmpty() || style == QStringLiteral("org.kde.desktop.plasma")) && QFile::exists(resolveFilePath(QStringLiteral("/styles/org.kde.desktop")))) { m_stylesFallbackChain.prepend(QStringLiteral("org.kde.desktop")); } #elif defined(Q_OS_ANDROID) if (!m_stylesFallbackChain.contains(QStringLiteral("Material"))) { m_stylesFallbackChain.prepend(QStringLiteral("Material")); } #else // do we have an iOS specific style? if (!m_stylesFallbackChain.contains(QStringLiteral("Material"))) { m_stylesFallbackChain.prepend(QStringLiteral("Material")); } #endif if (!style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/") + style)) && !m_stylesFallbackChain.contains(style)) { m_stylesFallbackChain.prepend(style); //if we have plasma deps installed, use them for extra integration if (style == QStringLiteral("org.kde.desktop") && QFile::exists(resolveFilePath(QStringLiteral("/styles/org.kde.desktop.plasma")))) { m_stylesFallbackChain.prepend(QStringLiteral("org.kde.desktop.plasma")); } } else { #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) m_stylesFallbackChain.prepend(QStringLiteral("org.kde.desktop")); #endif } //At this point the fallback chain will be selected->org.kde.desktop->Fallback s_selectedStyle = m_stylesFallbackChain.first(); qmlRegisterSingletonType(uri, 2, 0, "Settings", [](QQmlEngine*, QJSEngine*) -> QObject* { Settings *settings = new Settings; settings->setStyle(s_selectedStyle); return settings; } ); qmlRegisterUncreatableType(uri, 2, 0, "ApplicationHeaderStyle", QStringLiteral("Cannot create objects of type ApplicationHeaderStyle")); //old legacy retrocompatible Theme qmlRegisterSingletonType(componentUrl(QStringLiteral("Theme.qml")), uri, 2, 0, "Theme"); qmlRegisterSingletonType(componentUrl(QStringLiteral("Units.qml")), uri, 2, 0, "Units"); qmlRegisterType(componentUrl(QStringLiteral("Action.qml")), uri, 2, 0, "Action"); qmlRegisterType(componentUrl(QStringLiteral("AbstractApplicationHeader.qml")), uri, 2, 0, "AbstractApplicationHeader"); qmlRegisterType(componentUrl(QStringLiteral("AbstractApplicationWindow.qml")), uri, 2, 0, "AbstractApplicationWindow"); qmlRegisterType(componentUrl(QStringLiteral("AbstractListItem.qml")), uri, 2, 0, "AbstractListItem"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationHeader.qml")), uri, 2, 0, "ApplicationHeader"); qmlRegisterType(componentUrl(QStringLiteral("ToolBarApplicationHeader.qml")), uri, 2, 0, "ToolBarApplicationHeader"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationWindow.qml")), uri, 2, 0, "ApplicationWindow"); qmlRegisterType(componentUrl(QStringLiteral("BasicListItem.qml")), uri, 2, 0, "BasicListItem"); qmlRegisterType(componentUrl(QStringLiteral("OverlayDrawer.qml")), uri, 2, 0, "OverlayDrawer"); qmlRegisterType(componentUrl(QStringLiteral("ContextDrawer.qml")), uri, 2, 0, "ContextDrawer"); qmlRegisterType(componentUrl(QStringLiteral("GlobalDrawer.qml")), uri, 2, 0, "GlobalDrawer"); qmlRegisterType(componentUrl(QStringLiteral("Heading.qml")), uri, 2, 0, "Heading"); qmlRegisterType(componentUrl(QStringLiteral("Separator.qml")), uri, 2, 0, "Separator"); qmlRegisterType(componentUrl(QStringLiteral("PageRow.qml")), uri, 2, 0, "PageRow"); qmlRegisterType(uri, 2, 0, "Icon"); qmlRegisterType(componentUrl(QStringLiteral("Label.qml")), uri, 2, 0, "Label"); //TODO: uncomment for 2.3 release //qmlRegisterTypeNotAvailable(uri, 2, 3, "Label", "Label type not supported anymore, use QtQuick.Controls.Label 2.0 instead"); qmlRegisterType(componentUrl(QStringLiteral("OverlaySheet.qml")), uri, 2, 0, "OverlaySheet"); qmlRegisterType(componentUrl(QStringLiteral("Page.qml")), uri, 2, 0, "Page"); qmlRegisterType(componentUrl(QStringLiteral("ScrollablePage.qml")), uri, 2, 0, "ScrollablePage"); qmlRegisterType(componentUrl(QStringLiteral("SplitDrawer.qml")), uri, 2, 0, "SplitDrawer"); qmlRegisterType(componentUrl(QStringLiteral("SwipeListItem.qml")), uri, 2, 0, "SwipeListItem"); //2.1 qmlRegisterType(componentUrl(QStringLiteral("AbstractItemViewHeader.qml")), uri, 2, 1, "AbstractItemViewHeader"); qmlRegisterType(componentUrl(QStringLiteral("ItemViewHeader.qml")), uri, 2, 1, "ItemViewHeader"); qmlRegisterType(componentUrl(QStringLiteral("AbstractApplicationItem.qml")), uri, 2, 1, "AbstractApplicationItem"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationItem.qml")), uri, 2, 1, "ApplicationItem"); //2.2 //Theme changed from a singleton to an attached property qmlRegisterUncreatableType(uri, 2, 2, "Theme", QStringLiteral("Cannot create objects of type Theme, use it as an attached property")); //2.3 qmlRegisterType(componentUrl(QStringLiteral("FormLayout.qml")), uri, 2, 3, "FormLayout"); qmlRegisterUncreatableType(uri, 2, 3, "FormData", QStringLiteral("Cannot create objects of type FormData, use it as an attached property")); qmlRegisterUncreatableType(uri, 2, 3, "MnemonicData", QStringLiteral("Cannot create objects of type MnemonicData, use it as an attached property")); //2.4 qmlRegisterType(componentUrl(QStringLiteral("AbstractCard.qml")), uri, 2, 4, "AbstractCard"); qmlRegisterType(componentUrl(QStringLiteral("Card.qml")), uri, 2, 4, "Card"); qmlRegisterType(componentUrl(QStringLiteral("CardsListView.qml")), uri, 2, 4, "CardsListView"); qmlRegisterType(componentUrl(QStringLiteral("CardsGridView.qml")), uri, 2, 4, "CardsGridView"); qmlRegisterType(componentUrl(QStringLiteral("CardsLayout.qml")), uri, 2, 4, "CardsLayout"); qmlRegisterType(componentUrl(QStringLiteral("InlineMessage.qml")), uri, 2, 4, "InlineMessage"); qmlRegisterUncreatableType(uri, 2, 4, "MessageType", QStringLiteral("Cannot create objects of type MessageType")); qmlRegisterType(uri, 2, 4, "DelegateRecycler"); //2.5 qmlRegisterType(componentUrl(QStringLiteral("ListItemDragHandle.qml")), uri, 2, 5, "ListItemDragHandle"); qmlRegisterType(componentUrl(QStringLiteral("ActionToolBar.qml")), uri, 2, 5, "ActionToolBar"); qmlRegisterUncreatableType(uri, 2, 5, "ScenePosition", QStringLiteral("Cannot create objects of type ScenePosition, use it as an attached property")); + //2.6 + qmlRegisterType(componentUrl(QStringLiteral("AboutPage.qml")), uri, 2, 6, "AboutPage"); + qmlRegisterType(componentUrl(QStringLiteral("LinkButton.qml")), uri, 2, 6, "LinkButton"); + qmlRegisterType(componentUrl(QStringLiteral("UrlButton.qml")), uri, 2, 6, "UrlButton"); + qmlProtectModule(uri, 2); } #include "moc_kirigamiplugin.cpp" diff --git a/src/qmldir b/src/qmldir index dbac7043..20438e46 100644 --- a/src/qmldir +++ b/src/qmldir @@ -1,45 +1,48 @@ module org.kde.kirigami classname KirigamiPlugin depends QtQuick.Controls 2.0 depends QtGraphicalEffects 1.0 designersupported typeinfo plugins.qmltypes singleton Theme 2.2 Theme.qml OverlaySheet 2.5 OverlaySheet.qml ApplicationItem 2.1 ApplicationItem.qml AbstractApplicationWindow 2.5 AbstractApplicationWindow.qml FormLayout 2.5 FormLayout.qml GlobalDrawer 2.5 GlobalDrawer.qml BasicListItem 2.5 BasicListItem.qml AbstractItemViewHeader 2.1 AbstractItemViewHeader.qml Heading 2.5 Heading.qml Action 2.5 Action.qml Separator 2.5 Separator.qml ItemViewHeader 2.1 ItemViewHeader.qml SwipeListItem 2.5 SwipeListItem.qml AbstractListItem 2.5 AbstractListItem.qml Icon 2.5 Icon.qml Units 2.5 Units.qml Page 2.5 Page.qml Label 2.5 Label.qml AbstractApplicationItem 2.1 AbstractApplicationItem.qml ToolBarApplicationHeader 2.5 ToolBarApplicationHeader.qml ScrollablePage 2.5 ScrollablePage.qml ApplicationHeader 2.5 ApplicationHeader.qml AbstractApplicationHeader 2.5 AbstractApplicationHeader.qml ContextDrawer 2.5 ContextDrawer.qml ApplicationWindow 2.5 ApplicationWindow.qml PageRow 2.5 PageRow.qml AbstractCard 2.5 AbstractCard.qml Card 2.5 Card.qml CardsLayout 2.5 CardsLayout.qml CardsListView 2.5 CardsListView.qml CardsGridView 2.5 CardsGridView.qml InlineMessage 2.5 InlineMessage.qml ListItemDragHandle 2.5 ListItemDragHandle.qml ActionToolBar 2.5 ActionToolBar.qml BannerImage 2.5 private/BannerImage.qml +AboutPage 2.6 AboutPage.qml +UrlButton 2.6 UrlButton.qml +LinkButton 2.6 LinkButton.qml diff --git a/src/settings.cpp b/src/settings.cpp index a6cf19d4..eaba50b0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,133 +1,141 @@ /* * Copyright 2016 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 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. */ #include "settings.h" #include #include #include #include +#include #include "libkirigami/tabletmodewatcher.h" +#include "../kirigami_version.h" Settings::Settings(QObject *parent) : QObject(parent) { m_tabletModeAvailable = Kirigami::TabletModeWatcher::self()->isTabletModeAvailable(); connect(Kirigami::TabletModeWatcher::self(), &Kirigami::TabletModeWatcher::tabletModeAvailableChanged, this, [this](bool tabletModeAvailable) { setTabletModeAvailable(tabletModeAvailable); }); m_tabletMode = Kirigami::TabletModeWatcher::self()->isTabletMode(); connect(Kirigami::TabletModeWatcher::self(), &Kirigami::TabletModeWatcher::tabletModeChanged, this, [this](bool tabletMode) { setTabletMode(tabletMode); }); #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) m_mobile = true; #else //Mostly for debug purposes and for platforms which are always mobile, //such as Plasma Mobile if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE")) { m_mobile = (QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("1") || QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE")) == QStringLiteral("true")); } else { m_mobile = false; } #endif const QString configPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, QStringLiteral("kdeglobals")); if (QFile::exists(configPath)) { QSettings globals(configPath, QSettings::IniFormat); globals.beginGroup(QStringLiteral("KDE")); m_scrollLines = qMax(1, globals.value(QStringLiteral("WheelScrollLines"), 3).toInt()); } else { m_scrollLines = 3; } } Settings::~Settings() { } void Settings::setTabletModeAvailable(bool mobileAvailable) { if (mobileAvailable == m_tabletModeAvailable) { return; } m_tabletModeAvailable = mobileAvailable; emit tabletModeAvailableChanged(); } bool Settings::isTabletModeAvailable() const { return m_tabletModeAvailable; } void Settings::setIsMobile(bool mobile) { if (mobile == m_mobile) { return; } m_mobile = mobile; emit isMobileChanged(); } bool Settings::isMobile() const { return m_mobile; } void Settings::setTabletMode(bool tablet) { if (tablet == m_tabletMode) { return; } m_tabletMode = tablet; emit tabletModeChanged(); } bool Settings::tabletMode() const { return m_tabletMode; } QString Settings::style() const { return m_style; } void Settings::setStyle(const QString &style) { m_style = style; } int Settings::mouseWheelScrollLines() const { return m_scrollLines; } -#include "moc_settings.cpp" - +QStringList Settings::information() const +{ + return { + tr("KDE Frameworks %1").arg(QStringLiteral(KIRIGAMI2_VERSION_STRING)), + tr("The %1 windowing system").arg(QGuiApplication::platformName()), + tr("Qt %2 (built against %3)").arg(QString::fromLocal8Bit(qVersion()), QStringLiteral(QT_VERSION_STR)) + }; +} diff --git a/src/settings.h b/src/settings.h index b918d1d9..f38b194f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,97 +1,107 @@ /* * Copyright 2016 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 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. */ #ifndef SETTINGS_H #define SETTINGS_H #include /** * This class contains global kirigami settings about the current device setup * It is exposed to QML as the singleton "Settings" */ class Settings : public QObject { Q_OBJECT /** * True if the system can dynamically enter in tablet mode * (or the device is actually a tablet). * such as transformable laptops that support keyboard detachment */ Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged) /** * True if we are running on a small mobile device such as a mobile phone * This is used when we want to do specific adaptations to our UI for * small screen form factors, such as having bigger touch areas. */ Q_PROPERTY(bool isMobile READ isMobile NOTIFY isMobileChanged) /** * True if the device we are running on is behaving like a tablet: * Note that this doesn't mean exactly a tablet form factor, but * that the preferred input mode for the device is the touch screen * and that pointer and keyboard are either secondary or not available. */ Q_PROPERTY(bool tabletMode READ tabletMode NOTIFY tabletModeChanged) /** * name of the QtQuickControls2 style we are using, * for instance org.kde.desktop, Plasma, Material, Universal etc */ Q_PROPERTY(QString style READ style CONSTANT) //TODO: make this adapt without file watchers? /** * How many lines of text the mouse wheel should scroll */ Q_PROPERTY(int mouseWheelScrollLines READ mouseWheelScrollLines CONSTANT) + /** + * @returns runtime information about the libraries in use + * + * @since 5.52 + * @since org.kde.kirigami 2.6 + */ + Q_PROPERTY(QStringList information READ information CONSTANT) + public: Settings(QObject *parent = nullptr); ~Settings(); void setTabletModeAvailable(bool mobile); bool isTabletModeAvailable() const; void setIsMobile(bool mobile); bool isMobile() const; void setTabletMode(bool tablet); bool tabletMode() const; QString style() const; void setStyle(const QString &style); int mouseWheelScrollLines() const; + QStringList information() const; + Q_SIGNALS: void tabletModeAvailableChanged(); void tabletModeChanged(); void isMobileChanged(); private: QString m_style; int m_scrollLines = 0; bool m_tabletModeAvailable : 1; bool m_mobile : 1; bool m_tabletMode : 1; }; #endif