aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quickcontrols2/desktopgallery/CustomFrames.qml62
-rw-r--r--examples/quickcontrols2/desktopgallery/Frames.qml65
-rw-r--r--examples/quickcontrols2/desktopgallery/desktopgallery.pro2
-rw-r--r--examples/quickcontrols2/desktopgallery/main.qml2
-rw-r--r--src/imports/controls/macos/Frame.qml43
-rw-r--r--src/imports/controls/macos/macos.pri1
-rw-r--r--src/imports/nativestyle/controls/DefaultFrame.qml68
-rw-r--r--src/imports/nativestyle/controls/controls.pri1
-rw-r--r--src/imports/nativestyle/items/items.pri2
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemframe.cpp65
-rw-r--r--src/imports/nativestyle/items/qquickstyleitemframe.h56
-rw-r--r--src/imports/nativestyle/qmldir1
-rw-r--r--src/imports/nativestyle/qstyle/qquickcommonstyle.cpp7
-rw-r--r--src/imports/nativestyle/qstyle/qquickstyle.h1
14 files changed, 376 insertions, 0 deletions
diff --git a/examples/quickcontrols2/desktopgallery/CustomFrames.qml b/examples/quickcontrols2/desktopgallery/CustomFrames.qml
new file mode 100644
index 00000000..0b74b220
--- /dev/null
+++ b/examples/quickcontrols2/desktopgallery/CustomFrames.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Layouts 2.15
+
+ControlContainer {
+ id: container
+ title: "Frames"
+
+ Row {
+ spacing: container.rowSpacing
+
+ Frame {
+ width: 200
+ height: 50
+ background: Rectangle {
+ border.width: 1
+ border.color: "green"
+ Text {
+ anchors.centerIn: parent
+ color: "green"
+ text: "Custom background"
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols2/desktopgallery/Frames.qml b/examples/quickcontrols2/desktopgallery/Frames.qml
new file mode 100644
index 00000000..91cbec6d
--- /dev/null
+++ b/examples/quickcontrols2/desktopgallery/Frames.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 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Layouts 2.15
+
+ControlContainer {
+ id: container
+ title: "Frames"
+
+ Row {
+ spacing: container.rowSpacing
+
+ Frame {
+ width: 100
+ height: 50
+ }
+
+ Frame {
+ Rectangle {
+ implicitWidth: label.width + 50
+ implicitHeight: 45
+ Label {
+ id: label
+ anchors.centerIn: parent
+ text: "Frame with contents"
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols2/desktopgallery/desktopgallery.pro b/examples/quickcontrols2/desktopgallery/desktopgallery.pro
index 36f9ffe1..493beae7 100644
--- a/examples/quickcontrols2/desktopgallery/desktopgallery.pro
+++ b/examples/quickcontrols2/desktopgallery/desktopgallery.pro
@@ -20,6 +20,8 @@ QML_FILES = \
CustomSpinBoxes.qml \
TextFields.qml \
CustomTextFields.qml \
+ Frames.qml \
+ CustomFrames.qml \
OTHER_FILES += $$QML_FILES
RESOURCES += $$QML_FILES
diff --git a/examples/quickcontrols2/desktopgallery/main.qml b/examples/quickcontrols2/desktopgallery/main.qml
index 5d6af9ba..0d697ad7 100644
--- a/examples/quickcontrols2/desktopgallery/main.qml
+++ b/examples/quickcontrols2/desktopgallery/main.qml
@@ -84,6 +84,7 @@ ApplicationWindow {
RadioButtons { }
SpinBoxes { }
TextFields { }
+ Frames { }
Sliders { }
SlidersSmall { }
SlidersMini { }
@@ -105,6 +106,7 @@ ApplicationWindow {
CustomRadioButtons { }
CustomSpinBoxes { }
CustomTextFields { }
+ CustomFrames { }
CustomSliders { }
}
}
diff --git a/src/imports/controls/macos/Frame.qml b/src/imports/controls/macos/Frame.qml
new file mode 100644
index 00000000..024e31a2
--- /dev/null
+++ b/src/imports/controls/macos/Frame.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 2.12
+import QtQuick.Controls 2.12
+import QtQuick.Controls.impl 2.12
+import QtQuick.NativeStyle 6.0 as NativeStyle
+
+NativeStyle.DefaultFrame {
+}
diff --git a/src/imports/controls/macos/macos.pri b/src/imports/controls/macos/macos.pri
index b4c0a944..de599a49 100644
--- a/src/imports/controls/macos/macos.pri
+++ b/src/imports/controls/macos/macos.pri
@@ -6,3 +6,4 @@ QML_FILES += \
$$PWD/RadioButton.qml \
$$PWD/SpinBox.qml \
$$PWD/TextField.qml \
+ $$PWD/Frame.qml \
diff --git a/src/imports/nativestyle/controls/DefaultFrame.qml b/src/imports/nativestyle/controls/DefaultFrame.qml
new file mode 100644
index 00000000..db80886e
--- /dev/null
+++ b/src/imports/nativestyle/controls/DefaultFrame.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 2.12
+import QtQuick.Controls 2.12
+import QtQuick.Controls.impl 2.12
+import QtQuick.Templates 2.12 as T
+import QtQuick.NativeStyle 6.0 as NativeStyle
+
+T.Frame {
+ id: control
+
+ property bool nativeBackground: background instanceof NativeStyle.StyleItem
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ contentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ contentHeight + topPadding + bottomPadding)
+
+ leftPadding: nativeBackground ? background.contentPadding.left + leftInset : 12
+ rightPadding: nativeBackground ? background.contentPadding.right + rightInset : 12
+ topPadding: nativeBackground ? background.contentPadding.top + topInset : 12
+ bottomPadding: nativeBackground ? background.contentPadding.bottom + bottomInset : 12
+
+ topInset: nativeBackground ? background.insets.top : 0
+ bottomInset: nativeBackground ? background.insets.bottom : 0
+ leftInset: nativeBackground ? background.insets.left : 0
+ rightInset: nativeBackground ? background.insets.right : 0
+
+ background: NativeStyle.Frame {
+ control: control
+ contentWidth: control.contentWidth
+ contentHeight: control.contentHeight
+ }
+}
diff --git a/src/imports/nativestyle/controls/controls.pri b/src/imports/nativestyle/controls/controls.pri
index 16031f3d..eeddfa03 100644
--- a/src/imports/nativestyle/controls/controls.pri
+++ b/src/imports/nativestyle/controls/controls.pri
@@ -6,3 +6,4 @@ QML_FILES += \
$$PWD/DefaultRadioButton.qml \
$$PWD/DefaultSpinBox.qml \
$$PWD/DefaultTextField.qml \
+ $$PWD/DefaultFrame.qml \
diff --git a/src/imports/nativestyle/items/items.pri b/src/imports/nativestyle/items/items.pri
index cb1a9046..8641adff 100644
--- a/src/imports/nativestyle/items/items.pri
+++ b/src/imports/nativestyle/items/items.pri
@@ -9,6 +9,7 @@ HEADERS += \
$$PWD/qquickstyleitemslider.h \
$$PWD/qquickstyleitemspinbox.h \
$$PWD/qquickstyleitemtextfield.h \
+ $$PWD/qquickstyleitemframe.h \
SOURCES += \
$$PWD/qquickstyleitem.cpp \
@@ -19,3 +20,4 @@ SOURCES += \
$$PWD/qquickstyleitemslider.cpp \
$$PWD/qquickstyleitemspinbox.cpp \
$$PWD/qquickstyleitemtextfield.cpp \
+ $$PWD/qquickstyleitemframe.cpp \
diff --git a/src/imports/nativestyle/items/qquickstyleitemframe.cpp b/src/imports/nativestyle/items/qquickstyleitemframe.cpp
new file mode 100644
index 00000000..fe5d1370
--- /dev/null
+++ b/src/imports/nativestyle/items/qquickstyleitemframe.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include "qquickstyleitemframe.h"
+
+StyleItemGeometry QQuickStyleItemFrame::calculateGeometry()
+{
+ QStyleOptionFrame styleOption;
+ initStyleOption(styleOption);
+
+ StyleItemGeometry geometry;
+ geometry.minimumSize = style()->sizeFromContents(QStyle::CT_Frame, &styleOption, QSize(0, 0));
+ geometry.implicitSize = contentSize();
+ styleOption.rect = QRect(QPoint(0, 0), geometry.implicitSize);
+ geometry.contentRect = style()->subElementRect(QStyle::SE_FrameContents, &styleOption);
+ return geometry;
+}
+
+void QQuickStyleItemFrame::paintEvent(QPainter *painter)
+{
+ QStyleOptionFrame styleOption;
+ initStyleOption(styleOption);
+ style()->drawControl(QStyle::CE_ShapedFrame, &styleOption, painter);
+}
+
+void QQuickStyleItemFrame::initStyleOption(QStyleOptionFrame &styleOption)
+{
+ initStyleOptionBase(styleOption);
+ styleOption.lineWidth = 1;
+ styleOption.frameShape = QStyleOptionFrame::StyledPanel;
+ styleOption.features = QStyleOptionFrame::Flat;
+}
diff --git a/src/imports/nativestyle/items/qquickstyleitemframe.h b/src/imports/nativestyle/items/qquickstyleitemframe.h
new file mode 100644
index 00000000..70063ed6
--- /dev/null
+++ b/src/imports/nativestyle/items/qquickstyleitemframe.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTYLEITEMFRAME_H
+#define QQUICKSTYLEITEMFRAME_H
+
+#include "qquickstyleitem.h"
+#include <QtQuickTemplates2/private/qquickframe_p.h>
+
+class QQuickStyleItemFrame : public QQuickStyleItem
+{
+ Q_OBJECT
+ QML_NAMED_ELEMENT(Frame)
+
+protected:
+ void paintEvent(QPainter *painter) override;
+ StyleItemGeometry calculateGeometry() override;
+
+private:
+ void initStyleOption(QStyleOptionFrame &styleOption);
+};
+
+#endif // QQUICKSTYLEITEMFRAME_H
diff --git a/src/imports/nativestyle/qmldir b/src/imports/nativestyle/qmldir
index 435e5e8d..9e2d0da7 100644
--- a/src/imports/nativestyle/qmldir
+++ b/src/imports/nativestyle/qmldir
@@ -10,3 +10,4 @@ DefaultSlider 6.0 controls/DefaultSlider.qml
DefaultGroupBox 6.0 controls/DefaultGroupBox.qml
DefaultSpinBox 6.0 controls/DefaultSpinBox.qml
DefaultTextField 6.0 controls/DefaultTextField.qml
+DefaultFrame 6.0 controls/DefaultFrame.qml
diff --git a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
index 287e88d6..0cb8e848 100644
--- a/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
+++ b/src/imports/nativestyle/qstyle/qquickcommonstyle.cpp
@@ -4666,6 +4666,13 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, c
if (const QStyleOptionSlider *option = qstyleoption_cast<const QStyleOptionSlider *>(opt))
sz = subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderHandle).size();
break;
+ case CT_Frame:
+ if (const QStyleOptionFrame *option = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+ const int ninePatchSplit = 1;
+ int w = qMax(10, (option->lineWidth * 2) + ninePatchSplit);
+ sz = QSize(w, w);
+ }
+ break;
case CT_ScrollBar:
case CT_MenuBar:
case CT_Menu:
diff --git a/src/imports/nativestyle/qstyle/qquickstyle.h b/src/imports/nativestyle/qstyle/qquickstyle.h
index a9278a33..91e09f4b 100644
--- a/src/imports/nativestyle/qstyle/qquickstyle.h
+++ b/src/imports/nativestyle/qstyle/qquickstyle.h
@@ -552,6 +552,7 @@ public:
CT_GroupBox,
CT_MdiControls,
CT_ItemViewItem,
+ CT_Frame,
// do not add any values below/greater than this
CT_CustomBase = 0xf0000000
};