阻抗弹窗
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ApplicationWindowStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.4
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for ApplicationWindow.
|
||||
|
||||
You can create a custom window background by replacing the "background"
|
||||
delegate of ApplicationWindowStyle with a custom design.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
ApplicationWindow {
|
||||
style: ApplicationWindowStyle {
|
||||
background: BorderImage {
|
||||
source: "background.png"
|
||||
border { left: 20; top: 20; right: 20; bottom: 20 }
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
QtObject {
|
||||
/*! The window attached to this style. */
|
||||
readonly property ApplicationWindow control: __control
|
||||
|
||||
/*! A custom background for the window.
|
||||
|
||||
\note The window might have a custom background color set. The custom
|
||||
background color is automatically filled by the window. The background
|
||||
delegate should respect the custom background color by either hiding
|
||||
itself altogether when a custom background color is set, or by letting
|
||||
the custom background color shine through.
|
||||
|
||||
The following read-only property is available within the scope
|
||||
of the background delegate:
|
||||
\table
|
||||
\row \li \b {styleData.hasColor} : bool \li Whether the window has a custom background color set.
|
||||
\endtable
|
||||
*/
|
||||
property Component background: Rectangle {
|
||||
visible: !styleData.hasColor
|
||||
color: SystemPaletteSingleton.window(true)
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
readonly property alias contentArea: contentArea
|
||||
readonly property alias menuBarArea: menuBarArea
|
||||
readonly property alias toolBarArea: toolBarArea
|
||||
readonly property alias statusBarArea: statusBarArea
|
||||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentArea
|
||||
anchors.top: toolBarArea.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: statusBarArea.top
|
||||
}
|
||||
|
||||
Item {
|
||||
id: toolBarArea
|
||||
anchors.top: parent.menuBarArea.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
implicitHeight: childrenRect.height
|
||||
height: visibleChildren.length > 0 ? implicitHeight: 0
|
||||
}
|
||||
|
||||
Item {
|
||||
id: menuBarArea
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
implicitHeight: childrenRect.height
|
||||
height: visibleChildren.length > 0 ? implicitHeight: 0
|
||||
}
|
||||
|
||||
Item {
|
||||
id: statusBarArea
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
implicitHeight: childrenRect.height
|
||||
height: visibleChildren.length > 0 ? implicitHeight: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype BasicTableViewStyle
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\inherits ScrollViewStyle
|
||||
\qmlabstract
|
||||
*/
|
||||
|
||||
ScrollViewStyle {
|
||||
id: root
|
||||
|
||||
/*! \qmlproperty BasicTableView BasicTableViewStyle::control
|
||||
\internal */
|
||||
readonly property BasicTableView control: __control
|
||||
|
||||
/*! \qmlproperty color BasicTableViewStyle::textColor
|
||||
The text color. */
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*! \qmlproperty color BasicTableViewStyle::backgroundColor
|
||||
The background color. */
|
||||
property color backgroundColor: control.backgroundVisible ? SystemPaletteSingleton.base(control.enabled) : "transparent"
|
||||
|
||||
/*! \qmlproperty color BasicTableViewStyle::alternateBackgroundColor
|
||||
The alternate background color. */
|
||||
property color alternateBackgroundColor: "#f5f5f5"
|
||||
|
||||
/*! \qmlproperty color BasicTableViewStyle::highlightedTextColor
|
||||
The text highlight color, used within selections. */
|
||||
property color highlightedTextColor: "white"
|
||||
|
||||
/*! \qmlproperty bool BasicTableViewStyle::activateItemOnSingleClick
|
||||
Activates items on single click.
|
||||
|
||||
Its default value is \c false.
|
||||
*/
|
||||
property bool activateItemOnSingleClick: false
|
||||
|
||||
padding.top: control.headerVisible ? 0 : 1
|
||||
|
||||
/*! \qmlproperty Component BasicTableViewStyle::headerDelegate
|
||||
\internal
|
||||
|
||||
Different documentation for TableViewStyle and TreeViewStyle.
|
||||
See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
|
||||
*/
|
||||
property Component headerDelegate: BorderImage {
|
||||
height: Math.round(textItem.implicitHeight * 1.2)
|
||||
source: "images/header.png"
|
||||
border.left: 4
|
||||
border.bottom: 2
|
||||
border.top: 2
|
||||
Text {
|
||||
id: textItem
|
||||
anchors.fill: parent
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: styleData.textAlignment
|
||||
anchors.leftMargin: horizontalAlignment === Text.AlignLeft ? 12 : 1
|
||||
anchors.rightMargin: horizontalAlignment === Text.AlignRight ? 8 : 1
|
||||
text: styleData.value
|
||||
elide: Text.ElideRight
|
||||
color: textColor
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
Rectangle {
|
||||
width: 1
|
||||
height: parent.height - 2
|
||||
y: 1
|
||||
color: "#ccc"
|
||||
}
|
||||
}
|
||||
|
||||
/*! \qmlproperty Component BasicTableViewStyle::rowDelegate
|
||||
\internal
|
||||
|
||||
Different documentation for TableViewStyle and TreeViewStyle.
|
||||
See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
|
||||
*/
|
||||
property Component rowDelegate: Rectangle {
|
||||
height: Math.round(TextSingleton.implicitHeight * 1.2)
|
||||
property color selectedColor: control.activeFocus ? "#07c" : "#999"
|
||||
color: styleData.selected ? selectedColor :
|
||||
!styleData.alternate ? alternateBackgroundColor : backgroundColor
|
||||
}
|
||||
|
||||
/*! \qmlproperty Component BasicTableViewStyle::itemDelegate
|
||||
\internal
|
||||
|
||||
Different documentation for TableViewStyle and TreeViewStyle.
|
||||
See qtquickcontrolsstyles-tableviewstyle.qdoc and qtquickcontrolsstyles-treeviewstyle.qdoc
|
||||
*/
|
||||
property Component itemDelegate: Item {
|
||||
height: Math.max(16, label.implicitHeight)
|
||||
property int implicitWidth: label.implicitWidth + 20
|
||||
|
||||
Text {
|
||||
id: label
|
||||
objectName: "label"
|
||||
width: parent.width - x - (horizontalAlignment === Text.AlignRight ? 8 : 1)
|
||||
x: (styleData.hasOwnProperty("depth") && styleData.column === 0) ? 0 :
|
||||
horizontalAlignment === Text.AlignRight ? 1 : 8
|
||||
horizontalAlignment: styleData.textAlignment
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1
|
||||
elide: styleData.elideMode
|
||||
text: styleData.value !== undefined ? styleData.value.toString() : ""
|
||||
color: styleData.textColor
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Part of TreeViewStyle
|
||||
*/
|
||||
property Component __branchDelegate: null
|
||||
|
||||
/*! \internal
|
||||
Part of TreeViewStyle
|
||||
*/
|
||||
property int __indentation: 12
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype BusyIndicatorStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.2
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for BusyIndicatorStyle.
|
||||
|
||||
You can create a busy indicator by replacing the "indicator" delegate
|
||||
of the BusyIndicatorStyle with a custom design.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
BusyIndicator {
|
||||
style: BusyIndicatorStyle {
|
||||
indicator: Image {
|
||||
visible: control.running
|
||||
source: "spinner.png"
|
||||
RotationAnimator on rotation {
|
||||
running: control.running
|
||||
loops: Animation.Infinite
|
||||
duration: 2000
|
||||
from: 0 ; to: 360
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
Style {
|
||||
id: indicatorstyle
|
||||
|
||||
/*! The \l BusyIndicator this style is attached to. */
|
||||
readonly property BusyIndicator control: __control
|
||||
|
||||
/*! This defines the appearance of the busy indicator. */
|
||||
property Component indicator: Item {
|
||||
id: indicatorItem
|
||||
|
||||
implicitWidth: 48
|
||||
implicitHeight: 48
|
||||
|
||||
opacity: control.running ? 1 : 0
|
||||
Behavior on opacity { OpacityAnimator { duration: 250 } }
|
||||
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
anchors.alignWhenCentered: true
|
||||
width: Math.min(parent.width, parent.height)
|
||||
height: width
|
||||
source: width <= 32 ? "images/spinner_small.png" :
|
||||
width >= 48 ? "images/spinner_large.png" :
|
||||
"images/spinner_medium.png"
|
||||
RotationAnimator on rotation {
|
||||
duration: 800
|
||||
loops: Animation.Infinite
|
||||
from: 0
|
||||
to: 360
|
||||
running: indicatorItem.visible && (control.running || indicatorItem.opacity > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
anchors.fill: parent
|
||||
implicitWidth: indicatorLoader.implicitWidth
|
||||
implicitHeight: indicatorLoader.implicitHeight
|
||||
|
||||
Loader {
|
||||
id: indicatorLoader
|
||||
sourceComponent: indicator
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width, parent.height)
|
||||
height: width
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ButtonStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Button.
|
||||
|
||||
You can create a custom button by replacing the "background" delegate
|
||||
of the ButtonStyle with a custom design.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
Button {
|
||||
text: "A button"
|
||||
style: ButtonStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 100
|
||||
implicitHeight: 25
|
||||
border.width: control.activeFocus ? 2 : 1
|
||||
border.color: "#888"
|
||||
radius: 4
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
|
||||
GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
If you need a custom label, you can replace the label item.
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: buttonstyle
|
||||
|
||||
/*! The \l {QtQuick.Controls::}{Button} this style is attached to. */
|
||||
readonly property Button control: __control
|
||||
|
||||
/*! The padding between the background and the label components. */
|
||||
padding {
|
||||
top: 4
|
||||
left: 4
|
||||
right: 4 + (control.menu !== null ? Math.round(TextSingleton.implicitHeight * 0.5) : 0)
|
||||
bottom: 4
|
||||
}
|
||||
|
||||
/*! This defines the background of the button. */
|
||||
property Component background: Item {
|
||||
property bool down: control.pressed || (control.checkable && control.checked)
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
|
||||
implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: down ? 0 : -1
|
||||
color: "#10000000"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: down ? "#aaa" : "#fefefe" ; position: 0}
|
||||
GradientStop {color: down ? "#ccc" : "#e3e3e3" ; position: down ? 0.1: 1}
|
||||
}
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
color: control.activeFocus ? "#47b" : "white"
|
||||
opacity: control.hovered || control.activeFocus ? 0.1 : 0
|
||||
Behavior on opacity {NumberAnimation{ duration: 100 }}
|
||||
}
|
||||
}
|
||||
Image {
|
||||
id: imageItem
|
||||
visible: control.menu !== null
|
||||
source: "images/arrow-down.png"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 4
|
||||
opacity: control.enabled ? 0.6 : 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the label of the button. */
|
||||
property Component label: Item {
|
||||
implicitWidth: row.implicitWidth
|
||||
implicitHeight: row.implicitHeight
|
||||
baselineOffset: row.y + text.y + text.baselineOffset
|
||||
Row {
|
||||
id: row
|
||||
anchors.centerIn: parent
|
||||
spacing: 2
|
||||
Image {
|
||||
source: control.iconSource
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
id: text
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: StyleHelpers.stylizeMnemonics(control.text)
|
||||
color: SystemPaletteSingleton.buttonText(control.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
anchors.fill: parent
|
||||
implicitWidth: Math.max(labelLoader.implicitWidth + padding.left + padding.right, backgroundLoader.implicitWidth)
|
||||
implicitHeight: Math.max(labelLoader.implicitHeight + padding.top + padding.bottom, backgroundLoader.implicitHeight)
|
||||
baselineOffset: labelLoader.item ? padding.top + labelLoader.item.baselineOffset : 0
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: labelLoader
|
||||
sourceComponent: label
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.topMargin: padding.top
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.bottomMargin: padding.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,695 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype CalendarStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.3
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for \l Calendar.
|
||||
|
||||
\section2 Component Map
|
||||
|
||||
\image calendarstyle-components-week-numbers.png
|
||||
|
||||
The calendar has the following styleable components:
|
||||
|
||||
\table
|
||||
\row \li \image square-white.png
|
||||
\li \l background
|
||||
\li Fills the entire control.
|
||||
\row \li \image square-yellow.png
|
||||
\li \l navigationBar
|
||||
\li
|
||||
\row \li \image square-green.png
|
||||
\li \l dayOfWeekDelegate
|
||||
\li One instance per day of week.
|
||||
\row \li \image square-red.png
|
||||
\li \l weekNumberDelegate
|
||||
\li One instance per week.
|
||||
\row \li \image square-blue.png
|
||||
\li \l dayDelegate
|
||||
\li One instance per day of month.
|
||||
\endtable
|
||||
|
||||
\section2 Custom Style Example
|
||||
\qml
|
||||
Calendar {
|
||||
anchors.centerIn: parent
|
||||
|
||||
style: CalendarStyle {
|
||||
gridVisible: false
|
||||
dayDelegate: Rectangle {
|
||||
gradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0.00
|
||||
color: styleData.selected ? "#111" : (styleData.visibleMonth && styleData.valid ? "#444" : "#666");
|
||||
}
|
||||
GradientStop {
|
||||
position: 1.00
|
||||
color: styleData.selected ? "#444" : (styleData.visibleMonth && styleData.valid ? "#111" : "#666");
|
||||
}
|
||||
GradientStop {
|
||||
position: 1.00
|
||||
color: styleData.selected ? "#777" : (styleData.visibleMonth && styleData.valid ? "#111" : "#666");
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: styleData.date.getDate()
|
||||
anchors.centerIn: parent
|
||||
color: styleData.valid ? "white" : "grey"
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#555"
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 1
|
||||
height: parent.height
|
||||
color: "#555"
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: calendarStyle
|
||||
|
||||
/*!
|
||||
The Calendar this style is attached to.
|
||||
*/
|
||||
readonly property Calendar control: __control
|
||||
|
||||
/*!
|
||||
The color of the grid lines.
|
||||
*/
|
||||
property color gridColor: "#d3d3d3"
|
||||
|
||||
/*!
|
||||
This property determines the visibility of the grid.
|
||||
|
||||
The default value is \c true.
|
||||
*/
|
||||
property bool gridVisible: true
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
The width of each grid line.
|
||||
*/
|
||||
property real __gridLineWidth: 1
|
||||
|
||||
/*! \internal */
|
||||
property color __horizontalSeparatorColor: gridColor
|
||||
|
||||
/*! \internal */
|
||||
property color __verticalSeparatorColor: gridColor
|
||||
|
||||
function __cellRectAt(index) {
|
||||
return CalendarUtils.cellRectAt(index, control.__panel.columns, control.__panel.rows,
|
||||
control.__panel.availableWidth, control.__panel.availableHeight, gridVisible ? __gridLineWidth : 0);
|
||||
}
|
||||
|
||||
function __isValidDate(date) {
|
||||
return date !== undefined
|
||||
&& date.getTime() >= control.minimumDate.getTime()
|
||||
&& date.getTime() <= control.maximumDate.getTime();
|
||||
}
|
||||
|
||||
/*!
|
||||
The background of the calendar.
|
||||
|
||||
The implicit size of the calendar is calculated based on the implicit size of the background delegate.
|
||||
*/
|
||||
property Component background: Rectangle {
|
||||
color: "#fff"
|
||||
implicitWidth: Math.max(250, Math.round(TextSingleton.implicitHeight * 14))
|
||||
implicitHeight: Math.max(250, Math.round(TextSingleton.implicitHeight * 14))
|
||||
}
|
||||
|
||||
/*!
|
||||
The navigation bar of the calendar.
|
||||
|
||||
Styles the bar at the top of the calendar that contains the
|
||||
next month/previous month buttons and the selected date label.
|
||||
|
||||
The properties provided to the delegate are:
|
||||
\table
|
||||
\row \li readonly property string \b styleData.title
|
||||
\li The title of the calendar.
|
||||
\endtable
|
||||
*/
|
||||
property Component navigationBar: Rectangle {
|
||||
height: Math.round(TextSingleton.implicitHeight * 2.73)
|
||||
color: "#f9f9f9"
|
||||
|
||||
Rectangle {
|
||||
color: Qt.rgba(1,1,1,0.6)
|
||||
height: 1
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
height: 1
|
||||
width: parent.width
|
||||
color: "#ddd"
|
||||
}
|
||||
HoverButton {
|
||||
id: previousMonth
|
||||
width: parent.height
|
||||
height: width
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
source: "images/leftanglearrow.png"
|
||||
onClicked: control.showPreviousMonth()
|
||||
}
|
||||
Label {
|
||||
id: dateText
|
||||
text: styleData.title
|
||||
elide: Text.ElideRight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: TextSingleton.implicitHeight * 1.25
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: previousMonth.right
|
||||
anchors.leftMargin: 2
|
||||
anchors.right: nextMonth.left
|
||||
anchors.rightMargin: 2
|
||||
}
|
||||
HoverButton {
|
||||
id: nextMonth
|
||||
width: parent.height
|
||||
height: width
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
source: "images/rightanglearrow.png"
|
||||
onClicked: control.showNextMonth()
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The delegate that styles each date in the calendar.
|
||||
|
||||
The properties provided to each delegate are:
|
||||
\table
|
||||
\row \li readonly property date \b styleData.date
|
||||
\li The date this delegate represents.
|
||||
\row \li readonly property bool \b styleData.selected
|
||||
\li \c true if this is the selected date.
|
||||
\row \li readonly property int \b styleData.index
|
||||
\li The index of this delegate.
|
||||
\row \li readonly property bool \b styleData.valid
|
||||
\li \c true if this date is greater than or equal to than \l {Calendar::minimumDate}{minimumDate} and
|
||||
less than or equal to \l {Calendar::maximumDate}{maximumDate}.
|
||||
\row \li readonly property bool \b styleData.today
|
||||
\li \c true if this date is equal to today's date.
|
||||
\row \li readonly property bool \b styleData.visibleMonth
|
||||
\li \c true if the month in this date is the visible month.
|
||||
\row \li readonly property bool \b styleData.hovered
|
||||
\li \c true if the mouse is over this cell.
|
||||
\note This property is \c true even when the mouse is hovered over an invalid date.
|
||||
\row \li readonly property bool \b styleData.pressed
|
||||
\li \c true if the mouse is pressed on this cell.
|
||||
\note This property is \c true even when the mouse is pressed on an invalid date.
|
||||
\endtable
|
||||
*/
|
||||
property Component dayDelegate: Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: (!addExtraMargin || control.weekNumbersVisible) && styleData.index % CalendarUtils.daysInAWeek === 0 ? 0 : -1
|
||||
anchors.rightMargin: !addExtraMargin && styleData.index % CalendarUtils.daysInAWeek === CalendarUtils.daysInAWeek - 1 ? 0 : -1
|
||||
anchors.bottomMargin: !addExtraMargin && styleData.index >= CalendarUtils.daysInAWeek * (CalendarUtils.weeksOnACalendarMonth - 1) ? 0 : -1
|
||||
anchors.topMargin: styleData.selected ? -1 : 0
|
||||
color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "transparent"
|
||||
|
||||
readonly property bool addExtraMargin: control.frameVisible && styleData.selected
|
||||
readonly property color sameMonthDateTextColor: "#444"
|
||||
readonly property color selectedDateColor: Qt.platform.os === "osx" ? "#3778d0" : SystemPaletteSingleton.highlight(control.enabled)
|
||||
readonly property color selectedDateTextColor: "white"
|
||||
readonly property color differentMonthDateTextColor: "#bbb"
|
||||
readonly property color invalidDateColor: "#dddddd"
|
||||
Label {
|
||||
id: dayDelegateText
|
||||
text: styleData.date.getDate()
|
||||
anchors.centerIn: parent
|
||||
horizontalAlignment: Text.AlignRight
|
||||
font.pixelSize: Math.min(parent.height/3, parent.width/3)
|
||||
color: {
|
||||
var theColor = invalidDateColor;
|
||||
if (styleData.valid) {
|
||||
// Date is within the valid range.
|
||||
theColor = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor;
|
||||
if (styleData.selected)
|
||||
theColor = selectedDateTextColor;
|
||||
}
|
||||
theColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The delegate that styles each weekday.
|
||||
|
||||
The height of the weekday row is calculated based on the maximum implicit height of the delegates.
|
||||
|
||||
The properties provided to each delegate are:
|
||||
\table
|
||||
\row \li readonly property int \b styleData.index
|
||||
\li The index (0-6) of the delegate.
|
||||
\row \li readonly property int \b styleData.dayOfWeek
|
||||
\li The day of the week this delegate represents. Possible values:
|
||||
\list
|
||||
\li \c Locale.Sunday
|
||||
\li \c Locale.Monday
|
||||
\li \c Locale.Tuesday
|
||||
\li \c Locale.Wednesday
|
||||
\li \c Locale.Thursday
|
||||
\li \c Locale.Friday
|
||||
\li \c Locale.Saturday
|
||||
\endlist
|
||||
\endtable
|
||||
*/
|
||||
property Component dayOfWeekDelegate: Rectangle {
|
||||
color: gridVisible ? "#fcfcfc" : "transparent"
|
||||
implicitHeight: Math.round(TextSingleton.implicitHeight * 2.25)
|
||||
Label {
|
||||
text: control.locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat)
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The delegate that styles each week number.
|
||||
|
||||
The width of the week number column is calculated based on the maximum implicit width of the delegates.
|
||||
|
||||
The properties provided to each delegate are:
|
||||
\table
|
||||
\row \li readonly property int \b styleData.index
|
||||
\li The index (0-5) of the delegate.
|
||||
\row \li readonly property int \b styleData.weekNumber
|
||||
\li The number of the week this delegate represents.
|
||||
\endtable
|
||||
*/
|
||||
property Component weekNumberDelegate: Rectangle {
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight * 2)
|
||||
Label {
|
||||
text: styleData.weekNumber
|
||||
anchors.centerIn: parent
|
||||
color: "#444"
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
id: panelItem
|
||||
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: backgroundLoader.implicitHeight
|
||||
|
||||
property alias navigationBarItem: navigationBarLoader.item
|
||||
|
||||
property alias dayOfWeekHeaderRow: dayOfWeekHeaderRow
|
||||
|
||||
readonly property int weeksToShow: 6
|
||||
readonly property int rows: weeksToShow
|
||||
readonly property int columns: CalendarUtils.daysInAWeek
|
||||
|
||||
// The combined available width and height to be shared amongst each cell.
|
||||
readonly property real availableWidth: viewContainer.width
|
||||
readonly property real availableHeight: viewContainer.height
|
||||
|
||||
property int hoveredCellIndex: -1
|
||||
property int pressedCellIndex: -1
|
||||
property int pressCellIndex: -1
|
||||
property var pressDate: null
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
border.color: gridColor
|
||||
visible: control.frameVisible
|
||||
}
|
||||
|
||||
Item {
|
||||
id: container
|
||||
anchors.fill: parent
|
||||
anchors.margins: control.frameVisible ? 1 : 0
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: navigationBarLoader
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
sourceComponent: navigationBar
|
||||
active: control.navigationBarVisible
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property string title: control.locale.standaloneMonthName(control.visibleMonth)
|
||||
+ new Date(control.visibleYear, control.visibleMonth, 1).toLocaleDateString(control.locale, " yyyy")
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: dayOfWeekHeaderRow
|
||||
anchors.top: navigationBarLoader.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: (control.weekNumbersVisible ? weekNumbersItem.width : 0)
|
||||
anchors.right: parent.right
|
||||
spacing: gridVisible ? __gridLineWidth : 0
|
||||
property alias __repeater: repeater
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: CalendarHeaderModel {
|
||||
locale: control.locale
|
||||
}
|
||||
Loader {
|
||||
id: dayOfWeekDelegateLoader
|
||||
sourceComponent: dayOfWeekDelegate
|
||||
width: __cellRectAt(index).width
|
||||
|
||||
readonly property int __index: index
|
||||
readonly property var __dayOfWeek: dayOfWeek
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: dayOfWeekDelegateLoader.__index
|
||||
readonly property alias dayOfWeek: dayOfWeekDelegateLoader.__dayOfWeek
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: topGridLine
|
||||
color: __horizontalSeparatorColor
|
||||
width: parent.width
|
||||
height: __gridLineWidth
|
||||
visible: gridVisible
|
||||
anchors.top: dayOfWeekHeaderRow.bottom
|
||||
}
|
||||
|
||||
Row {
|
||||
id: gridRow
|
||||
width: weekNumbersItem.width + viewContainer.width
|
||||
height: viewContainer.height
|
||||
anchors.top: topGridLine.bottom
|
||||
|
||||
Column {
|
||||
id: weekNumbersItem
|
||||
visible: control.weekNumbersVisible
|
||||
height: viewContainer.height
|
||||
spacing: gridVisible ? __gridLineWidth : 0
|
||||
Repeater {
|
||||
id: weekNumberRepeater
|
||||
model: panelItem.weeksToShow
|
||||
|
||||
Loader {
|
||||
id: weekNumberDelegateLoader
|
||||
height: __cellRectAt(index * panelItem.columns).height
|
||||
sourceComponent: weekNumberDelegate
|
||||
|
||||
readonly property int __index: index
|
||||
property int __weekNumber: control.__model.weekNumberAt(index)
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onVisibleMonthChanged: __weekNumber = control.__model.weekNumberAt(index)
|
||||
onVisibleYearChanged: __weekNumber = control.__model.weekNumberAt(index)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: control.__model
|
||||
onCountChanged: __weekNumber = control.__model.weekNumberAt(index)
|
||||
}
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: weekNumberDelegateLoader.__index
|
||||
readonly property int weekNumber: weekNumberDelegateLoader.__weekNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: separator
|
||||
anchors.topMargin: - dayOfWeekHeaderRow.height - 1
|
||||
anchors.top: weekNumbersItem.top
|
||||
anchors.bottom: weekNumbersItem.bottom
|
||||
|
||||
width: __gridLineWidth
|
||||
color: __verticalSeparatorColor
|
||||
visible: control.weekNumbersVisible
|
||||
}
|
||||
|
||||
// Contains the grid lines and the grid itself.
|
||||
Item {
|
||||
id: viewContainer
|
||||
width: container.width - (control.weekNumbersVisible ? weekNumbersItem.width + separator.width : 0)
|
||||
height: container.height - navigationBarLoader.height - dayOfWeekHeaderRow.height - topGridLine.height
|
||||
|
||||
Repeater {
|
||||
id: verticalGridLineRepeater
|
||||
model: panelItem.columns - 1
|
||||
delegate: Rectangle {
|
||||
x: __cellRectAt(index + 1).x - __gridLineWidth
|
||||
y: 0
|
||||
width: __gridLineWidth
|
||||
height: viewContainer.height
|
||||
color: gridColor
|
||||
visible: gridVisible
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: horizontalGridLineRepeater
|
||||
model: panelItem.rows - 1
|
||||
delegate: Rectangle {
|
||||
x: 0
|
||||
y: __cellRectAt((index + 1) * panelItem.columns).y - __gridLineWidth
|
||||
width: viewContainer.width
|
||||
height: __gridLineWidth
|
||||
color: gridColor
|
||||
visible: gridVisible
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
|
||||
function cellIndexAt(mouseX, mouseY) {
|
||||
var viewContainerPos = viewContainer.mapFromItem(mouseArea, mouseX, mouseY);
|
||||
var child = viewContainer.childAt(viewContainerPos.x, viewContainerPos.y);
|
||||
// In the tests, the mouseArea sometimes gets picked instead of the cells,
|
||||
// probably because stuff is still loading. To be safe, we check for that here.
|
||||
return child && child !== mouseArea ? child.__index : -1;
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
hoveredCellIndex = cellIndexAt(mouseX, mouseY);
|
||||
if (hoveredCellIndex === undefined) {
|
||||
hoveredCellIndex = cellIndexAt(mouseX, mouseY);
|
||||
}
|
||||
|
||||
var date = view.model.dateAt(hoveredCellIndex);
|
||||
if (__isValidDate(date)) {
|
||||
control.hovered(date);
|
||||
}
|
||||
}
|
||||
|
||||
onExited: {
|
||||
hoveredCellIndex = -1;
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
|
||||
var previousHoveredCellIndex = hoveredCellIndex;
|
||||
hoveredCellIndex = indexOfCell;
|
||||
if (indexOfCell !== -1) {
|
||||
var date = view.model.dateAt(indexOfCell);
|
||||
if (__isValidDate(date)) {
|
||||
if (hoveredCellIndex !== previousHoveredCellIndex)
|
||||
control.hovered(date);
|
||||
|
||||
// The date must be different for the pressed signal to be emitted.
|
||||
if (pressed && date.getTime() !== control.selectedDate.getTime()) {
|
||||
control.pressed(date);
|
||||
|
||||
// You can't select dates in a different month while dragging.
|
||||
if (date.getMonth() === control.selectedDate.getMonth()) {
|
||||
control.selectedDate = date;
|
||||
pressedCellIndex = indexOfCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
pressCellIndex = cellIndexAt(mouse.x, mouse.y);
|
||||
pressDate = null;
|
||||
if (pressCellIndex !== -1) {
|
||||
var date = view.model.dateAt(pressCellIndex);
|
||||
pressedCellIndex = pressCellIndex;
|
||||
pressDate = date;
|
||||
if (__isValidDate(date)) {
|
||||
control.selectedDate = date;
|
||||
control.pressed(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
|
||||
if (indexOfCell !== -1) {
|
||||
// The cell index might be valid, but the date has to be too. We could let the
|
||||
// selected date validation take care of this, but then the selected date would
|
||||
// change to the earliest day if a day before the minimum date is clicked, for example.
|
||||
var date = view.model.dateAt(indexOfCell);
|
||||
if (__isValidDate(date)) {
|
||||
control.released(date);
|
||||
}
|
||||
}
|
||||
pressedCellIndex = -1;
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
|
||||
if (indexOfCell !== -1 && indexOfCell === pressCellIndex) {
|
||||
if (__isValidDate(pressDate))
|
||||
control.clicked(pressDate);
|
||||
}
|
||||
}
|
||||
|
||||
onDoubleClicked: {
|
||||
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
|
||||
if (indexOfCell !== -1) {
|
||||
var date = view.model.dateAt(indexOfCell);
|
||||
if (__isValidDate(date))
|
||||
control.doubleClicked(date);
|
||||
}
|
||||
}
|
||||
|
||||
onPressAndHold: {
|
||||
var indexOfCell = cellIndexAt(mouse.x, mouse.y);
|
||||
if (indexOfCell !== -1 && indexOfCell === pressCellIndex) {
|
||||
var date = view.model.dateAt(indexOfCell);
|
||||
if (__isValidDate(date))
|
||||
control.pressAndHold(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onSelectedDateChanged: view.selectedDateChanged()
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: view
|
||||
|
||||
property int currentIndex: -1
|
||||
|
||||
model: control.__model
|
||||
|
||||
Component.onCompleted: selectedDateChanged()
|
||||
|
||||
function selectedDateChanged() {
|
||||
if (model !== undefined && model.locale !== undefined) {
|
||||
currentIndex = model.indexAt(control.selectedDate);
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Loader {
|
||||
id: delegateLoader
|
||||
|
||||
x: __cellRectAt(index).x
|
||||
y: __cellRectAt(index).y
|
||||
width: __cellRectAt(index).width
|
||||
height: __cellRectAt(index).height
|
||||
sourceComponent: dayDelegate
|
||||
|
||||
readonly property int __index: index
|
||||
readonly property date __date: date
|
||||
// We rely on the fact that an invalid QDate will be converted to a Date
|
||||
// whose year is -4713, which is always an invalid date since our
|
||||
// earliest minimum date is the year 1.
|
||||
readonly property bool valid: __isValidDate(date)
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: delegateLoader.__index
|
||||
readonly property bool selected: control.selectedDate.getFullYear() === date.getFullYear() &&
|
||||
control.selectedDate.getMonth() === date.getMonth() &&
|
||||
control.selectedDate.getDate() === date.getDate()
|
||||
readonly property alias date: delegateLoader.__date
|
||||
readonly property bool valid: delegateLoader.valid
|
||||
// TODO: this will not be correct if the app is running when a new day begins.
|
||||
readonly property bool today: date.getTime() === new Date().setHours(0, 0, 0, 0)
|
||||
readonly property bool visibleMonth: date.getMonth() === control.visibleMonth
|
||||
readonly property bool hovered: panelItem.hoveredCellIndex == index
|
||||
readonly property bool pressed: panelItem.pressedCellIndex == index
|
||||
// todo: pressed property here, clicked and doubleClicked in the control itself
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Window 2.1
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype CheckBoxStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for CheckBox.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
CheckBox {
|
||||
text: "Check Box"
|
||||
style: CheckBoxStyle {
|
||||
indicator: Rectangle {
|
||||
implicitWidth: 16
|
||||
implicitHeight: 16
|
||||
radius: 3
|
||||
border.color: control.activeFocus ? "darkblue" : "gray"
|
||||
border.width: 1
|
||||
Rectangle {
|
||||
visible: control.checked
|
||||
color: "#555"
|
||||
border.color: "#333"
|
||||
radius: 1
|
||||
anchors.margins: 4
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
Style {
|
||||
id: checkboxStyle
|
||||
|
||||
/*! The \l CheckBox this style is attached to. */
|
||||
readonly property CheckBox control: __control
|
||||
|
||||
/*! This defines the text label. */
|
||||
property Component label: Item {
|
||||
implicitWidth: text.implicitWidth + 2
|
||||
implicitHeight: text.implicitHeight
|
||||
baselineOffset: text.baselineOffset
|
||||
Rectangle {
|
||||
anchors.fill: text
|
||||
anchors.margins: -1
|
||||
anchors.leftMargin: -3
|
||||
anchors.rightMargin: -3
|
||||
visible: control.activeFocus
|
||||
height: 6
|
||||
radius: 3
|
||||
color: "#224f9fef"
|
||||
border.color: "#47b"
|
||||
opacity: 0.6
|
||||
}
|
||||
Text {
|
||||
id: text
|
||||
text: StyleHelpers.stylizeMnemonics(control.text)
|
||||
anchors.centerIn: parent
|
||||
color: SystemPaletteSingleton.text(control.enabled)
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
}
|
||||
/*! The background under indicator and label. */
|
||||
property Component background
|
||||
|
||||
/*! The spacing between indicator and label. */
|
||||
property int spacing: Math.round(TextSingleton.implicitHeight/4)
|
||||
|
||||
/*! This defines the indicator button. */
|
||||
property Component indicator: Item {
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight)
|
||||
implicitHeight: implicitWidth
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: -1
|
||||
color: "#44ffffff"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#eee" ; position: 0}
|
||||
GradientStop {color: control.pressed ? "#eee" : "#fff" ; position: 0.1}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "images/check.png"
|
||||
opacity: control.checkedState === Qt.Checked ? control.enabled ? 1 : 0.5 : 0
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: 1
|
||||
Behavior on opacity {NumberAnimation {duration: 80}}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Math.round(baserect.radius)
|
||||
antialiasing: true
|
||||
gradient: Gradient {
|
||||
GradientStop {color: control.pressed ? "#555" : "#999" ; position: 0}
|
||||
GradientStop {color: "#555" ; position: 1}
|
||||
}
|
||||
radius: baserect.radius - 1
|
||||
anchors.centerIn: parent
|
||||
anchors.alignWhenCentered: true
|
||||
border.color: "#222"
|
||||
Behavior on opacity {NumberAnimation {duration: 80}}
|
||||
opacity: control.checkedState === Qt.PartiallyChecked ? control.enabled ? 1 : 0.5 : 0
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: Math.max(backgroundLoader.implicitWidth, row.implicitWidth + padding.left + padding.right)
|
||||
implicitHeight: Math.max(backgroundLoader.implicitHeight, labelLoader.implicitHeight + padding.top + padding.bottom,indicatorLoader.implicitHeight + padding.top + padding.bottom)
|
||||
baselineOffset: labelLoader.item ? padding.top + labelLoader.item.baselineOffset : 0
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: background
|
||||
anchors.fill: parent
|
||||
}
|
||||
RowLayout {
|
||||
id: row
|
||||
anchors.fill: parent
|
||||
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.topMargin: padding.top
|
||||
anchors.bottomMargin: padding.bottom
|
||||
|
||||
spacing: checkboxStyle.spacing
|
||||
Loader {
|
||||
id: indicatorLoader
|
||||
sourceComponent: indicator
|
||||
}
|
||||
Loader {
|
||||
id: labelLoader
|
||||
Layout.fillWidth: true
|
||||
sourceComponent: label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
|
||||
ButtonStyle {
|
||||
id: buttonStyle
|
||||
|
||||
label: Text {
|
||||
anchors.fill: parent
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: control.text
|
||||
font.pixelSize: TextSingleton.font.pixelSize * 1.25
|
||||
color: control.pressed || control.checked ? __buttonHelper.textColorDown : __buttonHelper.textColorUp
|
||||
styleColor: control.pressed || control.checked ? __buttonHelper.textRaisedColorDown : __buttonHelper.textRaisedColorUp
|
||||
style: Text.Raised
|
||||
wrapMode: Text.Wrap
|
||||
fontSizeMode: Text.Fit
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property alias __buttonHelper: buttonHelper
|
||||
|
||||
CircularButtonStyleHelper {
|
||||
id: buttonHelper
|
||||
control: buttonStyle.control
|
||||
}
|
||||
|
||||
background: Item {
|
||||
implicitWidth: __buttonHelper.implicitWidth
|
||||
implicitHeight: __buttonHelper.implicitHeight
|
||||
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onPressedChanged: backgroundCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
__buttonHelper.paintBackground(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,497 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype CircularGaugeStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for CircularGauge.
|
||||
|
||||
You can create a custom circular gauge by replacing the following delegates:
|
||||
\list
|
||||
\li \l background
|
||||
\li \l tickmark
|
||||
\li \l minorTickmark
|
||||
\li \l tickmarkLabel
|
||||
\li \l needle
|
||||
\li \l foreground
|
||||
\endlist
|
||||
|
||||
Below is an example that changes the needle to a basic orange \l Rectangle:
|
||||
\code
|
||||
CircularGauge {
|
||||
style: CircularGaugeStyle {
|
||||
needle: Rectangle {
|
||||
y: outerRadius * 0.15
|
||||
implicitWidth: outerRadius * 0.03
|
||||
implicitHeight: outerRadius * 0.9
|
||||
antialiasing: true
|
||||
color: Qt.rgba(0.66, 0.3, 0, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
The result:
|
||||
\image circulargauge-needle-example-2.png CircularGaugeStyle example
|
||||
|
||||
\section2 Direction
|
||||
|
||||
\l minimumValueAngle and \l maximumValueAngle determine not only the
|
||||
position of the tickmarks, labels and needle, but the direction in which
|
||||
they are displayed around the gauge. For example, if \l minimumValueAngle
|
||||
is greater than \l maximumValueAngle, the gauge will be anti-clockwise.
|
||||
Below, there are two gauges: the top gauge has a \l minimumValueAngle of
|
||||
\c -90 degrees and a \l maximumValueAngle of \c 90 degrees, and the bottom
|
||||
gauge has the opposite.
|
||||
|
||||
\image circulargauge-reversed.png Reversed CircularGauge
|
||||
|
||||
\sa {Styling CircularGauge}
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: circularGaugeStyle
|
||||
|
||||
/*!
|
||||
The \l CircularGauge that this style is attached to.
|
||||
*/
|
||||
readonly property CircularGauge control: __control
|
||||
|
||||
/*!
|
||||
The distance from the center of the gauge to the outer edge of the
|
||||
gauge.
|
||||
|
||||
This property is useful for determining the size of the various
|
||||
components of the style, in order to ensure that they are scaled
|
||||
proportionately when the gauge is resized.
|
||||
*/
|
||||
readonly property real outerRadius: Math.min(control.width, control.height) * 0.5
|
||||
|
||||
/*!
|
||||
This property determines the angle at which the minimum value is
|
||||
displayed on the gauge.
|
||||
|
||||
The angle set affects the following components of the gauge:
|
||||
\list
|
||||
\li The angle of the needle
|
||||
\li The position of the tickmarks and labels
|
||||
\endlist
|
||||
|
||||
The angle origin points north:
|
||||
|
||||
\image circulargauge-angles.png
|
||||
|
||||
There is no minimum or maximum angle for this property, but the default
|
||||
style only supports angles whose absolute range is less than or equal
|
||||
to \c 360 degrees. This is because ranges higher than \c 360 degrees
|
||||
will cause the tickmarks and labels to overlap each other.
|
||||
|
||||
The default value is \c -145.
|
||||
*/
|
||||
property real minimumValueAngle: -145
|
||||
|
||||
/*!
|
||||
This property determines the angle at which the maximum value is
|
||||
displayed on the gauge.
|
||||
|
||||
The angle set affects the following components of the gauge:
|
||||
\list
|
||||
\li The angle of the needle
|
||||
\li The position of the tickmarks and labels
|
||||
\endlist
|
||||
|
||||
The angle origin points north:
|
||||
|
||||
\image circulargauge-angles.png
|
||||
|
||||
There is no minimum or maximum angle for this property, but the default
|
||||
style only supports angles whose absolute range is less than or equal
|
||||
to \c 360 degrees. This is because ranges higher than \c 360 degrees
|
||||
will cause the tickmarks and labels to overlap each other.
|
||||
|
||||
The default value is \c 145.
|
||||
*/
|
||||
property real maximumValueAngle: 145
|
||||
|
||||
/*!
|
||||
The range between \l minimumValueAngle and \l maximumValueAngle, in
|
||||
degrees. This value will always be positive.
|
||||
*/
|
||||
readonly property real angleRange: control.__panel.circularTickmarkLabel.angleRange
|
||||
|
||||
/*!
|
||||
This property holds the rotation of the needle in degrees.
|
||||
*/
|
||||
property real needleRotation: {
|
||||
var percentage = (control.value - control.minimumValue) / (control.maximumValue - control.minimumValue);
|
||||
minimumValueAngle + percentage * angleRange;
|
||||
}
|
||||
|
||||
/*!
|
||||
The interval at which tickmarks are displayed.
|
||||
|
||||
For example, if this property is set to \c 10 (the default),
|
||||
control.minimumValue to \c 0, and control.maximumValue to \c 100,
|
||||
the tickmarks displayed will be 0, 10, 20, etc., to 100,
|
||||
around the gauge.
|
||||
*/
|
||||
property real tickmarkStepSize: 10
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the gauge (outerRadius) at
|
||||
which the outermost point of the tickmark line is drawn.
|
||||
*/
|
||||
property real tickmarkInset: 0
|
||||
|
||||
|
||||
/*!
|
||||
The amount of tickmarks displayed by the gauge, calculated from
|
||||
\l tickmarkStepSize and the control's
|
||||
\l {CircularGauge::minimumValue}{minimumValue} and
|
||||
\l {CircularGauge::maximumValue}{maximumValue}.
|
||||
|
||||
\sa minorTickmarkCount
|
||||
*/
|
||||
readonly property int tickmarkCount: control.__panel.circularTickmarkLabel.tickmarkCount
|
||||
|
||||
/*!
|
||||
The amount of minor tickmarks between each tickmark.
|
||||
|
||||
The default value is \c 4.
|
||||
|
||||
\sa tickmarkCount
|
||||
*/
|
||||
property int minorTickmarkCount: 4
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the gauge (outerRadius) at
|
||||
which the outermost point of the minor tickmark line is drawn.
|
||||
*/
|
||||
property real minorTickmarkInset: 0
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the gauge (outerRadius) at
|
||||
which the center of the value marker text is drawn.
|
||||
*/
|
||||
property real labelInset: __protectedScope.toPixels(0.19)
|
||||
|
||||
/*!
|
||||
The interval at which tickmark labels are displayed.
|
||||
|
||||
For example, if this property is set to \c 10 (the default),
|
||||
control.minimumValue to \c 0, and control.maximumValue to \c 100, the
|
||||
tickmark labels displayed will be 0, 10, 20, etc., to 100,
|
||||
around the gauge.
|
||||
*/
|
||||
property real labelStepSize: tickmarkStepSize
|
||||
|
||||
/*!
|
||||
The amount of tickmark labels displayed by the gauge, calculated from
|
||||
\l labelStepSize and the control's
|
||||
\l {CircularGauge::minimumValue}{minimumValue} and
|
||||
\l {CircularGauge::maximumValue}{maximumValue}.
|
||||
|
||||
\sa tickmarkCount, minorTickmarkCount
|
||||
*/
|
||||
readonly property int labelCount: control.__panel.circularTickmarkLabel.labelCount
|
||||
|
||||
/*! \qmlmethod real CircularGaugeStyle::valueToAngle(real value)
|
||||
Returns \a value as an angle in degrees.
|
||||
|
||||
This function is useful for custom drawing or positioning of items in
|
||||
the style's components. For example, it can be used to calculate the
|
||||
angles at which to draw an arc around the gauge indicating the safe
|
||||
area for the needle to be within.
|
||||
|
||||
For example, if minimumValueAngle is set to \c 270 and
|
||||
maximumValueAngle is set to \c 90, this function will return \c 270
|
||||
when passed minimumValue and \c 90 when passed maximumValue.
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-background}{
|
||||
Styling CircularGauge's background}
|
||||
*/
|
||||
function valueToAngle(value) {
|
||||
return control.__panel.circularTickmarkLabel.valueToAngle(value);
|
||||
}
|
||||
|
||||
property QtObject __protectedScope: QtObject {
|
||||
/*!
|
||||
Converts a value expressed as a percentage of \l outerRadius to
|
||||
a pixel value.
|
||||
*/
|
||||
function toPixels(percentageOfOuterRadius) {
|
||||
return percentageOfOuterRadius * outerRadius;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The background of the gauge.
|
||||
|
||||
If set, the background determines the implicit size of the gauge.
|
||||
|
||||
By default, there is no background defined.
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-background}{
|
||||
Styling CircularGauge's background}
|
||||
*/
|
||||
property Component background
|
||||
|
||||
/*!
|
||||
This component defines each individual tickmark. The position of each
|
||||
tickmark is already set; only the
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight} need to be specified.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this tickmark represents.
|
||||
\endtable
|
||||
|
||||
To illustrate what these properties refer to, we can use the following
|
||||
example:
|
||||
|
||||
\snippet circulargauge-tickmark-indices-values.qml tickmarks
|
||||
|
||||
We've replaced the conventional \e line tickmarks with \l Text items
|
||||
and have hidden the tickmarkLabel component in order to make the
|
||||
association clearer:
|
||||
|
||||
\image circulargauge-tickmark-indices-values.png Tickmarks
|
||||
|
||||
The index property can be useful if you have another model that
|
||||
contains images to display for each index, for example.
|
||||
|
||||
The value property is useful for drawing lower and upper limits around
|
||||
the gauge to indicate the recommended value ranges. For example, speeds
|
||||
above 200 kilometers an hour in a car's speedometer could be indicated
|
||||
as dangerous using this property.
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-tickmark}{
|
||||
Styling CircularGauge's tickmark}
|
||||
*/
|
||||
property Component tickmark: Rectangle {
|
||||
implicitWidth: outerRadius * 0.02
|
||||
antialiasing: true
|
||||
implicitHeight: outerRadius * 0.06
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each individual minor tickmark. The position of
|
||||
each minor tickmark is already set; only the
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight} need to be specified.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this tickmark represents.
|
||||
\endtable
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-minorTickmark}{
|
||||
Styling CircularGauge's minorTickmark}
|
||||
*/
|
||||
property Component minorTickmark: Rectangle {
|
||||
implicitWidth: outerRadius * 0.01
|
||||
antialiasing: true
|
||||
implicitHeight: outerRadius * 0.03
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
/*!
|
||||
This defines the text of each tickmark label on the gauge.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this label.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this label represents.
|
||||
\endtable
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-tickmarkLabel}{
|
||||
Styling CircularGauge's tickmarkLabel}
|
||||
*/
|
||||
property Component tickmarkLabel: Text {
|
||||
font.pixelSize: Math.max(6, __protectedScope.toPixels(0.12))
|
||||
text: styleData.value
|
||||
color: "#c8c8c8"
|
||||
antialiasing: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
/*!
|
||||
The needle that points to the gauge's current value.
|
||||
|
||||
This component is drawn below the \l foreground component.
|
||||
|
||||
The style expects the needle to be pointing up at a rotation of \c 0,
|
||||
in order for the rotation to be correct. For example:
|
||||
|
||||
\image circulargauge-needle.png CircularGauge's needle
|
||||
|
||||
When defining your own needle component, the only properties that the
|
||||
style requires you to set are the
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight}.
|
||||
|
||||
Optionally, you can set \l {Item::x}{x} and \l {Item::y}{y} to change
|
||||
the needle's transform origin. Setting the \c x position can be useful
|
||||
for needle images where the needle is not centered exactly
|
||||
horizontally. Setting the \c y position allows you to make the base of
|
||||
the needle hang over the center of the gauge.
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-needle}{
|
||||
Styling CircularGauge's needle}
|
||||
*/
|
||||
property Component needle: Item {
|
||||
implicitWidth: __protectedScope.toPixels(0.08)
|
||||
implicitHeight: 0.9 * outerRadius
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: "images/needle.png"
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The foreground of the gauge. This component is drawn above all others.
|
||||
|
||||
Like \l background, the foreground component fills the entire gauge.
|
||||
|
||||
By default, the knob of the gauge is defined here.
|
||||
|
||||
\sa {Styling CircularGauge#styling-circulargauge-foreground}{
|
||||
Styling CircularGauge's foreground}
|
||||
*/
|
||||
property Component foreground: Item {
|
||||
Image {
|
||||
source: "images/knob.png"
|
||||
anchors.centerIn: parent
|
||||
scale: {
|
||||
var idealHeight = __protectedScope.toPixels(0.2);
|
||||
var originalImageHeight = sourceSize.height;
|
||||
idealHeight / originalImageHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
id: panelItem
|
||||
implicitWidth: backgroundLoader.item ? backgroundLoader.implicitWidth : TextSingleton.implicitHeight * 16
|
||||
implicitHeight: backgroundLoader.item ? backgroundLoader.implicitHeight : TextSingleton.implicitHeight * 16
|
||||
|
||||
property alias background: backgroundLoader.item
|
||||
property alias circularTickmarkLabel: circularTickmarkLabel_
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: circularGaugeStyle.background
|
||||
width: outerRadius * 2
|
||||
height: outerRadius * 2
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
CircularTickmarkLabel {
|
||||
id: circularTickmarkLabel_
|
||||
anchors.fill: backgroundLoader
|
||||
|
||||
minimumValue: control.minimumValue
|
||||
maximumValue: control.maximumValue
|
||||
stepSize: control.stepSize
|
||||
tickmarksVisible: control.tickmarksVisible
|
||||
minimumValueAngle: circularGaugeStyle.minimumValueAngle
|
||||
maximumValueAngle: circularGaugeStyle.maximumValueAngle
|
||||
tickmarkStepSize: circularGaugeStyle.tickmarkStepSize
|
||||
tickmarkInset: circularGaugeStyle.tickmarkInset
|
||||
minorTickmarkCount: circularGaugeStyle.minorTickmarkCount
|
||||
minorTickmarkInset: circularGaugeStyle.minorTickmarkInset
|
||||
labelInset: circularGaugeStyle.labelInset
|
||||
labelStepSize: circularGaugeStyle.labelStepSize
|
||||
|
||||
style: CircularTickmarkLabelStyle {
|
||||
tickmark: circularGaugeStyle.tickmark
|
||||
minorTickmark: circularGaugeStyle.minorTickmark
|
||||
tickmarkLabel: circularGaugeStyle.tickmarkLabel
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: needleLoader
|
||||
sourceComponent: circularGaugeStyle.needle
|
||||
transform: [
|
||||
Rotation {
|
||||
angle: needleRotation
|
||||
origin.x: needleLoader.width / 2
|
||||
origin.y: needleLoader.height
|
||||
},
|
||||
Translate {
|
||||
x: panelItem.width / 2 - needleLoader.width / 2
|
||||
y: panelItem.height / 2 - needleLoader.height
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: foreground
|
||||
sourceComponent: circularGaugeStyle.foreground
|
||||
anchors.fill: backgroundLoader
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras.Private 1.0
|
||||
import QtQuick.Extras.Private.CppUtils 1.0
|
||||
|
||||
Style {
|
||||
id: circularTickmarkLabelStyle
|
||||
|
||||
/*!
|
||||
The distance from the center of the control to the outer edge.
|
||||
*/
|
||||
readonly property real outerRadius: Math.min(control.width, control.height) * 0.5
|
||||
|
||||
property QtObject __protectedScope: QtObject {
|
||||
/*!
|
||||
Converts a value expressed as a percentage of \l outerRadius to
|
||||
a pixel value.
|
||||
*/
|
||||
function toPixels(percentageOfOuterRadius) {
|
||||
return percentageOfOuterRadius * outerRadius;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each individual tickmark. The position of each
|
||||
tickmark is already set; only the size needs to be specified.
|
||||
*/
|
||||
property Component tickmark: Rectangle {
|
||||
width: outerRadius * 0.02
|
||||
antialiasing: true
|
||||
height: outerRadius * 0.06
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each individual minor tickmark. The position of
|
||||
each minor tickmark is already set; only the size needs to be specified.
|
||||
*/
|
||||
property Component minorTickmark: Rectangle {
|
||||
width: outerRadius * 0.01
|
||||
antialiasing: true
|
||||
height: outerRadius * 0.03
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
/*!
|
||||
This defines the text of each tickmark label on the gauge.
|
||||
*/
|
||||
property Component tickmarkLabel: Text {
|
||||
font.pixelSize: Math.max(6, __protectedScope.toPixels(0.12))
|
||||
text: styleData.value
|
||||
color: "#c8c8c8"
|
||||
antialiasing: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
id: panelItem
|
||||
implicitWidth: 250
|
||||
implicitHeight: 250
|
||||
|
||||
function rangeUsed(count, stepSize) {
|
||||
return (((count - 1) * stepSize) / (control.maximumValue - control.minimumValue)) * control.angleRange;
|
||||
}
|
||||
|
||||
readonly property real tickmarkSectionSize: rangeUsed(control.tickmarkCount, control.tickmarkStepSize) / (control.tickmarkCount - 1)
|
||||
readonly property real tickmarkSectionValue: (control.maximumValue - control.minimumValue) / (control.tickmarkCount - 1)
|
||||
readonly property real minorTickmarkSectionSize: tickmarkSectionSize / (control.minorTickmarkCount + 1)
|
||||
readonly property real minorTickmarkSectionValue: tickmarkSectionValue / (control.minorTickmarkCount + 1)
|
||||
readonly property int totalMinorTickmarkCount: {
|
||||
// The size of each section within two major tickmarks, expressed as a percentage.
|
||||
var minorSectionPercentage = 1 / (control.minorTickmarkCount + 1);
|
||||
// The amount of major tickmarks not able to be displayed; will be 0 if they all fit.
|
||||
var tickmarksNotDisplayed = control.__tickmarkCount - control.tickmarkCount;
|
||||
var count = control.minorTickmarkCount * (control.tickmarkCount - 1);
|
||||
// We'll try to display as many minor tickmarks as we can to fill up the space.
|
||||
count + tickmarksNotDisplayed / minorSectionPercentage;
|
||||
}
|
||||
readonly property real labelSectionSize: rangeUsed(control.labelCount, control.labelStepSize) / (control.labelCount - 1)
|
||||
|
||||
function toPixels(percentageOfOuterRadius) {
|
||||
return percentageOfOuterRadius * outerRadius;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the angle of \a marker (in the range 0 ... n - 1, where n
|
||||
is the amount of markers) on the gauge where sections are of size
|
||||
tickmarkSectionSize.
|
||||
*/
|
||||
function tickmarkAngleFromIndex(tickmarkIndex) {
|
||||
return tickmarkIndex * tickmarkSectionSize + control.minimumValueAngle;
|
||||
}
|
||||
|
||||
function labelAngleFromIndex(labelIndex) {
|
||||
return labelIndex * labelSectionSize + control.minimumValueAngle;
|
||||
}
|
||||
|
||||
function labelPosFromIndex(index, labelWidth, labelHeight) {
|
||||
return MathUtils.centerAlongCircle(outerRadius, outerRadius, labelWidth, labelHeight,
|
||||
MathUtils.degToRadOffset(labelAngleFromIndex(index)),
|
||||
outerRadius - control.labelInset)
|
||||
}
|
||||
|
||||
function minorTickmarkAngleFromIndex(minorTickmarkIndex) {
|
||||
var baseAngle = tickmarkAngleFromIndex(Math.floor(minorTickmarkIndex / control.minorTickmarkCount));
|
||||
// + minorTickmarkSectionSize because we don't want the first minor tickmark to start on top of its "parent" tickmark.
|
||||
var relativeMinorAngle = (minorTickmarkIndex % control.minorTickmarkCount * minorTickmarkSectionSize) + minorTickmarkSectionSize;
|
||||
return baseAngle + relativeMinorAngle;
|
||||
}
|
||||
|
||||
function tickmarkValueFromIndex(majorIndex) {
|
||||
return (majorIndex * tickmarkSectionValue) + control.minimumValue;
|
||||
}
|
||||
|
||||
function tickmarkValueFromMinorIndex(minorIndex) {
|
||||
var majorIndex = Math.floor(minorIndex / control.minorTickmarkCount);
|
||||
var relativeMinorIndex = minorIndex % control.minorTickmarkCount;
|
||||
return tickmarkValueFromIndex(majorIndex) + ((relativeMinorIndex * minorTickmarkSectionValue) + minorTickmarkSectionValue);
|
||||
}
|
||||
|
||||
Loader {
|
||||
active: control.tickmarksVisible && tickmark != null
|
||||
width: outerRadius * 2
|
||||
height: outerRadius * 2
|
||||
anchors.centerIn: parent
|
||||
|
||||
sourceComponent: Repeater {
|
||||
id: tickmarkRepeater
|
||||
model: control.tickmarkCount
|
||||
delegate: Loader {
|
||||
id: tickmarkLoader
|
||||
objectName: "tickmark" + styleData.index
|
||||
x: tickmarkRepeater.width / 2
|
||||
y: tickmarkRepeater.height / 2
|
||||
|
||||
transform: [
|
||||
Translate {
|
||||
y: -outerRadius + control.tickmarkInset
|
||||
},
|
||||
Rotation {
|
||||
angle: panelItem.tickmarkAngleFromIndex(styleData.index) - __tickmarkWidthAsAngle / 2
|
||||
}
|
||||
]
|
||||
|
||||
sourceComponent: tickmark
|
||||
|
||||
property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: tickmarkLoader.__index
|
||||
readonly property real value: tickmarkValueFromIndex(index)
|
||||
}
|
||||
|
||||
readonly property real __tickmarkWidthAsAngle: MathUtils.radToDeg((width / (MathUtils.pi2 * outerRadius)) * MathUtils.pi2)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
active: control.tickmarksVisible && minorTickmark != null
|
||||
width: outerRadius * 2
|
||||
height: outerRadius * 2
|
||||
anchors.centerIn: parent
|
||||
|
||||
sourceComponent: Repeater {
|
||||
id: minorRepeater
|
||||
anchors.fill: parent
|
||||
model: totalMinorTickmarkCount
|
||||
delegate: Loader {
|
||||
id: minorTickmarkLoader
|
||||
objectName: "minorTickmark" + styleData.index
|
||||
x: minorRepeater.width / 2
|
||||
y: minorRepeater.height / 2
|
||||
transform: [
|
||||
Translate {
|
||||
y: -outerRadius + control.minorTickmarkInset
|
||||
},
|
||||
Rotation {
|
||||
angle: panelItem.minorTickmarkAngleFromIndex(styleData.index) - __minorTickmarkWidthAsAngle / 2
|
||||
}
|
||||
]
|
||||
|
||||
sourceComponent: minorTickmark
|
||||
|
||||
property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: minorTickmarkLoader.__index
|
||||
readonly property real value: tickmarkValueFromMinorIndex(index)
|
||||
}
|
||||
|
||||
readonly property real __minorTickmarkWidthAsAngle: MathUtils.radToDeg((width / (MathUtils.pi2 * outerRadius)) * MathUtils.pi2)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
id: labelLoader
|
||||
active: control.tickmarksVisible && tickmarkLabel != null
|
||||
width: outerRadius * 2
|
||||
height: outerRadius * 2
|
||||
anchors.centerIn: parent
|
||||
|
||||
sourceComponent: Item {
|
||||
id: labelItem
|
||||
width: outerRadius * 2
|
||||
height: outerRadius * 2
|
||||
anchors.centerIn: parent
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onMinimumValueChanged: valueTextModel.update()
|
||||
onMaximumValueChanged: valueTextModel.update()
|
||||
onTickmarkStepSizeChanged: valueTextModel.update()
|
||||
onLabelStepSizeChanged: valueTextModel.update()
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: labelItemRepeater
|
||||
|
||||
Component.onCompleted: valueTextModel.update();
|
||||
|
||||
model: ListModel {
|
||||
id: valueTextModel
|
||||
|
||||
function update() {
|
||||
if (control.labelStepSize === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make bigger if it's too small and vice versa.
|
||||
// +1 because we want to show 11 values, with, for example: 0, 10, 20... 100.
|
||||
var difference = control.labelCount - count;
|
||||
if (difference > 0) {
|
||||
for (; difference > 0; --difference) {
|
||||
append({ value: 0 });
|
||||
}
|
||||
} else if (difference < 0) {
|
||||
for (; difference < 0; ++difference) {
|
||||
remove(count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
for (var value = control.minimumValue;
|
||||
value <= control.maximumValue && index < count;
|
||||
value += control.labelStepSize, ++index) {
|
||||
setProperty(index, "value", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate: Loader {
|
||||
id: tickmarkLabelDelegateLoader
|
||||
objectName: "labelDelegateLoader" + index
|
||||
sourceComponent: tickmarkLabel
|
||||
x: pos.x
|
||||
y: pos.y
|
||||
|
||||
readonly property point pos: panelItem.labelPosFromIndex(index, width, height);
|
||||
|
||||
readonly property int __index: index
|
||||
readonly property real __value: value
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property var value: index != -1 ? tickmarkLabelDelegateLoader.__value : 0
|
||||
readonly property alias index: tickmarkLabelDelegateLoader.__index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Window 2.1
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.1
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ComboBoxStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for ComboBox.
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: cbStyle
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration renderType
|
||||
\since QtQuick.Controls.Styles 1.2
|
||||
|
||||
Override the default rendering type for the control.
|
||||
|
||||
Supported render types are:
|
||||
\list
|
||||
\li Text.QtRendering
|
||||
\li Text.NativeRendering
|
||||
\endlist
|
||||
|
||||
The default value is platform dependent.
|
||||
|
||||
\sa Text::renderType
|
||||
*/
|
||||
property int renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The font of the control.
|
||||
*/
|
||||
property font font
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The text color.
|
||||
*/
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The text highlight color, used behind selections.
|
||||
*/
|
||||
property color selectionColor: SystemPaletteSingleton.highlight(control.enabled)
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The highlighted text color, used in selections.
|
||||
*/
|
||||
property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled)
|
||||
|
||||
/*! The \l ComboBox this style is attached to. */
|
||||
readonly property ComboBox control: __control
|
||||
|
||||
/*! The padding between the background and the label components. */
|
||||
padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
|
||||
|
||||
/*! The size of the drop down button when the combobox is editable. */
|
||||
property int dropDownButtonWidth: Math.round(TextSingleton.implicitHeight)
|
||||
|
||||
/*! \internal Alias kept for backwards compatibility with a spelling mistake in 5.2.0) */
|
||||
property alias drowDownButtonWidth: cbStyle.dropDownButtonWidth
|
||||
|
||||
/*! This defines the background of the button. */
|
||||
property Component background: Item {
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
|
||||
implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: control.pressed ? 0 : -1
|
||||
color: "#10000000"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: control.pressed ? "#bababa" : "#fefefe" ; position: 0}
|
||||
GradientStop {color: control.pressed ? "#ccc" : "#e3e3e3" ; position: 1}
|
||||
}
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
color: control.activeFocus ? "#47b" : "white"
|
||||
opacity: control.hovered || control.activeFocus ? 0.1 : 0
|
||||
Behavior on opacity {NumberAnimation{ duration: 100 }}
|
||||
}
|
||||
}
|
||||
Image {
|
||||
id: imageItem
|
||||
visible: control.menu !== null
|
||||
source: "images/arrow-down.png"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: dropDownButtonWidth / 2
|
||||
opacity: control.enabled ? 0.6 : 0.3
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component __editor: Item {
|
||||
implicitWidth: 100
|
||||
implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
|
||||
clip: true
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: 0
|
||||
color: "#44ffffff"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
anchors.rightMargin: -radius
|
||||
anchors.bottomMargin: 1
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#e0e0e0" ; position: 0}
|
||||
GradientStop {color: "#fff" ; position: 0.1}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#aaa"
|
||||
anchors.bottomMargin: 2
|
||||
anchors.topMargin: 1
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
width: 1
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the label of the button. */
|
||||
property Component label: Item {
|
||||
implicitWidth: textitem.implicitWidth + 20
|
||||
baselineOffset: textitem.y + textitem.baselineOffset
|
||||
Text {
|
||||
id: textitem
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: control.currentText
|
||||
renderType: cbStyle.renderType
|
||||
font: cbStyle.font
|
||||
color: cbStyle.textColor
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
property bool popup: false
|
||||
property font font: cbStyle.font
|
||||
property color textColor: cbStyle.textColor
|
||||
property color selectionColor: cbStyle.selectionColor
|
||||
property color selectedTextColor: cbStyle.selectedTextColor
|
||||
property int dropDownButtonWidth: cbStyle.dropDownButtonWidth
|
||||
anchors.centerIn: parent
|
||||
anchors.fill: parent
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: Math.max(labelLoader.implicitHeight + padding.top + padding.bottom, backgroundLoader.implicitHeight)
|
||||
baselineOffset: labelLoader.item ? padding.top + labelLoader.item.baselineOffset: 0
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: editorLoader
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: dropDownButtonWidth + padding.right
|
||||
anchors.bottomMargin: -1
|
||||
sourceComponent: control.editable ? __editor : null
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: labelLoader
|
||||
sourceComponent: label
|
||||
visible: !control.editable
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.topMargin: padding.top
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.bottomMargin: padding.bottom
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component __dropDownStyle: MenuStyle {
|
||||
font: cbStyle.font
|
||||
__labelColor: cbStyle.textColor
|
||||
__selectedLabelColor: cbStyle.selectedTextColor
|
||||
__selectedBackgroundColor: cbStyle.selectionColor
|
||||
__maxPopupHeight: 600
|
||||
__menuItemType: "comboboxitem"
|
||||
__scrollerStyle: ScrollViewStyle { }
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component __popupStyle: Style {
|
||||
property int __maxPopupHeight: 400
|
||||
property int submenuOverlap: 0
|
||||
property int submenuPopupDelay: 100
|
||||
|
||||
property Component frame: Rectangle {
|
||||
id: popupFrame
|
||||
border.color: "white"
|
||||
Text {
|
||||
text: "NOT IMPLEMENTED"
|
||||
color: "red"
|
||||
font {
|
||||
pixelSize: 10
|
||||
bold: true
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
rotation: -Math.atan2(popupFrame.height, popupFrame.width) * 180 / Math.PI
|
||||
}
|
||||
}
|
||||
|
||||
property Component menuItemPanel: Text {
|
||||
text: styleData.text
|
||||
}
|
||||
|
||||
property Component __scrollerStyle: null
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
The cursor handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the cursor position. The interactive area is determined by the
|
||||
geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __cursorHandle
|
||||
|
||||
/*! \internal
|
||||
The selection handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the first selected character. The interactive area is determined
|
||||
by the geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __selectionHandle
|
||||
|
||||
/*! \internal
|
||||
The cursor delegate.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
*/
|
||||
property Component __cursorDelegate
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
|
||||
QtObject {
|
||||
property Item control
|
||||
|
||||
property color buttonColorUpTop: "#e3e3e3"
|
||||
property color buttonColorUpBottom: "#b3b3b3"
|
||||
property color buttonColorDownTop: "#d3d3d3"
|
||||
property color buttonColorDownBottom: "#939393"
|
||||
property color textColorUp: "#4e4e4e"
|
||||
property color textColorDown: "#303030"
|
||||
property color textRaisedColorUp: "#ffffff"
|
||||
property color textRaisedColorDown: "#e3e3e3"
|
||||
property color offColor: "#ff0000"
|
||||
property color offColorShine: "#ff6666"
|
||||
property color onColor: "#00cc00"
|
||||
property color onColorShine: "#66ff66"
|
||||
property color inactiveColor: "#1f1f1f"
|
||||
property color inactiveColorShine: "#666666"
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private.CppUtils 1.1
|
||||
|
||||
/*!
|
||||
\qmltype DelayButtonStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for DelayButton.
|
||||
|
||||
You can create a custom DelayButton by replacing the following delegates:
|
||||
\list
|
||||
\li \l foreground
|
||||
\li \l {ButtonStyle::}{label}
|
||||
\endlist
|
||||
*/
|
||||
|
||||
CircularButtonStyle {
|
||||
id: delayButtonStyle
|
||||
|
||||
/*!
|
||||
The \l DelayButton that this style is attached to.
|
||||
*/
|
||||
readonly property DelayButton control: __control
|
||||
|
||||
/*!
|
||||
The gradient of the progress bar around the button.
|
||||
*/
|
||||
property Gradient progressBarGradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: "#ff6666"
|
||||
}
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: "#ff0000"
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The color of the drop shadow under the progress bar.
|
||||
*/
|
||||
property color progressBarDropShadowColor: "#ff6666"
|
||||
|
||||
background: Item {
|
||||
implicitWidth: __buttonHelper.implicitWidth
|
||||
implicitHeight: __buttonHelper.implicitHeight
|
||||
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onPressedChanged: backgroundCanvas.requestPaint()
|
||||
onCheckedChanged: backgroundCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
__buttonHelper.paintBackground(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The foreground of the button.
|
||||
|
||||
The progress bar is drawn here.
|
||||
*/
|
||||
property Component foreground: Item {
|
||||
id: foregroundItem
|
||||
|
||||
state: "normal"
|
||||
states: [
|
||||
State {
|
||||
name: "normal"
|
||||
|
||||
PropertyChanges {
|
||||
target: foregroundItem
|
||||
opacity: 1
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "activated"
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
from: "normal"
|
||||
to: "activated"
|
||||
SequentialAnimation {
|
||||
loops: Animation.Infinite
|
||||
|
||||
NumberAnimation {
|
||||
target: foregroundItem
|
||||
property: "opacity"
|
||||
from: 0.8
|
||||
to: 0
|
||||
duration: 500
|
||||
easing.type: Easing.InOutSine
|
||||
}
|
||||
NumberAnimation {
|
||||
target: foregroundItem
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 0.8
|
||||
duration: 500
|
||||
easing.type: Easing.InOutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onActivated: state = "activated"
|
||||
onCheckedChanged: if (!control.checked) state = "normal"
|
||||
}
|
||||
|
||||
CircularProgressBar {
|
||||
id: progressBar
|
||||
visible: false
|
||||
width: Math.min(parent.width, parent.height) + progressBarDropShadow.radius * 3 * 2
|
||||
height: width
|
||||
anchors.centerIn: parent
|
||||
antialiasing: true
|
||||
barWidth: __buttonHelper.outerArcLineWidth
|
||||
inset: progressBarDropShadow.radius * 3
|
||||
minimumValueAngle: -180
|
||||
maximumValueAngle: 180
|
||||
|
||||
progress: control.progress
|
||||
|
||||
// TODO: Add gradient property if/when we drop support for building with 5.1.
|
||||
function updateGradient() {
|
||||
clearStops();
|
||||
for (var i = 0; i < progressBarGradient.stops.length; ++i) {
|
||||
addStop(progressBarGradient.stops[i].position, progressBarGradient.stops[i].color);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: updateGradient()
|
||||
|
||||
Connections {
|
||||
target: delayButtonStyle
|
||||
onProgressBarGradientChanged: progressBar.updateGradient()
|
||||
}
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
id: progressBarDropShadow
|
||||
anchors.fill: progressBar
|
||||
// QTBUG-33747
|
||||
// cached: !control.pressed
|
||||
color: progressBarDropShadowColor
|
||||
source: progressBar
|
||||
}
|
||||
}
|
||||
|
||||
panel: Item {
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: backgroundLoader.implicitHeight
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: foregroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: foreground
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: labelLoader
|
||||
sourceComponent: label
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.topMargin: padding.top
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.bottomMargin: padding.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
import QtQuick.Extras.Private.CppUtils 1.0
|
||||
|
||||
/*!
|
||||
\qmltype DialStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Dial.
|
||||
|
||||
You can create a custom dial by replacing the following delegates:
|
||||
\list
|
||||
\li \l background
|
||||
\endlist
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: dialStyle
|
||||
|
||||
/*!
|
||||
The \l Dial that this style is attached to.
|
||||
*/
|
||||
readonly property Dial control: __control
|
||||
|
||||
/*!
|
||||
The distance from the center of the dial to the outer edge of the dial.
|
||||
|
||||
This property is useful for determining the size of the various
|
||||
components of the style, in order to ensure that they are scaled
|
||||
proportionately when the dial is resized.
|
||||
*/
|
||||
readonly property real outerRadius: Math.min(control.height, control.width) / 2
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the dial (outerRadius)
|
||||
to the center of the handle.
|
||||
*/
|
||||
property real handleInset: (__tickmarkRadius * 4) + ((__handleRadius * 2) * 0.55)
|
||||
|
||||
/*!
|
||||
The interval at which tickmarks are displayed.
|
||||
|
||||
For example, if this property is set to \c 10,
|
||||
control.minimumValue to \c 0, and control.maximumValue to \c 100,
|
||||
the tickmarks displayed will be 0, 10, 20, etc., to 100, along
|
||||
the circumference of the dial.
|
||||
*/
|
||||
property real tickmarkStepSize: 1
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the dial (outerRadius) at
|
||||
which the outermost point of the tickmark line is drawn.
|
||||
*/
|
||||
property real tickmarkInset: 0
|
||||
|
||||
|
||||
/*!
|
||||
The amount of tickmarks displayed by the dial, calculated from
|
||||
\l tickmarkStepSize and the control's
|
||||
\l {Dial::minimumValue}{minimumValue} and
|
||||
\l {Dial::maximumValue}{maximumValue}.
|
||||
|
||||
\sa minorTickmarkCount
|
||||
*/
|
||||
readonly property int tickmarkCount: control.__panel.circularTickmarkLabel.tickmarkCount
|
||||
|
||||
/*!
|
||||
The amount of minor tickmarks between each tickmark.
|
||||
|
||||
\sa tickmarkCount
|
||||
*/
|
||||
property int minorTickmarkCount: 0
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the dial (outerRadius) at
|
||||
which the outermost point of the minor tickmark line is drawn.
|
||||
*/
|
||||
property real minorTickmarkInset: 0
|
||||
|
||||
/*!
|
||||
The distance in pixels from the outside of the dial (outerRadius) at
|
||||
which the center of the value marker text is drawn.
|
||||
*/
|
||||
property real labelInset: 0
|
||||
|
||||
/*!
|
||||
The interval at which tickmark labels are displayed.
|
||||
|
||||
For example, if this property is set to \c 10 (the default),
|
||||
control.minimumValue to \c 0, and control.maximumValue to \c 100, the
|
||||
tickmark labels displayed will be 0, 10, 20, etc., to 100,
|
||||
along the circumference of the dial.
|
||||
*/
|
||||
property real labelStepSize: tickmarkStepSize
|
||||
|
||||
/*!
|
||||
The amount of tickmark labels displayed by the dial, calculated from
|
||||
\l labelStepSize and the control's
|
||||
\l {Dial::minimumValue}{minimumValue} and
|
||||
\l {Dial::maximumValue}{maximumValue}.
|
||||
|
||||
\sa tickmarkCount, minorTickmarkCount
|
||||
*/
|
||||
readonly property int labelCount: control.__panel.circularTickmarkLabel.labelCount
|
||||
|
||||
/*! \qmlmethod real DialStyle::valueToAngle(real value)
|
||||
Returns \a value as an angle in degrees.
|
||||
|
||||
This function is useful for custom drawing or positioning of items in
|
||||
the style's components. For example, it can be used to calculate the
|
||||
angles at which to draw an arc around the dial indicating the safe
|
||||
range of values.
|
||||
*/
|
||||
function valueToAngle(value) {
|
||||
return control.__panel.circularTickmarkLabel.valueToAngle(value);
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
readonly property real __tickmarkRadius: outerRadius * 0.06
|
||||
|
||||
/*! \internal */
|
||||
readonly property real __handleRadius: outerRadius * 0.15
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
This property determines whether it is possible to change the value of
|
||||
the dial simply by pressing/tapping.
|
||||
|
||||
If \c false, the user must drag to rotate the dial and hence change the
|
||||
value.
|
||||
|
||||
This property is useful for touch devices, where it is easy to
|
||||
accidentally tap while flicking, for example.
|
||||
*/
|
||||
property bool __dragToSet: Settings.hasTouchScreen && Settings.isMobile
|
||||
|
||||
/*!
|
||||
The background of the dial.
|
||||
|
||||
The implicit size of the dial is taken from this component.
|
||||
*/
|
||||
property Component background: Item {
|
||||
id: backgroundItem
|
||||
implicitWidth: backgroundHelper.implicitWidth
|
||||
implicitHeight: backgroundHelper.implicitHeight
|
||||
|
||||
CircularButtonStyleHelper {
|
||||
id: backgroundHelper
|
||||
control: dialStyle.control
|
||||
property color zeroMarkerColor: "#a8a8a8"
|
||||
property color zeroMarkerColorTransparent: "transparent"
|
||||
property real zeroMarkerLength: outerArcLineWidth * 1.25
|
||||
property real zeroMarkerWidth: outerArcLineWidth * 0.3
|
||||
|
||||
smallestAxis: Math.min(backgroundItem.width, backgroundItem.height) - __tickmarkRadius * 4
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
readonly property real xCenter: width / 2
|
||||
readonly property real yCenter: height / 2
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
backgroundHelper.paintBackground(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The handle of the dial.
|
||||
|
||||
The handle is automatically positioned within the dial, based on the
|
||||
\l handleInset and the implicit width and height of the handle itself.
|
||||
*/
|
||||
property Component handle: Canvas {
|
||||
implicitWidth: __handleRadius * 2
|
||||
implicitHeight: __handleRadius * 2
|
||||
|
||||
HandleStyleHelper {
|
||||
id: handleHelper
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
handleHelper.paintHandle(ctx, 1, 1, width - 2, height - 2);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each individual tickmark. The position of each
|
||||
tickmark is already set; only the
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight} need to be specified.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this tickmark represents.
|
||||
\endtable
|
||||
*/
|
||||
property Component tickmark: Rectangle {
|
||||
implicitWidth: outerRadius * 0.015 + (styleData.index === 0 || styleData.index === tickmarkCount ? 1 : (styleData.index) / tickmarkCount) * __tickmarkRadius * 0.75
|
||||
implicitHeight: implicitWidth
|
||||
radius: height / 2
|
||||
color: styleData.index === 0 ? "transparent" : Qt.rgba(0, 0, 0, 0.266)
|
||||
antialiasing: true
|
||||
border.width: styleData.index === 0 ? Math.max(1, outerRadius * 0.0075) : 0
|
||||
border.color: Qt.rgba(0, 0, 0, 0.266)
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each individual minor tickmark. The position of each
|
||||
minor tickmark is already set; only the
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight} need to be specified.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this tickmark represents.
|
||||
\endtable
|
||||
|
||||
By default, no minor tickmark is defined.
|
||||
*/
|
||||
property Component minorTickmark
|
||||
|
||||
/*!
|
||||
This defines the text of each tickmark label on the dial.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this label.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this label represents.
|
||||
\endtable
|
||||
|
||||
By default, no label is defined.
|
||||
*/
|
||||
property Component tickmarkLabel
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: backgroundLoader.implicitHeight
|
||||
|
||||
property alias background: backgroundLoader.item
|
||||
property alias circularTickmarkLabel: circularTickmarkLabel_
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: dialStyle.background
|
||||
width: outerRadius * 2
|
||||
height: width
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: handleLoader
|
||||
sourceComponent: dialStyle.handle
|
||||
x: backgroundLoader.x + __pos.x - width / 2
|
||||
y: backgroundLoader.y + __pos.y - height / 2
|
||||
|
||||
readonly property point __pos: {
|
||||
var radians = 0;
|
||||
if (control.__wrap) {
|
||||
radians = (control.value - control.minimumValue) /
|
||||
(control.maximumValue - control.minimumValue) *
|
||||
(MathUtils.pi2) + backgroundHelper.zeroAngle;
|
||||
} else {
|
||||
radians = -(Math.PI * 8 - (control.value - control.minimumValue) * 10 *
|
||||
Math.PI / (control.maximumValue - control.minimumValue)) / 6;
|
||||
}
|
||||
|
||||
return MathUtils.centerAlongCircle(backgroundLoader.width / 2, backgroundLoader.height / 2,
|
||||
0, 0, radians, outerRadius - handleInset)
|
||||
}
|
||||
}
|
||||
|
||||
CircularTickmarkLabel {
|
||||
id: circularTickmarkLabel_
|
||||
anchors.fill: backgroundLoader
|
||||
|
||||
minimumValue: control.minimumValue
|
||||
maximumValue: control.maximumValue
|
||||
stepSize: control.stepSize
|
||||
tickmarksVisible: control.tickmarksVisible
|
||||
minimumValueAngle: -150
|
||||
maximumValueAngle: 150
|
||||
tickmarkStepSize: dialStyle.tickmarkStepSize
|
||||
tickmarkInset: dialStyle.tickmarkInset
|
||||
minorTickmarkCount: dialStyle.minorTickmarkCount
|
||||
minorTickmarkInset: dialStyle.minorTickmarkInset
|
||||
labelInset: dialStyle.labelInset
|
||||
labelStepSize: dialStyle.labelStepSize
|
||||
|
||||
style: CircularTickmarkLabelStyle {
|
||||
tickmark: dialStyle.tickmark
|
||||
minorTickmark: dialStyle.minorTickmark
|
||||
tickmarkLabel: dialStyle.tickmarkLabel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype FocusFrameStyle
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
*/
|
||||
Item {
|
||||
property int margin: -3
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype GaugeStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Gauge.
|
||||
|
||||
You can create a custom gauge by replacing the following delegates:
|
||||
\list
|
||||
\li \l background
|
||||
\li valueBar
|
||||
\li tickmarkLabel
|
||||
\endlist
|
||||
|
||||
Below, you'll find an example of how to create a temperature gauge that
|
||||
changes color as its value increases:
|
||||
|
||||
\code
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
Rectangle {
|
||||
width: 80
|
||||
height: 200
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 2000
|
||||
onTriggered: gauge.value = gauge.value == gauge.maximumValue ? 5 : gauge.maximumValue
|
||||
}
|
||||
|
||||
Gauge {
|
||||
id: gauge
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
|
||||
value: 5
|
||||
Behavior on value {
|
||||
NumberAnimation {
|
||||
duration: 1000
|
||||
}
|
||||
}
|
||||
|
||||
style: GaugeStyle {
|
||||
valueBar: Rectangle {
|
||||
implicitWidth: 16
|
||||
color: Qt.rgba(gauge.value / gauge.maximumValue, 0, 1 - gauge.value / gauge.maximumValue, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\image gauge-temperature.png
|
||||
The gauge displaying values at various points during the animation.
|
||||
|
||||
\sa {Styling Gauge}
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: gaugeStyle
|
||||
|
||||
/*!
|
||||
The \l Gauge that this style is attached to.
|
||||
*/
|
||||
readonly property Gauge control: __control
|
||||
|
||||
/*!
|
||||
This property holds the value displayed by the gauge as a position in
|
||||
pixels.
|
||||
|
||||
It is useful for custom styling.
|
||||
*/
|
||||
readonly property real valuePosition: control.__panel.valuePosition
|
||||
|
||||
/*!
|
||||
The background of the gauge, displayed behind the \l valueBar.
|
||||
|
||||
By default, no background is defined.
|
||||
*/
|
||||
property Component background
|
||||
|
||||
/*!
|
||||
Each tickmark displayed by the gauge.
|
||||
|
||||
To set the size of the tickmarks, specify an
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight}.
|
||||
|
||||
The widest tickmark will determine the space set aside for all
|
||||
tickmarks. For this reason, the \c implicitWidth of each tickmark
|
||||
should be greater than or equal to that of each minor tickmark. If you
|
||||
need minor tickmarks to have greater widths than the major tickmarks,
|
||||
set the larger width in a child item of the \l minorTickmark component.
|
||||
|
||||
For layouting reasons, each tickmark should have the same
|
||||
\c implicitHeight. If different heights are needed for individual
|
||||
tickmarks, specify those heights in a child item of the component.
|
||||
|
||||
In the example below, we decrease the height of the tickmarks:
|
||||
|
||||
\code
|
||||
tickmark: Item {
|
||||
implicitWidth: 18
|
||||
implicitHeight: 1
|
||||
|
||||
Rectangle {
|
||||
color: "#c8c8c8"
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 3
|
||||
anchors.rightMargin: 3
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\image gauge-tickmark-example.png Gauge tickmark example
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this tickmark represents.
|
||||
\row \li \c {readonly property real} \b styleData.valuePosition
|
||||
\li The value that this tickmark represents as a position in
|
||||
pixels, with 0 being at the bottom of the gauge.
|
||||
\endtable
|
||||
|
||||
\sa minorTickmark
|
||||
*/
|
||||
property Component tickmark: Item {
|
||||
implicitWidth: Math.round(TextSingleton.height * 1.1)
|
||||
implicitHeight: Math.max(2, Math.round(TextSingleton.height * 0.1))
|
||||
|
||||
Rectangle {
|
||||
color: "#c8c8c8"
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Math.round(TextSingleton.implicitHeight * 0.2)
|
||||
anchors.rightMargin: Math.round(TextSingleton.implicitHeight * 0.2)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Each minor tickmark displayed by the gauge.
|
||||
|
||||
To set the size of the minor tickmarks, specify an
|
||||
\l {Item::implicitWidth}{implicitWidth} and
|
||||
\l {Item::implicitHeight}{implicitHeight}.
|
||||
|
||||
For layouting reasons, each minor tickmark should have the same
|
||||
\c implicitHeight. If different heights are needed for individual
|
||||
tickmarks, specify those heights in a child item of the component.
|
||||
|
||||
In the example below, we decrease the width of the minor tickmarks:
|
||||
|
||||
\code
|
||||
minorTickmark: Item {
|
||||
implicitWidth: 8
|
||||
implicitHeight: 1
|
||||
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 2
|
||||
anchors.rightMargin: 4
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\image gauge-minorTickmark-example.png Gauge minorTickmark example
|
||||
|
||||
Each instance of this component has access to the following property:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this minor tickmark.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this minor tickmark represents.
|
||||
\row \li \c {readonly property real} \b styleData.valuePosition
|
||||
\li The value that this minor tickmark represents as a
|
||||
position in pixels, with 0 being at the bottom of the
|
||||
gauge.
|
||||
\endtable
|
||||
|
||||
\sa tickmark
|
||||
*/
|
||||
property Component minorTickmark: Item {
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight * 0.65)
|
||||
implicitHeight: Math.max(1, Math.round(TextSingleton.implicitHeight * 0.05))
|
||||
|
||||
Rectangle {
|
||||
color: "#c8c8c8"
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: control.__tickmarkAlignment === Qt.AlignBottom || control.__tickmarkAlignment === Qt.AlignRight
|
||||
? Math.max(3, Math.round(TextSingleton.implicitHeight * 0.2))
|
||||
: 0
|
||||
anchors.rightMargin: control.__tickmarkAlignment === Qt.AlignBottom || control.__tickmarkAlignment === Qt.AlignRight
|
||||
? 0
|
||||
: Math.max(3, Math.round(TextSingleton.implicitHeight * 0.2))
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
This defines the text of each tickmark label on the gauge.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this label.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value that this label represents.
|
||||
\endtable
|
||||
*/
|
||||
property Component tickmarkLabel: Text {
|
||||
text: control.formatValue(styleData.value)
|
||||
font: control.font
|
||||
color: "#c8c8c8"
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
/*!
|
||||
The bar that represents the value of the gauge.
|
||||
|
||||
To height of the value bar is automatically resized according to
|
||||
\l {Gauge::value}{value}, and does not need to be specified.
|
||||
|
||||
When a custom valueBar is defined, its
|
||||
\l {Item::implicitWidth}{implicitWidth} property must be set.
|
||||
*/
|
||||
property Component valueBar: Rectangle {
|
||||
color: "#00bbff"
|
||||
implicitWidth: TextSingleton.implicitHeight
|
||||
}
|
||||
|
||||
/*!
|
||||
The bar that represents the foreground of the gauge.
|
||||
|
||||
This component is drawn above every other component.
|
||||
*/
|
||||
property Component foreground: Canvas {
|
||||
readonly property real xCenter: width / 2
|
||||
readonly property real yCenter: height / 2
|
||||
property real shineLength: height * 0.95
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, width, height);
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, yCenter, width, yCenter);
|
||||
|
||||
gradient.addColorStop(0, Qt.rgba(1, 1, 1, 0.08));
|
||||
gradient.addColorStop(1, Qt.rgba(1, 1, 1, 0.20));
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
id: panelComponent
|
||||
implicitWidth: control.orientation === Qt.Vertical ? tickmarkLabelBoundsWidth + rawBarWidth : TextSingleton.height * 14
|
||||
implicitHeight: control.orientation === Qt.Vertical ? TextSingleton.height * 14 : tickmarkLabelBoundsWidth + rawBarWidth
|
||||
|
||||
readonly property int tickmarkCount: (control.maximumValue - control.minimumValue) / control.tickmarkStepSize + 1
|
||||
readonly property real tickmarkSpacing: (tickmarkLabelBounds.height - tickmarkWidth * tickmarkCount) / (tickmarkCount - 1)
|
||||
|
||||
property real tickmarkLength: tickmarkColumn.width
|
||||
// Can't deduce this from the column, so we set it from within the first tickmark delegate loader.
|
||||
property real tickmarkWidth: 2
|
||||
|
||||
readonly property real tickmarkOffset: control.orientation === Qt.Vertical ? control.__hiddenText.height / 2 : control.__hiddenText.width / 2
|
||||
|
||||
readonly property real minorTickmarkStep: control.tickmarkStepSize / (control.minorTickmarkCount + 1);
|
||||
|
||||
/*!
|
||||
Returns the marker text that should be displayed based on
|
||||
\a markerPos (\c 0 to \c 1.0).
|
||||
*/
|
||||
function markerTextFromPos(markerPos) {
|
||||
return markerPos * (control.maximumValue - control.minimumValue) + control.minimumValue;
|
||||
}
|
||||
|
||||
readonly property real rawBarWidth: valueBarLoader.item.implicitWidth
|
||||
readonly property real barLength: (control.orientation === Qt.Vertical ? control.height : control.width) - (tickmarkOffset * 2 - 2)
|
||||
|
||||
readonly property real tickmarkLabelBoundsWidth: tickmarkLength + (control.orientation === Qt.Vertical ? control.__hiddenText.width : control.__hiddenText.height)
|
||||
readonly property int valuePosition: valueBarLoader.height
|
||||
|
||||
Item {
|
||||
id: container
|
||||
|
||||
width: control.orientation === Qt.Vertical ? parent.width : parent.height
|
||||
height: control.orientation === Qt.Vertical ? parent.height : parent.width
|
||||
rotation: control.orientation === Qt.Horizontal ? 90 : 0
|
||||
transformOrigin: Item.Center
|
||||
anchors.centerIn: parent
|
||||
|
||||
Item {
|
||||
id: valueBarItem
|
||||
|
||||
x: control.__tickmarkAlignment === Qt.AlignLeft || control.__tickmarkAlignment === Qt.AlignTop ? tickmarkLabelBounds.x + tickmarkLabelBounds.width : 0
|
||||
width: rawBarWidth
|
||||
height: barLength
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: background
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: valueBarLoader
|
||||
sourceComponent: valueBar
|
||||
|
||||
readonly property real valueAsPercentage: (control.value - control.minimumValue) / (control.maximumValue - control.minimumValue)
|
||||
|
||||
y: Math.round(parent.height - height)
|
||||
height: Math.round(valueAsPercentage * parent.height)
|
||||
}
|
||||
}
|
||||
Item {
|
||||
id: tickmarkLabelBounds
|
||||
|
||||
x: control.__tickmarkAlignment === Qt.AlignLeft || control.__tickmarkAlignment === Qt.AlignTop ? 0 : valueBarItem.width
|
||||
width: tickmarkLabelBoundsWidth
|
||||
height: barLength
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
// We want our items to be laid out from bottom to top, but Column can't do that, so we flip
|
||||
// the whole item containing the tickmarks and labels vertically. Then, we flip each tickmark
|
||||
// and label back again.
|
||||
transform: Rotation {
|
||||
axis.x: 1
|
||||
axis.y: 0
|
||||
axis.z: 0
|
||||
origin.x: tickmarkLabelBounds.width / 2
|
||||
origin.y: tickmarkLabelBounds.height / 2
|
||||
angle: 180
|
||||
}
|
||||
|
||||
Column {
|
||||
id: tickmarkColumn
|
||||
x: control.__tickmarkAlignment === Qt.AlignRight || control.__tickmarkAlignment === Qt.AlignBottom ? 0 : tickmarkLabelBounds.width - width
|
||||
spacing: tickmarkSpacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Repeater {
|
||||
id: tickmarkRepeater
|
||||
model: tickmarkCount
|
||||
delegate: Loader {
|
||||
id: tickmarkDelegateLoader
|
||||
|
||||
sourceComponent: gaugeStyle.tickmark
|
||||
transform: Rotation {
|
||||
axis.x: 1
|
||||
axis.y: 0
|
||||
axis.z: 0
|
||||
origin.x: tickmarkDelegateLoader.width / 2
|
||||
origin.y: tickmarkDelegateLoader.height / 2
|
||||
angle: 180
|
||||
}
|
||||
|
||||
onHeightChanged: {
|
||||
if (index == 0)
|
||||
tickmarkWidth = height;
|
||||
}
|
||||
|
||||
readonly property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: tickmarkDelegateLoader.__index
|
||||
readonly property real value: (index / (tickmarkCount - 1)) * (control.maximumValue - control.minimumValue) + control.minimumValue
|
||||
readonly property int valuePosition: Math.round(tickmarkDelegateLoader.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Doesn't need to be in a column, since we assume that the major tickmarks will always be longer than us.
|
||||
Repeater {
|
||||
id: minorTickmarkRepeater
|
||||
model: (tickmarkCount - 1) * control.minorTickmarkCount
|
||||
delegate: Loader {
|
||||
id: minorTickmarkDelegateLoader
|
||||
|
||||
x: control.__tickmarkAlignment === Qt.AlignRight || control.__tickmarkAlignment === Qt.AlignBottom ? 0 : tickmarkLabelBounds.width - width
|
||||
y: {
|
||||
var tickmarkWidthOffset = Math.floor(index / control.minorTickmarkCount) * tickmarkWidth + tickmarkWidth;
|
||||
var relativePosition = (index % control.minorTickmarkCount + 1) * (tickmarkSpacing / (control.minorTickmarkCount + 1));
|
||||
var clusterOffset = Math.floor(index / control.minorTickmarkCount) * tickmarkSpacing;
|
||||
// We assume that each minorTickmark's height is the same.
|
||||
return clusterOffset + tickmarkWidthOffset + relativePosition - height / 2;
|
||||
}
|
||||
|
||||
transform: Rotation {
|
||||
axis.x: 1
|
||||
axis.y: 0
|
||||
axis.z: 0
|
||||
origin.x: minorTickmarkDelegateLoader.width / 2
|
||||
origin.y: minorTickmarkDelegateLoader.height / 2
|
||||
angle: 180
|
||||
}
|
||||
|
||||
sourceComponent: gaugeStyle.minorTickmark
|
||||
|
||||
readonly property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: minorTickmarkDelegateLoader.__index
|
||||
readonly property real value: {
|
||||
var tickmarkIndex = Math.floor(index / control.minorTickmarkCount);
|
||||
return index * minorTickmarkStep + minorTickmarkStep * tickmarkIndex + minorTickmarkStep + control.minimumValue;
|
||||
}
|
||||
readonly property int valuePosition: Math.round(minorTickmarkDelegateLoader.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: tickmarkLabelItem
|
||||
x: control.__tickmarkAlignment === Qt.AlignRight || control.__tickmarkAlignment === Qt.AlignBottom
|
||||
? tickmarkLength
|
||||
: tickmarkLabelBounds.width - tickmarkLength - width
|
||||
width: control.__hiddenText.width
|
||||
// Use the bar height instead of the container's, as the labels seem to be translated by 1 when we
|
||||
// flip the control vertically, and this fixes that.
|
||||
height: parent.height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Repeater {
|
||||
id: tickmarkTextRepeater
|
||||
model: tickmarkCount
|
||||
delegate: Item {
|
||||
x: {
|
||||
if (control.orientation === Qt.Vertical)
|
||||
return 0;
|
||||
|
||||
// Align the text to the edge of the tickmarks.
|
||||
return ((width - height) / 2) * (control.__tickmarkAlignment === Qt.AlignBottom ? -1 : 1);
|
||||
}
|
||||
y: index * labelDistance - height / 2
|
||||
|
||||
width: control.__hiddenText.width
|
||||
height: control.__hiddenText.height
|
||||
|
||||
transformOrigin: Item.Center
|
||||
rotation: control.orientation === Qt.Vertical ? 0 : 90
|
||||
|
||||
readonly property real labelDistance: tickmarkLabelBounds.height / (tickmarkCount - 1)
|
||||
|
||||
Loader {
|
||||
id: tickmarkTextRepeaterDelegate
|
||||
|
||||
x: {
|
||||
if (control.orientation === Qt.Horizontal) {
|
||||
return parent.width / 2 - width / 2;
|
||||
}
|
||||
|
||||
return control.__tickmarkAlignment === Qt.AlignRight || control.__tickmarkAlignment === Qt.AlignBottom
|
||||
? 0
|
||||
: parent.width - width;
|
||||
}
|
||||
|
||||
transform: Rotation {
|
||||
axis.x: 1
|
||||
axis.y: 0
|
||||
axis.z: 0
|
||||
origin.x: tickmarkTextRepeaterDelegate.width / 2
|
||||
origin.y: tickmarkTextRepeaterDelegate.height / 2
|
||||
angle: 180
|
||||
}
|
||||
|
||||
sourceComponent: tickmarkLabel
|
||||
|
||||
readonly property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: tickmarkTextRepeaterDelegate.__index
|
||||
readonly property real value: markerTextFromPos(index / (tickmarkTextRepeater.count - 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
id: foregroundLoader
|
||||
sourceComponent: foreground
|
||||
anchors.fill: valueBarItem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype GroupBoxStyle
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\ingroup controlsstyling
|
||||
\since 5.1
|
||||
*/
|
||||
Style {
|
||||
|
||||
/*! The \l GroupBox this style is attached to. */
|
||||
readonly property GroupBox control: __control
|
||||
|
||||
/*! The margin from the content item to the groupbox. */
|
||||
padding {
|
||||
top: (control.title.length > 0 || control.checkable ? TextSingleton.implicitHeight : 0) + 10
|
||||
left: 8
|
||||
right: 8
|
||||
bottom: 6
|
||||
}
|
||||
|
||||
/*! The title text color. */
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*! The check box. */
|
||||
property Component checkbox: Item {
|
||||
implicitWidth: 18
|
||||
implicitHeight: 18
|
||||
BorderImage {
|
||||
anchors.fill: parent
|
||||
source: "images/editbox.png"
|
||||
border.top: 6
|
||||
border.bottom: 6
|
||||
border.left: 6
|
||||
border.right: 6
|
||||
}
|
||||
Rectangle {
|
||||
height: 16
|
||||
width: 16
|
||||
antialiasing: true
|
||||
visible: control.checked
|
||||
color: "#666"
|
||||
radius: 1
|
||||
anchors.margins: 4
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 3
|
||||
anchors.bottomMargin: 5
|
||||
border.color: "#222"
|
||||
opacity: control.enabled ? 1 : 0.5
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
color: "transparent"
|
||||
border.color: "#33ffffff"
|
||||
}
|
||||
}
|
||||
BorderImage {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -1
|
||||
source: "images/focusframe.png"
|
||||
visible: control.activeFocus
|
||||
border.left: 4
|
||||
border.right: 4
|
||||
border.top: 4
|
||||
border.bottom: 4
|
||||
}
|
||||
}
|
||||
|
||||
/*! The groupbox frame. */
|
||||
property Component panel: Item {
|
||||
anchors.fill: parent
|
||||
Loader {
|
||||
id: checkboxloader
|
||||
anchors.left: parent.left
|
||||
sourceComponent: control.checkable ? checkbox : null
|
||||
anchors.verticalCenter: label.verticalCenter
|
||||
width: item ? item.implicitWidth : 0
|
||||
}
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.left: checkboxloader.right
|
||||
anchors.margins: 4
|
||||
text: control.title
|
||||
color: textColor
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
|
||||
BorderImage {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: padding.top - 7
|
||||
source: "images/groupbox.png"
|
||||
border.left: 4
|
||||
border.right: 4
|
||||
border.top: 4
|
||||
border.bottom: 4
|
||||
visible: !control.flat
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
Style {
|
||||
id: handleStyle
|
||||
property alias handleColorTop: __helper.handleColorTop
|
||||
property alias handleColorBottom: __helper.handleColorBottom
|
||||
property alias handleColorBottomStop: __helper.handleColorBottomStop
|
||||
|
||||
HandleStyleHelper {
|
||||
id: __helper
|
||||
}
|
||||
|
||||
property Component handle: Item {
|
||||
implicitWidth: 50
|
||||
implicitHeight: 50
|
||||
|
||||
Canvas {
|
||||
id: handleCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
__helper.paintHandle(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Component panel: Item {
|
||||
Loader {
|
||||
id: handleLoader
|
||||
sourceComponent: handle
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
|
||||
QtObject {
|
||||
id: handleStyleHelper
|
||||
|
||||
property color handleColorTop: "#969696"
|
||||
property color handleColorBottom: Qt.rgba(0.9, 0.9, 0.9, 0.298)
|
||||
property real handleColorBottomStop: 0.7
|
||||
|
||||
property color handleRingColorTop: "#b0b0b0"
|
||||
property color handleRingColorBottom: "transparent"
|
||||
|
||||
/*!
|
||||
If \a ctx is the only argument, this is equivalent to calling
|
||||
paintHandle(\c ctx, \c 0, \c 0, \c ctx.canvas.width, \c ctx.canvas.height).
|
||||
*/
|
||||
function paintHandle(ctx, handleX, handleY, handleWidth, handleHeight) {
|
||||
ctx.reset();
|
||||
|
||||
if (handleWidth < 0)
|
||||
return;
|
||||
|
||||
if (arguments.length == 1) {
|
||||
handleX = 0;
|
||||
handleY = 0;
|
||||
handleWidth = ctx.canvas.width;
|
||||
handleHeight = ctx.canvas.height;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
var gradient = ctx.createRadialGradient(handleX, handleY, 0,
|
||||
handleX, handleY, handleWidth * 1.5);
|
||||
gradient.addColorStop(0, handleColorTop);
|
||||
gradient.addColorStop(handleColorBottomStop, handleColorBottom);
|
||||
ctx.ellipse(handleX, handleY, handleWidth, handleHeight);
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
|
||||
/* Draw the ring gradient around the handle. */
|
||||
// Clip first, so we only draw inside the ring.
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(handleX, handleY, handleWidth, handleHeight);
|
||||
ctx.ellipse(handleX + 2, handleY + 2, handleWidth - 4, handleHeight - 4);
|
||||
ctx.clip();
|
||||
|
||||
ctx.beginPath();
|
||||
gradient = ctx.createLinearGradient(handleX + handleWidth / 2, handleY,
|
||||
handleX + handleWidth / 2, handleY + handleHeight);
|
||||
gradient.addColorStop(0, handleRingColorTop);
|
||||
gradient.addColorStop(1, handleRingColorBottom);
|
||||
ctx.ellipse(handleX, handleY, handleWidth, handleHeight);
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype MenuBarStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.3
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for MenuBar.
|
||||
|
||||
\note Styling menu bars may not be supported on platforms using native menu bars
|
||||
through their QPA plugin.
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: root
|
||||
|
||||
/*!
|
||||
\qmlmethod string MenuBarStyle::formatMnemonic(string text, bool underline = false)
|
||||
Returns a formatted string to render mnemonics for a given menu item.
|
||||
|
||||
The mnemonic character is prefixed by an ampersand in the original string.
|
||||
|
||||
Passing \c true for \c underline will underline the mnemonic character (e.g.,
|
||||
\c formatMnemonic("&File", true) will return \c "<u>F</u>ile"). Passing \c false
|
||||
for \c underline will return the plain text form (e.g., \c formatMnemonic("&File", false)
|
||||
will return \c "File").
|
||||
|
||||
\sa Label
|
||||
*/
|
||||
function formatMnemonic(text, underline) {
|
||||
return underline ? StyleHelpers.stylizeMnemonics(text) : StyleHelpers.removeMnemonics(text)
|
||||
}
|
||||
|
||||
/*! The background for the full menu bar.
|
||||
|
||||
The background will be extended to the full containing window width.
|
||||
Its height will always fit all of the menu bar items. The final size
|
||||
will include the paddings.
|
||||
*/
|
||||
property Component background: Rectangle {
|
||||
color: "#dcdcdc"
|
||||
implicitHeight: 20
|
||||
}
|
||||
|
||||
/*! The menu bar item.
|
||||
|
||||
\target styleData properties
|
||||
This item has to be configured using the \b styleData object which is in scope,
|
||||
and contains the following read-only properties:
|
||||
\table
|
||||
\row \li \b {styleData.index} : int \li The index of the menu item in its menu.
|
||||
\row \li \b {styleData.selected} : bool \li \c true if the menu item is selected.
|
||||
\row \li \b {styleData.open} : bool \li \c true when the pull down menu is open.
|
||||
\row \li \b {styleData.text} : string \li The menu bar item's text.
|
||||
\row \li \b {styleData.underlineMnemonic} : bool \li When \c true, the style should underline the menu item's label mnemonic.
|
||||
\endtable
|
||||
|
||||
*/
|
||||
property Component itemDelegate: Rectangle {
|
||||
implicitWidth: text.width + 12
|
||||
implicitHeight: text.height + 4
|
||||
color: styleData.enabled && styleData.open ? "#49d" : "transparent"
|
||||
|
||||
Text {
|
||||
id: text
|
||||
font: root.font
|
||||
text: formatMnemonic(styleData.text, styleData.underlineMnemonic)
|
||||
anchors.centerIn: parent
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
color: styleData.open ? "white" : SystemPaletteSingleton.windowText(control.enabled && styleData.enabled)
|
||||
}
|
||||
}
|
||||
|
||||
/*! The style component for the menubar's own menus and their submenus.
|
||||
|
||||
\sa {MenuStyle}
|
||||
*/
|
||||
property Component menuStyle: MenuStyle {
|
||||
font: root.font
|
||||
}
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The font of the control.
|
||||
*/
|
||||
property font font
|
||||
|
||||
/*! \internal */
|
||||
property bool __isNative: true
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Window 2.1
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype MenuStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.3
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Menu.
|
||||
|
||||
\target styleData properties
|
||||
The \b styleData object contains the following read-only properties:
|
||||
\table
|
||||
\row \li \b {styleData.index} : int \li The index of the menu item in its menu.
|
||||
\row \li \b {styleData.type} : enumeration \li The type of menu item. See below for possible values.
|
||||
\row \li \b {styleData.selected} : bool \li \c true if the menu item is selected.
|
||||
\row \li \b {styleData.pressed} : bool \li \c true if the menu item is pressed. Available since 5.4.
|
||||
\row \li \b {styleData.text} : string \li The menu item's text, or title if it's a submenu.
|
||||
\row \li \b {styleData.underlineMnemonic} : bool \li Whether the style should underline the menu item's label mnemonic.
|
||||
\row \li \b {styleData.shortcut} : string \li The text for the menu item's shortcut.
|
||||
\row \li \b {styleData.iconSource} : url \li The source URL to the menu item's icon. Undefined if it has no icon.
|
||||
\row \li \b {styleData.enabled} : bool \li \c true if the menu item is enabled.
|
||||
\row \li \b {styleData.checkable} : bool \li \c true if the menu item is checkable.
|
||||
\row \li \b {styleData.exclusive} : bool \li \c true if the menu item is checkable, and it's part of an \l ExclusiveGroup.
|
||||
\row \li \b {styleData.checked} : bool \li \c true if the menu item is checkable and currently checked.
|
||||
\row \li \b {styleData.scrollerDirection} : enumeration \li If the menu item is a scroller, its pointing direction.
|
||||
Valid values are \c Qt.UpArrow, \c Qt.DownArrow, and \c Qt.NoArrow.
|
||||
\endtable
|
||||
|
||||
The valid values for \b {styleData.type} are:
|
||||
\list
|
||||
\li MenuItemType.Item
|
||||
\li MenuItemType.Menu
|
||||
\li MenuItemType.Separator
|
||||
\li MenuItemType.ScrollIndicator
|
||||
\endlist
|
||||
|
||||
\note Styling menus may not be supported on platforms using native menus
|
||||
through their QPA plugin.
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: styleRoot
|
||||
|
||||
padding {
|
||||
top: 1
|
||||
bottom: 1
|
||||
left: 1
|
||||
right: 1
|
||||
}
|
||||
|
||||
/*! The amount of pixels by which a submenu popup overlaps horizontally its parent menu. */
|
||||
property int submenuOverlap: 1
|
||||
|
||||
/*! The number of milliseconds to wait before opening a submenu. */
|
||||
property int submenuPopupDelay: 200
|
||||
|
||||
/*!
|
||||
\qmlmethod string MenuStyle::formatMnemonic(string text, bool underline = false)
|
||||
Returns a rich-text string to render mnemonics for a given menu item.
|
||||
|
||||
The mnemonic character is prefixed by an ampersand in the original string.
|
||||
|
||||
Passing \c true for \c underline will underline the mnemonic character (e.g.,
|
||||
\c formatMnemonic("&Open...", true) will return \c "<u>O</u>pen..."). Passing \c false
|
||||
for \c underline will return the plain text form (e.g., \c formatMnemonic("&Open...", false)
|
||||
will return \c "Open...").
|
||||
|
||||
\sa Label
|
||||
*/
|
||||
function formatMnemonic(text, underline) {
|
||||
return underline ? StyleHelpers.stylizeMnemonics(text) : StyleHelpers.removeMnemonics(text)
|
||||
}
|
||||
|
||||
/*! The background frame for the menu popup.
|
||||
|
||||
The \l Menu will resize the frame to its contents plus the padding.
|
||||
*/
|
||||
property Component frame: Rectangle {
|
||||
color: styleRoot.__backgroundColor
|
||||
border { width: 1; color: styleRoot.__borderColor }
|
||||
}
|
||||
|
||||
/*! \qmlproperty Object MenuStyle::itemDelegate
|
||||
|
||||
The object containing the menu item subcontrol components. These subcontrols are used
|
||||
for normal menu items only, i.e. not for separators or scroll indicators.
|
||||
|
||||
The subcontrols are:
|
||||
|
||||
\list
|
||||
\li \b {itemDelegate.background} : Component
|
||||
|
||||
The menu item background component.
|
||||
|
||||
Its appearance generally changes with \l {styleData properties} {styleData.selected}
|
||||
and \l {styleData properties} {styleData.enabled}.
|
||||
|
||||
The default implementation shows only when the item is enabled and selected. It remains
|
||||
invisible otherwise.
|
||||
|
||||
\li \b {itemDelegate.label} : Component
|
||||
|
||||
Component for the actual text label.
|
||||
|
||||
The text itself is fetched from \l {styleData properties} {styleData.text}, and its appearance should depend
|
||||
on \l {styleData properties} {styleData.enabled} and \l {styleData properties} {styleData.selected}.
|
||||
|
||||
If \l {styleData properties} {styleData.underlineMnemonic} is true, the label should underline its mnemonic
|
||||
character. \l formatMnemonic provides the default formatting.
|
||||
|
||||
\li \b {itemDelegate.submenuIndicator} : Component
|
||||
|
||||
It indicates that the current menu item is a submenu.
|
||||
|
||||
Only used when \l {styleData properties} {styleData.type} equals \c MenuItemType.Menu.
|
||||
|
||||
\li \b {itemDelegate.shortcut} : Component
|
||||
|
||||
Displays the shortcut attached to the menu item.
|
||||
|
||||
Only used when \l {styleData properties} {styleData.shortcut} is not empty.
|
||||
|
||||
\li \b {itemDelegate.checkmarkIndicator} : Component
|
||||
|
||||
Will be used when \l {styleData properties} {styleData.checkable} is \c true and its appearance
|
||||
may depend on \l {styleData properties} {styleData.exclusive}, i.e., whether it will behave like a
|
||||
checkbox or a radio button. Use \l {styleData properties} {styleData.checked} for the checked state.
|
||||
\endlist
|
||||
|
||||
\note This property cannot be overwritten although all of the subcontrol properties can.
|
||||
*/
|
||||
property alias itemDelegate: internalMenuItem
|
||||
|
||||
MenuItemSubControls {
|
||||
id: internalMenuItem
|
||||
|
||||
background: Rectangle {
|
||||
visible: styleData.selected && styleData.enabled
|
||||
gradient: Gradient {
|
||||
id: selectedGradient
|
||||
GradientStop { color: Qt.lighter(__selectedBackgroundColor, 1.3); position: -0.2 }
|
||||
GradientStop { color: __selectedBackgroundColor; position: 1.4 }
|
||||
}
|
||||
|
||||
border.width: 1
|
||||
border.color: Qt.darker(__selectedBackgroundColor, 1)
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
label: Text {
|
||||
text: formatMnemonic(styleData.text, styleData.underlineMnemonic)
|
||||
color: __currentTextColor
|
||||
font: styleRoot.font
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
|
||||
submenuIndicator: Text {
|
||||
text: __mirrored ? "\u25c2" : "\u25b8" // BLACK LEFT/RIGHT-POINTING SMALL TRIANGLE
|
||||
font: styleRoot.font
|
||||
color: __currentTextColor
|
||||
style: styleData.selected ? Text.Normal : Text.Raised
|
||||
styleColor: Qt.lighter(color, 4)
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
|
||||
shortcut: Text {
|
||||
text: styleData.shortcut
|
||||
font {
|
||||
bold: styleRoot.font.bold
|
||||
capitalization: styleRoot.font.capitalization
|
||||
family: styleRoot.font.family
|
||||
italic: styleRoot.font.italic
|
||||
letterSpacing: styleRoot.font.letterSpacing
|
||||
pixelSize: styleRoot.font.pixelSize * 0.9
|
||||
strikeout: styleRoot.font.strikeout
|
||||
underline: styleRoot.font.underline
|
||||
weight: styleRoot.font.weight
|
||||
wordSpacing: styleRoot.font.wordSpacing
|
||||
}
|
||||
color: __currentTextColor
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
|
||||
checkmarkIndicator: Loader {
|
||||
sourceComponent: styleData.exclusive ? exclusiveCheckMark : nonExclusiveCheckMark
|
||||
Component {
|
||||
id: exclusiveCheckMark
|
||||
Rectangle {
|
||||
x: 1
|
||||
width: 10
|
||||
height: 10
|
||||
color: "white"
|
||||
border.color: "gray"
|
||||
antialiasing: true
|
||||
radius: height/2
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
visible: styleData.checked
|
||||
width: 4
|
||||
height: 4
|
||||
color: "#666"
|
||||
border.color: "#222"
|
||||
antialiasing: true
|
||||
radius: height/2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: nonExclusiveCheckMark
|
||||
BorderImage {
|
||||
width: 12
|
||||
height: 12
|
||||
source: "images/editbox.png"
|
||||
border.top: 6
|
||||
border.bottom: 6
|
||||
border.left: 6
|
||||
border.right: 6
|
||||
|
||||
Rectangle {
|
||||
antialiasing: true
|
||||
visible: styleData.checked
|
||||
color: "#666"
|
||||
radius: 1
|
||||
anchors.margins: 4
|
||||
anchors.fill: parent
|
||||
border.color: "#222"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
color: "transparent"
|
||||
border.color: "#33ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! Component for the separator menu item.
|
||||
|
||||
Will be used when \l {styleData properties} {styleData.type} equals \c MenuItemType.Separator.
|
||||
*/
|
||||
property Component separator: Item {
|
||||
implicitHeight: styleRoot.font.pixelSize / 2
|
||||
Rectangle {
|
||||
width: parent.width - 2
|
||||
height: 1
|
||||
x: 1
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: "darkgray"
|
||||
}
|
||||
}
|
||||
|
||||
/*! Component for the scroll indicator menu item.
|
||||
|
||||
Will be used when \l {styleData properties} {styleData.type} equals \c MenuItemType.ScrollIndicator.
|
||||
Its appearance should follow \l {styleData properties} {styleData.scrollerDirection}.
|
||||
|
||||
This is the item added at the top and bottom of the menu popup when its contents won't fit the screen
|
||||
to indicate more content is available in the direction of the arrow.
|
||||
*/
|
||||
property Component scrollIndicator: Image {
|
||||
anchors.centerIn: parent
|
||||
source: styleData.scrollerDirection === Qt.UpArrow ? "images/arrow-up.png" : "images/arrow-down.png"
|
||||
}
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The font of the control.
|
||||
*/
|
||||
property font font
|
||||
|
||||
/*! \internal */
|
||||
property string __menuItemType: "menuitem"
|
||||
|
||||
/*! \internal
|
||||
The menu popup frame background color.
|
||||
|
||||
This is set to be a uniform background. If you want a gradient or a pixmap,
|
||||
you should override \l frame.
|
||||
|
||||
\sa frame, borderColor
|
||||
*/
|
||||
property color __backgroundColor: "#dcdcdc"
|
||||
|
||||
/*! \internal
|
||||
The menu popup frame border color.
|
||||
|
||||
The border width is set to 1 pixel. Override \l frame if you want a larger border.
|
||||
|
||||
\sa frame, backgroundColor
|
||||
*/
|
||||
property color __borderColor: "darkgray"
|
||||
|
||||
/*! \internal
|
||||
The maximum height for a popup before it will show scrollers.
|
||||
*/
|
||||
property int __maxPopupHeight: 600
|
||||
|
||||
/*! \internal
|
||||
The menu item background color when selected.
|
||||
|
||||
This property is provided for convenience and only sets the color.
|
||||
It does not change the style in any other way.
|
||||
*/
|
||||
property color __selectedBackgroundColor: "#49d"
|
||||
|
||||
/*! \internal
|
||||
The menu item label color.
|
||||
|
||||
When set, keyboard shorcuts get the same color as the item's text.
|
||||
|
||||
\sa selectedLabelColor, disabledLabelColor
|
||||
*/
|
||||
property color __labelColor: "#444"
|
||||
|
||||
/*! \internal
|
||||
The menu item label color when selected.
|
||||
|
||||
\sa labelColor, selectedLabelColor
|
||||
*/
|
||||
property color __selectedLabelColor: "white"
|
||||
|
||||
/*! \internal
|
||||
The menu item label color when disabled.
|
||||
|
||||
\sa labelColor, disabledLabelColor
|
||||
*/
|
||||
property color __disabledLabelColor: "gray"
|
||||
|
||||
|
||||
/*! \internal */
|
||||
readonly property bool __mirrored: Qt.application.layoutDirection === Qt.RightToLeft
|
||||
|
||||
/*! \internal
|
||||
The margin between the frame and the menu item label's left side.
|
||||
|
||||
Generally, this should be large enough to fit optional checkmarks on
|
||||
the label's left side.
|
||||
*/
|
||||
property int __leftLabelMargin: 18
|
||||
|
||||
/*! \internal
|
||||
The margin between the menu item label's right side and the frame. */
|
||||
property int __rightLabelMargin: 12
|
||||
|
||||
/*! \internal
|
||||
The minimum spacing between the menu item label's text right side and any
|
||||
element located on its right (submenu indicator or shortcut).
|
||||
*/
|
||||
property int __minRightLabelSpacing: 28
|
||||
|
||||
/*! \internal */
|
||||
property Component __scrollerStyle: null
|
||||
|
||||
/*! \internal
|
||||
The menu item contents itself.
|
||||
|
||||
The default implementation uses \l MenuItemStyle.
|
||||
*/
|
||||
property Component menuItemPanel: Item {
|
||||
id: panel
|
||||
|
||||
property QtObject __styleData: styleData
|
||||
/*! \internal
|
||||
The current color of the text label.
|
||||
|
||||
Use this if you're overriding e.g. \l shortcutIndicator to keep the color matched
|
||||
with \l label, or to derive new colors from it.
|
||||
*/
|
||||
property color currentTextColor: !styleData.enabled ? __disabledLabelColor :
|
||||
styleData.selected ? __selectedLabelColor : __labelColor
|
||||
|
||||
implicitWidth: Math.max((parent ? parent.width : 0),
|
||||
Math.round(__leftLabelMargin + labelLoader.width + __rightLabelMargin +
|
||||
(rightIndicatorLoader.active ? __minRightLabelSpacing + rightIndicatorLoader.width : 0)))
|
||||
implicitHeight: Math.round(styleData.type === MenuItemType.Separator ? separatorLoader.implicitHeight :
|
||||
!!styleData.scrollerDirection ? styleRoot.font.pixelSize * 0.75 : labelLoader.height + 4)
|
||||
|
||||
Loader {
|
||||
property alias styleData: panel.__styleData
|
||||
property alias __currentTextColor: panel.currentTextColor
|
||||
anchors.fill: parent
|
||||
sourceComponent: itemDelegate.background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: separatorLoader
|
||||
property alias styleData: panel.__styleData
|
||||
property alias __currentTextColor: panel.currentTextColor
|
||||
anchors.fill: parent
|
||||
sourceComponent: separator
|
||||
active: styleData.type === MenuItemType.Separator
|
||||
}
|
||||
|
||||
Loader {
|
||||
property alias styleData: panel.__styleData
|
||||
property alias __currentTextColor: panel.currentTextColor
|
||||
x: __mirrored ? parent.width - width - 4 : 4
|
||||
anchors.verticalCenterOffset: -1
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
active: __menuItemType === "menuitem" && styleData.checkable
|
||||
sourceComponent: itemDelegate.checkmarkIndicator
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: labelLoader
|
||||
readonly property real offset: __menuItemType === "menuitem" ? __leftLabelMargin : 6
|
||||
property alias styleData: panel.__styleData
|
||||
property alias __currentTextColor: panel.currentTextColor
|
||||
x: __mirrored ? parent.width - width - offset : offset
|
||||
y: 1
|
||||
active: styleData.type !== MenuItemType.Separator
|
||||
sourceComponent: itemDelegate.label
|
||||
baselineOffset: item ? item.baselineOffset : 0.0
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: rightIndicatorLoader
|
||||
property alias styleData: panel.__styleData
|
||||
property alias __currentTextColor: panel.currentTextColor
|
||||
active: styleData.type === MenuItemType.Menu || styleData.shortcut !== ""
|
||||
sourceComponent: styleData.type === MenuItemType.Menu ? itemDelegate.submenuIndicator : itemDelegate.shortcut
|
||||
LayoutMirroring.enabled: __mirrored
|
||||
baselineOffset: item ? item.baselineOffset : 0.0
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: 6
|
||||
baseline: !styleData.isSubmenu ? labelLoader.baseline : undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
import QtQuick.Extras.Private.CppUtils 1.0
|
||||
|
||||
/*!
|
||||
\qmltype PieMenuStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for PieMenu.
|
||||
|
||||
PieMenuStyle is a style for PieMenu that draws each section of the menu as a
|
||||
filled "slice".
|
||||
|
||||
You can create a custom pie menu by replacing the following delegates:
|
||||
\list
|
||||
\li \l background
|
||||
\li \l cancel
|
||||
\li \l menuItem
|
||||
\li \l title
|
||||
\endlist
|
||||
|
||||
To customize the appearance of each menuItem without having to define your
|
||||
own, you can use the \l backgroundColor and \l selectionColor properties.
|
||||
To customize the drop shadow, use the \l shadowColor, \l shadowRadius and
|
||||
\l shadowSpread properties.
|
||||
|
||||
Icons that are too large for the section that they are in will be scaled
|
||||
down appropriately.
|
||||
|
||||
To style individual sections of the menu, use the menuItem component:
|
||||
\code
|
||||
PieMenuStyle {
|
||||
shadowRadius: 0
|
||||
|
||||
menuItem: Item {
|
||||
id: item
|
||||
rotation: -90 + sectionCenterAngle(styleData.index)
|
||||
|
||||
Rectangle {
|
||||
width: parent.height * 0.2
|
||||
height: width
|
||||
color: "darkorange"
|
||||
radius: width / 2
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Text {
|
||||
id: textItem
|
||||
text: control.menuItems[styleData.index].text
|
||||
anchors.centerIn: parent
|
||||
color: control.currentIndex === styleData.index ? "red" : "white"
|
||||
rotation: -item.rotation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\image piemenu-menuitem-example.png A custom PieMenu
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: pieMenuStyle
|
||||
|
||||
/*!
|
||||
The \l PieMenu that this style is attached to.
|
||||
*/
|
||||
readonly property PieMenu control: __control
|
||||
|
||||
/*! The background color. */
|
||||
property color backgroundColor: Qt.rgba(0.6, 0.6, 0.6, 0.66)
|
||||
|
||||
/*! The selection color. */
|
||||
property color selectionColor: "#eee"
|
||||
|
||||
/*!
|
||||
The shadow color.
|
||||
|
||||
\sa DropShadow
|
||||
*/
|
||||
property color shadowColor: Qt.rgba(0, 0, 0, 0.26)
|
||||
|
||||
/*!
|
||||
The shadow radius.
|
||||
|
||||
\sa DropShadow
|
||||
*/
|
||||
property real shadowRadius: 10
|
||||
|
||||
/*!
|
||||
The shadow spread.
|
||||
|
||||
\sa DropShadow
|
||||
*/
|
||||
property real shadowSpread: 0.3
|
||||
|
||||
/*!
|
||||
The distance from the center of the menu to the outer edge of the menu.
|
||||
|
||||
\sa cancelRadius
|
||||
*/
|
||||
readonly property real radius: Math.min(control.width, control.height) * 0.5
|
||||
|
||||
/*!
|
||||
The radius of the area that is used to cancel the menu.
|
||||
|
||||
\sa radius
|
||||
*/
|
||||
property real cancelRadius: radius * 0.4
|
||||
|
||||
/*!
|
||||
The angle (in degrees) at which the first menu item will be drawn.
|
||||
|
||||
The absolute range formed by \a startAngle and \l endAngle must be
|
||||
less than or equal to \c 360 degrees.
|
||||
|
||||
Menu items are displayed clockwise when \a startAngle is less than
|
||||
\l endAngle, otherwise they are displayed anti-clockwise.
|
||||
|
||||
\sa endAngle
|
||||
*/
|
||||
property real startAngle: -90
|
||||
|
||||
/*!
|
||||
The angle (in degrees) at which the last menu item will be drawn.
|
||||
|
||||
The absolute range formed by \l startAngle and \a endAngle must be
|
||||
less than or equal to \c 360 degrees.
|
||||
|
||||
Menu items are displayed clockwise when \l startAngle is less than
|
||||
\a endAngle, otherwise they are displayed anti-clockwise.
|
||||
|
||||
\sa startAngle
|
||||
*/
|
||||
property real endAngle: 90
|
||||
|
||||
/*!
|
||||
\qmlmethod real PieMenuStyle::sectionStartAngle(int itemIndex)
|
||||
Returns the start of the section at \a itemIndex as an angle in degrees.
|
||||
*/
|
||||
function sectionStartAngle(itemIndex) {
|
||||
return MathUtils.radToDegOffset(control.__protectedScope.sectionStartAngle(itemIndex));
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod real PieMenuStyle::sectionCenterAngle(int itemIndex)
|
||||
Returns the center of the section at \a itemIndex as an angle in
|
||||
degrees.
|
||||
*/
|
||||
function sectionCenterAngle(itemIndex) {
|
||||
return MathUtils.radToDegOffset(control.__protectedScope.sectionCenterAngle(itemIndex));
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod real PieMenuStyle::sectionEndAngle(int itemIndex)
|
||||
Returns the end of the section at \a itemIndex as an angle in degrees.
|
||||
*/
|
||||
function sectionEndAngle(itemIndex) {
|
||||
return MathUtils.radToDegOffset(control.__protectedScope.sectionEndAngle(itemIndex));
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
The distance in pixels from the center of each menu item's icon to the
|
||||
center of the menu. A higher value means that the icons will be further
|
||||
from the center of the menu.
|
||||
*/
|
||||
readonly property real __iconOffset: cancelRadius + ((radius - cancelRadius) / 2)
|
||||
|
||||
/*! \internal */
|
||||
readonly property real __selectableRadius: radius - cancelRadius
|
||||
|
||||
/*! \internal */
|
||||
property int __implicitWidth: Math.round(TextSingleton.implicitHeight * 12.5)
|
||||
|
||||
/*! \internal */
|
||||
property int __implicitHeight: __implicitWidth
|
||||
|
||||
/*!
|
||||
The background of the menu.
|
||||
|
||||
By default, there is no background defined.
|
||||
*/
|
||||
property Component background
|
||||
|
||||
/*!
|
||||
The cancel component of the menu.
|
||||
|
||||
This is an area in the center of the menu that closes the menu when
|
||||
clicked.
|
||||
|
||||
By default, it is not visible.
|
||||
*/
|
||||
property Component cancel: null
|
||||
|
||||
/*!
|
||||
The component that displays the text of the currently selected menu
|
||||
item, or the title if there is no current item.
|
||||
|
||||
The current item's text is available via the \c styleData.text
|
||||
property.
|
||||
*/
|
||||
property Component title: Text {
|
||||
font.pointSize: 20
|
||||
text: styleData.text
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: "#ccc"
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
/*!
|
||||
This component defines each section of the pie menu.
|
||||
|
||||
This component covers the width and height of the control.
|
||||
|
||||
No mouse events are propagated to this component, which means that
|
||||
controls like Button will not function when used within it. You can
|
||||
check if the mouse is over this section by comparing
|
||||
\c control.currentIndex to \c styleData.index.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this menu item.
|
||||
\row \li \c {readonly property bool} \b styleData.hovered
|
||||
\li \c true if this menu item is under the mouse.
|
||||
\row \li \c {readonly property bool} \b styleData.pressed
|
||||
\li \c true if the mouse is pressed down on this menu item.
|
||||
\endtable
|
||||
*/
|
||||
property Component menuItem: Item {
|
||||
id: actionRootDelegateItem
|
||||
|
||||
function drawRingSection(ctx, x, y, section, r, ringWidth, ringColor) {
|
||||
ctx.fillStyle = ringColor;
|
||||
|
||||
// Draw one section.
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x,y);
|
||||
|
||||
// Canvas draws 0 degrees at 3 o'clock, whereas we want it to draw it at 12.
|
||||
var start = control.__protectedScope.sectionStartAngle(section);
|
||||
var end = control.__protectedScope.sectionEndAngle(section);
|
||||
ctx.arc(x, y, r, start, end, start > end);
|
||||
ctx.fill();
|
||||
|
||||
// Either change this to the background color, or use the global composition.
|
||||
ctx.fillStyle = "black";
|
||||
ctx.globalCompositeOperation = "destination-out";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y);
|
||||
ctx.arc(x, y, ringWidth, 0, Math.PI * 2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
// If using the global composition method, make sure to change it back to default.
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: actionCanvas
|
||||
anchors.fill: parent
|
||||
property color currentColor: control.currentIndex === styleData.index ? selectionColor : backgroundColor
|
||||
|
||||
Connections {
|
||||
target: pieMenuStyle
|
||||
onStartAngleChanged: actionCanvas.requestPaint()
|
||||
onEndAngleChanged: actionCanvas.requestPaint()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onCurrentIndexChanged: actionCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
drawRingSection(ctx, width / 2, height / 2, styleData.index, radius, cancelRadius, currentColor);
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var __styleData: styleData
|
||||
|
||||
PieMenuIcon {
|
||||
control: pieMenuStyle.control
|
||||
styleData: __styleData
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: __implicitWidth
|
||||
implicitHeight: __implicitHeight
|
||||
|
||||
property alias titleItem: titleLoader.item
|
||||
|
||||
Item {
|
||||
id: itemgroup
|
||||
anchors.fill: parent
|
||||
visible: false
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: background
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: cancelLoader
|
||||
sourceComponent: cancel
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: menuItemRepeater
|
||||
model: control.__protectedScope.visibleItems
|
||||
|
||||
delegate: Loader {
|
||||
id: menuItemLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: menuItem
|
||||
|
||||
readonly property int __index: index
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: menuItemLoader.__index
|
||||
readonly property bool hovered: control.currentIndex === index
|
||||
readonly property bool pressed: control.__protectedScope.pressedIndex === index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DropShadow {
|
||||
id: dropShadow
|
||||
anchors.fill: itemgroup
|
||||
spread: shadowSpread
|
||||
samples: shadowRadius * 2 + 1
|
||||
transparentBorder: true
|
||||
color: shadowColor
|
||||
source: itemgroup
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: titleLoader
|
||||
sourceComponent: title
|
||||
x: parent.x + parent.width / 2 - width / 2
|
||||
y: -height - 10
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
property string text: control.currentIndex !== -1
|
||||
? control.__protectedScope.visibleItems[control.currentIndex].text
|
||||
: control.title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ProgressBarStyle
|
||||
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for ProgressBar.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
ProgressBar {
|
||||
value: slider.value
|
||||
style: ProgressBarStyle {
|
||||
background: Rectangle {
|
||||
radius: 2
|
||||
color: "lightgray"
|
||||
border.color: "gray"
|
||||
border.width: 1
|
||||
implicitWidth: 200
|
||||
implicitHeight: 24
|
||||
}
|
||||
progress: Rectangle {
|
||||
color: "lightsteelblue"
|
||||
border.color: "steelblue"
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
|
||||
Note that the example above is somewhat simplified and will not animate
|
||||
an indeterminate progress bar. The following snippet demonstrates
|
||||
how you can incorporate a custom animation for the indeterminate
|
||||
state as well.
|
||||
|
||||
\code
|
||||
progress: Rectangle {
|
||||
border.color: "steelblue"
|
||||
color: "lightsteelblue"
|
||||
|
||||
// Indeterminate animation by animating alternating stripes:
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
visible: control.indeterminate
|
||||
clip: true
|
||||
Row {
|
||||
Repeater {
|
||||
Rectangle {
|
||||
color: index % 2 ? "steelblue" : "lightsteelblue"
|
||||
width: 20 ; height: control.height
|
||||
}
|
||||
model: control.width / 20 + 2
|
||||
}
|
||||
XAnimator on x {
|
||||
from: 0 ; to: -40
|
||||
loops: Animation.Infinite
|
||||
running: control.indeterminate
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: progressBarStyle
|
||||
|
||||
/*! The \l ProgressBar this style is attached to. */
|
||||
readonly property ProgressBar control: __control
|
||||
|
||||
/*! A value in the range [0-1] indicating the current progress. */
|
||||
readonly property real currentProgress: control.indeterminate ? 1.0 :
|
||||
control.value / control.maximumValue
|
||||
|
||||
/*! This property holds the visible contents of the progress bar
|
||||
You can access the Slider through the \c control property.
|
||||
|
||||
For convenience, you can also access the readonly property \c styleData.progress
|
||||
which provides the current progress as a \c real in the range [0-1]
|
||||
*/
|
||||
padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
|
||||
|
||||
/*! \qmlproperty Component ProgressBarStyle::progress
|
||||
The progress component for this style.
|
||||
*/
|
||||
property Component progress: Item {
|
||||
property color progressColor: "#49d"
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
Rectangle {
|
||||
id: base
|
||||
anchors.fill: parent
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
antialiasing: true
|
||||
gradient: Gradient {
|
||||
GradientStop {color: Qt.lighter(progressColor, 1.3) ; position: 0}
|
||||
GradientStop {color: progressColor ; position: 1.4}
|
||||
}
|
||||
border.width: 1
|
||||
border.color: Qt.darker(progressColor, 1.2)
|
||||
Rectangle {
|
||||
color: "transparent"
|
||||
radius: 1.5
|
||||
clip: true
|
||||
antialiasing: true
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
border.color: Qt.rgba(1,1,1,0.1)
|
||||
Image {
|
||||
visible: control.indeterminate
|
||||
height: parent.height
|
||||
NumberAnimation on x {
|
||||
from: -39
|
||||
to: 0
|
||||
running: control.indeterminate
|
||||
duration: 800
|
||||
loops: Animation.Infinite
|
||||
}
|
||||
fillMode: Image.Tile
|
||||
width: parent.width + 25
|
||||
source: "images/progress-indeterminate.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
height: parent.height - 2
|
||||
width: 1
|
||||
y: 1
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 1
|
||||
color: Qt.rgba(1,1,1,0.1)
|
||||
visible: splitter.visible
|
||||
}
|
||||
Rectangle {
|
||||
id: splitter
|
||||
height: parent.height - 2
|
||||
width: 1
|
||||
y: 1
|
||||
anchors.right: parent.right
|
||||
color: Qt.darker(progressColor, 1.2)
|
||||
property int offset: currentProgress * control.width
|
||||
visible: offset > base.radius && offset < control.width - base.radius + 1
|
||||
}
|
||||
}
|
||||
|
||||
/*! \qmlproperty Component ProgressBarStyle::background
|
||||
The background component for this style.
|
||||
|
||||
\note The implicitWidth and implicitHeight of the background component
|
||||
must be set.
|
||||
*/
|
||||
property Component background: Item {
|
||||
implicitWidth: 200
|
||||
implicitHeight: Math.max(17, Math.round(TextSingleton.implicitHeight * 0.7))
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: control.pressed ? 0 : -1
|
||||
color: "#44ffffff"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#eee" ; position: 0}
|
||||
GradientStop {color: "#fff" ; position: 0.1}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
radius: TextSingleton.implicitHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
color: control.activeFocus ? "#47b" : "white"
|
||||
opacity: control.hovered || control.activeFocus ? 0.1 : 0
|
||||
Behavior on opacity {NumberAnimation{ duration: 100 }}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \qmlproperty Component ProgressBarStyle::panel
|
||||
The panel component for this style.
|
||||
*/
|
||||
property Component panel: Item{
|
||||
property bool horizontal: control.orientation == Qt.Horizontal
|
||||
implicitWidth: horizontal ? backgroundLoader.implicitWidth : backgroundLoader.implicitHeight
|
||||
implicitHeight: horizontal ? backgroundLoader.implicitHeight : backgroundLoader.implicitWidth
|
||||
|
||||
Item {
|
||||
width: horizontal ? parent.width : parent.height
|
||||
height: !horizontal ? parent.width : parent.height
|
||||
y: horizontal ? 0 : width
|
||||
rotation: horizontal ? 0 : -90
|
||||
transformOrigin: Item.TopLeft
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
sourceComponent: progressBarStyle.progress
|
||||
anchors.topMargin: padding.top
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.bottomMargin: padding.bottom
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
width: currentProgress * (parent.width - padding.left - padding.right)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype RadioButtonStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for RadioButton.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
RadioButton {
|
||||
text: "Radio Button"
|
||||
style: RadioButtonStyle {
|
||||
indicator: Rectangle {
|
||||
implicitWidth: 16
|
||||
implicitHeight: 16
|
||||
radius: 9
|
||||
border.color: control.activeFocus ? "darkblue" : "gray"
|
||||
border.width: 1
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
visible: control.checked
|
||||
color: "#555"
|
||||
radius: 9
|
||||
anchors.margins: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: radiobuttonStyle
|
||||
|
||||
/*! The \l RadioButton this style is attached to. */
|
||||
readonly property RadioButton control: __control
|
||||
|
||||
/*! This defines the text label. */
|
||||
property Component label: Item {
|
||||
implicitWidth: text.implicitWidth + 2
|
||||
implicitHeight: text.implicitHeight
|
||||
baselineOffset: text.y + text.baselineOffset
|
||||
Rectangle {
|
||||
anchors.fill: text
|
||||
anchors.margins: -1
|
||||
anchors.leftMargin: -3
|
||||
anchors.rightMargin: -3
|
||||
visible: control.activeFocus
|
||||
height: 6
|
||||
radius: 3
|
||||
color: "#224f9fef"
|
||||
border.color: "#47b"
|
||||
opacity: 0.6
|
||||
}
|
||||
Text {
|
||||
id: text
|
||||
text: StyleHelpers.stylizeMnemonics(control.text)
|
||||
anchors.centerIn: parent
|
||||
color: SystemPaletteSingleton.text(control.enabled)
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
/*! The background under indicator and label. */
|
||||
property Component background
|
||||
|
||||
/*! The spacing between indicator and label. */
|
||||
property int spacing: Math.round(TextSingleton.implicitHeight/4)
|
||||
|
||||
/*! This defines the indicator button. */
|
||||
property Component indicator: Rectangle {
|
||||
width: Math.round(TextSingleton.implicitHeight)
|
||||
height: width
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#eee" ; position: 0}
|
||||
GradientStop {color: control.pressed ? "#eee" : "#fff" ; position: 0.4}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
border.color: control.activeFocus ? "#16c" : "gray"
|
||||
antialiasing: true
|
||||
radius: height/2
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: Math.round(parent.width * 0.5)
|
||||
height: width
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#999" ; position: 0}
|
||||
GradientStop {color: "#555" ; position: 1}
|
||||
}
|
||||
border.color: "#222"
|
||||
antialiasing: true
|
||||
radius: height/2
|
||||
Behavior on opacity {NumberAnimation {duration: 80}}
|
||||
opacity: control.checked ? control.enabled ? 1 : 0.5 : 0
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: Math.max(backgroundLoader.implicitWidth, row.implicitWidth + padding.left + padding.right)
|
||||
implicitHeight: Math.max(backgroundLoader.implicitHeight, labelLoader.implicitHeight + padding.top + padding.bottom,indicatorLoader.implicitHeight + padding.top + padding.bottom)
|
||||
baselineOffset: labelLoader.item ? padding.top + labelLoader.item.baselineOffset : 0
|
||||
|
||||
Loader {
|
||||
id:backgroundLoader
|
||||
sourceComponent: background
|
||||
anchors.fill: parent
|
||||
}
|
||||
Row {
|
||||
id: row
|
||||
anchors.fill: parent
|
||||
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.topMargin: padding.top
|
||||
anchors.bottomMargin: padding.bottom
|
||||
|
||||
spacing: radiobuttonStyle.spacing
|
||||
Loader {
|
||||
id: indicatorLoader
|
||||
sourceComponent: indicator
|
||||
}
|
||||
Loader {
|
||||
id: labelLoader
|
||||
sourceComponent: label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ScrollViewStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup viewsstyling
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for ScrollView.
|
||||
*/
|
||||
Style {
|
||||
id: root
|
||||
|
||||
/*! The \l ScrollView this style is attached to. */
|
||||
readonly property ScrollView control: __control
|
||||
|
||||
/*! This property controls the frame border padding of the scrollView. */
|
||||
padding {left: 1; top: 1; right: 1; bottom: 1}
|
||||
|
||||
/*! This Component paints the corner area between scroll bars */
|
||||
property Component corner: Rectangle { color: "#ccc" }
|
||||
|
||||
/*! This component determines if the flickable should reposition itself at the
|
||||
mouse location when clicked. */
|
||||
property bool scrollToClickedPosition: true
|
||||
|
||||
/*! This property holds whether the scroll bars are transient. Transient scroll bars
|
||||
appear when the content is scrolled and disappear when they are no longer needed.
|
||||
|
||||
The default value is platform dependent. */
|
||||
property bool transientScrollBars: Settings.isMobile && Settings.hasTouchScreen
|
||||
|
||||
/*! This Component paints the frame around scroll bars. */
|
||||
property Component frame: Rectangle {
|
||||
color: control["backgroundVisible"] ? "white": "transparent"
|
||||
border.color: "#999"
|
||||
border.width: 1
|
||||
radius: 1
|
||||
visible: control.frameVisible
|
||||
}
|
||||
|
||||
/*! This is the minimum extent of the scroll bar handle.
|
||||
|
||||
The default value is \c 30.
|
||||
*/
|
||||
|
||||
property int minimumHandleLength: 30
|
||||
|
||||
/*! This property controls the edge overlap
|
||||
between the handle and the increment/decrement buttons.
|
||||
|
||||
The default value is \c 30.
|
||||
*/
|
||||
|
||||
property int handleOverlap: 1
|
||||
|
||||
/*! This component controls the appearance of the
|
||||
scroll bar background.
|
||||
|
||||
You can access the following state properties:
|
||||
|
||||
\table
|
||||
\row \li property bool \b styleData.hovered
|
||||
\row \li property bool \b styleData.horizontal
|
||||
\endtable
|
||||
*/
|
||||
|
||||
property Component scrollBarBackground: Item {
|
||||
property bool sticky: false
|
||||
property bool hovered: styleData.hovered
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight)
|
||||
implicitHeight: Math.round(TextSingleton.implicitHeight)
|
||||
clip: true
|
||||
opacity: transientScrollBars ? 0.5 : 1.0
|
||||
visible: !Settings.hasTouchScreen && (!transientScrollBars || sticky)
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#ddd"
|
||||
border.color: "#aaa"
|
||||
anchors.rightMargin: styleData.horizontal ? -2 : -1
|
||||
anchors.leftMargin: styleData.horizontal ? -2 : 0
|
||||
anchors.topMargin: styleData.horizontal ? 0 : -2
|
||||
anchors.bottomMargin: styleData.horizontal ? -1 : -2
|
||||
}
|
||||
onHoveredChanged: if (hovered) sticky = true
|
||||
onVisibleChanged: if (!visible) sticky = false
|
||||
}
|
||||
|
||||
/*! This component controls the appearance of the
|
||||
scroll bar handle.
|
||||
|
||||
You can access the following state properties:
|
||||
|
||||
\table
|
||||
\row \li property bool \b styleData.hovered
|
||||
\row \li property bool \b styleData.pressed
|
||||
\row \li property bool \b styleData.horizontal
|
||||
\endtable
|
||||
*/
|
||||
|
||||
property Component handle: Item {
|
||||
property bool sticky: false
|
||||
property bool hovered: __activeControl !== "none"
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight) + 1
|
||||
implicitHeight: Math.round(TextSingleton.implicitHeight) + 1
|
||||
BorderImage {
|
||||
id: img
|
||||
opacity: styleData.pressed && !transientScrollBars ? 0.5 : styleData.hovered ? 1 : 0.8
|
||||
source: "images/scrollbar-handle-" + (transientScrollBars ? "transient" : styleData.horizontal ? "horizontal" : "vertical") + ".png"
|
||||
border.left: transientScrollBars ? 5 : 2
|
||||
border.top: transientScrollBars ? 5 : 2
|
||||
border.right: transientScrollBars ? 5 : 2
|
||||
border.bottom: transientScrollBars ? 5 : 2
|
||||
anchors.top: !styleData.horizontal ? parent.top : undefined
|
||||
anchors.margins: transientScrollBars ? 2 : 0
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: styleData.horizontal ? parent.left : undefined
|
||||
width: !styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.width
|
||||
height: styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.height
|
||||
Behavior on width { enabled: !styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } }
|
||||
Behavior on height { enabled: styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } }
|
||||
}
|
||||
onHoveredChanged: if (hovered) sticky = true
|
||||
onVisibleChanged: if (!visible) sticky = false
|
||||
}
|
||||
|
||||
/*! This component controls the appearance of the
|
||||
scroll bar increment button.
|
||||
|
||||
You can access the following state properties:
|
||||
|
||||
\table
|
||||
\row \li property bool \b styleData.hovered
|
||||
\row \li property bool \b styleData.pressed
|
||||
\row \li property bool \b styleData.horizontal
|
||||
\endtable
|
||||
*/
|
||||
property Component incrementControl: Rectangle {
|
||||
visible: !transientScrollBars
|
||||
implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
|
||||
implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: -1
|
||||
anchors.rightMargin: -1
|
||||
border.color: "#aaa"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
color: "transparent"
|
||||
border.color: "#44ffffff"
|
||||
}
|
||||
Image {
|
||||
source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
|
||||
anchors.centerIn: parent
|
||||
opacity: control.enabled ? 0.6 : 0.5
|
||||
}
|
||||
gradient: Gradient {
|
||||
GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
|
||||
GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! This component controls the appearance of the
|
||||
scroll bar decrement button.
|
||||
|
||||
You can access the following state properties:
|
||||
|
||||
\table
|
||||
\row \li property bool \b styleData.hovered
|
||||
\row \li property bool \b styleData.pressed
|
||||
\row \li property bool \b styleData.horizontal
|
||||
\endtable
|
||||
*/
|
||||
property Component decrementControl: Rectangle {
|
||||
visible: !transientScrollBars
|
||||
implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
|
||||
implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight)
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: styleData.horizontal ? 0 : -1
|
||||
anchors.leftMargin: styleData.horizontal ? -1 : 0
|
||||
anchors.bottomMargin: styleData.horizontal ? -1 : 0
|
||||
anchors.rightMargin: styleData.horizontal ? 0 : -1
|
||||
color: "lightgray"
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
color: "transparent"
|
||||
border.color: "#44ffffff"
|
||||
}
|
||||
Image {
|
||||
source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1
|
||||
anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0
|
||||
opacity: control.enabled ? 0.6 : 0.5
|
||||
}
|
||||
gradient: Gradient {
|
||||
GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
|
||||
GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
|
||||
}
|
||||
border.color: "#aaa"
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component __scrollbar: Item {
|
||||
id: panel
|
||||
property string activeControl: "none"
|
||||
property bool scrollToClickPosition: true
|
||||
property bool isTransient: transientScrollBars
|
||||
|
||||
property bool on: false
|
||||
property bool raised: false
|
||||
property bool sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed
|
||||
|
||||
states: State {
|
||||
name: "out"
|
||||
when: isTransient
|
||||
&& (!__stickyScrollbars || !flickableItem.moving)
|
||||
&& panel.activeControl === "none"
|
||||
&& !panel.on
|
||||
&& !panel.raised
|
||||
PropertyChanges { target: panel; opacity: 0 }
|
||||
}
|
||||
|
||||
transitions: Transition {
|
||||
to: "out"
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: root.__scrollBarFadeDelay }
|
||||
NumberAnimation { properties: "opacity"; duration: root.__scrollBarFadeDuration }
|
||||
PropertyAction { target: panel; property: "visible"; value: false }
|
||||
}
|
||||
}
|
||||
|
||||
implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth
|
||||
implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200
|
||||
|
||||
function pixelMetric(arg) {
|
||||
if (arg === "scrollbarExtent")
|
||||
return (__styleData.horizontal ? bg.height : bg.width);
|
||||
return 0;
|
||||
}
|
||||
|
||||
function styleHint(arg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function hitTest(argX, argY) {
|
||||
if (itemIsHit(handleControl, argX, argY))
|
||||
return "handle"
|
||||
else if (itemIsHit(incrementLoader, argX, argY))
|
||||
return "up";
|
||||
else if (itemIsHit(decrementLoader, argX, argY))
|
||||
return "down";
|
||||
else if (itemIsHit(bg, argX, argY)) {
|
||||
if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y)
|
||||
return "upPage"
|
||||
else
|
||||
return "downPage"
|
||||
}
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
function subControlRect(arg) {
|
||||
if (arg === "handle") {
|
||||
return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height);
|
||||
} else if (arg === "groove") {
|
||||
if (__styleData.horizontal) {
|
||||
return Qt.rect(incrementLoader.width - handleOverlap,
|
||||
0,
|
||||
__control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2),
|
||||
__control.height);
|
||||
} else {
|
||||
return Qt.rect(0,
|
||||
incrementLoader.height - handleOverlap,
|
||||
__control.width,
|
||||
__control.height - (incrementLoader.height + decrementLoader.height - handleOverlap * 2));
|
||||
}
|
||||
}
|
||||
return Qt.rect(0,0,0,0);
|
||||
}
|
||||
|
||||
function itemIsHit(argItem, argX, argY) {
|
||||
var pos = argItem.mapFromItem(__control, argX, argY);
|
||||
return (pos.x >= 0 && pos.x <= argItem.width && pos.y >= 0 && pos.y <= argItem.height);
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: incrementLoader
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
sourceComponent: decrementControl
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property bool hovered: activeControl === "up"
|
||||
readonly property bool pressed: __styleData.upPressed
|
||||
readonly property bool horizontal: __styleData.horizontal
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: bg
|
||||
anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom
|
||||
anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top
|
||||
anchors.left: __styleData.horizontal ? incrementLoader.right : undefined
|
||||
anchors.right: __styleData.horizontal ? decrementLoader.left : undefined
|
||||
sourceComponent: scrollBarBackground
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property bool horizontal: __styleData.horizontal
|
||||
readonly property bool hovered: activeControl !== "none"
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: decrementLoader
|
||||
anchors.bottom: __styleData.horizontal ? undefined : parent.bottom
|
||||
anchors.right: __styleData.horizontal ? parent.right : undefined
|
||||
sourceComponent: incrementControl
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property bool hovered: activeControl === "down"
|
||||
readonly property bool pressed: __styleData.downPressed
|
||||
readonly property bool horizontal: __styleData.horizontal
|
||||
}
|
||||
}
|
||||
|
||||
property var flickableItem: control.flickableItem
|
||||
property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
|
||||
Math.min(1, ((flickableItem && flickableItem.contentWidth > 0.0) ? flickableItem.width/flickableItem.contentWidth : 1)) * bg.width :
|
||||
Math.min(1, ((flickableItem && flickableItem.contentHeight > 0.0) ? flickableItem.height/flickableItem.contentHeight : 1)) * bg.height)
|
||||
readonly property real range: __control.maximumValue - __control.minimumValue
|
||||
readonly property real begin: __control.value - __control.minimumValue
|
||||
|
||||
Loader {
|
||||
id: handleControl
|
||||
height: __styleData.horizontal ? implicitHeight : extent
|
||||
width: __styleData.horizontal ? extent : implicitWidth
|
||||
anchors.top: bg.top
|
||||
anchors.left: bg.left
|
||||
anchors.topMargin: __styleData.horizontal || range === 0 ? 0 : -handleOverlap + (2 * begin * (bg.height + (2 * handleOverlap) - extent) + range) / (2 * range)
|
||||
anchors.leftMargin: __styleData.horizontal && range !== 0 ? -handleOverlap + (2 * begin * (bg.width + (2 * handleOverlap) - extent) + range) / (2 * range) : 0
|
||||
sourceComponent: handle
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property bool hovered: activeControl === "handle"
|
||||
readonly property bool pressed: __styleData.handlePressed
|
||||
readonly property bool horizontal: __styleData.horizontal
|
||||
}
|
||||
readonly property alias __activeControl: panel.activeControl
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property bool __externalScrollBars: false
|
||||
/*! \internal */
|
||||
property int __scrollBarSpacing: 4
|
||||
/*! \internal */
|
||||
property int __scrollBarFadeDelay: 450
|
||||
/*! \internal */
|
||||
property int __scrollBarFadeDuration: 200
|
||||
/*! \internal */
|
||||
property bool __stickyScrollbars: false
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype SliderStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Slider.
|
||||
|
||||
The slider style allows you to create a custom appearance for
|
||||
a \l Slider control.
|
||||
|
||||
The implicit size of the slider is calculated based on the
|
||||
maximum implicit size of the \c background and \c handle
|
||||
delegates combined.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
Slider {
|
||||
anchors.centerIn: parent
|
||||
style: SliderStyle {
|
||||
groove: Rectangle {
|
||||
implicitWidth: 200
|
||||
implicitHeight: 8
|
||||
color: "gray"
|
||||
radius: 8
|
||||
}
|
||||
handle: Rectangle {
|
||||
anchors.centerIn: parent
|
||||
color: control.pressed ? "white" : "lightgray"
|
||||
border.color: "gray"
|
||||
border.width: 2
|
||||
implicitWidth: 34
|
||||
implicitHeight: 34
|
||||
radius: 12
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
Style {
|
||||
id: styleitem
|
||||
|
||||
/*! The \l Slider this style is attached to. */
|
||||
readonly property Slider control: __control
|
||||
|
||||
padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
|
||||
|
||||
/*! This property holds the item for the slider handle.
|
||||
You can access the slider through the \c control property
|
||||
*/
|
||||
property Component handle: Item{
|
||||
implicitWidth: implicitHeight
|
||||
implicitHeight: TextSingleton.implicitHeight * 1.2
|
||||
|
||||
FastGlow {
|
||||
source: handle
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: -1
|
||||
anchors.topMargin: 1
|
||||
smooth: true
|
||||
color: "#11000000"
|
||||
spread: 0.8
|
||||
transparentBorder: true
|
||||
blur: 0.1
|
||||
|
||||
}
|
||||
Rectangle {
|
||||
id: handle
|
||||
anchors.fill: parent
|
||||
|
||||
radius: width/2
|
||||
gradient: Gradient {
|
||||
GradientStop { color: control.pressed ? "#e0e0e0" : "#fff" ; position: 1 }
|
||||
GradientStop { color: "#eee" ; position: 0 }
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
radius: width/2
|
||||
border.color: "#99ffffff"
|
||||
color: control.activeFocus ? "#224f7fbf" : "transparent"
|
||||
}
|
||||
border.color: control.activeFocus ? "#47b" : "#777"
|
||||
}
|
||||
|
||||
}
|
||||
/*! This property holds the background groove of the slider.
|
||||
|
||||
You can access the handle position through the \c styleData.handlePosition property.
|
||||
*/
|
||||
property Component groove: Item {
|
||||
property color fillColor: "#49d"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
|
||||
implicitHeight: Math.max(6, Math.round(TextSingleton.implicitHeight * 0.3))
|
||||
Rectangle {
|
||||
radius: height/2
|
||||
anchors.fill: parent
|
||||
border.width: 1
|
||||
border.color: "#888"
|
||||
gradient: Gradient {
|
||||
GradientStop { color: "#bbb" ; position: 0 }
|
||||
GradientStop { color: "#ccc" ; position: 0.6 }
|
||||
GradientStop { color: "#ccc" ; position: 1 }
|
||||
}
|
||||
}
|
||||
Item {
|
||||
clip: true
|
||||
width: styleData.handlePosition
|
||||
height: parent.height
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
border.color: Qt.darker(fillColor, 1.2)
|
||||
radius: height/2
|
||||
gradient: Gradient {
|
||||
GradientStop {color: Qt.lighter(fillColor, 1.3) ; position: 0}
|
||||
GradientStop {color: fillColor ; position: 1.4}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! This property holds the tick mark labels.
|
||||
\since QtQuick.Controls.Styles 1.1
|
||||
|
||||
Every tickmark that should be drawn must be defined within this
|
||||
component, so it is common to use a \l Repeater, for example.
|
||||
|
||||
You can access the handle width through the \c styleData.handleWidth property.
|
||||
*/
|
||||
property Component tickmarks: Repeater {
|
||||
id: repeater
|
||||
model: control.stepSize > 0 ? 1 + (control.maximumValue - control.minimumValue) / control.stepSize : 0
|
||||
Rectangle {
|
||||
color: "#777"
|
||||
width: 1 ; height: 3
|
||||
y: repeater.height
|
||||
x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))
|
||||
}
|
||||
}
|
||||
|
||||
/*! This property holds the slider style panel.
|
||||
|
||||
Note that it is generally not recommended to override this.
|
||||
*/
|
||||
property Component panel: Item {
|
||||
id: root
|
||||
property int handleWidth: handleLoader.width
|
||||
property int handleHeight: handleLoader.height
|
||||
|
||||
property bool horizontal : control.orientation === Qt.Horizontal
|
||||
property int horizontalSize: grooveLoader.implicitWidth + padding.left + padding.right
|
||||
property int verticalSize: Math.max(handleLoader.implicitHeight, grooveLoader.implicitHeight) + padding.top + padding.bottom
|
||||
|
||||
implicitWidth: horizontal ? horizontalSize : verticalSize
|
||||
implicitHeight: horizontal ? verticalSize : horizontalSize
|
||||
|
||||
y: horizontal ? 0 : height
|
||||
rotation: horizontal ? 0 : -90
|
||||
transformOrigin: Item.TopLeft
|
||||
|
||||
Item {
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
Loader {
|
||||
id: grooveLoader
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property int handlePosition: handleLoader.x + handleLoader.width/2
|
||||
}
|
||||
x: padding.left
|
||||
sourceComponent: groove
|
||||
width: (horizontal ? parent.width : parent.height) - padding.left - padding.right
|
||||
y: Math.round(padding.top + (Math.round(horizontal ? parent.height : parent.width - padding.top - padding.bottom) - grooveLoader.item.height)/2)
|
||||
}
|
||||
Loader {
|
||||
id: tickMarkLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: control.tickmarksEnabled ? tickmarks : null
|
||||
property QtObject styleData: QtObject { readonly property int handleWidth: control.__panel.handleWidth }
|
||||
}
|
||||
Loader {
|
||||
id: handleLoader
|
||||
sourceComponent: handle
|
||||
anchors.verticalCenter: grooveLoader.verticalCenter
|
||||
x: Math.round((control.__handlePos - control.minimumValue) / (control.maximumValue - control.minimumValue) * ((horizontal ? root.width : root.height) - item.width))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype SpinBoxStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.2
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for SpinBox.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
SpinBox {
|
||||
style: SpinBoxStyle{
|
||||
background: Rectangle {
|
||||
implicitWidth: 100
|
||||
implicitHeight: 20
|
||||
border.color: "gray"
|
||||
radius: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: spinboxStyle
|
||||
|
||||
/*! The \l SpinBox this style is attached to. */
|
||||
readonly property SpinBox control: __control
|
||||
|
||||
/*! The content margins of the text field. */
|
||||
padding { top: 1 ; left: Math.round(styleData.contentHeight/2) ; right: Math.max(22, Math.round(styleData.contentHeight)) ; bottom: 0 }
|
||||
/*! \qmlproperty enumeration horizontalAlignment
|
||||
|
||||
This property defines the default text aligment.
|
||||
|
||||
The supported values are:
|
||||
\list
|
||||
\li Qt.AlignLeft
|
||||
\li Qt.AlignHCenter
|
||||
\li Qt.AlignRight
|
||||
\endlist
|
||||
|
||||
The default value is Qt.AlignRight
|
||||
*/
|
||||
property int horizontalAlignment: Qt.AlignRight
|
||||
|
||||
/*! The text color. */
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*! The text highlight color, used behind selections. */
|
||||
property color selectionColor: SystemPaletteSingleton.highlight(control.enabled)
|
||||
|
||||
/*! The highlighted text color, used in selections. */
|
||||
property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled)
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration renderType
|
||||
|
||||
Override the default rendering type for the control.
|
||||
|
||||
Supported render types are:
|
||||
\list
|
||||
\li Text.QtRendering
|
||||
\li Text.NativeRendering
|
||||
\endlist
|
||||
|
||||
The default value is platform dependent.
|
||||
|
||||
\sa Text::renderType
|
||||
*/
|
||||
property int renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
|
||||
/*!
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
The font of the control.
|
||||
*/
|
||||
property font font
|
||||
|
||||
/*! The button used to increment the value. */
|
||||
property Component incrementControl: Item {
|
||||
implicitWidth: padding.right
|
||||
Image {
|
||||
source: "images/arrow-up.png"
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: 1
|
||||
opacity: control.enabled ? (styleData.upPressed ? 1 : 0.6) : 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/*! The button used to decrement the value. */
|
||||
property Component decrementControl: Item {
|
||||
implicitWidth: padding.right
|
||||
Image {
|
||||
source: "images/arrow-down.png"
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: -2
|
||||
opacity: control.enabled ? (styleData.downPressed ? 1 : 0.6) : 0.5
|
||||
}
|
||||
}
|
||||
|
||||
/*! The background of the SpinBox. */
|
||||
property Component background: Item {
|
||||
implicitHeight: Math.max(25, Math.round(styleData.contentHeight * 1.2))
|
||||
implicitWidth: styleData.contentWidth + padding.left + padding.right
|
||||
baselineOffset: control.__baselineOffset
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: -1
|
||||
color: "#44ffffff"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#eee" ; position: 0}
|
||||
GradientStop {color: "#fff" ; position: 0.1}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
radius: control.font.pixelSize * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
id: styleitem
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: backgroundLoader.implicitHeight
|
||||
baselineOffset: backgroundLoader.item ? backgroundLoader.item.baselineOffset : 0
|
||||
|
||||
property font font: spinboxStyle.font
|
||||
|
||||
property color foregroundColor: spinboxStyle.textColor
|
||||
property color selectionColor: spinboxStyle.selectionColor
|
||||
property color selectedTextColor: spinboxStyle.selectedTextColor
|
||||
|
||||
property var margins: spinboxStyle.padding
|
||||
|
||||
property rect upRect: Qt.rect(width - incrementControlLoader.implicitWidth, 0, incrementControlLoader.implicitWidth, height / 2 + 1)
|
||||
property rect downRect: Qt.rect(width - decrementControlLoader.implicitWidth, height / 2, decrementControlLoader.implicitWidth, height / 2)
|
||||
|
||||
property int horizontalAlignment: spinboxStyle.horizontalAlignment
|
||||
property int verticalAlignment: Qt.AlignVCenter
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: incrementControlLoader
|
||||
x: upRect.x
|
||||
y: upRect.y
|
||||
width: upRect.width
|
||||
height: upRect.height
|
||||
sourceComponent: incrementControl
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: decrementControlLoader
|
||||
x: downRect.x
|
||||
y: downRect.y
|
||||
width: downRect.width
|
||||
height: downRect.height
|
||||
sourceComponent: decrementControl
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
The cursor handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the cursor position. The interactive area is determined by the
|
||||
geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __cursorHandle
|
||||
|
||||
/*! \internal
|
||||
The selection handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the first selected character. The interactive area is determined
|
||||
by the geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __selectionHandle
|
||||
|
||||
/*! \internal
|
||||
The cursor delegate.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
*/
|
||||
property Component __cursorDelegate
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype StatusBarStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\ingroup controlsstyling
|
||||
\since 5.2
|
||||
\brief Provides custom styling for StatusBar.
|
||||
|
||||
The status bar can be defined by overriding the background component and
|
||||
setting the content padding.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
StatusBar {
|
||||
style: StatusBarStyle {
|
||||
padding {
|
||||
left: 8
|
||||
right: 8
|
||||
top: 3
|
||||
bottom: 3
|
||||
}
|
||||
background: Rectangle {
|
||||
implicitHeight: 16
|
||||
implicitWidth: 200
|
||||
gradient: Gradient{
|
||||
GradientStop{color: "#eee" ; position: 0}
|
||||
GradientStop{color: "#ccc" ; position: 1}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#999"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
|
||||
/*! The content padding inside the status bar. */
|
||||
padding {
|
||||
left: 3
|
||||
right: 3
|
||||
top: 3
|
||||
bottom: 2
|
||||
}
|
||||
|
||||
/*! This defines the background of the status bar. */
|
||||
property Component background: Rectangle {
|
||||
implicitHeight: 16
|
||||
implicitWidth: 200
|
||||
|
||||
gradient: Gradient{
|
||||
GradientStop{color: "#eee" ; position: 0}
|
||||
GradientStop{color: "#ccc" ; position: 1}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#999"
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the panel of the status bar. */
|
||||
property Component panel: Loader {
|
||||
sourceComponent: background
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
/*!
|
||||
\qmltype StatusIndicatorStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for StatusIndicatorStyle.
|
||||
|
||||
You can create a custom status indicator by defining the \l indicator
|
||||
component.
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: pieMenuStyle
|
||||
|
||||
/*!
|
||||
The \l StatusIndicator that this style is attached to.
|
||||
*/
|
||||
readonly property StatusIndicator control: __control
|
||||
|
||||
/*!
|
||||
The color that instances of
|
||||
\l [QtQuickExtras]{StatusIndicator} will have.
|
||||
The \l [QtQuickExtras]{StatusIndicator::}{color}
|
||||
property in \l [QtQuickExtras]{StatusIndicator}
|
||||
will override this property when set.
|
||||
*/
|
||||
property color color: "red"
|
||||
|
||||
/*!
|
||||
This defines the indicator in both its on and off status.
|
||||
*/
|
||||
property Component indicator: Item {
|
||||
readonly property real shineStep: 0.05
|
||||
readonly property real smallestAxis: Math.min(control.width, control.height)
|
||||
readonly property real outerRecessPercentage: 0.11
|
||||
readonly property color offColor: Qt.rgba(0.13, 0.13, 0.13)
|
||||
readonly property color baseColor: control.active ? control.color : offColor
|
||||
|
||||
implicitWidth: TextSingleton.implicitHeight * 2
|
||||
implicitHeight: implicitWidth
|
||||
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
width: Math.min(parent.width, parent.height)
|
||||
// height: width --- QTBUG-42878
|
||||
height: Math.min(parent.width, parent.height)
|
||||
anchors.centerIn: parent
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onActiveChanged: backgroundCanvas.requestPaint()
|
||||
onColorChanged: backgroundCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
// Draw the semi-transparent background.
|
||||
ctx.beginPath();
|
||||
var gradient = ctx.createLinearGradient(width / 2, 0, width / 2, height * 0.75);
|
||||
gradient.addColorStop(0.0, Qt.rgba(0, 0, 0, control.active ? 0.1 : 0.25));
|
||||
gradient.addColorStop(1.0, control.active ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(0.74, 0.74, 0.74, 0.25));
|
||||
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.ellipse(0, 0, width, height);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: shadowGuard
|
||||
anchors.fill: backgroundCanvas
|
||||
anchors.margins: -shadow.radius
|
||||
|
||||
Canvas {
|
||||
id: colorCanvas
|
||||
anchors.fill: parent
|
||||
anchors.margins: shadow.radius
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onActiveChanged: colorCanvas.requestPaint()
|
||||
onColorChanged: colorCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
// Draw the actual color within the circle.
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = baseColor;
|
||||
var recess = smallestAxis * outerRecessPercentage;
|
||||
ctx.ellipse(recess, recess, width - recess * 2, height - recess * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
id: shadow
|
||||
source: shadowGuard
|
||||
color: control.color
|
||||
cached: true
|
||||
anchors.fill: shadowGuard
|
||||
visible: control.active
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: foregroundCanvas
|
||||
anchors.fill: backgroundCanvas
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onActiveChanged: foregroundCanvas.requestPaint()
|
||||
onColorChanged: foregroundCanvas.requestPaint()
|
||||
}
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
// Draw the first shine.
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = Qt.rgba(1, 1, 1, 0.03);
|
||||
var recessPercentage = outerRecessPercentage + shineStep * 0.65;
|
||||
var recess = smallestAxis * recessPercentage;
|
||||
ctx.ellipse(recess, recess, width - recess * 2, height - recess * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Draw the second, inner shine.
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = Qt.rgba(1, 1, 1, 0.06);
|
||||
recessPercentage += shineStep;
|
||||
recess = smallestAxis * recessPercentage;
|
||||
ctx.ellipse(recess, recess, width - recess * 2, height - recess * 2);
|
||||
ctx.fill();
|
||||
|
||||
// Now draw the final arced shine that goes over the first and second shines.
|
||||
// First, clip the entire shine area.
|
||||
ctx.beginPath();
|
||||
recessPercentage -= shineStep;
|
||||
recess = smallestAxis * recessPercentage;
|
||||
ctx.ellipse(recess, recess, width - recess * 2, height - recess * 2);
|
||||
ctx.clip();
|
||||
|
||||
if (!control.active) {
|
||||
// Then, clip the bottom area out of the shine.
|
||||
ctx.ellipse(recess, height * 0.425, width - recess * 2, height - recess * 2);
|
||||
ctx.clip();
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
var gradient;
|
||||
if (!control.active) {
|
||||
// Draw the shine arc.
|
||||
gradient = ctx.createLinearGradient(width / 2, height * 0.2, width / 2, height * 0.65);
|
||||
gradient.addColorStop(0.0, Qt.rgba(1, 1, 1, 0.05));
|
||||
gradient.addColorStop(1.0, "transparent");
|
||||
} else {
|
||||
// Draw the radial shine.
|
||||
gradient = ctx.createRadialGradient(width / 2, height / 2, 0, width / 2, height / 2, width * 0.5 /* (same as height) */);
|
||||
gradient.addColorStop(0.0, Qt.lighter(baseColor, 1.4));
|
||||
gradient.addColorStop(1.0, "transparent");
|
||||
}
|
||||
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.ellipse(recess, recess, width - recess * 2, height - recess * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: indicatorLoader.implicitWidth
|
||||
implicitHeight: indicatorLoader.implicitHeight
|
||||
|
||||
Loader {
|
||||
id: indicatorLoader
|
||||
width: Math.max(1, parent.width)
|
||||
height: Math.max(1, parent.height)
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: indicator
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype SwitchStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.2
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Switch.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
Switch {
|
||||
style: SwitchStyle {
|
||||
groove: Rectangle {
|
||||
implicitWidth: 100
|
||||
implicitHeight: 20
|
||||
radius: 9
|
||||
border.color: control.activeFocus ? "darkblue" : "gray"
|
||||
border.width: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
Style {
|
||||
id: switchstyle
|
||||
|
||||
/*! The content padding. */
|
||||
padding {
|
||||
top: 0
|
||||
left: 0
|
||||
right: 0
|
||||
bottom: 0
|
||||
}
|
||||
|
||||
/*! This defines the switch handle. */
|
||||
property Component handle: Rectangle {
|
||||
opacity: control.enabled ? 1.0 : 0.5
|
||||
implicitWidth: Math.round((parent.parent.width - padding.left - padding.right)/2)
|
||||
implicitHeight: control.height - padding.top - padding.bottom
|
||||
|
||||
border.color: control.activeFocus ? Qt.darker(highlight, 2) : Qt.darker(button, 2)
|
||||
property color bg: control.activeFocus ? Qt.darker(highlight, 1.2) : button
|
||||
property color highlight: SystemPaletteSingleton.highlight(control.enabled)
|
||||
property color button: SystemPaletteSingleton.button(control.enabled)
|
||||
gradient: Gradient {
|
||||
GradientStop {color: Qt.lighter(bg, 1.4) ; position: 0}
|
||||
GradientStop {color: bg ; position: 1}
|
||||
}
|
||||
|
||||
radius: 2
|
||||
}
|
||||
|
||||
/*! This property holds the background groove of the switch. */
|
||||
property Component groove: Rectangle {
|
||||
property color shadow: control.checked ? Qt.darker(highlight, 1.2): "#999"
|
||||
property color bg: control.checked ? highlight:"#bbb"
|
||||
property color highlight: SystemPaletteSingleton.highlight(control.enabled)
|
||||
|
||||
implicitWidth: Math.round(implicitHeight * 3)
|
||||
implicitHeight: Math.max(16, Math.round(TextSingleton.implicitHeight))
|
||||
|
||||
border.color: "gray"
|
||||
color: "red"
|
||||
|
||||
radius: 2
|
||||
Behavior on shadow {ColorAnimation{ duration: 80 }}
|
||||
Behavior on bg {ColorAnimation{ duration: 80 }}
|
||||
gradient: Gradient {
|
||||
GradientStop {color: shadow; position: 0}
|
||||
GradientStop {color: bg ; position: 0.2}
|
||||
GradientStop {color: bg ; position: 1}
|
||||
}
|
||||
Rectangle {
|
||||
color: "#44ffffff"
|
||||
height: 1
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: -1
|
||||
width: parent.width - 2
|
||||
x: 1
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
|
||||
implicitWidth: Math.round(grooveLoader.width + padding.left + padding.right)
|
||||
implicitHeight: grooveLoader.implicitHeight + padding.top + padding.bottom
|
||||
|
||||
property var __handle: handleLoader
|
||||
property int min: padding.left
|
||||
property int max: grooveLoader.width - handleLoader.width - padding.right
|
||||
|
||||
Loader {
|
||||
id: grooveLoader
|
||||
y: padding.top
|
||||
x: padding.left
|
||||
|
||||
sourceComponent: groove
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
|
||||
Loader {
|
||||
id: handleLoader
|
||||
|
||||
z:1
|
||||
|
||||
x: control.checked ? max : min
|
||||
|
||||
anchors.top: grooveLoader.top
|
||||
anchors.bottom: grooveLoader.bottom
|
||||
anchors.topMargin: padding.top
|
||||
anchors.bottomMargin: padding.bottom
|
||||
|
||||
Behavior on x {
|
||||
id: behavior
|
||||
enabled: handleLoader.status === Loader.Ready
|
||||
NumberAnimation {
|
||||
duration: 150
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
sourceComponent: handle
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype TabViewStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup viewsstyling
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for TabView.
|
||||
|
||||
\qml
|
||||
TabView {
|
||||
id: frame
|
||||
anchors.fill: parent
|
||||
anchors.margins: 4
|
||||
Tab { title: "Tab 1" }
|
||||
Tab { title: "Tab 2" }
|
||||
Tab { title: "Tab 3" }
|
||||
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: styleData.selected ? "steelblue" :"lightsteelblue"
|
||||
border.color: "steelblue"
|
||||
implicitWidth: Math.max(text.width + 4, 80)
|
||||
implicitHeight: 20
|
||||
radius: 2
|
||||
Text {
|
||||
id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: styleData.selected ? "white" : "black"
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "steelblue" }
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
|
||||
*/
|
||||
|
||||
Style {
|
||||
|
||||
/*! The \l ScrollView this style is attached to. */
|
||||
readonly property TabView control: __control
|
||||
|
||||
/*! This property holds whether the user can move the tabs.
|
||||
Tabs are not movable by default. */
|
||||
property bool tabsMovable: false
|
||||
|
||||
/*! This property holds the horizontal alignment of
|
||||
the tab buttons. Supported values are:
|
||||
\list
|
||||
\li Qt.AlignLeft (default)
|
||||
\li Qt.AlignHCenter
|
||||
\li Qt.AlignRight
|
||||
\endlist
|
||||
*/
|
||||
property int tabsAlignment: Qt.AlignLeft
|
||||
|
||||
/*! This property holds the amount of overlap there are between
|
||||
individual tab buttons. */
|
||||
property int tabOverlap: 1
|
||||
|
||||
/*! This property holds the amount of overlap there are between
|
||||
individual tab buttons and the frame. */
|
||||
property int frameOverlap: 2
|
||||
|
||||
/*! This defines the tab frame. */
|
||||
property Component frame: Rectangle {
|
||||
color: "#dcdcdc"
|
||||
border.color: "#aaa"
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
border.color: "#66ffffff"
|
||||
anchors.margins: 1
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the tab. You can access the tab state through the
|
||||
\c styleData property, with the following properties:
|
||||
|
||||
\table
|
||||
\row \li readonly property int \b styleData.index \li This is the current tab index.
|
||||
\row \li readonly property bool \b styleData.selected \li This is the active tab.
|
||||
\row \li readonly property string \b styleData.title \li Tab title text.
|
||||
\row \li readonly property bool \b styleData.nextSelected \li The next tab is selected.
|
||||
\row \li readonly property bool \b styleData.previousSelected \li The previous tab is selected.
|
||||
\row \li readonly property bool \b styleData.pressed \li The tab is being pressed. (since QtQuick.Controls.Styles 1.3)
|
||||
\row \li readonly property bool \b styleData.hovered \li The tab is being hovered.
|
||||
\row \li readonly property bool \b styleData.enabled \li The tab is enabled. (since QtQuick.Controls.Styles 1.2)
|
||||
\row \li readonly property bool \b styleData.activeFocus \li The tab button has keyboard focus.
|
||||
\row \li readonly property bool \b styleData.availableWidth \li The available width for the tabs.
|
||||
\row \li readonly property bool \b styleData.totalWidth \li The total width of the tabs. (since QtQuick.Controls.Styles 1.2)
|
||||
\endtable
|
||||
*/
|
||||
property Component tab: Item {
|
||||
scale: control.tabPosition === Qt.TopEdge ? 1 : -1
|
||||
|
||||
property int totalOverlap: tabOverlap * (control.count - 1)
|
||||
property real maxTabWidth: control.count > 0 ? (styleData.availableWidth + totalOverlap) / control.count : 0
|
||||
|
||||
implicitWidth: Math.round(Math.min(maxTabWidth, textitem.implicitWidth + 20))
|
||||
implicitHeight: Math.round(textitem.implicitHeight + 10)
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: styleData.selected ? 0 : 2
|
||||
BorderImage {
|
||||
anchors.fill: parent
|
||||
source: styleData.selected ? "images/tab_selected.png" : "images/tab.png"
|
||||
border.top: 6
|
||||
border.bottom: 6
|
||||
border.left: 6
|
||||
border.right: 6
|
||||
anchors.topMargin: styleData.selected ? 0 : 1
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: textitem
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: styleData.title
|
||||
elide: Text.ElideMiddle
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
scale: control.tabPosition === Qt.TopEdge ? 1 : -1
|
||||
color: SystemPaletteSingleton.text(styleData.enabled)
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: textitem.paintedWidth + 6
|
||||
height: textitem.paintedHeight + 4
|
||||
visible: (styleData.activeFocus && styleData.selected)
|
||||
radius: 3
|
||||
color: "#224f9fef"
|
||||
border.color: "#47b"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the left corner. */
|
||||
property Component leftCorner: null
|
||||
|
||||
/*! This defines the right corner. */
|
||||
property Component rightCorner: null
|
||||
|
||||
/*! This defines the tab bar background. */
|
||||
property Component tabBar: null
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
|
||||
BasicTableViewStyle {
|
||||
id: root
|
||||
|
||||
readonly property TableView control: __control
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype TextAreaStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.2
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for TextArea.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
TextArea {
|
||||
style: TextAreaStyle {
|
||||
textColor: "#333"
|
||||
selectionColor: "steelblue"
|
||||
selectedTextColor: "#eee"
|
||||
backgroundColor: "#eee"
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
ScrollViewStyle {
|
||||
id: style
|
||||
|
||||
/*! The \l TextArea this style is attached to. */
|
||||
readonly property TextArea control: __control
|
||||
|
||||
/*! The current font. */
|
||||
property font font
|
||||
|
||||
/*! The text color. */
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*! The text highlight color, used behind selections. */
|
||||
property color selectionColor: SystemPaletteSingleton.highlight(control.enabled)
|
||||
|
||||
/*! The highlighted text color, used in selections. */
|
||||
property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled)
|
||||
|
||||
/*! The background color. */
|
||||
property color backgroundColor: control.backgroundVisible ? SystemPaletteSingleton.base(control.enabled) : "transparent"
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration renderType
|
||||
|
||||
Override the default rendering type for the control.
|
||||
|
||||
Supported render types are:
|
||||
\list
|
||||
\li Text.QtRendering
|
||||
\li Text.NativeRendering
|
||||
\endlist
|
||||
|
||||
The default value is platform dependent.
|
||||
|
||||
\sa Text::renderType
|
||||
*/
|
||||
property int renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
|
||||
/*! The default margin, in pixels, around the text in the TextArea.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
\sa TextArea::textMargin */
|
||||
property real textMargin: 4
|
||||
|
||||
/*! \internal
|
||||
The cursor handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the cursor position. The interactive area is determined by the
|
||||
geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __cursorHandle
|
||||
|
||||
/*! \internal
|
||||
The selection handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the first selected character. The interactive area is determined
|
||||
by the geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __selectionHandle
|
||||
|
||||
/*! \internal
|
||||
The cursor delegate.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
*/
|
||||
property Component __cursorDelegate
|
||||
|
||||
/*! \internal
|
||||
The delegate for the cut/copy/paste menu.
|
||||
\since QtQuick.Controls.Styles 1.4
|
||||
*/
|
||||
property Component __editMenu
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype TextFieldStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.1
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for TextField.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
TextField {
|
||||
style: TextFieldStyle {
|
||||
textColor: "black"
|
||||
background: Rectangle {
|
||||
radius: 2
|
||||
implicitWidth: 100
|
||||
implicitHeight: 24
|
||||
border.color: "#333"
|
||||
border.width: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: style
|
||||
|
||||
/*! The \l TextField this style is attached to. */
|
||||
readonly property TextField control: __control
|
||||
|
||||
/*! The content margins of the text field. */
|
||||
padding { top: 4 ; left: Math.round(control.__contentHeight/3) ; right: control.__contentHeight/3 ; bottom: 4 }
|
||||
|
||||
/*! The current font. */
|
||||
property font font
|
||||
|
||||
/*! The text color. */
|
||||
property color textColor: SystemPaletteSingleton.text(control.enabled)
|
||||
|
||||
/*! The text highlight color, used behind selections. */
|
||||
property color selectionColor: SystemPaletteSingleton.highlight(control.enabled)
|
||||
|
||||
/*! The highlighted text color, used in selections. */
|
||||
property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled)
|
||||
|
||||
/*!
|
||||
\qmlproperty string passwordCharacter
|
||||
\since QtQuick.Controls.Styles 1.4
|
||||
|
||||
The password character that is displayed when echoMode
|
||||
on the TextField is set to TextInput.Password or
|
||||
TextInput.PasswordEchoOnEdit.
|
||||
*/
|
||||
property string passwordCharacter: Qt.styleHints.passwordMaskCharacter
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration renderType
|
||||
\since QtQuick.Controls.Styles 1.1
|
||||
|
||||
Override the default rendering type for the control.
|
||||
|
||||
Supported render types are:
|
||||
\list
|
||||
\li Text.QtRendering
|
||||
\li Text.NativeRendering
|
||||
\endlist
|
||||
|
||||
The default value is platform dependent.
|
||||
|
||||
\sa Text::renderType
|
||||
*/
|
||||
property int renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
|
||||
/*! The placeholder text color, used when the text field is empty.
|
||||
\since QtQuick.Controls.Styles 1.1
|
||||
*/
|
||||
property color placeholderTextColor: Qt.rgba(0, 0, 0, 0.5)
|
||||
|
||||
/*! The background of the text field. */
|
||||
property Component background: Item {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: -1
|
||||
color: "#44ffffff"
|
||||
radius: baserect.radius
|
||||
}
|
||||
Rectangle {
|
||||
id: baserect
|
||||
gradient: Gradient {
|
||||
GradientStop {color: "#e0e0e0" ; position: 0}
|
||||
GradientStop {color: "#fff" ; position: 0.1}
|
||||
GradientStop {color: "#fff" ; position: 1}
|
||||
}
|
||||
radius: control.__contentHeight * 0.16
|
||||
anchors.fill: parent
|
||||
border.color: control.activeFocus ? "#47b" : "#999"
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
anchors.fill: parent
|
||||
|
||||
property int topMargin: padding.top
|
||||
property int leftMargin: padding.left
|
||||
property int rightMargin: padding.right
|
||||
property int bottomMargin: padding.bottom
|
||||
|
||||
property color textColor: style.textColor
|
||||
property color selectionColor: style.selectionColor
|
||||
property color selectedTextColor: style.selectedTextColor
|
||||
|
||||
implicitWidth: backgroundLoader.implicitWidth || Math.round(control.__contentHeight * 8)
|
||||
implicitHeight: backgroundLoader.implicitHeight || Math.max(25, Math.round(control.__contentHeight * 1.2))
|
||||
baselineOffset: padding.top + control.__baselineOffset
|
||||
|
||||
property color placeholderTextColor: style.placeholderTextColor
|
||||
property font font: style.font
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
sourceComponent: background
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
The cursor handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the cursor position. The interactive area is determined by the
|
||||
geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __cursorHandle
|
||||
|
||||
/*! \internal
|
||||
The selection handle.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The parent of the handle is positioned to the top left corner of
|
||||
the first selected character. The interactive area is determined
|
||||
by the geometry of the handle delegate.
|
||||
|
||||
The following signals and read-only properties are available within the scope
|
||||
of the handle delegate:
|
||||
\table
|
||||
\row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the handle is pressed.
|
||||
\row \li \b {styleData.position} : int \li The character position of the handle.
|
||||
\row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on.
|
||||
\row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text.
|
||||
\endtable
|
||||
*/
|
||||
property Component __selectionHandle
|
||||
|
||||
/*! \internal
|
||||
The cursor delegate.
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
*/
|
||||
property Component __cursorDelegate
|
||||
|
||||
/*! \internal
|
||||
The delegate for the cut/copy/paste menu.
|
||||
\since QtQuick.Controls.Styles 1.4
|
||||
*/
|
||||
property Component __editMenu
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
import QtQuick.Extras.Private.CppUtils 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ToggleButtonStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for ToggleButton.
|
||||
|
||||
You can create a custom toggle button by replacing the same delegates that
|
||||
\l {ButtonStyle} provides.
|
||||
*/
|
||||
|
||||
CircularButtonStyle {
|
||||
id: circularButtonStyle
|
||||
|
||||
/*!
|
||||
The \l ToggleButton that this style is attached to.
|
||||
*/
|
||||
readonly property ToggleButton control: __control
|
||||
|
||||
/*!
|
||||
The gradient that is displayed on the inactive state indicator. The
|
||||
inactive state indicator will be the checked gradient when the button
|
||||
is unchecked, and the unchecked gradient when the button is checked.
|
||||
|
||||
\sa checkedGradient, uncheckedGradient
|
||||
*/
|
||||
property Gradient inactiveGradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: commonStyleHelper.inactiveColor
|
||||
}
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: commonStyleHelper.inactiveColorShine
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The gradient that is displayed on the checked state indicator.
|
||||
|
||||
\sa uncheckedGradient, inactiveGradient
|
||||
*/
|
||||
property Gradient checkedGradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: commonStyleHelper.onColor
|
||||
}
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: commonStyleHelper.onColorShine
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The gradient that is displayed on the unchecked state indicator.
|
||||
|
||||
\sa checkedGradient, inactiveGradient
|
||||
*/
|
||||
property Gradient uncheckedGradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0
|
||||
color: commonStyleHelper.offColor
|
||||
}
|
||||
GradientStop {
|
||||
position: 1
|
||||
color: commonStyleHelper.offColorShine
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The color that is used for the drop shadow below the checked state
|
||||
indicator.
|
||||
|
||||
\sa uncheckedDropShadowColor
|
||||
*/
|
||||
property color checkedDropShadowColor: commonStyleHelper.onColor
|
||||
|
||||
/*!
|
||||
The color that is used for the drop shadow below the checked state
|
||||
indicator.
|
||||
|
||||
\sa checkedDropShadowColor
|
||||
*/
|
||||
property color uncheckedDropShadowColor: commonStyleHelper.offColor
|
||||
|
||||
CommonStyleHelper {
|
||||
id: commonStyleHelper
|
||||
}
|
||||
|
||||
background: Item {
|
||||
implicitWidth: __buttonHelper.implicitWidth
|
||||
implicitHeight: __buttonHelper.implicitHeight
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onPressedChanged: {
|
||||
backgroundCanvas.requestPaint();
|
||||
}
|
||||
|
||||
onCheckedChanged: {
|
||||
uncheckedCanvas.requestPaint();
|
||||
checkedCanvas.requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: circularButtonStyle
|
||||
|
||||
onCheckedGradientChanged: checkedCanvas.requestPaint()
|
||||
onCheckedDropShadowColorChanged: checkedCanvas.requestPaint()
|
||||
onUncheckedGradientChanged: uncheckedCanvas.requestPaint()
|
||||
onUncheckedDropShadowColorChanged: uncheckedCanvas.requestPaint()
|
||||
onInactiveGradientChanged: {
|
||||
checkedCanvas.requestPaint();
|
||||
uncheckedCanvas.requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: circularButtonStyle.checkedGradient
|
||||
onUpdated: checkedCanvas.requestPaint()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: circularButtonStyle.uncheckedGradient
|
||||
onUpdated: uncheckedCanvas.requestPaint()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: circularButtonStyle.inactiveGradient
|
||||
onUpdated: {
|
||||
uncheckedCanvas.requestPaint();
|
||||
checkedCanvas.requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
__buttonHelper.paintBackground(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: uncheckedCanvas
|
||||
anchors.fill: parent
|
||||
anchors.margins: -(__buttonHelper.radius * 3)
|
||||
visible: control.checked
|
||||
|
||||
readonly property real xCenter: width / 2
|
||||
readonly property real yCenter: height / 2
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
/* Draw unchecked indicator */
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = __buttonHelper.outerArcLineWidth - __buttonHelper.innerArcLineWidth;
|
||||
ctx.arc(xCenter, yCenter, __buttonHelper.outerArcRadius + __buttonHelper.innerArcLineWidth / 2,
|
||||
MathUtils.degToRad(180), MathUtils.degToRad(270), false);
|
||||
var gradient = ctx.createLinearGradient(xCenter, yCenter + __buttonHelper.radius,
|
||||
xCenter, yCenter - __buttonHelper.radius);
|
||||
var relevantGradient = control.checked ? inactiveGradient : uncheckedGradient;
|
||||
for (var i = 0; i < relevantGradient.stops.length; ++i) {
|
||||
gradient.addColorStop(relevantGradient.stops[i].position, relevantGradient.stops[i].color);
|
||||
}
|
||||
ctx.strokeStyle = gradient;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: checkedCanvas
|
||||
anchors.fill: parent
|
||||
anchors.margins: -(__buttonHelper.radius * 3)
|
||||
visible: !control.checked
|
||||
|
||||
readonly property real xCenter: width / 2
|
||||
readonly property real yCenter: height / 2
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
/* Draw checked indicator */
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = __buttonHelper.outerArcLineWidth - __buttonHelper.innerArcLineWidth;
|
||||
ctx.arc(xCenter, yCenter, __buttonHelper.outerArcRadius + __buttonHelper.innerArcLineWidth / 2,
|
||||
MathUtils.degToRad(270), MathUtils.degToRad(0), false);
|
||||
var gradient = ctx.createLinearGradient(xCenter, yCenter + __buttonHelper.radius,
|
||||
xCenter, yCenter - __buttonHelper.radius);
|
||||
var relevantGradient = control.checked ? checkedGradient : inactiveGradient;
|
||||
for (var i = 0; i < relevantGradient.stops.length; ++i) {
|
||||
gradient.addColorStop(relevantGradient.stops[i].position, relevantGradient.stops[i].color);
|
||||
}
|
||||
ctx.strokeStyle = gradient;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
id: uncheckedDropShadow
|
||||
anchors.fill: uncheckedCanvas
|
||||
cached: true
|
||||
color: uncheckedDropShadowColor
|
||||
source: uncheckedCanvas
|
||||
visible: !control.checked
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
id: checkedDropShadow
|
||||
anchors.fill: checkedCanvas
|
||||
cached: true
|
||||
color: checkedDropShadowColor
|
||||
source: checkedCanvas
|
||||
visible: control.checked
|
||||
}
|
||||
}
|
||||
|
||||
panel: Item {
|
||||
implicitWidth: backgroundLoader.implicitWidth
|
||||
implicitHeight: backgroundLoader.implicitHeight
|
||||
|
||||
Loader {
|
||||
id: backgroundLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: background
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: labelLoader
|
||||
sourceComponent: label
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: padding.left
|
||||
anchors.topMargin: padding.top
|
||||
anchors.rightMargin: padding.right
|
||||
anchors.bottomMargin: padding.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ToolBarStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\ingroup controlsstyling
|
||||
\since 5.2
|
||||
\brief Provides custom styling for ToolBar.
|
||||
|
||||
The tool bar can be defined by overriding the background component and
|
||||
setting the content padding.
|
||||
|
||||
Example:
|
||||
\qml
|
||||
ToolBar {
|
||||
style: ToolBarStyle {
|
||||
padding {
|
||||
left: 8
|
||||
right: 8
|
||||
top: 3
|
||||
bottom: 3
|
||||
}
|
||||
background: Rectangle {
|
||||
implicitWidth: 100
|
||||
implicitHeight: 40
|
||||
border.color: "#999"
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0 ; color: "#fff" }
|
||||
GradientStop { position: 1 ; color: "#eee" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
*/
|
||||
|
||||
Style {
|
||||
|
||||
/*! The content padding inside the tool bar. */
|
||||
padding {
|
||||
left: 6
|
||||
right: 6
|
||||
top: 3
|
||||
bottom: 3
|
||||
}
|
||||
|
||||
/*! This defines the background of the tool bar. */
|
||||
property Component background: Item {
|
||||
implicitHeight: 40
|
||||
implicitWidth: 200
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
gradient: Gradient{
|
||||
GradientStop{color: "#eee" ; position: 0}
|
||||
GradientStop{color: "#ccc" ; position: 1}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "#999"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! This defines the menu button appearance on platforms
|
||||
that have a unified tool bar and menu bar.
|
||||
|
||||
\since QtQuick.Controls.Styles 1.3
|
||||
|
||||
The following read-only properties are available within the scope
|
||||
of the menu button delegate:
|
||||
\table
|
||||
\row \li \b {styleData.pressed} : bool \li Whether the button is pressed.
|
||||
\row \li \b {styleData.hovered} : bool \li Whether the button is hovered.
|
||||
\row \li \b {styleData.activeFocus} : bool \li Whether the button has active focus.
|
||||
\endtable
|
||||
*/
|
||||
property Component menuButton: null
|
||||
|
||||
/*! This defines the panel of the tool bar. */
|
||||
property Component panel: Loader {
|
||||
sourceComponent: background
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype ToolButtonStyle
|
||||
\internal
|
||||
\ingroup controlsstyling
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
*/
|
||||
Style {
|
||||
readonly property ToolButton control: __control
|
||||
property Component panel: Item {
|
||||
id: styleitem
|
||||
implicitWidth: (hasIcon ? icon.width : Math.max(label.implicitWidth + frame.border.left + frame.border.right, 36))
|
||||
+ (arrow.visible ? 10 : 0)
|
||||
implicitHeight: hasIcon ? icon.height : Math.max(label.implicitHeight, 36)
|
||||
|
||||
readonly property bool hasIcon: icon.status === Image.Ready || icon.status === Image.Loading
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
visible: control.pressed || (control.checkable && control.checked)
|
||||
color: "lightgray"
|
||||
radius:4
|
||||
border.color: "#aaa"
|
||||
}
|
||||
Item {
|
||||
anchors.left: parent.left
|
||||
anchors.right: arrow.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
clip: true
|
||||
Text {
|
||||
id: label
|
||||
visible: !hasIcon
|
||||
anchors.centerIn: parent
|
||||
text: StyleHelpers.stylizeMnemonics(control.text)
|
||||
renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering
|
||||
}
|
||||
Image {
|
||||
id: icon
|
||||
anchors.centerIn: parent
|
||||
source: control.iconSource
|
||||
}
|
||||
}
|
||||
|
||||
BorderImage {
|
||||
id: frame
|
||||
anchors.fill: parent
|
||||
anchors.margins: -1
|
||||
anchors.topMargin: -2
|
||||
anchors.rightMargin: 0
|
||||
source: "images/focusframe.png"
|
||||
visible: control.activeFocus
|
||||
border.left: 4
|
||||
border.right: 4
|
||||
border.top: 4
|
||||
border.bottom: 4
|
||||
}
|
||||
|
||||
Image {
|
||||
id: arrow
|
||||
visible: control.menu !== null
|
||||
source: visible ? "images/arrow-down.png" : ""
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: visible ? 3 : 0
|
||||
opacity: control.enabled ? 0.7 : 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
BasicTableViewStyle {
|
||||
id: root
|
||||
|
||||
readonly property TreeView control: __control
|
||||
|
||||
property int indentation: 16
|
||||
|
||||
property Component branchDelegate: Item {
|
||||
width: indentation
|
||||
height: 16
|
||||
Text {
|
||||
visible: styleData.column === 0 && styleData.hasChildren
|
||||
text: styleData.isExpanded ? "\u25bc" : "\u25b6"
|
||||
color: !control.activeFocus || styleData.selected ? styleData.textColor : "#666"
|
||||
font.pointSize: 10
|
||||
renderType: Text.NativeRendering
|
||||
style: Text.PlainText
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: 2
|
||||
}
|
||||
}
|
||||
|
||||
__branchDelegate: branchDelegate
|
||||
__indentation: indentation
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Quick Extras module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Extras 1.4
|
||||
import QtQuick.Extras.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype TumblerStyle
|
||||
\inqmlmodule QtQuick.Controls.Styles
|
||||
\since 5.5
|
||||
\ingroup controlsstyling
|
||||
\brief Provides custom styling for Tumbler.
|
||||
|
||||
You can create a custom tumbler by replacing the following delegates:
|
||||
\list
|
||||
\li \l background
|
||||
\li \l foreground
|
||||
\li \l separator
|
||||
\li \l delegate
|
||||
\li \l highlight
|
||||
\li \l frame
|
||||
\endlist
|
||||
*/
|
||||
|
||||
Style {
|
||||
id: tumblerStyle
|
||||
|
||||
padding.left: __padding
|
||||
padding.right: __padding
|
||||
padding.top: __padding
|
||||
padding.bottom: __padding
|
||||
|
||||
/*!
|
||||
The \l Tumbler that this style is attached to.
|
||||
*/
|
||||
readonly property Tumbler control: __control
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
This property holds the spacing between each delegate.
|
||||
|
||||
This property has no effect.
|
||||
*/
|
||||
property real spacing: 0
|
||||
|
||||
/*!
|
||||
This property holds the amount of items visible in each column.
|
||||
|
||||
This value should be an odd number.
|
||||
*/
|
||||
property int visibleItemCount: 3
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
TODO: how do we handle differing padding values?
|
||||
*/
|
||||
readonly property real __padding: Math.max(6, Math.round(TextSingleton.implicitHeight * 0.4))
|
||||
/*! \internal */
|
||||
property real __delegateHeight: 0
|
||||
/*! \internal */
|
||||
property real __separatorWidth: 0
|
||||
|
||||
/*!
|
||||
The background of the tumbler.
|
||||
*/
|
||||
property Component background: Rectangle {
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.00; color: "#acacac" }
|
||||
GradientStop { position: 0.12; color: "#d5d5d5" }
|
||||
GradientStop { position: 0.24; color: "#e8e8e8" }
|
||||
GradientStop { position: 0.39; color: "#ffffff" }
|
||||
GradientStop { position: 0.61; color: "#ffffff" }
|
||||
GradientStop { position: 0.76; color: "#e8e8e8" }
|
||||
GradientStop { position: 0.88; color: "#d5d5d5" }
|
||||
GradientStop { position: 1.00; color: "#acacac" }
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The foreground of the tumbler.
|
||||
*/
|
||||
property Component foreground: Item {
|
||||
clip: true
|
||||
|
||||
Rectangle {
|
||||
id: rect
|
||||
anchors.fill: parent
|
||||
// Go one pixel larger than our parent so that we can hide our one pixel frame
|
||||
// that the shadow is created from.
|
||||
anchors.margins: -1
|
||||
color: "transparent"
|
||||
border.color: "black"
|
||||
visible: false
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
anchors.fill: rect
|
||||
source: rect
|
||||
samples: 15
|
||||
spread: 0.45
|
||||
cached: true
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The separator between each column.
|
||||
|
||||
The \l {Item::}{implicitWidth} property must be set, and should be the
|
||||
same value for each separator.
|
||||
*/
|
||||
property Component separator: Canvas {
|
||||
implicitWidth: Math.max(10, Math.round(TextSingleton.implicitHeight * 0.4))
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
ctx.fillStyle = "#11000000";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
ctx.fillStyle = "#11000000";
|
||||
ctx.fillRect(width * 0.2, 0, width * 0.6, height);
|
||||
ctx.fillStyle = "#66000000";
|
||||
ctx.fillRect(width * 0.4, 0, width * 0.2, height);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The foreground of each column.
|
||||
|
||||
In terms of stacking order, this component is displayed above the
|
||||
delegate and highlight components, but below the foreground component.
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.column
|
||||
\li The index of the column that contains this item.
|
||||
\row \li \c {readonly property bool} \b styleData.activeFocus
|
||||
\li \c true if the column that contains this item has active focus.
|
||||
|
||||
\endtable
|
||||
|
||||
Delegates for items in specific columns can be defined using
|
||||
TumblerColumn's \l {TumblerColumn::columnForeground}{columnForeground}
|
||||
property, which will be used instead of this component.
|
||||
*/
|
||||
property Component columnForeground
|
||||
|
||||
/*!
|
||||
The frame around the tumbler.
|
||||
|
||||
The \l {Item::}{implicitWidth} property must be set, and should be the
|
||||
same value for each separator.
|
||||
*/
|
||||
property Component frame: Canvas {
|
||||
onPaint: {
|
||||
// workaround for QTBUG-40792
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
var cornerRadius = Math.max(2, Math.round(TextSingleton.implicitHeight * 0.2));
|
||||
var outerLineWidth = Math.max(1, Math.round(TextSingleton.implicitHeight * 0.05));
|
||||
var innerLineWidth = __padding - outerLineWidth;
|
||||
|
||||
ctx.save();
|
||||
ctx.lineWidth = outerLineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.roundedRect(0, 0, width, height, cornerRadius, cornerRadius);
|
||||
ctx.roundedRect(outerLineWidth, outerLineWidth, width - outerLineWidth * 2, height - outerLineWidth * 2,
|
||||
cornerRadius - outerLineWidth, cornerRadius - outerLineWidth);
|
||||
ctx.clip();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, width, height);
|
||||
var gradient = ctx.createLinearGradient(width / 2, 0, width / 2, height);
|
||||
gradient.addColorStop(0, "#33b3b3b3");
|
||||
gradient.addColorStop(1, "#4ce6e6e6");
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
|
||||
// The inner stroke must account for its corner radius.
|
||||
cornerRadius -= outerLineWidth;
|
||||
|
||||
ctx.save();
|
||||
ctx.lineWidth = innerLineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.roundedRect(outerLineWidth, outerLineWidth, width - outerLineWidth * 2, height - outerLineWidth * 2,
|
||||
cornerRadius, cornerRadius);
|
||||
ctx.roundedRect(outerLineWidth + innerLineWidth, outerLineWidth + innerLineWidth,
|
||||
width - outerLineWidth * 2 - innerLineWidth * 2, height - outerLineWidth * 2 - innerLineWidth * 2,
|
||||
cornerRadius - innerLineWidth, cornerRadius - innerLineWidth);
|
||||
ctx.clip();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, width, height);
|
||||
gradient = ctx.createLinearGradient(width / 2, 0, width / 2, height);
|
||||
gradient.addColorStop(0, "#4c666666");
|
||||
gradient.addColorStop(1, "#40cccccc");
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The delegate provides a template defining each item instantiated in the
|
||||
column. Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this delegate in the model.
|
||||
\row \li \c {readonly property int} \b styleData.column
|
||||
\li The index of the column that contains this item.
|
||||
\row \li \c {readonly property real} \b styleData.value
|
||||
\li The value for this delegate from the model.
|
||||
\row \li \c {readonly property bool} \b styleData.current
|
||||
\li \c true if this delegate is the current item.
|
||||
\row \li \c {readonly property real} \b styleData.displacement
|
||||
\li \c A value from \c {-visibleItemCount / 2} to
|
||||
\c {visibleItemCount / 2} which represents how far away
|
||||
this item is from being the current item, with \c 0 being
|
||||
completely current.
|
||||
|
||||
For example, the item below will be 40% opaque when
|
||||
it is not the current item, and transition to 100%
|
||||
opacity when it becomes the current item:
|
||||
|
||||
\code
|
||||
delegate: Text {
|
||||
text: styleData.value
|
||||
opacity: 0.4 + Math.max(0, 1 - Math.abs(styleData.displacement)) * 0.6
|
||||
}
|
||||
\endcode
|
||||
\row \li \c {readonly property bool} \b styleData.activeFocus
|
||||
\li \c true if the column that contains this item has active focus.
|
||||
|
||||
\endtable
|
||||
|
||||
Properties of the model are also available depending upon the type of
|
||||
\l {qml-data-models}{Data Model}.
|
||||
|
||||
Delegates for items in specific columns can be defined using
|
||||
TumblerColumn's \l {TumblerColumn::delegate}{delegate} property, which
|
||||
will be used instead of this delegate.
|
||||
|
||||
The \l {Item::}{implicitHeight} property must be set, and it must be
|
||||
the same for each delegate.
|
||||
*/
|
||||
property Component delegate: Item {
|
||||
implicitHeight: (control.height - padding.top - padding.bottom) / tumblerStyle.visibleItemCount
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: styleData.value
|
||||
color: "#666666"
|
||||
opacity: 0.4 + Math.max(0, 1 - Math.abs(styleData.displacement)) * 0.6
|
||||
font.pixelSize: Math.round(TextSingleton.font.pixelSize * 1.25)
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
The delegate for the highlight of each column.
|
||||
|
||||
Delegates for the highlight of specific columns can be defined using
|
||||
TumblerColumn's \l {TumblerColumn::highlight}{highlight} property,
|
||||
which will be used instead of this delegate.
|
||||
|
||||
Each instance of this component has access to the following properties:
|
||||
|
||||
\table
|
||||
\row \li \c {readonly property int} \b styleData.index
|
||||
\li The index of this column in the tumbler.
|
||||
\row \li \c {readonly property int} \b styleData.columnIndex
|
||||
\li The index of the column that contains this highlight.
|
||||
\row \li \c {readonly property bool} \b styleData.activeFocus
|
||||
\li \c true if the column that contains this highlight has active focus.
|
||||
\endtable
|
||||
*/
|
||||
property Component highlight
|
||||
|
||||
/*! \internal */
|
||||
property Component panel: Item {
|
||||
implicitWidth: {
|
||||
var w = (__separatorWidth * (control.columnCount - 1)) + tumblerStyle.padding.left + tumblerStyle.padding.right;
|
||||
for (var i = 0; i < control.columnCount; ++i)
|
||||
w += control.getColumn(i).width;
|
||||
return w;
|
||||
}
|
||||
implicitHeight: TextSingleton.implicitHeight * 10 + tumblerStyle.padding.top + tumblerStyle.padding.bottom
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 99 B |
|
After Width: | Height: | Size: 138 B |
|
After Width: | Height: | Size: 98 B |
|
After Width: | Height: | Size: 139 B |
|
After Width: | Height: | Size: 99 B |
|
After Width: | Height: | Size: 148 B |
|
After Width: | Height: | Size: 112 B |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 554 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 176 B |
|
After Width: | Height: | Size: 417 B |
|
After Width: | Height: | Size: 416 B |
|
After Width: | Height: | Size: 271 B |
|
After Width: | Height: | Size: 225 B |
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 206 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 228 B |
|
After Width: | Height: | Size: 825 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 839 B |