diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,16 +40,22 @@ # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) +include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(ECMPoQmTools) include(KDEInstallDirs) include(KDECMakeSettings) +include(ECMQtDeclareLoggingCategory) +include(ECMAddQch) include(KDECompilerSettings NO_POLICY_SCOPE) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Kirigami2") +option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) +add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") + configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5Kirigami2Config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2Config.cmake" @@ -65,9 +71,14 @@ COMPONENT Devel ) +install(EXPORT KF5Kirigami2Targets + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + FILE KF5Kirigami2Targets.cmake + NAMESPACE KF5::) + ecm_setup_version(${KF5_VERSION} - VARIABLE_PREFIX KIRIGAMI + VARIABLE_PREFIX KIRIGAMI2 VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kirigami_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2ConfigVersion.cmake" SOVERSION 5) diff --git a/KF5Kirigami2Config.cmake.in b/KF5Kirigami2Config.cmake.in --- a/KF5Kirigami2Config.cmake.in +++ b/KF5Kirigami2Config.cmake.in @@ -1,11 +1,15 @@ @PACKAGE_INIT@ +include(CMakeFindDependencyMacro) +find_dependency(Qt5Core @REQUIRED_QT_VERSION@) + # Any changes in this ".cmake" file will be overwritten by CMake, the source is the ".cmake.in" file. -#include("${CMAKE_CURRENT_LIST_DIR}/KF5KirigamiTargets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/KF5Kirigami2Targets.cmake") -set(Kirigami_INSTALL_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@") +set(Kirigami2_INSTALL_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@") -#set(Kirigami_LIBRARIES KF5::Kirigami) +#set(Kirigami2_LIBRARIES KF5::Kirigami2) include("${CMAKE_CURRENT_LIST_DIR}/KF5Kirigami2Macros.cmake") +@PACKAGE_INCLUDE_QCHTARGETS@ diff --git a/KF5Kirigami2Macros.cmake b/KF5Kirigami2Macros.cmake --- a/KF5Kirigami2Macros.cmake +++ b/KF5Kirigami2Macros.cmake @@ -28,6 +28,9 @@ endif() endif() if (NOT EXISTS ${path}) + file(GLOB_RECURSE path ${_BREEZEICONS_DIR}/icons/*/symbolic/${icon}.svg ) + endif() + if (NOT EXISTS ${path}) return() endif() diff --git a/autotests/tst_keynavigation.qml b/autotests/tst_keynavigation.qml --- a/autotests/tst_keynavigation.qml +++ b/autotests/tst_keynavigation.qml @@ -20,7 +20,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Window 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import QtTest 1.0 import "../tests" diff --git a/autotests/tst_listskeynavigation.qml b/autotests/tst_listskeynavigation.qml --- a/autotests/tst_listskeynavigation.qml +++ b/autotests/tst_listskeynavigation.qml @@ -21,7 +21,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Window 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import QtTest 1.0 import "../tests" diff --git a/autotests/tst_pagerow.qml b/autotests/tst_pagerow.qml --- a/autotests/tst_pagerow.qml +++ b/autotests/tst_pagerow.qml @@ -20,7 +20,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Window 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import QtTest 1.0 TestCase { diff --git a/examples/applicationitemapp/main.qml b/examples/applicationitemapp/main.qml --- a/examples/applicationitemapp/main.qml +++ b/examples/applicationitemapp/main.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationItem { id: root diff --git a/examples/galleryapp/CMakeLists.txt b/examples/galleryapp/CMakeLists.txt --- a/examples/galleryapp/CMakeLists.txt +++ b/examples/galleryapp/CMakeLists.txt @@ -15,4 +15,4 @@ install(TARGETS kirigami2gallery ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) include(${CMAKE_SOURCE_DIR}/KF5Kirigami2Macros.cmake) -kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-cancel document-decrypt mail-reply-sender bookmarks folder) +kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-cancel document-decrypt mail-reply-sender bookmarks folder media-record-symbolic) diff --git a/examples/galleryapp/resources.qrc b/examples/galleryapp/resources.qrc --- a/examples/galleryapp/resources.qrc +++ b/examples/galleryapp/resources.qrc @@ -19,6 +19,7 @@ ../gallerydata/contents/ui/gallery/MetricsGallery.qml ../gallerydata/contents/ui/gallery/LayersGallery.qml ../gallerydata/contents/ui/ExampleApp.qml + ../gallerydata/contents/ui/gallery/ColorSetGallery.qml ../gallerydata/contents/ui/DesktopExampleApp.qml ../gallerydata/metadata.desktop qtquickcontrols2.conf diff --git a/examples/gallerydata/contents/ui/DesktopExampleApp.qml b/examples/gallerydata/contents/ui/DesktopExampleApp.qml --- a/examples/gallerydata/contents/ui/DesktopExampleApp.qml +++ b/examples/gallerydata/contents/ui/DesktopExampleApp.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import "gallery" Kirigami.ApplicationWindow { diff --git a/examples/gallerydata/contents/ui/ExampleApp.qml b/examples/gallerydata/contents/ui/ExampleApp.qml --- a/examples/gallerydata/contents/ui/ExampleApp.qml +++ b/examples/gallerydata/contents/ui/ExampleApp.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import "gallery" Kirigami.ApplicationWindow { diff --git a/examples/gallerydata/contents/ui/MainPage.qml b/examples/gallerydata/contents/ui/MainPage.qml --- a/examples/gallerydata/contents/ui/MainPage.qml +++ b/examples/gallerydata/contents/ui/MainPage.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as QQC2 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ScrollablePage { id: pageRoot @@ -123,6 +123,10 @@ component: "Colors" } ListElement { + text: "Color Sets" + component: "ColorSet" + } + ListElement { text: "Metrics" component: "Metrics" } diff --git a/examples/gallerydata/contents/ui/gallery/ButtonGallery.qml b/examples/gallerydata/contents/ui/gallery/ButtonGallery.qml --- a/examples/gallerydata/contents/ui/gallery/ButtonGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/ButtonGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/CheckBoxGallery.qml b/examples/gallerydata/contents/ui/gallery/CheckBoxGallery.qml --- a/examples/gallerydata/contents/ui/gallery/CheckBoxGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/CheckBoxGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/ColorSetGallery.qml b/examples/gallerydata/contents/ui/gallery/ColorSetGallery.qml new file mode 100644 --- /dev/null +++ b/examples/gallerydata/contents/ui/gallery/ColorSetGallery.qml @@ -0,0 +1,174 @@ +/* + * 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. + */ + +import QtQuick 2.0 +import QtQuick.Controls 2.0 as Controls +import QtQuick.Layouts 1.2 +import org.kde.kirigami 2.2 as Kirigami + +Kirigami.ScrollablePage { + id: page + title: "Color Sets" + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + ColumnLayout { + GridLayout { + columns: 2 + Kirigami.Label { + text: "Global Drawer color set:" + Layout.alignment: Qt.AlignRight + } + Controls.ComboBox { + Kirigami.Theme.inherit: true + currentIndex: 1 + model: ["Window", "View", "Complementary"] + onCurrentTextChanged: applicationWindow().globalDrawer.Kirigami.Theme.colorSet = currentText + } + + Kirigami.Label { + text: "Page color set:" + Layout.alignment: Qt.AlignRight + } + Controls.ComboBox { + Kirigami.Theme.inherit: true + currentIndex: 0 + model: ["Window", "View", "Complementary"] + onCurrentTextChanged: page.Kirigami.Theme.colorSet = currentText + } + } + + Controls.Frame { + Kirigami.Theme.inherit: true + Layout.minimumHeight: childrenRect.height + Layout.fillWidth: true + height: childrenRect.height + width: parent.width + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + contentItem: ColumnLayout { + width: parent.width + Kirigami.Label { + text: "Set inherited from parent Item" + } + Kirigami.BasicListItem { + width: parent.width + icon: "media-record-symbolic" + label: "Delegate1" + } + Kirigami.BasicListItem { + width: parent.width + label: "Delegate2" + } + } + } + + Controls.Frame { + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Window + Layout.minimumHeight: childrenRect.height + Layout.fillWidth: true + height: childrenRect.height + width: parent.width + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + contentItem: ColumnLayout { + width: parent.width + Kirigami.Label { + text: "Window Set" + } + Kirigami.BasicListItem { + width: parent.width + icon: "media-record-symbolic" + label: "Delegate1" + } + Kirigami.BasicListItem { + width: parent.width + label: "Delegate2" + } + } + } + + Controls.Frame { + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.View + Layout.minimumHeight: childrenRect.height + Layout.fillWidth: true + height: childrenRect.height + width: parent.width + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + contentItem: ColumnLayout { + width: parent.width + Kirigami.Label { + text: "View Set" + } + Kirigami.BasicListItem { + width: parent.width + icon: "media-record-symbolic" + label: "Delegate1" + } + Kirigami.BasicListItem { + width: parent.width + label: "Delegate2" + } + } + } + + Controls.Frame { + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary + Layout.minimumHeight: childrenRect.height + Layout.fillWidth: true + height: childrenRect.height + width: parent.width + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + contentItem: ColumnLayout { + Kirigami.Label { + text: "Complementary Set" + } + Kirigami.BasicListItem { + width: parent.width + icon: "media-record-symbolic" + label: "Delegate1" + } + Kirigami.BasicListItem { + width: parent.width + label: "Delegate2" + } + } + } + + Controls.Button { + Kirigami.Theme.colorSet: Kirigami.Theme.Button + Kirigami.Theme.inherit: false + text: "Fixed Color Button" + } + Controls.Button { + Kirigami.Theme.inherit: true + text: "Dynamic Color Button" + } + } +} diff --git a/examples/gallerydata/contents/ui/gallery/ColorsGallery.qml b/examples/gallerydata/contents/ui/gallery/ColorsGallery.qml --- a/examples/gallerydata/contents/ui/gallery/ColorsGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/ColorsGallery.qml @@ -19,9 +19,10 @@ import QtQuick 2.0 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { + id: page title: "Colors" // leftPadding: 20//Units.gridUnit @@ -31,9 +32,10 @@ } function getkeys() { var keys = []; - for(var v in Theme) { - if (endsWith(v, "Color")) - keys.push(v); + + for(var v in page.Theme.keys) { + if (endsWith(page.Theme.keys[v], "Color")) + keys.push(page.Theme.keys[v]); } keys.sort(); return keys; diff --git a/examples/gallerydata/contents/ui/gallery/LayersGallery.qml b/examples/gallerydata/contents/ui/gallery/LayersGallery.qml --- a/examples/gallerydata/contents/ui/gallery/LayersGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/LayersGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/ListViewGallery.qml b/examples/gallerydata/contents/ui/gallery/ListViewGallery.qml --- a/examples/gallerydata/contents/ui/gallery/ListViewGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/ListViewGallery.qml @@ -19,7 +19,7 @@ import QtQuick 2.4 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/ListViewHeaderItemsGallery.qml b/examples/gallerydata/contents/ui/gallery/ListViewHeaderItemsGallery.qml --- a/examples/gallerydata/contents/ui/gallery/ListViewHeaderItemsGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/ListViewHeaderItemsGallery.qml @@ -19,7 +19,7 @@ import QtQuick 2.4 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/MetricsGallery.qml b/examples/gallerydata/contents/ui/gallery/MetricsGallery.qml --- a/examples/gallerydata/contents/ui/gallery/MetricsGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/MetricsGallery.qml @@ -21,7 +21,7 @@ import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 as QQC2 import QtQuick.Window 2.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/MiscGallery.qml b/examples/gallerydata/contents/ui/gallery/MiscGallery.qml --- a/examples/gallerydata/contents/ui/gallery/MiscGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/MiscGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/MultipleColumnsGallery.qml b/examples/gallerydata/contents/ui/gallery/MultipleColumnsGallery.qml --- a/examples/gallerydata/contents/ui/gallery/MultipleColumnsGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/MultipleColumnsGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/NonScrollableGallery.qml b/examples/gallerydata/contents/ui/gallery/NonScrollableGallery.qml --- a/examples/gallerydata/contents/ui/gallery/NonScrollableGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/NonScrollableGallery.qml @@ -19,7 +19,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Page { id: page diff --git a/examples/gallerydata/contents/ui/gallery/ProgressBarGallery.qml b/examples/gallerydata/contents/ui/gallery/ProgressBarGallery.qml --- a/examples/gallerydata/contents/ui/gallery/ProgressBarGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/ProgressBarGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/RadioButtonGallery.qml b/examples/gallerydata/contents/ui/gallery/RadioButtonGallery.qml --- a/examples/gallerydata/contents/ui/gallery/RadioButtonGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/RadioButtonGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/SliderGallery.qml b/examples/gallerydata/contents/ui/gallery/SliderGallery.qml --- a/examples/gallerydata/contents/ui/gallery/SliderGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/SliderGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page @@ -93,6 +93,7 @@ text: slider2.position.toFixed(1) } } + Controls.RangeSlider {} Label { text: "Vertical:" } diff --git a/examples/gallerydata/contents/ui/gallery/SwitchGallery.qml b/examples/gallerydata/contents/ui/gallery/SwitchGallery.qml --- a/examples/gallerydata/contents/ui/gallery/SwitchGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/SwitchGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/gallerydata/contents/ui/gallery/TabBarGallery.qml b/examples/gallerydata/contents/ui/gallery/TabBarGallery.qml --- a/examples/gallerydata/contents/ui/gallery/TabBarGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/TabBarGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Page { id: page diff --git a/examples/gallerydata/contents/ui/gallery/TextFieldGallery.qml b/examples/gallerydata/contents/ui/gallery/TextFieldGallery.qml --- a/examples/gallerydata/contents/ui/gallery/TextFieldGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/TextFieldGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/minimalqmake/Page1Form.ui.qml b/examples/minimalqmake/Page1Form.ui.qml --- a/examples/minimalqmake/Page1Form.ui.qml +++ b/examples/minimalqmake/Page1Form.ui.qml @@ -20,7 +20,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.Page { title: qsTr("Page 1") diff --git a/examples/minimalqmake/kirigami-icons.qrc b/examples/minimalqmake/kirigami-icons.qrc --- a/examples/minimalqmake/kirigami-icons.qrc +++ b/examples/minimalqmake/kirigami-icons.qrc @@ -10,5 +10,6 @@ 3rdparty/breeze-icons/icons/actions/22/handle-right.svg 3rdparty/breeze-icons/icons/actions/32/view-list-icons.svg 3rdparty/breeze-icons/icons/categories/32/applications-graphics.svg + 3rdparty/breeze-icons/icons/categories/22/media-record-symbolic.svg diff --git a/examples/minimalqmake/main.qml b/examples/minimalqmake/main.qml --- a/examples/minimalqmake/main.qml +++ b/examples/minimalqmake/main.qml @@ -21,7 +21,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { visible: true diff --git a/examples/simpleexamples/AbstractApplicationWindow.qml b/examples/simpleexamples/AbstractApplicationWindow.qml --- a/examples/simpleexamples/AbstractApplicationWindow.qml +++ b/examples/simpleexamples/AbstractApplicationWindow.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.AbstractApplicationWindow { id: root diff --git a/examples/simpleexamples/FixedSidebar.qml b/examples/simpleexamples/FixedSidebar.qml --- a/examples/simpleexamples/FixedSidebar.qml +++ b/examples/simpleexamples/FixedSidebar.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/MultipleColumnsGallery.qml b/examples/simpleexamples/MultipleColumnsGallery.qml --- a/examples/simpleexamples/MultipleColumnsGallery.qml +++ b/examples/simpleexamples/MultipleColumnsGallery.qml @@ -20,7 +20,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 ScrollablePage { id: page diff --git a/examples/simpleexamples/SplitDrawer.qml b/examples/simpleexamples/SplitDrawer.qml --- a/examples/simpleexamples/SplitDrawer.qml +++ b/examples/simpleexamples/SplitDrawer.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/TabBarHeader.qml b/examples/simpleexamples/TabBarHeader.qml --- a/examples/simpleexamples/TabBarHeader.qml +++ b/examples/simpleexamples/TabBarHeader.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/customdrawer.qml b/examples/simpleexamples/customdrawer.qml --- a/examples/simpleexamples/customdrawer.qml +++ b/examples/simpleexamples/customdrawer.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/minimal.qml b/examples/simpleexamples/minimal.qml --- a/examples/simpleexamples/minimal.qml +++ b/examples/simpleexamples/minimal.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/pushpopclear.qml b/examples/simpleexamples/pushpopclear.qml --- a/examples/simpleexamples/pushpopclear.qml +++ b/examples/simpleexamples/pushpopclear.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/examples/simpleexamples/simpleChatApp.qml b/examples/simpleexamples/simpleChatApp.qml --- a/examples/simpleexamples/simpleChatApp.qml +++ b/examples/simpleexamples/simpleChatApp.qml @@ -20,7 +20,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as QQC2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { id: root diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,8 @@ ecm_create_qm_loader(kirigami_QM_LOADER libkirigami2plugin_qt) endif() +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libkirigami ${CMAKE_CURRENT_BINARY_DIR}/libkirigami) + set(kirigami_SRCS kirigamiplugin.cpp enums.cpp @@ -21,9 +23,11 @@ ELSE(STATIC_LIBRARY) +add_subdirectory(libkirigami) add_library(kirigamiplugin SHARED ${kirigami_SRCS}) + set_target_properties(kirigamiplugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/org/kde/kirigami.2) -target_link_libraries(kirigamiplugin Qt5::Core Qt5::Qml Qt5::Quick) +target_link_libraries(kirigamiplugin KF5::Kirigami2 Qt5::Core Qt5::Qml Qt5::Quick) add_custom_target(copy) diff --git a/src/controls/AbstractApplicationHeader.qml b/src/controls/AbstractApplicationHeader.qml --- a/src/controls/AbstractApplicationHeader.qml +++ b/src/controls/AbstractApplicationHeader.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" import "templates" as T diff --git a/src/controls/AbstractApplicationItem.qml b/src/controls/AbstractApplicationItem.qml --- a/src/controls/AbstractApplicationItem.qml +++ b/src/controls/AbstractApplicationItem.qml @@ -21,7 +21,7 @@ import QtQuick.Templates 2.0 as T2 import QtQuick.Window 2.2 import "templates/private" -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtGraphicalEffects 1.0 /** @@ -39,7 +39,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationItem { * [...] @@ -225,7 +225,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationItem { * [...] @@ -237,7 +237,7 @@ * @endcode * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.Page { * [...] diff --git a/src/controls/AbstractApplicationWindow.qml b/src/controls/AbstractApplicationWindow.qml --- a/src/controls/AbstractApplicationWindow.qml +++ b/src/controls/AbstractApplicationWindow.qml @@ -20,7 +20,7 @@ import QtQuick 2.5 import QtQuick.Controls 2.0 as QQC2 import "templates/private" -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtGraphicalEffects 1.0 /** @@ -38,7 +38,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -177,7 +177,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -189,7 +189,7 @@ * @endcode * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.Page { * [...] diff --git a/src/controls/AbstractItemViewHeader.qml b/src/controls/AbstractItemViewHeader.qml --- a/src/controls/AbstractItemViewHeader.qml +++ b/src/controls/AbstractItemViewHeader.qml @@ -19,7 +19,7 @@ import QtQuick 2.5 import QtQuick.Templates 2.0 as T2 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami /** * An item that can be used as an header for a ListView. diff --git a/src/controls/ApplicationItem.qml b/src/controls/ApplicationItem.qml --- a/src/controls/ApplicationItem.qml +++ b/src/controls/ApplicationItem.qml @@ -19,7 +19,7 @@ import QtQuick 2.5 import "templates/private" -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import QtGraphicalEffects 1.0 /** @@ -36,7 +36,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationItem { * [...] diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -19,7 +19,7 @@ import QtQuick 2.5 import "templates/private" -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import QtGraphicalEffects 1.0 /** @@ -34,7 +34,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] diff --git a/src/controls/BasicListItem.qml b/src/controls/BasicListItem.qml --- a/src/controls/BasicListItem.qml +++ b/src/controls/BasicListItem.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** * An item delegate for the primitive ListView component. diff --git a/src/controls/ContextDrawer.qml b/src/controls/ContextDrawer.qml --- a/src/controls/ContextDrawer.qml +++ b/src/controls/ContextDrawer.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "templates/private" @@ -29,7 +29,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -41,7 +41,7 @@ * @endcode * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.Page { * [...] @@ -96,6 +96,8 @@ handleVisible: applicationWindow == undefined ? false : applicationWindow().controlsVisible contentItem: ScrollView { + //this just to create the attached property + Theme.inherit: true implicitWidth: Units.gridUnit * 20 ListView { id: menu diff --git a/src/controls/GlobalDrawer.qml b/src/controls/GlobalDrawer.qml --- a/src/controls/GlobalDrawer.qml +++ b/src/controls/GlobalDrawer.qml @@ -21,7 +21,7 @@ import QtQuick.Templates 2.0 as T2 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" import "templates/private" @@ -33,7 +33,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -95,7 +95,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -134,7 +134,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -158,7 +158,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -209,6 +209,8 @@ contentItem: ScrollView { id: scrollView + //ensure the attached property exists + Theme.inherit: true anchors.fill: parent implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8) horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff @@ -288,6 +290,7 @@ Layout.minimumWidth: Units.iconSizes.large Layout.minimumHeight: width visible: valid + isMask: false //TODO: find a better way to control selective coloring on Android enabled: !Settings.isMobile } @@ -409,6 +412,7 @@ enabled: model ? model.enabled : modelData.enabled opacity: enabled ? 1.0 : 0.3 Icon { + isMask: true anchors { verticalCenter: contentItem.verticalCenter right: contentItem.right diff --git a/src/controls/Heading.qml b/src/controls/Heading.qml --- a/src/controls/Heading.qml +++ b/src/controls/Heading.qml @@ -19,7 +19,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.0 as QQC2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** * A heading label used for subsections of texts. @@ -31,7 +31,7 @@ * Example usage: * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * [...] * Column { * Kirigami.Heading { diff --git a/src/controls/Icon.qml b/src/controls/Icon.qml --- a/src/controls/Icon.qml +++ b/src/controls/Icon.qml @@ -19,7 +19,7 @@ import QtQuick 2.0 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** * Graphical representatrion of an Icon @@ -58,6 +58,13 @@ */ property bool selected: false + /** + * isMask: bool + * true if the icon should be treated as a monochrome icon which can be tinted + * @since 2.2 + */ + property bool isMask: true + implicitWidth: image.source != "" ? Units.iconSizes.smallMedium : 0 implicitHeight: image.source != "" ? Units.iconSizes.smallMedium : 0 @@ -75,6 +82,6 @@ source: image color: root.selected ? Theme.highlightedTextColor : Theme.textColor cached: true - visible: root.enabled && root.valid + visible: root.enabled && root.valid && root.isMask } } diff --git a/src/controls/ItemViewHeader.qml b/src/controls/ItemViewHeader.qml --- a/src/controls/ItemViewHeader.qml +++ b/src/controls/ItemViewHeader.qml @@ -20,7 +20,7 @@ import QtQuick 2.5 import QtQuick.Templates 2.0 as T2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.1 as Kirigami +import org.kde.kirigami 2.2 as Kirigami import "private" /** diff --git a/src/controls/Label.qml b/src/controls/Label.qml --- a/src/controls/Label.qml +++ b/src/controls/Label.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Window 2.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtQuick.Templates 2.0 as T2 /** diff --git a/src/controls/OverlayDrawer.qml b/src/controls/OverlayDrawer.qml --- a/src/controls/OverlayDrawer.qml +++ b/src/controls/OverlayDrawer.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtGraphicalEffects 1.0 import QtQuick.Templates 2.0 as T2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" import "templates" as T @@ -37,7 +37,7 @@ //BEGIN Properties background: Rectangle { - color: Theme.viewBackgroundColor + color: Theme.backgroundColor Item { parent: root.handle diff --git a/src/controls/OverlaySheet.qml b/src/controls/OverlaySheet.qml --- a/src/controls/OverlaySheet.qml +++ b/src/controls/OverlaySheet.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" import "templates" as T diff --git a/src/controls/Page.qml b/src/controls/Page.qml --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 as Kirigami import "private" import QtQuick.Templates 2.0 as T2 @@ -37,25 +37,25 @@ * leftPadding: int * default contents padding at left */ - leftPadding: Units.gridUnit + leftPadding: Kirigami.Units.gridUnit /** * topPadding: int * default contents padding at top */ - topPadding: Units.gridUnit + topPadding: Kirigami.Units.gridUnit /** * rightPadding: int * default contents padding at right */ - rightPadding: Units.gridUnit + rightPadding: Kirigami.Units.gridUnit /** * bottomPadding: int * default contents padding at bottom */ - bottomPadding: Units.gridUnit + bottomPadding: Kirigami.Units.gridUnit /** * flickable: Flickable @@ -75,7 +75,7 @@ * * Example usage: * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.ApplicationWindow { * [...] @@ -87,7 +87,7 @@ * @endcode * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * * Kirigami.Page { * [...] @@ -122,7 +122,7 @@ * Example usage: * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * Kirigami.Page { * actions.main: Kirigami.Action { * iconName: "edit" @@ -144,7 +144,7 @@ * Example usage: * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * Kirigami.Page { * actions.left: Kirigami.Action { * iconName: "edit" @@ -166,7 +166,7 @@ * Example usage: * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * Kirigami.Page { * actions.right: Kirigami.Action { * iconName: "edit" @@ -184,7 +184,7 @@ * Actions properties are grouped. * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * Kirigami.Page { * actions { * main: Kirigami.Action {...} @@ -228,7 +228,7 @@ anchors.topMargin: (applicationWindow() && !applicationWindow().wideScreen && Settings.isMobile && applicationWindow().controlsVisible && applicationWindow().header ? applicationWindow().header.preferredHeight : 0) //NOTE: This exists just because control instances require it - contentItem: Item { + contentItem: Item { onChildrenChanged: { //NOTE: make sure OverlaySheets are directly under the root //so they are over all the contents and don't have margins diff --git a/src/controls/PageRow.qml b/src/controls/PageRow.qml --- a/src/controls/PageRow.qml +++ b/src/controls/PageRow.qml @@ -22,7 +22,7 @@ import QtQml.Models 2.2 import QtQuick.Templates 2.0 as T import QtQuick.Controls 2.0 as QQC2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** * PageRow implements a row-based navigation model, which can be used diff --git a/src/controls/ScrollablePage.qml b/src/controls/ScrollablePage.qml --- a/src/controls/ScrollablePage.qml +++ b/src/controls/ScrollablePage.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" /** @@ -101,6 +101,8 @@ */ property bool keyboardNavigationEnabled: true + Theme.colorSet: flickable && flickable.hasOwnProperty("model") ? Theme.View : Theme.Window + RefreshableScrollView { id: scrollView z: 0 @@ -116,6 +118,7 @@ bottomMargin: root.footer ? root.footer.height : 0 } } + anchors.topMargin: 0 diff --git a/src/controls/Separator.qml b/src/controls/Separator.qml --- a/src/controls/Separator.qml +++ b/src/controls/Separator.qml @@ -19,7 +19,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** * A visual separator @@ -32,5 +32,5 @@ Rectangle { height: Units.devicePixelRatio width: Units.devicePixelRatio - color: Qt.tint(Theme.textColor, Qt.rgba(Theme.viewBackgroundColor.r, Theme.viewBackgroundColor.g, Theme.viewBackgroundColor.b, 0.7)) + color: Qt.tint(Theme.textColor, Qt.rgba(Theme.backgroundColor.r, Theme.backgroundColor.g, Theme.backgroundColor.b, 0.7)) } diff --git a/src/controls/Theme.qml b/src/controls/Theme.qml --- a/src/controls/Theme.qml +++ b/src/controls/Theme.qml @@ -19,7 +19,7 @@ import QtQuick 2.4 -pragma Singleton +//pragma Singleton /** * A set of named colors for the application diff --git a/src/controls/ToolBarApplicationHeader.qml b/src/controls/ToolBarApplicationHeader.qml --- a/src/controls/ToolBarApplicationHeader.qml +++ b/src/controls/ToolBarApplicationHeader.qml @@ -21,7 +21,7 @@ import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.2 import "private" -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** diff --git a/src/controls/Units.qml b/src/controls/Units.qml --- a/src/controls/Units.qml +++ b/src/controls/Units.qml @@ -19,7 +19,7 @@ import QtQuick 2.4 import QtQuick.Window 2.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 pragma Singleton diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -1386,7 +1386,6 @@ exportMetaObjectRevisions: [0] isComposite: true isCreatable: false - isSingleton: true Property { name: "textColor"; type: "QColor" } Property { name: "disabledTextColor"; type: "QColor" } Property { name: "highlightColor"; type: "QColor" } diff --git a/src/controls/private/ActionButton.qml b/src/controls/private/ActionButton.qml --- a/src/controls/private/ActionButton.qml +++ b/src/controls/private/ActionButton.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../templates/private" diff --git a/src/controls/private/CornerShadow.qml b/src/controls/private/CornerShadow.qml --- a/src/controls/private/CornerShadow.qml +++ b/src/controls/private/CornerShadow.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 RadialGradient { id: shadow diff --git a/src/controls/private/DefaultListItemBackground.qml b/src/controls/private/DefaultListItemBackground.qml --- a/src/controls/private/DefaultListItemBackground.qml +++ b/src/controls/private/DefaultListItemBackground.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Rectangle { id: background @@ -42,7 +42,7 @@ on_FirstElementChanged: { if (_firstElement) { - var newObject = Qt.createQmlObject('import QtQuick 2.0; import org.kde.kirigami 2.0; Separator {anchors {left: parent.left; right: parent.right; bottom: parent.top} visible: listItem.separatorVisible}', + var newObject = Qt.createQmlObject('import QtQuick 2.0; import org.kde.kirigami 2.2; Separator {anchors {left: parent.left; right: parent.right; bottom: parent.top} visible: listItem.separatorVisible}', background); } } diff --git a/src/controls/private/EdgeShadow.qml b/src/controls/private/EdgeShadow.qml --- a/src/controls/private/EdgeShadow.qml +++ b/src/controls/private/EdgeShadow.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 LinearGradient { id: shadow diff --git a/src/controls/private/PrivateActionToolButton.qml b/src/controls/private/PrivateActionToolButton.qml --- a/src/controls/private/PrivateActionToolButton.qml +++ b/src/controls/private/PrivateActionToolButton.qml @@ -20,7 +20,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.0 as Controls -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Controls.ToolButton { id: control diff --git a/src/controls/private/RefreshableScrollView.qml b/src/controls/private/RefreshableScrollView.qml --- a/src/controls/private/RefreshableScrollView.qml +++ b/src/controls/private/RefreshableScrollView.qml @@ -21,7 +21,7 @@ import QtQuick.Controls 2.0 as QQC2 import QtGraphicalEffects 1.0 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../templates/private" as P /** @@ -33,7 +33,7 @@ * Example usage: * * @code - * import org.kde.kirigami 2.0 as Kirigami + * import org.kde.kirigami 2.2 as Kirigami * [...] * * Kirigami.RefreshableScrollView { diff --git a/src/controls/private/SwipeItemEventFilter.qml b/src/controls/private/SwipeItemEventFilter.qml --- a/src/controls/private/SwipeItemEventFilter.qml +++ b/src/controls/private/SwipeItemEventFilter.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 MouseArea { diff --git a/src/controls/templates/AbstractApplicationHeader.qml b/src/controls/templates/AbstractApplicationHeader.qml --- a/src/controls/templates/AbstractApplicationHeader.qml +++ b/src/controls/templates/AbstractApplicationHeader.qml @@ -20,7 +20,7 @@ import QtQuick 2.5 import QtQuick.Layouts 1.2 import "private" -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** diff --git a/src/controls/templates/AbstractListItem.qml b/src/controls/templates/AbstractListItem.qml --- a/src/controls/templates/AbstractListItem.qml +++ b/src/controls/templates/AbstractListItem.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtQuick.Templates 2.0 as T2 /** @@ -70,14 +70,14 @@ * Note: if custom text elements are inserted in an AbstractListItem, * their color proprty will ahve to be manually binded with this property */ - property color textColor: Theme.viewTextColor + property color textColor: Theme.textColor /** * backgroundColor: color * Color for the background of the item * It is advised to leave the default value (Theme.viewBackgroundColor) */ - property color backgroundColor: Theme.viewBackgroundColor + property color backgroundColor: Theme.backgroundColor /** * activeTextColor: color @@ -98,6 +98,7 @@ default property alias _default: listItem.contentItem + Theme.colorSet: Theme.View leftPadding: Units.smallSpacing * 2 topPadding: Units.smallSpacing * 2 rightPadding: Units.smallSpacing * 2 @@ -115,6 +116,7 @@ height: visible ? implicitHeight : 0 hoverEnabled: true + onPressed: listItem.forceActiveFocus(); - Accessible.role: Accessible.MenuItem + Accessible.role: Accessible.ListItem } diff --git a/src/controls/templates/ApplicationHeader.qml b/src/controls/templates/ApplicationHeader.qml --- a/src/controls/templates/ApplicationHeader.qml +++ b/src/controls/templates/ApplicationHeader.qml @@ -21,7 +21,7 @@ import QtQuick.Controls 2.0 as QQC2 import QtQuick.Layouts 1.2 import "private" -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 /** diff --git a/src/controls/templates/OverlayDrawer.qml b/src/controls/templates/OverlayDrawer.qml --- a/src/controls/templates/OverlayDrawer.qml +++ b/src/controls/templates/OverlayDrawer.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtQuick.Templates 2.0 as T2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "private" /** @@ -185,6 +185,11 @@ } } + Theme.colorSet: Theme.View + Theme.onColorSetChanged: { + contentItem.Theme.colorSet = Theme.colorSet + background.Theme.colorSet = Theme.colorSet + } //END Properties @@ -299,6 +304,8 @@ root.enter.enabled = true; } __internal.completed = true; + contentItem.Theme.colorSet = Theme.colorSet; + background.Theme.colorSet = Theme.colorSet; } //END signal handlers diff --git a/src/controls/templates/OverlaySheet.qml b/src/controls/templates/OverlaySheet.qml --- a/src/controls/templates/OverlaySheet.qml +++ b/src/controls/templates/OverlaySheet.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtGraphicalEffects 1.0 import QtQuick.Templates 2.0 as T2 import "private" diff --git a/src/controls/templates/SwipeListItem.qml b/src/controls/templates/SwipeListItem.qml --- a/src/controls/templates/SwipeListItem.qml +++ b/src/controls/templates/SwipeListItem.qml @@ -19,7 +19,7 @@ import QtQuick 2.7 import QtQuick.Layouts 1.2 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../private" import QtQuick.Templates 2.0 as T2 diff --git a/src/controls/templates/private/BackButton.qml b/src/controls/templates/private/BackButton.qml --- a/src/controls/templates/private/BackButton.qml +++ b/src/controls/templates/private/BackButton.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Controls 2.0 as Controls -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Controls.ToolButton { anchors { diff --git a/src/controls/templates/private/ContextIcon.qml b/src/controls/templates/private/ContextIcon.qml --- a/src/controls/templates/private/ContextIcon.qml +++ b/src/controls/templates/private/ContextIcon.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Item { id: canvas diff --git a/src/controls/templates/private/MenuIcon.qml b/src/controls/templates/private/MenuIcon.qml --- a/src/controls/templates/private/MenuIcon.qml +++ b/src/controls/templates/private/MenuIcon.qml @@ -20,7 +20,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 Item { id: canvas diff --git a/src/controls/templates/private/PassiveNotification.qml b/src/controls/templates/private/PassiveNotification.qml --- a/src/controls/templates/private/PassiveNotification.qml +++ b/src/controls/templates/private/PassiveNotification.qml @@ -21,7 +21,7 @@ import QtQuick.Controls 2.0 as QQC2 import QtQuick.Layouts 1.2 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 MouseArea { id: root diff --git a/src/controls/templates/private/ScrollView.qml b/src/controls/templates/private/ScrollView.qml --- a/src/controls/templates/private/ScrollView.qml +++ b/src/controls/templates/private/ScrollView.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 import QtQuick.Controls 2.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 MouseArea { id: root diff --git a/src/desktopicon.h b/src/desktopicon.h --- a/src/desktopicon.h +++ b/src/desktopicon.h @@ -27,6 +27,11 @@ class QNetworkAccessManager; class QNetworkReply; + +namespace Kirigami { + class PlatformTheme; +} + class DesktopIcon : public QQuickItem { Q_OBJECT @@ -39,6 +44,7 @@ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool valid READ valid NOTIFY validChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) + Q_PROPERTY(bool isMask READ isMask WRITE setIsMask NOTIFY isMaskChanged) public: DesktopIcon(QQuickItem *parent=0); @@ -63,6 +69,9 @@ void setSelected(bool selected = true); bool selected() const; + void setIsMask(bool mask); + bool isMask() const; + QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) Q_DECL_OVERRIDE; Q_SIGNALS: @@ -72,19 +81,23 @@ void activeChanged(); void validChanged(); void selectedChanged(); + void isMaskChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; QImage findIcon(const QSize& size); void handleFinished(QNetworkAccessManager* qnam, QNetworkReply* reply); void handleReadyRead(QNetworkReply* reply); QIcon::Mode iconMode() const; + private: + Kirigami::PlatformTheme *m_theme = nullptr; QVariant m_source; bool m_smooth; bool m_changed; bool m_active; bool m_selected; + bool m_isMask; QImage m_loadedImage; }; diff --git a/src/desktopicon.cpp b/src/desktopicon.cpp --- a/src/desktopicon.cpp +++ b/src/desktopicon.cpp @@ -19,6 +19,7 @@ */ #include "desktopicon.h" +#include "platformtheme.h" #include #include @@ -33,6 +34,7 @@ #include #include #include +#include class ManagedTextureNode : public QSGSimpleTextureNode { @@ -132,9 +134,11 @@ m_smooth(false), m_changed(false), m_active(false), - m_selected(false) + m_selected(false), + m_isMask(false) { setFlag(ItemHasContents, true); + //FIXME: not necessary anymore connect(qApp, &QGuiApplication::paletteChanged, this, [this]() { m_changed = true; update(); @@ -153,6 +157,17 @@ } m_source = icon; m_changed = true; + + if (!m_theme) { + m_theme = static_cast(qmlAttachedPropertiesObject(this, true)); + Q_ASSERT(m_theme); + + connect(m_theme, &Kirigami::PlatformTheme::colorsChanged, this, [this]() { + m_changed = true; + update(); + }); + } + update(); emit sourceChanged(); } @@ -211,6 +226,21 @@ return m_selected; } +void DesktopIcon::setIsMask(bool mask) +{ + if (m_isMask == mask) { + return; + } + + m_isMask = mask; + emit isMaskChanged(); +} + +bool DesktopIcon::isMask() const +{ + return m_isMask; +} + int DesktopIcon::implicitWidth() const { return 32; @@ -269,8 +299,11 @@ img = findIcon(size); break; case QVariant::Brush: + //todo: fill here too? case QVariant::Color: - //perhaps fill image instead? + img = QImage(size, QImage::Format_Alpha8); + img.fill(m_source.value()); + break; default: break; } @@ -402,10 +435,16 @@ } QIcon icon(iconSource); if (icon.availableSizes().isEmpty()) { - icon = QIcon::fromTheme(iconSource); + icon = m_theme->iconFromTheme(iconSource); } if (!icon.availableSizes().isEmpty()){ img = icon.pixmap(size, iconMode(), QIcon::On).toImage(); + if (m_isMask || icon.isMask()) { + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_SourceIn); + p.fillRect(img.rect(), m_theme->textColor()); + p.end(); + } } } return img; diff --git a/src/kirigamiplugin.cpp b/src/kirigamiplugin.cpp --- a/src/kirigamiplugin.cpp +++ b/src/kirigamiplugin.cpp @@ -28,6 +28,8 @@ #include #include +#include + static QString s_selectedStyle; QUrl KirigamiPlugin::componentUrl(const QString &fileName) const @@ -67,9 +69,8 @@ } //At this point the fallback chain will be selected->org.kde.desktop->Fallback + Kirigami::PlatformTheme::setFallbackThemeQmlPath(componentUrl(QStringLiteral("Theme.qml"))); - //TODO: in this plugin it will end up something similar to - //PlasmaCore's ColorScope? s_selectedStyle = m_stylesFallbackChain.first(); qmlRegisterSingletonType(uri, 2, 0, "Settings", [](QQmlEngine*, QJSEngine*) -> QObject* { @@ -82,6 +83,8 @@ qmlRegisterUncreatableType(uri, 2, 0, "ApplicationHeaderStyle", "Cannot create objects of type ApplicationHeaderStyle"); qmlRegisterSingletonType(componentUrl(QStringLiteral("Theme.qml")), uri, 2, 0, "Theme"); + //Theme changed from a singleton to an attached property + qmlRegisterUncreatableType(uri, 2, 2, "Theme", "Cannot create objects of type Theme, use it as an attached poperty"); qmlRegisterSingletonType(componentUrl(QStringLiteral("Units.qml")), uri, 2, 0, "Units"); qmlRegisterType(componentUrl(QStringLiteral("Action.qml")), uri, 2, 0, "Action"); @@ -101,7 +104,12 @@ //The icon is "special: we have to use a wrapper class to QIcon on org.kde.desktops #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - qmlRegisterType(uri, 2, 0, "Icon"); + //we know that we want a different implementation with Material and Plasma styles + if (s_selectedStyle == QStringLiteral("Material") || s_selectedStyle == QStringLiteral("Plasma")) { + qmlRegisterType(componentUrl(QStringLiteral("Icon.qml")), uri, 2, 0, "Icon"); + } else { + qmlRegisterType(uri, 2, 0, "Icon"); + } #else qmlRegisterType(componentUrl(QStringLiteral("Icon.qml")), uri, 2, 0, "Icon"); #endif diff --git a/src/libkirigami/CMakeLists.txt b/src/libkirigami/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/libkirigami/CMakeLists.txt @@ -0,0 +1,85 @@ + + +set(libkirigami_SRCS + platformtheme.cpp + basictheme.cpp + platformthemefactory.cpp +) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +ecm_qt_declare_logging_category(libkirigami_SRCS + HEADER loggingcategory.h + IDENTIFIER KirigamiLog + CATEGORY_NAME kf5.kirigami + DEFAULT_SEVERITY Warning +) + +add_library(KF5Kirigami2 ${libkirigami_SRCS}) +generate_export_header(KF5Kirigami2 BASE_NAME Kirigami2) +add_library(KF5::Kirigami2 ALIAS KF5Kirigami2) + +target_include_directories(KF5Kirigami2 + INTERFACE "$" +) + +target_link_libraries(KF5Kirigami2 + PUBLIC + Qt5::Core + PRIVATE + Qt5::Qml + Qt5::Quick + Qt5::QuickControls2 +) + +set_target_properties(KF5Kirigami2 PROPERTIES + VERSION ${KIRIGAMI_VERSION_STRING} + SOVERSION ${KIRIGAMI_SOVERSION} + EXPORT_NAME "Kirigami2" +) + +ecm_generate_headers(Kirigami2_HEADERS + HEADER_NAMES + PlatformTheme + PlatformThemeFactory + + REQUIRED_HEADERS Kirigami2_HEADERS +) + +install(TARGETS KF5Kirigami2 + EXPORT KF5Kirigami2Targets + ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) + + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/kirigami2_export.h + ${Kirigami2_HEADERS} + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/Kirigami2 + COMPONENT Devel) + +if(BUILD_QCH) + ecm_add_qch( + KF5Kirigami2_QCH + NAME Kirigami2 + BASE_NAME KF5Kirigami2 + VERSION ${KF5_VERSION} + ORG_DOMAIN org.kde + SOURCES # using only public headers, to cover only public API + ${Kirigami2_HEADERS} + MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" + LINK_QCHS + Qt5Core_QCH + BLANK_MACROS + KIRIGAMI_EXPORT + KIRIGAMI_DEPRECATED + TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} + QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} + COMPONENT Devel + ) +endif() + +include(ECMGeneratePriFile) +ecm_generate_pri_file(BASE_NAME Kirigami2 LIB_NAME KF5Kirigami2 DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/Kirigami2) +install(FILES ${PRI_FILENAME} + DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) + diff --git a/src/libkirigami/basictheme.cpp b/src/libkirigami/basictheme.cpp new file mode 100644 --- /dev/null +++ b/src/libkirigami/basictheme.cpp @@ -0,0 +1,275 @@ +/* +* Copyright (C) 2017 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 "basictheme_p.h" +#include +#include +#include +#include +#include +#include +#include + +namespace Kirigami { + +class BasicThemeDeclarativeSingleton +{ +public: + BasicThemeDeclarativeSingleton() + {} + + BasicThemeDeclarative self; +}; + +Q_GLOBAL_STATIC(BasicThemeDeclarativeSingleton, privateBasicThemeDeclarativeSelf) + +BasicThemeDeclarative::BasicThemeDeclarative() +{ + m_colorSyncTimer = new QTimer; + m_colorSyncTimer->setInterval(0); + m_colorSyncTimer->setSingleShot(true); +} + +BasicThemeDeclarative::~BasicThemeDeclarative() +{ + delete m_colorSyncTimer; +} + +void BasicThemeDeclarative::setQmlPath(const QUrl &path) +{ + m_qmlPath = path; +} + +QUrl BasicThemeDeclarative::qmlPath() const +{ + return m_qmlPath; +} + +QObject *BasicThemeDeclarative::instance(const BasicTheme *theme) +{ + if (m_declarativeBasicTheme) { + return m_declarativeBasicTheme; + } + + QQmlEngine *engine = qmlEngine(theme->parent()); + Q_ASSERT(engine); + + QQmlComponent c(engine); + c.loadUrl(m_qmlPath); + + m_declarativeBasicTheme = c.create(); + + return m_declarativeBasicTheme; +} + + + +BasicTheme::BasicTheme(QObject *parent) + : PlatformTheme(parent) +{ + //TODO: correct? + connect(qApp, &QGuiApplication::fontDatabaseChanged, this, [this]() {setDefaultFont(qApp->font());}); + + //connect all the declarative object signals to the timer start to compress, use the old syntax as they are all signals defined in QML + connect(basicThemeDeclarative()->instance(this), SIGNAL(textColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(disabledTextColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(highlightColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(highlightedTextColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(backgroundColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(linkColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(visitedLinkColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + + connect(basicThemeDeclarative()->instance(this), SIGNAL(buttonTextColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(buttonBackgroundColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(buttonHoverColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(buttonFocusColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + + connect(basicThemeDeclarative()->instance(this), SIGNAL(viewTextColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(viewBackgroundColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(viewHoverColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(viewFocusColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + + connect(basicThemeDeclarative()->instance(this), SIGNAL(complementaryTextColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(complementaryBackgroundColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(complementaryHoverColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + connect(basicThemeDeclarative()->instance(this), SIGNAL(complementaryFocusColorChanged()), + basicThemeDeclarative()->m_colorSyncTimer, SLOT(start())); + + //finally connect the timer to the sync + connect(basicThemeDeclarative()->m_colorSyncTimer, &QTimer::timeout, + this, &BasicTheme::syncColors); + connect(this, &BasicTheme::colorSetChanged, + this, [this]() { + syncColors(); + if (basicThemeDeclarative()->instance(this)) { + QMetaObject::invokeMethod(basicThemeDeclarative()->instance(this), "__propagateColorSet", Q_ARG(QVariant, QVariant::fromValue(this->parent())), Q_ARG(QVariant, colorSet())); + } + }); + syncColors(); +} + +BasicTheme::~BasicTheme() +{ +} + +QStringList BasicTheme::keys() const +{ + QStringList props; + for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { + const QString prop = metaObject()->property(i).name(); + if (prop != "keys") { + props << prop; + } + } + return props; +} + +//TODO: tint for which we need to chain to m_parentBasicTheme's color +#define RESOLVECOLOR(colorName, upperCaseColor) \ + QColor color;\ + switch (colorSet()) {\ + case BasicTheme::Button:\ + color = basicThemeDeclarative()->instance(this)->property("button"#upperCaseColor).value();\ + break;\ + case BasicTheme::View:\ + color = basicThemeDeclarative()->instance(this)->property("view"#upperCaseColor).value();\ + break;\ + case BasicTheme::Complementary:\ + color = basicThemeDeclarative()->instance(this)->property("complementary"#upperCaseColor).value();\ + break;\ + case BasicTheme::Window:\ + default:\ + color = basicThemeDeclarative()->instance(this)->property(#colorName).value();\ + }\ + + +#define PROXYCOLOR(colorName, upperCaseColor) \ + basicThemeDeclarative()->instance(this)->property(#colorName).value() + + +void BasicTheme::syncColors() +{ + { + RESOLVECOLOR(textColor, TextColor); + setTextColor(color); + }{ + setDisabledTextColor(PROXYCOLOR(disabledTextColor, DisabledTextColor)); + }{ + RESOLVECOLOR(backgroundColor, BackgroundColor) + setBackgroundColor(color); + }{ + setHighlightColor(PROXYCOLOR(highlightColor, HighlightColor)); + }{ + setHighlightedTextColor(PROXYCOLOR(highlightedTextColor, HighlightedTextColor)); + }{ + setLinkColor(PROXYCOLOR(linkColor, LinkColor)); + }{ + setVisitedLinkColor(PROXYCOLOR(visitedLinkColor, VisitedLinkColor)); + } + + //legacy + { + m_buttonTextColor = PROXYCOLOR(buttonTextColor, ButtonTextColor); + m_buttonBackgroundColor = PROXYCOLOR(buttonBackgroundColor, ButtonBackgroundColor); + m_buttonHoverColor = PROXYCOLOR(buttonHoverColor, ButtonHoverColor); + m_buttonFocusColor = PROXYCOLOR(buttonFocusColor, ButtonFocusColor); + m_viewTextColor = PROXYCOLOR(viewTextColor, ViewTextColor); + m_viewBackgroundColor = PROXYCOLOR(viewBackgroundColor, ViewBackgroundColor); + m_viewHoverColor = PROXYCOLOR(viewHoverColor, ViewHoverColor); + m_viewFocusColor = PROXYCOLOR(viewFocusColor, ViewFocusColor); + } + //TODO: build the qpalette + emit colorsChanged(); +} + +QColor BasicTheme::buttonTextColor() const +{ + qWarning()<<"WARNING: buttonTextColor is deprecated, use textColor with colorSet: Theme.Button instead"; + return m_buttonTextColor; +} + +QColor BasicTheme::buttonBackgroundColor() const +{ + qWarning()<<"WARNING: buttonBackgroundColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonBackgroundColor; +} + +QColor BasicTheme::buttonHoverColor() const +{ + qWarning()<<"WARNING: buttonHoverColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonHoverColor; +} + +QColor BasicTheme::buttonFocusColor() const +{ + qWarning()<<"WARNING: buttonFocusColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonFocusColor; +} + + +QColor BasicTheme::viewTextColor() const +{ + qWarning()<<"WARNING: viewTextColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewTextColor; +} + +QColor BasicTheme::viewBackgroundColor() const +{ + qWarning()<<"WARNING: viewBackgroundColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewBackgroundColor; +} + +QColor BasicTheme::viewHoverColor() const +{ + qWarning()<<"WARNING: viewHoverColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewHoverColor; +} + +QColor BasicTheme::viewFocusColor() const +{ + qWarning()<<"WARNING: viewFocusColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewFocusColor; +} + +BasicThemeDeclarative *BasicTheme::basicThemeDeclarative() +{ + return &privateBasicThemeDeclarativeSelf->self; +} + +} + +#include "moc_basictheme_p.cpp" diff --git a/src/libkirigami/basictheme_p.h b/src/libkirigami/basictheme_p.h new file mode 100644 --- /dev/null +++ b/src/libkirigami/basictheme_p.h @@ -0,0 +1,105 @@ +/* +* Copyright (C) 2017 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. +*/ + +#ifndef BASICTHEME_H +#define BASICTHEME_H + +#include "platformtheme.h" +#include +#include +#include +#include + +namespace Kirigami { + +class BasicTheme; + +class BasicThemeDeclarative +{ +public: + BasicThemeDeclarative(); + virtual ~BasicThemeDeclarative(); + + void setQmlPath(const QUrl &path); + QUrl qmlPath() const; + QObject *instance(const BasicTheme *theme); + + QTimer *m_colorSyncTimer; + +private: + QUrl m_qmlPath; + QObject *m_declarativeBasicTheme = nullptr; +}; + +class BasicTheme : public PlatformTheme +{ + Q_OBJECT + + // colors + Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY colorsChanged) + + Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY colorsChanged) + + //FIXME: this is due https://bugreports.qt.io/browse/QTBUG-63089 + Q_PROPERTY(QStringList keys READ keys CONSTANT) + +public: + explicit BasicTheme(QObject *parent = 0); + ~BasicTheme(); + + void syncColors(); + + QColor buttonTextColor() const; + QColor buttonBackgroundColor() const; + QColor buttonHoverColor() const; + QColor buttonFocusColor() const; + + QColor viewTextColor() const; + QColor viewBackgroundColor() const; + QColor viewHoverColor() const; + QColor viewFocusColor() const; + + QStringList keys() const; + + static BasicThemeDeclarative *basicThemeDeclarative(); + +Q_SIGNALS: + void colorsChanged(); + +private: + //legacy colors + QColor m_buttonTextColor; + QColor m_buttonBackgroundColor; + QColor m_buttonHoverColor; + QColor m_buttonFocusColor; + QColor m_viewTextColor; + QColor m_viewBackgroundColor; + QColor m_viewHoverColor; + QColor m_viewFocusColor; +}; + +} + +#endif // BASICTHEME_H diff --git a/src/libkirigami/platformtheme.h b/src/libkirigami/platformtheme.h new file mode 100644 --- /dev/null +++ b/src/libkirigami/platformtheme.h @@ -0,0 +1,146 @@ +/* +* Copyright (C) 2017 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. +*/ + +#ifndef PLATFORMTHEME_H +#define PLATFORMTHEME_H + +#include +#include +#include +#include + +#include + +namespace Kirigami { + +class PlatformThemePrivate; + +class KIRIGAMI2_EXPORT PlatformTheme : public QObject +{ + Q_OBJECT + + /** + * This enumeration describes the color set for which a color is being selected. + * + * Color sets define a color "environment", suitable for drawing all parts of a + * given region. Colors from different sets should not be combined. + */ + Q_PROPERTY(ColorSet colorSet READ colorSet WRITE setColorSet NOTIFY colorSetChanged) + + /** + * If true, the colorSet will be inherited from the colorset of a theme of one + * of the ancestor items + * default: true + */ + Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged) + + // colors + Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) + Q_PROPERTY(QColor disabledTextColor READ disabledTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor linkColor READ linkColor NOTIFY colorsChanged) + Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY colorsChanged) + + // font and palette + Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged) + Q_PROPERTY(QPalette palette READ palette NOTIFY paletteChanged) + + Q_ENUMS(ColorSet) + +public: + //kcolorscheme also has selection: this would replace highlightColor/highlightedTextColor which would become just + //wouldn't bother about tooltip for now, can always be added + enum ColorSet { + Window = 0, + Button, + View, + Complementary + }; + + explicit PlatformTheme(QObject *parent = 0); + ~PlatformTheme(); + + void setColorSet(PlatformTheme::ColorSet); + PlatformTheme::ColorSet colorSet() const; + + bool inherit() const; + void setInherit(bool inherit); + + QColor textColor() const; + QColor disabledTextColor() const; + QColor backgroundColor() const; + QColor highlightColor() const; + QColor highlightedTextColor() const; + //TODO: add positive/neutral/negative text + // hoverColor/focusColor would go there if the explicit properties are removed + //any other stuff missing from kcolorscheme? + + //can we kill link and visited link? + QColor linkColor() const; + QColor visitedLinkColor() const; + + //Setters, not accessible from QML but from implementations + void setTextColor(const QColor &color); + void setDisabledTextColor(const QColor &color); + void setBackgroundColor(const QColor &color); + void setHighlightColor(const QColor &color); + void setHighlightedTextColor(const QColor &color); + void setLinkColor(const QColor &color); + void setVisitedLinkColor(const QColor &color); + + + QFont defaultFont() const; + void setDefaultFont(const QFont &defaultFont); + + QPalette palette() const; + void setPalette(const QPalette &palette); + + //this will be used by desktopicon to fetch icons with KIconLoader + virtual Q_INVOKABLE QIcon iconFromTheme(const QString &name); + //this may be used somehow by the desktop QQC2 to set the styleoption palettes + + //QML attached property + static PlatformTheme *qmlAttachedProperties(QObject *object); + + /** + * @internal + */ + static void setFallbackThemeQmlPath(const QUrl &path); + static QUrl fallbackThemeQmlPath(); + +Q_SIGNALS: + //TODO: parameters to signals as this is also a c++ api + void colorsChanged(); + void defaultFontChanged(); + void colorSetChanged(); + void paletteChanged(); + void inheritChanged(); + +private: + PlatformThemePrivate *d; + friend class PlatformThemePrivate; +}; + +} + +QML_DECLARE_TYPEINFO(Kirigami::PlatformTheme, QML_HAS_ATTACHED_PROPERTIES) + +#endif // PLATFORMTHEME_H diff --git a/src/libkirigami/platformtheme.cpp b/src/libkirigami/platformtheme.cpp new file mode 100644 --- /dev/null +++ b/src/libkirigami/platformtheme.cpp @@ -0,0 +1,359 @@ +/* +* Copyright (C) 2017 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 "platformtheme.h" +#include "platformthemefactory.h" +#include "basictheme_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Kirigami { + +class PlatformThemePrivate { +public: + PlatformThemePrivate(PlatformTheme *q); + ~PlatformThemePrivate(); + + void findParentStyle(); + static QColor tint(const QColor &c1, const QColor &c2, qreal ratio); + + + PlatformTheme *q; + QTimer *setColorCompressTimer; + PlatformTheme::ColorSet m_colorSet = PlatformTheme::Window; + QSet m_childThemes; + QPointer m_parentTheme; + + QColor textColor; + QColor disabledTextColor; + QColor backgroundColor; + QColor highlightColor; + QColor highlightedTextColor; + QColor linkColor; + QColor visitedLinkColor; + QFont font; + QPalette palette; + bool m_inherit = true; +}; + +PlatformThemePrivate::PlatformThemePrivate(PlatformTheme *q) + : q(q) +{ + setColorCompressTimer = new QTimer(q); + setColorCompressTimer->setSingleShot(true); + setColorCompressTimer->setInterval(0); +} + +PlatformThemePrivate::~PlatformThemePrivate() +{} + +void PlatformThemePrivate::findParentStyle() +{ + if (m_parentTheme) { + m_parentTheme->d->m_childThemes.remove(q); + } + QQuickItem *candidate = qobject_cast(q->parent()); + while (candidate) { + candidate = candidate->parentItem(); + PlatformTheme *t = static_cast(qmlAttachedPropertiesObject(candidate, false)); + if (t) { + t->d->m_childThemes.insert(q); + m_parentTheme = t; + if (m_inherit) { + q->setColorSet(t->colorSet()); + } + break; + } + + } +} + +QColor PlatformThemePrivate::tint(const QColor &c1, const QColor &c2, qreal ratio) +{ + qreal r = c1.redF() + (c2.redF() - c1.redF()) * ratio; + qreal g = c1.greenF() + (c2.greenF() - c1.greenF()) * ratio; + qreal b = c1.blueF() + (c2.blueF() - c1.blueF()) * ratio; + + return QColor::fromRgbF(r, g, b, 1); +} + + + + +PlatformTheme::PlatformTheme(QObject *parent) + : QObject(parent), + d(new PlatformThemePrivate(this)) +{ + connect(d->setColorCompressTimer, &QTimer::timeout, + this, &PlatformTheme::colorsChanged); + d->findParentStyle(); + + if (QQuickItem *item = qobject_cast(parent)) { + connect(item, &QQuickItem::windowChanged, this, [this]() { + d->findParentStyle(); + }); + connect(item, &QQuickItem::parentChanged, this, [this]() { + d->findParentStyle(); + }); + } + + //TODO: correct? + connect(qApp, &QGuiApplication::fontDatabaseChanged, this, &PlatformTheme::defaultFontChanged); +} + +PlatformTheme::~PlatformTheme() +{ + if (d->m_parentTheme) { + d->m_parentTheme->d->m_childThemes.remove(this); + } +} + +void PlatformTheme::setColorSet(PlatformTheme::ColorSet colorSet) +{ + if (d->m_colorSet == colorSet) { + return; + } + + d->m_colorSet = colorSet; + + for (PlatformTheme *t : d->m_childThemes) { + if (t->inherit()) { + t->setColorSet(colorSet); + } + } + + emit colorSetChanged(); + d->setColorCompressTimer->start(); +} + +PlatformTheme::ColorSet PlatformTheme::colorSet() const +{ + return d->m_colorSet; +} + +bool PlatformTheme::inherit() const +{ + return d->m_inherit; +} + +void PlatformTheme::setInherit(bool inherit) +{ + if (d->m_inherit == inherit) { + return; + } + + d->m_inherit = inherit; + if (inherit && d->m_parentTheme) { + setColorSet(d->m_parentTheme->colorSet()); + } + emit inheritChanged(); +} + + +QColor PlatformTheme::textColor() const +{ + return d->textColor; +} + +QColor PlatformTheme::disabledTextColor() const +{ + return d->disabledTextColor; +} + +QColor PlatformTheme::highlightColor() const +{ + return d->highlightColor; +} + +QColor PlatformTheme::highlightedTextColor() const +{ + return d->highlightedTextColor; +} + +QColor PlatformTheme::backgroundColor() const +{ + return d->backgroundColor; +} + +QColor PlatformTheme::linkColor() const +{ + return d->linkColor; +} + +QColor PlatformTheme::visitedLinkColor() const +{ + return d->visitedLinkColor; +} + +void PlatformTheme::setTextColor(const QColor &color) +{ + if (d->textColor == color) { + return; + } + + d->textColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setDisabledTextColor(const QColor &color) +{ + if (d->disabledTextColor == color) { + return; + } + + d->disabledTextColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setBackgroundColor(const QColor &color) +{ + if (d->backgroundColor == color) { + return; + } + + d->backgroundColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setHighlightColor(const QColor &color) +{ + if (d->highlightColor == color) { + return; + } + + d->highlightColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setHighlightedTextColor(const QColor &color) +{ + if (d->highlightedTextColor == color) { + return; + } + + d->highlightedTextColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setLinkColor(const QColor &color) +{ + if (d->linkColor == color) { + return; + } + + d->linkColor = color; + d->setColorCompressTimer->start(); +} + +void PlatformTheme::setVisitedLinkColor(const QColor &color) +{ + if (d->visitedLinkColor == color) { + return; + } + + d->visitedLinkColor = color; + d->setColorCompressTimer->start(); +} + + + +QFont PlatformTheme::defaultFont() const +{ + return d->font; +} + +void PlatformTheme::setDefaultFont(const QFont &font) +{ + if (d->font == font) { + return; + } + + d->font = font; + emit defaultFontChanged(); +} + +QPalette PlatformTheme::palette() const +{ + return d->palette; +} + +void PlatformTheme::setPalette(const QPalette &palette) +{ + if (d->palette == palette) { + return; + } + + d->palette = palette; + emit paletteChanged(); +} + +QIcon PlatformTheme::iconFromTheme(const QString &name) +{ + QIcon icon = QIcon::fromTheme(name); + if (name.endsWith("-symbolic")) { + icon.setIsMask(true); + } + return icon; +} + + + +PlatformTheme *PlatformTheme::qmlAttachedProperties(QObject *object) +{ + for (const QString &path : QCoreApplication::libraryPaths()) { + QDir dir(path + "/kf5/kirigami"); + for (const QString &fileName : dir.entryList(QDir::Files)) { + //TODO: env variable? + if (fileName.startsWith(QQuickStyle::name())) { + QPluginLoader loader(dir.absoluteFilePath(fileName)); + QObject *plugin = loader.instance(); + //TODO: load actually a factory as plugin + + PlatformThemeFactory *factory = qobject_cast(plugin); + if (factory) { + return factory->create(object); + } + } + } + } + + return new BasicTheme(object); +} + +void PlatformTheme::setFallbackThemeQmlPath(const QUrl &path) +{ + BasicTheme::basicThemeDeclarative()->setQmlPath(path); +} + +QUrl PlatformTheme::fallbackThemeQmlPath() +{ + return BasicTheme::basicThemeDeclarative()->qmlPath(); +} + +} + +#include "moc_platformtheme.cpp" diff --git a/src/libkirigami/platformthemefactory.h b/src/libkirigami/platformthemefactory.h new file mode 100644 --- /dev/null +++ b/src/libkirigami/platformthemefactory.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2017 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. +*/ + +#ifndef PLATFORMTHEMEFACTORY_H +#define PLATFORMTHEMEFACTORY_H + +#include "platformtheme.h" +#include + +namespace Kirigami { + +class KIRIGAMI2_EXPORT PlatformThemeFactory : public QObject +{ + Q_OBJECT + +public: + explicit PlatformThemeFactory(QObject *parent = nullptr); + ~PlatformThemeFactory(); + + virtual PlatformTheme *create(QObject *parent) = 0; +}; + +} + +QT_BEGIN_NAMESPACE +#define PlatformThemeFactory_iid "org.kde.kirigami.PlatformThemeFactory" +Q_DECLARE_INTERFACE(Kirigami::PlatformThemeFactory, PlatformThemeFactory_iid) +QT_END_NAMESPACE + +#endif //PLATFORMTHEMEFACTORY_H diff --git a/src/libkirigami/platformthemefactory.cpp b/src/libkirigami/platformthemefactory.cpp new file mode 100644 --- /dev/null +++ b/src/libkirigami/platformthemefactory.cpp @@ -0,0 +1,39 @@ +/* +* Copyright (C) 2017 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 "platformthemefactory.h" +#include "platformtheme.h" + +#include + + +namespace Kirigami { + +PlatformThemeFactory::PlatformThemeFactory(QObject *parent) + : QObject(parent) +{ +} + +PlatformThemeFactory::~PlatformThemeFactory() +{ +} + +} + +#include "moc_platformthemefactory.cpp" diff --git a/src/styles/Material/AbstractListItem.qml b/src/styles/Material/AbstractListItem.qml --- a/src/styles/Material/AbstractListItem.qml +++ b/src/styles/Material/AbstractListItem.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.7 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../../private" import "../../templates" as T diff --git a/src/styles/Material/Label.qml b/src/styles/Material/Label.qml --- a/src/styles/Material/Label.qml +++ b/src/styles/Material/Label.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtQuick.Templates 2.0 as T2 /** diff --git a/src/styles/Material/SwipeListItem.qml b/src/styles/Material/SwipeListItem.qml --- a/src/styles/Material/SwipeListItem.qml +++ b/src/styles/Material/SwipeListItem.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../../private" import "../../templates" as T diff --git a/src/styles/Material/Theme.qml b/src/styles/Material/Theme.qml --- a/src/styles/Material/Theme.qml +++ b/src/styles/Material/Theme.qml @@ -19,6 +19,7 @@ import QtQuick 2.7 import QtQuick.Controls.Material 2.0 +import org.kde.kirigami 2.2 as Kirigami pragma Singleton @@ -50,11 +51,27 @@ property color viewHoverColor: theme.Material.listHighlightColor property color viewFocusColor: theme.Material.listHighlightColor + property color complementaryTextColor: fontMetrics.Material.foreground + property color complementaryBackgroundColor: fontMetrics.Material.background + property color complementaryHoverColor: fontMetrics.Material.listHighlightColor + property color complementaryFocusColor: fontMetrics.Material.listHighlightColor + property font defaultFont: fontMetrics.font property list children: [ TextMetrics { id: fontMetrics + //this is to get a source of dark colors + Material.theme: Material.Dark } ] + //for internal use + function __propagateColorSet(object, context) { + //TODO: actually check if it's a dark or light color + if (context == Kirigami.Theme.Complementary) { + object.Material.theme = Material.Dark; + } else { + object.Material.theme = Material.Light; + } + } } diff --git a/src/styles/Plasma/Icon.qml b/src/styles/Plasma/Icon.qml --- a/src/styles/Plasma/Icon.qml +++ b/src/styles/Plasma/Icon.qml @@ -23,7 +23,9 @@ PlasmaCore.IconItem { property bool selected: false + property bool isMask: false usesPlasmaTheme: false + colorGroup: PlasmaCore.ColorScope.colorGroup onSelectedChanged: { if (selected) { status = PlasmaCore.Svg.Selected; diff --git a/src/styles/Plasma/Theme.qml b/src/styles/Plasma/Theme.qml --- a/src/styles/Plasma/Theme.qml +++ b/src/styles/Plasma/Theme.qml @@ -21,6 +21,7 @@ import QtQuick 2.4 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kirigami 2.2 as Kirigami QtObject { property color textColor: theme.textColor @@ -42,5 +43,28 @@ property color viewHoverColor: theme.viewHoverColor property color viewFocusColor: theme.viewFocusColor + property color complementaryTextColor: theme.complementaryTextColor + property color complementaryBackgroundColor: theme.complementaryBackgroundColor + property color complementaryHoverColor: theme.complementaryHoverColor + property color complementaryFocusColor: theme.complementaryFocusColor + property variant defaultFont: theme.defaultFont + + function __propagateColorSet(object, context) { + object.PlasmaCore.ColorScope.inherit = false; + switch(context) { + case Kirigami.Theme.Window: + object.PlasmaCore.ColorScope.colorGroup = PlasmaCore.Theme.NormalColorGroup; + break; + case Kirigami.Theme.Button: + object.PlasmaCore.ColorScope.colorGroup = PlasmaCore.Theme.ButtonColorGroup; + break; + case Kirigami.Theme.View: + object.PlasmaCore.ColorScope.colorGroup = PlasmaCore.Theme.ViewColorGroup; + break; + case Kirigami.Theme.Complementary: + object.PlasmaCore.ColorScope.colorGroup = PlasmaCore.Theme.ComplementaryColorGroup; + break; + } + } } diff --git a/src/styles/org.kde.desktop/AbstractApplicationHeader.qml b/src/styles/org.kde.desktop/AbstractApplicationHeader.qml --- a/src/styles/org.kde.desktop/AbstractApplicationHeader.qml +++ b/src/styles/org.kde.desktop/AbstractApplicationHeader.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.1 +import org.kde.kirigami 2.2 import "../../templates" as T diff --git a/src/styles/org.kde.desktop/AbstractListItem.qml b/src/styles/org.kde.desktop/AbstractListItem.qml --- a/src/styles/org.kde.desktop/AbstractListItem.qml +++ b/src/styles/org.kde.desktop/AbstractListItem.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../../private" import "../../templates" as T diff --git a/src/styles/org.kde.desktop/ApplicationWindow.qml b/src/styles/org.kde.desktop/ApplicationWindow.qml --- a/src/styles/org.kde.desktop/ApplicationWindow.qml +++ b/src/styles/org.kde.desktop/ApplicationWindow.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.1 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../../" as Base diff --git a/src/styles/org.kde.desktop/OverlayDrawer.qml b/src/styles/org.kde.desktop/OverlayDrawer.qml --- a/src/styles/org.kde.desktop/OverlayDrawer.qml +++ b/src/styles/org.kde.desktop/OverlayDrawer.qml @@ -19,7 +19,7 @@ import QtQuick 2.1 import QtGraphicalEffects 1.0 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import QtQuick.Templates 2.0 import "../../templates" as T @@ -37,7 +37,7 @@ //BEGIN Properties background: Rectangle { - color: Theme.viewBackgroundColor + color: Theme.backgroundColor Item { parent: root.handle diff --git a/src/styles/org.kde.desktop/SwipeListItem.qml b/src/styles/org.kde.desktop/SwipeListItem.qml --- a/src/styles/org.kde.desktop/SwipeListItem.qml +++ b/src/styles/org.kde.desktop/SwipeListItem.qml @@ -18,7 +18,7 @@ */ import QtQuick 2.5 -import org.kde.kirigami 2.0 +import org.kde.kirigami 2.2 import "../../private" import "../../templates" as T diff --git a/src/styles/org.kde.desktop/Theme.qml b/src/styles/org.kde.desktop/Theme.qml --- a/src/styles/org.kde.desktop/Theme.qml +++ b/src/styles/org.kde.desktop/Theme.qml @@ -44,6 +44,11 @@ property color viewHoverColor: palette.highlight property color viewFocusColor: palette.highlight + property color complementaryTextColor: palette.base + property color complementaryBackgroundColor: palette.text + property color complementaryHoverColor: palette.highlight + property color complementaryFocusColor: palette.highlight + property font defaultFont: fontMetrics.font property list children: [ @@ -59,4 +64,6 @@ colorGroup: SystemPalette.Disabled } ] + + function __propagateColorSet(object, context) {} } diff --git a/tests/KeyboardListTest.qml b/tests/KeyboardListTest.qml --- a/tests/KeyboardListTest.qml +++ b/tests/KeyboardListTest.qml @@ -20,7 +20,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow { diff --git a/tests/KeyboardTest.qml b/tests/KeyboardTest.qml --- a/tests/KeyboardTest.qml +++ b/tests/KeyboardTest.qml @@ -19,7 +19,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.2 as Kirigami Kirigami.ApplicationWindow {