diff options
Diffstat (limited to 'src/quickcontrols2/macos')
-rw-r--r-- | src/quickcontrols2/macos/Button.qml | 43 | ||||
-rw-r--r-- | src/quickcontrols2/macos/CMakeLists.txt | 49 | ||||
-rw-r--r-- | src/quickcontrols2/macos/CheckBox.qml | 43 | ||||
-rw-r--r-- | src/quickcontrols2/macos/ComboBox.qml | 65 | ||||
-rw-r--r-- | src/quickcontrols2/macos/Dial.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/macos/Frame.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/macos/GroupBox.qml | 60 | ||||
-rw-r--r-- | src/quickcontrols2/macos/ProgressBar.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/macos/RadioButton.qml | 43 | ||||
-rw-r--r-- | src/quickcontrols2/macos/ScrollBar.qml | 64 | ||||
-rw-r--r-- | src/quickcontrols2/macos/ScrollView.qml | 75 | ||||
-rw-r--r-- | src/quickcontrols2/macos/Slider.qml | 68 | ||||
-rw-r--r-- | src/quickcontrols2/macos/SpinBox.qml | 126 | ||||
-rw-r--r-- | src/quickcontrols2/macos/TextArea.qml | 41 | ||||
-rw-r--r-- | src/quickcontrols2/macos/TextField.qml | 43 | ||||
-rw-r--r-- | src/quickcontrols2/macos/macos.pri | 15 | ||||
-rw-r--r-- | src/quickcontrols2/macos/qtquickcontrols2macosstyleplugin.cpp | 75 |
17 files changed, 933 insertions, 0 deletions
diff --git a/src/quickcontrols2/macos/Button.qml b/src/quickcontrols2/macos/Button.qml new file mode 100644 index 0000000000..58658c526f --- /dev/null +++ b/src/quickcontrols2/macos/Button.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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.DefaultButton { + id: control + readonly property Item __focusFrameTarget: control +} diff --git a/src/quickcontrols2/macos/CMakeLists.txt b/src/quickcontrols2/macos/CMakeLists.txt new file mode 100644 index 0000000000..d2578070a7 --- /dev/null +++ b/src/quickcontrols2/macos/CMakeLists.txt @@ -0,0 +1,49 @@ +##################################################################### +## qtquickcontrols2macosstyleplugin Plugin: +##################################################################### + +set(qml_files + "Button.qml" + "Slider.qml" + "GroupBox.qml" + "CheckBox.qml" + "RadioButton.qml" + "SpinBox.qml" + "TextField.qml" + "Frame.qml" + "TextArea.qml" + "ComboBox.qml" + "ScrollView.qml" + "ScrollBar.qml" + "ProgressBar.qml" + "Dial.qml" +) +set_source_files_properties(${qml_files} PROPERTIES + QT_QML_SOURCE_VERSION "2.0;6.0" +) + +qt_internal_add_qml_module(qtquickcontrols2macosstyleplugin + URI "QtQuick.Controls.macOS" + VERSION "${PROJECT_VERSION}" + CLASS_NAME QtQuickControls2MacOSStylePlugin + IMPORTS + QtQuick.Controls.Fusion/auto + PAST_MAJOR_VERSIONS 2 + PLUGIN_TARGET qtquickcontrols2macosstyleplugin + NO_PLUGIN_OPTIONAL + NO_GENERATE_PLUGIN_SOURCE + SOURCES + qtquickcontrols2macosstyleplugin.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/macos/CheckBox.qml b/src/quickcontrols2/macos/CheckBox.qml new file mode 100644 index 0000000000..23ad442634 --- /dev/null +++ b/src/quickcontrols2/macos/CheckBox.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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.DefaultCheckBox { + readonly property Item __focusFrameTarget: indicator + readonly property Item __focusFrameStyleItem: indicator +} diff --git a/src/quickcontrols2/macos/ComboBox.qml b/src/quickcontrols2/macos/ComboBox.qml new file mode 100644 index 0000000000..53baabf8b6 --- /dev/null +++ b/src/quickcontrols2/macos/ComboBox.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 + +NativeStyle.DefaultComboBox { + id: control + readonly property Item __focusFrameTarget: control + + 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 + + readonly property Item __focusFrameControl: control + } +} diff --git a/src/quickcontrols2/macos/Dial.qml b/src/quickcontrols2/macos/Dial.qml new file mode 100644 index 0000000000..2076a54ad6 --- /dev/null +++ b/src/quickcontrols2/macos/Dial.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.DefaultDial { +} diff --git a/src/quickcontrols2/macos/Frame.qml b/src/quickcontrols2/macos/Frame.qml new file mode 100644 index 0000000000..f16a083517 --- /dev/null +++ b/src/quickcontrols2/macos/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/macos/GroupBox.qml b/src/quickcontrols2/macos/GroupBox.qml new file mode 100644 index 0000000000..142ddd15ed --- /dev/null +++ b/src/quickcontrols2/macos/GroupBox.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 { + id: control + label: Item { + readonly property point labelPos : control.__nativeBackground + ? background.labelPos + : Qt.point(0,0) + x: labelPos.x + background.x + y: labelPos.y + background.y - groupBoxPadding.top + width: children[0].implicitWidth + height: children[0].implicitHeight + Text { + width: parent.width + height: parent.height + text: control.title + font: control.font + color: control.palette.windowText + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/src/quickcontrols2/macos/ProgressBar.qml b/src/quickcontrols2/macos/ProgressBar.qml new file mode 100644 index 0000000000..59a1689dba --- /dev/null +++ b/src/quickcontrols2/macos/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/macos/RadioButton.qml b/src/quickcontrols2/macos/RadioButton.qml new file mode 100644 index 0000000000..c9cdf9850c --- /dev/null +++ b/src/quickcontrols2/macos/RadioButton.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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 { + readonly property Item __focusFrameTarget: indicator + readonly property Item __focusFrameStyleItem: indicator +} diff --git a/src/quickcontrols2/macos/ScrollBar.qml b/src/quickcontrols2/macos/ScrollBar.qml new file mode 100644 index 0000000000..4a9f764b2a --- /dev/null +++ b/src/quickcontrols2/macos/ScrollBar.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 + + contentItem: NativeStyle.ScrollBar { + control: controlRoot + subControl: NativeStyle.ScrollBar.Handle + overrideState: NativeStyle.ScrollBar.NeverHovered + } + + 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 + 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 } } + } + +} diff --git a/src/quickcontrols2/macos/ScrollView.qml b/src/quickcontrols2/macos/ScrollView.qml new file mode 100644 index 0000000000..954c5d8aed --- /dev/null +++ b/src/quickcontrols2/macos/ScrollView.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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.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 + + NativeStyle.ScrollViewCorner { + y: parent.height + control: control + visible: control.ScrollBar.horizontal.visible + useNinePatchImage: false + } + } + + 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/macos/Slider.qml b/src/quickcontrols2/macos/Slider.qml new file mode 100644 index 0000000000..77543577d6 --- /dev/null +++ b/src/quickcontrols2/macos/Slider.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 { + id: control + readonly property Item __focusFrameTarget: handle + readonly property Item __focusFrameStyleItem: handle + + background: NativeStyle.Slider { + control: control + subControl: NativeStyle.Slider.Groove | NativeStyle.Slider.Handle + // We normally cannot use a nine patch image for the + // groove if we draw tickmarks (since then the scaling + // would scale the tickmarks too). The groove might + // also use a different background color before, and + // after, the handle. + useNinePatchImage: false + } + + handle: NativeStyle.Slider { + // The handle is hidden, since it will be drawn as a part + // of the background. But will still needs it to be here so + // that we can place the focus rect correctly. + visible: false + + control: control + subControl: NativeStyle.Slider.Handle + x: control.leftPadding + (control.horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) + useNinePatchImage: false + } +} diff --git a/src/quickcontrols2/macos/SpinBox.qml b/src/quickcontrols2/macos/SpinBox.qml new file mode 100644 index 0000000000..5928d37eb5 --- /dev/null +++ b/src/quickcontrols2/macos/SpinBox.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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(implicitBackgroundWidth + leftInset + rightInset, + 90 /* minimum */ ) + implicitHeight: Math.max(implicitBackgroundHeight, up.implicitIndicatorHeight + down.implicitIndicatorHeight) + + topInset + bottomInset + + spacing: 2 + + // Push the background right to make room for the indicators + rightInset: nativeIndicators ? up.implicitIndicatorWidth + spacing : 0 + + 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 + + readonly property Item __focusFrameTarget: contentItem + + validator: IntValidator { + locale: control.locale.name + bottom: Math.min(control.from, control.to) + top: Math.max(control.from, control.to) + } + + contentItem: TextInput { + 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: 2 + bottomPadding: 2 + leftPadding: 10 + rightPadding: 10 + + readOnly: !control.editable + validator: control.validator + inputMethodHints: control.inputMethodHints + + readonly property Item __focusFrameControl: control + } + + NativeStyle.SpinBox { + id: upAndDown + control: control + subControl: NativeStyle.SpinBox.Up + visible: nativeIndicators + x: up.indicator.x + y: up.indicator.y + useNinePatchImage: false + } + + up.indicator: Item { + x: parent.width - width + y: (parent.height / 2) - height + implicitWidth: upAndDown.width + implicitHeight: upAndDown.height / 2 + property bool _qt_default + } + + down.indicator: Item { + x: parent.width - width + y: up.indicator.y + upAndDown.height / 2 + implicitWidth: upAndDown.width + implicitHeight: upAndDown.height / 2 + property bool _qt_default + } + + background: NativeStyle.SpinBox { + control: control + subControl: NativeStyle.SpinBox.Frame + contentWidth: contentItem.implicitWidth + contentHeight: contentItem.implicitHeight + } +} diff --git a/src/quickcontrols2/macos/TextArea.qml b/src/quickcontrols2/macos/TextArea.qml new file mode 100644 index 0000000000..f6b883038b --- /dev/null +++ b/src/quickcontrols2/macos/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/macos/TextField.qml b/src/quickcontrols2/macos/TextField.qml new file mode 100644 index 0000000000..f3a748f604 --- /dev/null +++ b/src/quickcontrols2/macos/TextField.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** 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 { + id: control + readonly property Item __focusFrameTarget: control +} diff --git a/src/quickcontrols2/macos/macos.pri b/src/quickcontrols2/macos/macos.pri new file mode 100644 index 0000000000..d059151e2d --- /dev/null +++ b/src/quickcontrols2/macos/macos.pri @@ -0,0 +1,15 @@ +QML_FILES += \ + $$PWD/Button.qml \ + $$PWD/Slider.qml \ + $$PWD/GroupBox.qml \ + $$PWD/CheckBox.qml \ + $$PWD/RadioButton.qml \ + $$PWD/SpinBox.qml \ + $$PWD/TextField.qml \ + $$PWD/Frame.qml \ + $$PWD/TextArea.qml \ + $$PWD/ComboBox.qml \ + $$PWD/ScrollView.qml \ + $$PWD/ScrollBar.qml \ + $$PWD/ProgressBar.qml \ + $$PWD/Dial.qml \ diff --git a/src/quickcontrols2/macos/qtquickcontrols2macosstyleplugin.cpp b/src/quickcontrols2/macos/qtquickcontrols2macosstyleplugin.cpp new file mode 100644 index 0000000000..9a4fd0ce2b --- /dev/null +++ b/src/quickcontrols2/macos/qtquickcontrols2macosstyleplugin.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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_macOS(); + +QT_BEGIN_NAMESPACE + +class QtQuickControls2MacOSStylePlugin : public QQuickStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QtQuickControls2MacOSStylePlugin(QObject *parent = nullptr); + QString name() const override; + void initializeTheme(QQuickTheme *theme) override; +}; + + +QtQuickControls2MacOSStylePlugin::QtQuickControls2MacOSStylePlugin(QObject *parent): + QQuickStylePlugin(parent) +{ + volatile auto registration = &qml_register_types_QtQuick_Controls_macOS; + Q_UNUSED(registration); +} + +QString QtQuickControls2MacOSStylePlugin::name() const +{ + return QStringLiteral("macOS"); +} + +void QtQuickControls2MacOSStylePlugin::initializeTheme(QQuickTheme */*theme*/) +{ +} + +QT_END_NAMESPACE + +#include "qtquickcontrols2macosstyleplugin.moc" |