diff options
Diffstat (limited to 'src/quickcontrols2/windows')
-rw-r--r-- | src/quickcontrols2/windows/Button.qml | 97 | ||||
-rw-r--r-- | src/quickcontrols2/windows/CMakeLists.txt | 48 | ||||
-rw-r--r-- | src/quickcontrols2/windows/CheckBox.qml | 109 | ||||
-rw-r--r-- | src/quickcontrols2/windows/ComboBox.qml | 130 | ||||
-rw-r--r-- | src/quickcontrols2/windows/Frame.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/GroupBox.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/ProgressBar.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/RadioButton.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/ScrollBar.qml | 128 | ||||
-rw-r--r-- | src/quickcontrols2/windows/ScrollView.qml | 67 | ||||
-rw-r--r-- | src/quickcontrols2/windows/Slider.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/SpinBox.qml | 124 | ||||
-rw-r--r-- | src/quickcontrols2/windows/TextArea.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/TextField.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/windows/qtquickcontrols2windowsstyleplugin.cpp | 74 | ||||
-rw-r--r-- | src/quickcontrols2/windows/windows.pri | 14 |
16 files changed, 1078 insertions, 0 deletions
diff --git a/src/quickcontrols2/windows/Button.qml b/src/quickcontrols2/windows/Button.qml new file mode 100644 index 0000000000..1b73e1de00 --- /dev/null +++ b/src/quickcontrols2/windows/Button.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T +import QtQuick.NativeStyle as NativeStyle + +T.Button { + id: control + + readonly property bool __nativeBackground: background instanceof NativeStyle.StyleItem + + // Since QQuickControl will subtract the insets from the control size to + // figure out the background size, we need to reverse that here, otherwise + // the control ends up too big. + implicitWidth: implicitBackgroundWidth + leftInset + rightInset + implicitHeight: implicitBackgroundHeight + topInset + bottomInset + + font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined + + leftPadding: __nativeBackground ? background.contentPadding.left : 5 + rightPadding: __nativeBackground ? background.contentPadding.right : 5 + topPadding: __nativeBackground ? background.contentPadding.top : 5 + bottomPadding: __nativeBackground ? background.contentPadding.bottom : 5 + + background: NativeStyle.Button { + control: control + contentWidth: contentItem.implicitWidth + contentHeight: contentItem.implicitHeight + useNinePatchImage: false + overrideState: NativeStyle.StyleItem.NeverHovered + } + + NativeStyle.Button { + id: hoverButton + control: control + x: background.x + y: background.y + width: background.width + height: background.height + useNinePatchImage: false + overrideState: NativeStyle.StyleItem.AlwaysHovered + opacity: control.hovered ? 1 : 0 + visible: opacity !== 0 + Behavior on opacity { NumberAnimation { duration: hoverButton.transitionDuration } } + } + + icon.width: 24 + icon.height: 24 + icon.color: control.checked || control.highlighted ? control.palette.brightText : + control.flat && !control.down ? (control.visualFocus ? control.palette.highlight : control.palette.windowText) : control.palette.buttonText + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + + icon: control.icon + text: control.text + font: control.font + color: control.flat && !control.down ? (control.visualFocus ? control.palette.highlight : control.palette.windowText) : control.palette.buttonText + } +} diff --git a/src/quickcontrols2/windows/CMakeLists.txt b/src/quickcontrols2/windows/CMakeLists.txt new file mode 100644 index 0000000000..194b4f1e2d --- /dev/null +++ b/src/quickcontrols2/windows/CMakeLists.txt @@ -0,0 +1,48 @@ +##################################################################### +## qtquickcontrols2windowsstyleplugin Plugin: +##################################################################### + +set(qml_files + "Button.qml" + "CheckBox.qml" + "ComboBox.qml" + "Frame.qml" + "GroupBox.qml" + "ProgressBar.qml" + "RadioButton.qml" + "Slider.qml" + "SpinBox.qml" + "TextArea.qml" + "TextField.qml" + "ScrollBar.qml" + "ScrollView.qml" +) +set_source_files_properties(${qml_files} PROPERTIES + QT_QML_SOURCE_VERSION "2.0;6.0" +) + +qt_internal_add_qml_module(qtquickcontrols2windowsstyleplugin + URI "QtQuick.Controls.Windows" + VERSION "${PROJECT_VERSION}" + CLASS_NAME QtQuickControls2WindowsStylePlugin + IMPORTS + QtQuick.Controls.Fusion/auto + PAST_MAJOR_VERSIONS 2 + PLUGIN_TARGET qtquickcontrols2windowsstyleplugin + NO_PLUGIN_OPTIONAL + NO_GENERATE_PLUGIN_SOURCE + SOURCES + qtquickcontrols2windowsstyleplugin.cpp + QML_FILES + ${qml_files} + DEFINES + QT_NO_CAST_FROM_ASCII + QT_NO_CAST_TO_ASCII + LIBRARIES + Qt::CorePrivate + Qt::GuiPrivate + Qt::QmlPrivate + Qt::QuickControls2Private + Qt::QuickPrivate + Qt::QuickTemplates2Private +) diff --git a/src/quickcontrols2/windows/CheckBox.qml b/src/quickcontrols2/windows/CheckBox.qml new file mode 100644 index 0000000000..13fde0e656 --- /dev/null +++ b/src/quickcontrols2/windows/CheckBox.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Templates as T +import QtQuick.Controls +import QtQuick.Controls.impl +import QtQuick.NativeStyle as NativeStyle + +T.CheckBox { + id: control + + readonly property bool nativeIndicator: indicator instanceof NativeStyle.StyleItem + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding, + implicitIndicatorHeight + topPadding + bottomPadding) + + font.pixelSize: nativeIndicator ? indicator.styleFont(control).pixelSize : undefined + + spacing: nativeIndicator ? 0 : 6 + padding: nativeIndicator ? 0 : 6 + + indicator: NativeStyle.CheckBox { + control: control + y: control.topPadding + (control.availableHeight - height) >> 1 + contentWidth: contentItem.implicitWidth + contentHeight: contentItem.implicitHeight + useNinePatchImage: false + overrideState: NativeStyle.StyleItem.NeverHovered + } + + NativeStyle.CheckBox { + id: hoverCheckBox + control: control + x: indicator.x + y: indicator.y + z: 99 // Needs to be above the "unhovered" indicator + width: indicator.width + height: indicator.height + useNinePatchImage: false + overrideState: NativeStyle.StyleItem.AlwaysHovered + opacity: control.hovered ? 1 : 0 + visible: opacity !== 0 + Behavior on opacity { NumberAnimation { duration: hoverCheckBox.transitionDuration } } + } + + contentItem: CheckLabel { + text: control.text + font: control.font + color: control.palette.windowText + + // For some reason, the other styles set padding here (in the delegate), instead of in + // the control above. And they also adjust the indicator position by setting x and y + // explicitly (instead of using insets). So we follow the same pattern to ensure that + // setting a custom contentItem delegate from the app will end up looking the same for + // all styles. But this should probably be fixed for all styles (to make them work the + // same way as e.g Buttons). + leftPadding: { + if (nativeIndicator) + indicator.contentPadding.left + else + indicator && !mirrored ? indicator.width + spacing : 0 + } + + topPadding: nativeIndicator ? indicator.contentPadding.top : 0 + rightPadding: { + if (nativeIndicator) + indicator.contentPadding.right + else + indicator && mirrored ? indicator.width + spacing : 0 + } + } +} diff --git a/src/quickcontrols2/windows/ComboBox.qml b/src/quickcontrols2/windows/ComboBox.qml new file mode 100644 index 0000000000..237d90b592 --- /dev/null +++ b/src/quickcontrols2/windows/ComboBox.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtQuick.Controls.impl +import QtQuick.Templates as T +import QtQuick.NativeStyle as NativeStyle + +T.ComboBox { + id: control + + readonly property bool __nativeBackground: background instanceof NativeStyle.StyleItem + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding, + 90 /* minimum */ ) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding, + implicitIndicatorHeight + topPadding + bottomPadding) + + font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined + + leftPadding: __nativeBackground ? background.contentPadding.left : 5 + rightPadding: __nativeBackground ? background.contentPadding.right : 5 + topPadding: __nativeBackground ? background.contentPadding.top : 5 + bottomPadding: __nativeBackground ? background.contentPadding.bottom : 5 + + contentItem: T.TextField { + implicitWidth: contentWidth + implicitHeight: contentHeight + text: control.editable ? control.editText : control.displayText + + enabled: control.editable + autoScroll: control.editable + readOnly: control.down + inputMethodHints: control.inputMethodHints + validator: control.validator + selectByMouse: control.selectTextByMouse + + font: control.font + color: control.editable ? control.palette.text : control.palette.buttonText + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + verticalAlignment: Text.AlignVCenter + } + + background: NativeStyle.ComboBox { + control: control + contentWidth: contentItem.implicitWidth + contentHeight: contentItem.implicitHeight + useNinePatchImage: false + } + + delegate: ItemDelegate { + width: ListView.view.width + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData + palette.text: control.palette.text + palette.highlightedText: control.palette.highlightedText + font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal + highlighted: control.highlightedIndex === index + hoverEnabled: control.hoverEnabled + } + + popup: T.Popup { + readonly property var layoutMargins: control.__nativeBackground ? control.background.layoutMargins : null + x: layoutMargins ? layoutMargins.left : 0 + y: control.height - (layoutMargins ? layoutMargins.bottom : 0) + width: control.width - (layoutMargins ? layoutMargins.left + layoutMargins.right : 0) + height: Math.min(contentItem.implicitHeight, control.Window.height - topMargin - bottomMargin) + topMargin: 6 + bottomMargin: 6 + + contentItem: ListView { + clip: true + implicitHeight: contentHeight + model: control.delegateModel + currentIndex: control.highlightedIndex + highlightMoveDuration: 0 + + Rectangle { + z: 10 + width: parent.width + height: parent.height + color: "transparent" + border.color: control.palette.mid + } + + T.ScrollIndicator.vertical: ScrollIndicator { } + } + + background: Rectangle { + color: control.palette.window + } + } +} diff --git a/src/quickcontrols2/windows/Frame.qml b/src/quickcontrols2/windows/Frame.qml new file mode 100644 index 0000000000..f16a083517 --- /dev/null +++ b/src/quickcontrols2/windows/Frame.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultFrame { +} diff --git a/src/quickcontrols2/windows/GroupBox.qml b/src/quickcontrols2/windows/GroupBox.qml new file mode 100644 index 0000000000..4ffbaae6d3 --- /dev/null +++ b/src/quickcontrols2/windows/GroupBox.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultGroupBox { +} diff --git a/src/quickcontrols2/windows/ProgressBar.qml b/src/quickcontrols2/windows/ProgressBar.qml new file mode 100644 index 0000000000..59a1689dba --- /dev/null +++ b/src/quickcontrols2/windows/ProgressBar.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultProgressBar { +} diff --git a/src/quickcontrols2/windows/RadioButton.qml b/src/quickcontrols2/windows/RadioButton.qml new file mode 100644 index 0000000000..82b85698d2 --- /dev/null +++ b/src/quickcontrols2/windows/RadioButton.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultRadioButton { +} diff --git a/src/quickcontrols2/windows/ScrollBar.qml b/src/quickcontrols2/windows/ScrollBar.qml new file mode 100644 index 0000000000..0ccbb1557e --- /dev/null +++ b/src/quickcontrols2/windows/ScrollBar.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultScrollBar { + id: controlRoot + + topPadding: orientation === Qt.Vertical ? controlRoot.__decreaseVisual.indicator.height : 0 + bottomPadding: orientation === Qt.Vertical ? controlRoot.__increaseVisual.indicator.height : 0 + leftPadding: orientation === Qt.Horizontal ? controlRoot.__decreaseVisual.indicator.width : 0 + rightPadding: orientation === Qt.Horizontal ? controlRoot.__increaseVisual.indicator.width : 0 + + contentItem: NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.Handle + } + + NativeStyle.ScrollBar { + // Fade a hovered-looking version of the handle + // on top of the default handle when hovering it + x: contentItem.x + y: contentItem.y + z: 1 + width: contentItem.width + height: contentItem.height + control: controlRoot + subControl: NativeStyle.ScrollBar.Handle + overrideState: NativeStyle.StyleItem.AlwaysHovered + opacity: controlRoot.hovered || control.pressed ? 1 : 0 + visible: contentItem instanceof NativeStyle.StyleItem + Behavior on opacity { NumberAnimation { duration: contentItem.transitionDuration } } + } + + // The groove background should have window color + Rectangle { + x: background.x + y: background.y + z: -1 + width: background.width + height: background.height + color: controlRoot.palette.window + } + + background: NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.Groove + overrideState: NativeStyle.ScrollBar.NeverHovered + } + + __decreaseVisual.indicator: NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.SubLine + overrideState: NativeStyle.ScrollBar.AlwaysHovered + opacity: controlRoot.__decreaseVisual.hovered ? 1 : 0 + visible: contentItem instanceof NativeStyle.StyleItem + Behavior on opacity { NumberAnimation { duration: contentItem.transitionDuration } } + useNinePatchImage: false + } + + NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.SubLine + overrideState: NativeStyle.ScrollBar.AlwaysSunken + opacity: controlRoot.__decreaseVisual.pressed ? 1 : 0 + visible: contentItem instanceof NativeStyle.StyleItem + useNinePatchImage: false + z: 1 + } + + __increaseVisual.indicator: NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.AddLine + x: orientation == Qt.Horizontal ? controlRoot.width - width : 0 + y: orientation == Qt.Vertical ? controlRoot.height - height : 0 + overrideState: NativeStyle.ScrollBar.AlwaysHovered + opacity: controlRoot.__increaseVisual.hovered ? 1 : 0 + visible: contentItem instanceof NativeStyle.StyleItem + Behavior on opacity { NumberAnimation { duration: contentItem.transitionDuration } } + useNinePatchImage: false + } + + NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.AddLine + x: __increaseVisual.indicator.x + y: __increaseVisual.indicator.y + z: 1 + overrideState: NativeStyle.ScrollBar.AlwaysSunken + opacity: controlRoot.__increaseVisual.pressed ? 1 : 0 + visible: contentItem instanceof NativeStyle.StyleItem + useNinePatchImage: false + } +} diff --git a/src/quickcontrols2/windows/ScrollView.qml b/src/quickcontrols2/windows/ScrollView.qml new file mode 100644 index 0000000000..0e5ffff4b6 --- /dev/null +++ b/src/quickcontrols2/windows/ScrollView.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T + +T.ScrollView { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + contentHeight + topPadding + bottomPadding) + + rightPadding: ScrollBar.vertical.visible ? ScrollBar.vertical.width : 0 + bottomPadding: ScrollBar.horizontal.visible ? ScrollBar.horizontal.height : 0 + + ScrollBar.vertical: ScrollBar { + parent: control + x: control.mirrored ? 0 : control.width - width + y: 0 + height: control.height - (control.ScrollBar.horizontal.visible ? control.ScrollBar.horizontal.height : 0) + active: control.ScrollBar.horizontal.active + } + + ScrollBar.horizontal: ScrollBar { + parent: control + x: 0 + y: control.height - height + width: control.width - (control.ScrollBar.vertical.visible ? control.ScrollBar.vertical.width : 0) + active: control.ScrollBar.vertical.active + } +} diff --git a/src/quickcontrols2/windows/Slider.qml b/src/quickcontrols2/windows/Slider.qml new file mode 100644 index 0000000000..ab72fcaabd --- /dev/null +++ b/src/quickcontrols2/windows/Slider.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultSlider { +} diff --git a/src/quickcontrols2/windows/SpinBox.qml b/src/quickcontrols2/windows/SpinBox.qml new file mode 100644 index 0000000000..72309c60cd --- /dev/null +++ b/src/quickcontrols2/windows/SpinBox.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.Templates as T +import QtQuick.NativeStyle as NativeStyle + +T.SpinBox { + id: control + + property bool __nativeBackground: background instanceof NativeStyle.StyleItem + property bool nativeIndicators: up.indicator.hasOwnProperty("_qt_default") + && down.indicator.hasOwnProperty("_qt_default") + + font.pixelSize: __nativeBackground ? background.styleFont(control).pixelSize : undefined + + implicitWidth: Math.max(contentItem.implicitWidth + leftInset + rightInset, + 90 /* minimum */ ) + implicitHeight: Math.max(contentItem.implicitHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight) + + topInset + bottomInset + + spacing: 2 + + leftPadding: __nativeBackground ? background.contentPadding.left: 0 + topPadding: __nativeBackground ? background.contentPadding.top: 0 + rightPadding: (__nativeBackground ? background.contentPadding.right : 0) + rightInset + bottomPadding: __nativeBackground ? background.contentPadding.bottom: 0 + + validator: IntValidator { + locale: control.locale.name + bottom: Math.min(control.from, control.to) + top: Math.max(control.from, control.to) + } + + contentItem: TextField { + text: control.displayText + font: control.font + color: control.palette.text + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + horizontalAlignment: Qt.AlignLeft + verticalAlignment: Qt.AlignVCenter + + topPadding: 0 + bottomPadding: 0 + leftPadding: 10 + rightPadding: 10 + + readOnly: !control.editable + validator: control.validator + inputMethodHints: control.inputMethodHints + + // Since the indicators are embedded inside the TextField we need to avoid that + // the TextField consumes mouse events for that area. + // We achieve that by setting a containmentMask + containmentMask: Item { height: contentItem.height; width: contentItem.width - upAndDown.width } + } + + NativeStyle.SpinBox { + id: upAndDown + control: control + subControl: NativeStyle.SpinBox.Up + visible: nativeIndicators + x: up.indicator.x + y: up.indicator.y + //implicitHeight: contentItem.implicitHeight-2 + height: parent.height-2 + useNinePatchImage: false + z:99 + } + + up.indicator: Item { + x: parent.width - width - 2 + y: 1 + height: upAndDown.height >> 1 + implicitWidth: upAndDown.implicitWidth + implicitHeight: (upAndDown.implicitHeight >> 1) + property bool _qt_default + } + + down.indicator: Item { + x: parent.width - width - 2 + y: up.indicator.y + (upAndDown.height >> 1) + height: upAndDown.height - up.indicator.height + implicitWidth: upAndDown.implicitWidth + implicitHeight: upAndDown.implicitHeight >> 1 + property bool _qt_default + } + + background: Item {} // No background, the TextField will cover the whole control +} diff --git a/src/quickcontrols2/windows/TextArea.qml b/src/quickcontrols2/windows/TextArea.qml new file mode 100644 index 0000000000..f6b883038b --- /dev/null +++ b/src/quickcontrols2/windows/TextArea.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultTextArea { +} diff --git a/src/quickcontrols2/windows/TextField.qml b/src/quickcontrols2/windows/TextField.qml new file mode 100644 index 0000000000..bc0e2cb77a --- /dev/null +++ b/src/quickcontrols2/windows/TextField.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import QtQuick.NativeStyle as NativeStyle + +NativeStyle.DefaultTextField { +} diff --git a/src/quickcontrols2/windows/qtquickcontrols2windowsstyleplugin.cpp b/src/quickcontrols2/windows/qtquickcontrols2windowsstyleplugin.cpp new file mode 100644 index 0000000000..64e77e61c5 --- /dev/null +++ b/src/quickcontrols2/windows/qtquickcontrols2windowsstyleplugin.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQml/qqml.h> +#include <QtQuickControls2/private/qquickstyleplugin_p.h> +#include <QtQuickControls2/qquickstyle.h> + +extern void qml_register_types_QtQuick_Controls_Windows(); + +QT_BEGIN_NAMESPACE + +class QtQuickControls2WindowsStylePlugin : public QQuickStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QtQuickControls2WindowsStylePlugin(QObject *parent = nullptr); + QString name() const override; + void initializeTheme(QQuickTheme *theme) override; +}; + +QtQuickControls2WindowsStylePlugin::QtQuickControls2WindowsStylePlugin(QObject *parent): + QQuickStylePlugin(parent) +{ + volatile auto registration = &qml_register_types_QtQuick_Controls_Windows; + Q_UNUSED(registration); +} + +QString QtQuickControls2WindowsStylePlugin::name() const +{ + return QStringLiteral("Windows"); +} + +void QtQuickControls2WindowsStylePlugin::initializeTheme(QQuickTheme * /*theme*/) +{ +} + +QT_END_NAMESPACE + +#include "qtquickcontrols2windowsstyleplugin.moc" diff --git a/src/quickcontrols2/windows/windows.pri b/src/quickcontrols2/windows/windows.pri new file mode 100644 index 0000000000..7f13eab02f --- /dev/null +++ b/src/quickcontrols2/windows/windows.pri @@ -0,0 +1,14 @@ +QML_FILES += \ + $$PWD/Button.qml \ + $$PWD/CheckBox.qml \ + $$PWD/ComboBox.qml \ + $$PWD/Frame.qml \ + $$PWD/GroupBox.qml \ + $$PWD/ProgressBar.qml \ + $$PWD/RadioButton.qml \ + $$PWD/Slider.qml \ + $$PWD/SpinBox.qml \ + $$PWD/TextArea.qml \ + $$PWD/TextField.qml \ + $$PWD/ScrollBar.qml \ + $$PWD/ScrollView.qml \ |