阻抗弹窗
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
/*!
|
||||
\qmltype AbstractCheckable
|
||||
\inqmlmodule QtQuick.Controls
|
||||
\brief An abstract representation of a checkable control with a label
|
||||
\qmlabstract
|
||||
\internal
|
||||
|
||||
A checkable control is one that has two states: checked (on) and
|
||||
unchecked (off). AbstractCheckable encapsulates the basic behavior and
|
||||
states that are required by checkable controls.
|
||||
|
||||
Examples of checkable controls are RadioButton and
|
||||
CheckBox. CheckBox extends AbstractCheckable's behavior by adding a third
|
||||
state: partially checked.
|
||||
*/
|
||||
|
||||
Control {
|
||||
id: abstractCheckable
|
||||
|
||||
/*!
|
||||
Emitted whenever the control is clicked.
|
||||
*/
|
||||
signal clicked
|
||||
|
||||
/*!
|
||||
\qmlproperty bool AbstractCheckable::pressed
|
||||
|
||||
This property is \c true if the control is being pressed.
|
||||
Set this property to manually invoke a mouse click.
|
||||
*/
|
||||
property alias pressed: mouseArea.effectivePressed
|
||||
|
||||
/*! \qmlproperty bool AbstractCheckcable::hovered
|
||||
|
||||
This property indicates whether the control is being hovered.
|
||||
*/
|
||||
readonly property alias hovered: mouseArea.containsMouse
|
||||
|
||||
/*!
|
||||
This property is \c true if the control is checked.
|
||||
*/
|
||||
property bool checked: false
|
||||
Accessible.checked: checked
|
||||
Accessible.checkable: true
|
||||
|
||||
/*!
|
||||
This property is \c true if the control takes the focus when it is
|
||||
pressed; \l{QQuickItem::forceActiveFocus()}{forceActiveFocus()} will be
|
||||
called on the control.
|
||||
*/
|
||||
property bool activeFocusOnPress: false
|
||||
|
||||
/*!
|
||||
This property stores the ExclusiveGroup that the control belongs to.
|
||||
*/
|
||||
property ExclusiveGroup exclusiveGroup: null
|
||||
|
||||
/*!
|
||||
This property holds the text that the label should display.
|
||||
*/
|
||||
property string text
|
||||
|
||||
/*!
|
||||
This property holds the button tooltip.
|
||||
|
||||
\since QtQuick.Controls 1.7
|
||||
*/
|
||||
property string tooltip
|
||||
Accessible.description: tooltip
|
||||
|
||||
/*! \internal */
|
||||
property var __cycleStatesHandler: cycleRadioButtonStates
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
focus: true
|
||||
anchors.fill: parent
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
enabled: !keyPressed
|
||||
|
||||
property bool keyPressed: false
|
||||
property bool effectivePressed: pressed && containsMouse || keyPressed
|
||||
|
||||
onClicked: abstractCheckable.clicked();
|
||||
|
||||
onPressed: if (activeFocusOnPress) forceActiveFocus();
|
||||
|
||||
onExited: Tooltip.hideText()
|
||||
onCanceled: Tooltip.hideText()
|
||||
|
||||
onReleased: {
|
||||
if (containsMouse && (!exclusiveGroup || !checked))
|
||||
__cycleStatesHandler();
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: mouseArea.containsMouse && !pressed && tooltip.length && mouseArea.Window.visibility !== Window.Hidden
|
||||
onTriggered: Tooltip.showText(mouseArea, Qt.point(mouseArea.mouseX, mouseArea.mouseY), tooltip)
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
onExclusiveGroupChanged: {
|
||||
if (exclusiveGroup)
|
||||
exclusiveGroup.bindCheckable(abstractCheckable)
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && !mouseArea.pressed)
|
||||
mouseArea.keyPressed = true;
|
||||
}
|
||||
|
||||
Keys.onReleased: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && mouseArea.keyPressed) {
|
||||
mouseArea.keyPressed = false;
|
||||
if (!exclusiveGroup || !checked)
|
||||
__cycleStatesHandler();
|
||||
clicked();
|
||||
}
|
||||
}
|
||||
|
||||
Action {
|
||||
// handle mnemonic
|
||||
text: abstractCheckable.text
|
||||
onTriggered: {
|
||||
if (!abstractCheckable.exclusiveGroup || !abstractCheckable.checked)
|
||||
abstractCheckable.__cycleStatesHandler();
|
||||
abstractCheckable.clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,241 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
import QtQuick.Controls.Styles 1.1
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
/*!
|
||||
\qmltype BasicButton
|
||||
\internal
|
||||
\qmlabstract
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
|
||||
Control {
|
||||
id: button
|
||||
|
||||
/*! This signal is emitted when the button is clicked. */
|
||||
signal clicked
|
||||
|
||||
/*! \qmlproperty bool BasicButton::pressed
|
||||
|
||||
This property holds whether the button is being pressed. */
|
||||
readonly property alias pressed: button.__effectivePressed
|
||||
|
||||
/*! \qmlproperty bool BasicButton::hovered
|
||||
|
||||
This property indicates whether the control is being hovered.
|
||||
*/
|
||||
readonly property alias hovered: behavior.containsMouse
|
||||
|
||||
/*! This property holds whether the button is checkable.
|
||||
|
||||
The default value is \c false. */
|
||||
property bool checkable: false
|
||||
Accessible.checkable: checkable
|
||||
|
||||
/*! This property holds whether the button is checked.
|
||||
|
||||
Only checkable buttons can be checked.
|
||||
|
||||
The default value is \c false. */
|
||||
property bool checked: false
|
||||
Accessible.checked: checked
|
||||
|
||||
/*! This property holds the ExclusiveGroup that the button belongs to.
|
||||
|
||||
The default value is \c null. */
|
||||
property ExclusiveGroup exclusiveGroup: null
|
||||
|
||||
/*! This property holds the associated button action.
|
||||
|
||||
If a button has an action associated, the action defines the
|
||||
button's properties like checked, text, tooltip etc.
|
||||
|
||||
When an action is set, it's still possible to override the \l text,
|
||||
\l tooltip, \l iconSource, and \l iconName properties.
|
||||
|
||||
The default value is \c null. */
|
||||
property Action action: null
|
||||
|
||||
/*! This property specifies whether the button should gain active focus when pressed.
|
||||
|
||||
The default value is \c false. */
|
||||
property bool activeFocusOnPress: false
|
||||
|
||||
/*! This property holds the text shown on the button. If the button has no
|
||||
text, the \l text property will be an empty string.
|
||||
|
||||
The default value is the empty string.
|
||||
*/
|
||||
property string text: action ? action.text : ""
|
||||
|
||||
/*! This property holds the button tooltip. */
|
||||
property string tooltip: action ? (action.tooltip || StyleHelpers.removeMnemonics(action.text)) : ""
|
||||
|
||||
/*! This property holds the icon shown on the button. If the button has no
|
||||
icon, the iconSource property will be an empty string.
|
||||
|
||||
The default value is the empty string.
|
||||
*/
|
||||
property url iconSource: action ? action.iconSource : ""
|
||||
|
||||
/*! The image label source as theme name.
|
||||
When an icon from the platform icon theme is found, this takes
|
||||
precedence over iconSource.
|
||||
|
||||
\include icons.qdocinc iconName
|
||||
*/
|
||||
property string iconName: action ? action.iconName : ""
|
||||
|
||||
/*! \internal */
|
||||
property string __position: "only"
|
||||
/*! \internal */
|
||||
readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName)
|
||||
/*! \internal */
|
||||
property Action __action: action || ownAction
|
||||
/*! \internal */
|
||||
readonly property Action __iconAction: __iconOverriden ? ownAction : __action
|
||||
|
||||
/*! \internal */
|
||||
onExclusiveGroupChanged: {
|
||||
if (exclusiveGroup)
|
||||
exclusiveGroup.bindCheckable(button)
|
||||
}
|
||||
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.description: tooltip
|
||||
|
||||
/*! \internal */
|
||||
function accessiblePressAction() {
|
||||
__action.trigger(button)
|
||||
}
|
||||
|
||||
Action {
|
||||
id: ownAction
|
||||
enabled: button.enabled
|
||||
iconSource: !button.action || __iconOverriden ? button.iconSource : ""
|
||||
iconName: !button.action || __iconOverriden ? button.iconName : ""
|
||||
|
||||
// let ownAction handle mnemonic if and only if the button does
|
||||
// not already have an action assigned to avoid ambiguous shortcuts
|
||||
text: button.action ? "" : button.text
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: __action
|
||||
onTriggered: button.clicked()
|
||||
}
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed) {
|
||||
behavior.keyPressed = true;
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
onFocusChanged: if (!focus) behavior.keyPressed = false
|
||||
|
||||
Keys.onReleased: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
|
||||
behavior.keyPressed = false;
|
||||
__action.trigger(button)
|
||||
behavior.toggle()
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: behavior
|
||||
property bool keyPressed: false
|
||||
property bool effectivePressed: pressed && containsMouse || keyPressed
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
enabled: !keyPressed
|
||||
|
||||
function toggle() {
|
||||
if (button.checkable && !button.action && !(button.checked && button.exclusiveGroup))
|
||||
button.checked = !button.checked
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
if (containsMouse) {
|
||||
toggle()
|
||||
__action.trigger(button)
|
||||
}
|
||||
}
|
||||
onExited: Tooltip.hideText()
|
||||
onCanceled: Tooltip.hideText()
|
||||
onPressed: {
|
||||
if (activeFocusOnPress)
|
||||
button.forceActiveFocus()
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: behavior.containsMouse && !pressed && tooltip.length && behavior.Window.visibility !== Window.Hidden
|
||||
onTriggered: Tooltip.showText(behavior, Qt.point(behavior.mouseX, behavior.mouseY), tooltip)
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
property var __behavior: behavior
|
||||
|
||||
/*! \internal */
|
||||
property bool __effectivePressed: behavior.effectivePressed
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "boundAction"
|
||||
when: action !== null
|
||||
PropertyChanges {
|
||||
target: button
|
||||
enabled: action.enabled
|
||||
checkable: action.checkable
|
||||
checked: action.checked
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,793 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Controls 1.5
|
||||
import QtQuick.Controls.Private 1.0
|
||||
import QtQuick.Controls.Styles 1.2
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
/*!
|
||||
\qmltype BasicTableView
|
||||
\internal
|
||||
\qmlabstract
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
|
||||
ScrollView {
|
||||
id: root
|
||||
|
||||
/*! \qmlproperty bool BasicTableView::alternatingRowColors
|
||||
|
||||
This property is set to \c true if the view alternates the row color.
|
||||
The default value is \c true.
|
||||
*/
|
||||
property bool alternatingRowColors: true
|
||||
|
||||
/*! \qmlproperty bool BasicTableView::headerVisible
|
||||
|
||||
This property determines if the header is visible.
|
||||
The default value is \c true.
|
||||
*/
|
||||
property bool headerVisible: true
|
||||
|
||||
/*! \qmlproperty bool BasicTableView::backgroundVisible
|
||||
|
||||
This property determines if the background should be filled or not.
|
||||
|
||||
The default value is \c true.
|
||||
|
||||
\note The rowDelegate is not affected by this property
|
||||
*/
|
||||
property alias backgroundVisible: colorRect.visible
|
||||
|
||||
/*! \qmlproperty Component BasicTableView::itemDelegate
|
||||
\internal
|
||||
|
||||
Documentation differs between TableView and TreeView.
|
||||
See qtquickcontrols-treeview.qdoc and qtquickcontrols-tableview.qdoc
|
||||
*/
|
||||
property Component itemDelegate: __style ? __style.itemDelegate : null
|
||||
|
||||
/*! \qmlproperty Component BasicTableView::rowDelegate
|
||||
\keyword basictableview-rowdelegate
|
||||
|
||||
This property defines a delegate to draw a row.
|
||||
|
||||
In the row delegate you have access to the following special properties:
|
||||
\list
|
||||
\li styleData.alternate - true when the row uses the alternate background color
|
||||
\li styleData.selected - true when the row is currently selected
|
||||
\li styleData.row - the index of the row
|
||||
\li styleData.hasActiveFocus - true when the row has focus (since QtQuick.Controls 1.3)
|
||||
\li styleData.pressed - true when the row is pressed (since QtQuick.Controls 1.3)
|
||||
\endlist
|
||||
|
||||
\note For performance reasons, created delegates can be recycled
|
||||
across multiple table rows. This implies that when you make use of implicit
|
||||
properties such as \c styleData.row or \c model, these values can change
|
||||
after the delegate has been constructed. This means that you should not assume
|
||||
that content is fixed when \c Component.onCompleted is called, but instead rely on
|
||||
bindings to such properties.
|
||||
*/
|
||||
property Component rowDelegate: __style ? __style.rowDelegate : null
|
||||
|
||||
/*! \qmlproperty Component BasicTableView::headerDelegate
|
||||
\keyword basictableview-headerdelegate
|
||||
|
||||
This property defines a delegate to draw a header.
|
||||
|
||||
In the header delegate you have access to the following special properties:
|
||||
\list
|
||||
\li styleData.value - the value or text for this item
|
||||
\li styleData.column - the index of the column
|
||||
\li styleData.pressed - true when the column is being pressed
|
||||
\li styleData.containsMouse - true when the column is under the mouse
|
||||
\li styleData.textAlignment - the horizontal text alignment of the column (since QtQuickControls 1.1)
|
||||
\endlist
|
||||
*/
|
||||
property Component headerDelegate: __style ? __style.headerDelegate : null
|
||||
|
||||
/*! \qmlproperty int BasicTableView::sortIndicatorColumn
|
||||
|
||||
Index of the current sort column.
|
||||
The default value is \c {0}.
|
||||
*/
|
||||
property int sortIndicatorColumn
|
||||
|
||||
/*! \qmlproperty bool BasicTableView::sortIndicatorVisible
|
||||
|
||||
This property shows or hides the sort indicator
|
||||
The default value is \c false.
|
||||
\note The view itself does not sort the data.
|
||||
*/
|
||||
property bool sortIndicatorVisible: false
|
||||
|
||||
/*! \qmlproperty enumeration BasicTableView::sortIndicatorOrder
|
||||
|
||||
This sets the sorting order of the sort indicator
|
||||
The allowed values are:
|
||||
\list
|
||||
\li Qt.AscendingOrder - the default
|
||||
\li Qt.DescendingOrder
|
||||
\endlist
|
||||
*/
|
||||
property int sortIndicatorOrder: Qt.AscendingOrder
|
||||
|
||||
/*! \qmlproperty Component BasicTableView::contentHeader
|
||||
This is the content header of the view.
|
||||
*/
|
||||
property alias contentHeader: listView.header
|
||||
|
||||
/*! \qmlproperty Component BasicTableView::contentFooter
|
||||
This is the content footer of the view.
|
||||
*/
|
||||
property alias contentFooter: listView.footer
|
||||
|
||||
/*! \qmlproperty int BasicTableView::columnCount
|
||||
The current number of columns
|
||||
*/
|
||||
readonly property alias columnCount: columnModel.count
|
||||
|
||||
/*! \qmlpropertygroup BasicTableView::section
|
||||
\internal
|
||||
\qmlproperty string BasicTableView::section.property
|
||||
\qmlproperty enumeration BasicTableView::section.criteria
|
||||
\qmlproperty Component BasicTableView::section.delegate
|
||||
\qmlproperty enumeration BasicTableView::section.labelPositioning
|
||||
|
||||
Moved to the qdoc files to keep the grouped property layout.
|
||||
See qtquickcontrols-treeview.qdoc and qtquickcontrols-tableview.qdoc
|
||||
*/
|
||||
property alias section: listView.section
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration BasicTableView::selectionMode
|
||||
\since QtQuick.Controls 1.1
|
||||
|
||||
This enum indicates how the view responds to user selections:
|
||||
|
||||
The possible modes are:
|
||||
|
||||
\list
|
||||
|
||||
\li SelectionMode.NoSelection - Items cannot be selected.
|
||||
|
||||
\li SelectionMode.SingleSelection - When the user selects an item,
|
||||
any already-selected item becomes unselected, and the user cannot
|
||||
unselect the selected item. (Default)
|
||||
|
||||
\li SelectionMode.MultiSelection - When the user selects an item in the usual way,
|
||||
the selection status of that item is toggled and the other items are left alone.
|
||||
|
||||
\li SelectionMode.ExtendedSelection - When the user selects an item in the usual way,
|
||||
the selection is cleared and the new item selected. However, if the user presses the
|
||||
Ctrl key when clicking on an item, the clicked item gets toggled and all other items
|
||||
are left untouched. If the user presses the Shift key while clicking
|
||||
on an item, all items between the current item and the clicked item are selected or unselected,
|
||||
depending on the state of the clicked item. Multiple items can be selected by dragging the
|
||||
mouse over them.
|
||||
|
||||
\li SelectionMode.ContiguousSelection - When the user selects an item in the usual way,
|
||||
the selection is cleared and the new item selected. However, if the user presses the Shift key while
|
||||
clicking on an item, all items between the current item and the clicked item are selected.
|
||||
|
||||
\endlist
|
||||
*/
|
||||
property int selectionMode: SelectionMode.SingleSelection
|
||||
|
||||
/*!
|
||||
\qmlmethod TableViewColumn BasicTableView::addColumn(object column)
|
||||
|
||||
Adds a \a column and returns the added column.
|
||||
|
||||
The \a column argument can be an instance of TableViewColumn,
|
||||
or a Component. The component has to contain a TableViewColumn.
|
||||
Otherwise \c null is returned.
|
||||
*/
|
||||
function addColumn(column) {
|
||||
return insertColumn(columnCount, column)
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod TableViewColumn BasicTableView::insertColumn(int index, object column)
|
||||
|
||||
Inserts a \a column at the given \a index and returns the inserted column.
|
||||
|
||||
The \a column argument can be an instance of TableViewColumn,
|
||||
or a Component. The component has to contain a TableViewColumn.
|
||||
Otherwise \c null is returned.
|
||||
*/
|
||||
function insertColumn(index, column) {
|
||||
if (__isTreeView && index === 0 && columnCount > 0) {
|
||||
console.warn(__viewTypeName + "::insertColumn(): Can't replace column 0")
|
||||
return null
|
||||
}
|
||||
var object = column
|
||||
if (typeof column['createObject'] === 'function') {
|
||||
object = column.createObject(root)
|
||||
} else if (object.__view) {
|
||||
console.warn(__viewTypeName + "::insertColumn(): you cannot add a column to multiple views")
|
||||
return null
|
||||
}
|
||||
if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) {
|
||||
object.__view = root
|
||||
columnModel.insert(index, {columnItem: object})
|
||||
if (root.__columns[index] !== object) {
|
||||
// The new column needs to be put into __columns at the specified index
|
||||
// so the list needs to be recreated to be correct
|
||||
var arr = []
|
||||
for (var i = 0; i < index; ++i)
|
||||
arr.push(root.__columns[i])
|
||||
arr.push(object)
|
||||
for (i = index; i < root.__columns.length; ++i)
|
||||
arr.push(root.__columns[i])
|
||||
root.__columns = arr
|
||||
}
|
||||
return object
|
||||
}
|
||||
|
||||
if (object !== column)
|
||||
object.destroy()
|
||||
console.warn(__viewTypeName + "::insertColumn(): invalid argument")
|
||||
return null
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod void BasicTableView::removeColumn(int index)
|
||||
|
||||
Removes and destroys a column at the given \a index.
|
||||
*/
|
||||
function removeColumn(index) {
|
||||
if (index < 0 || index >= columnCount) {
|
||||
console.warn(__viewTypeName + "::removeColumn(): invalid argument")
|
||||
return
|
||||
}
|
||||
if (__isTreeView && index === 0) {
|
||||
console.warn(__viewTypeName + "::removeColumn(): Can't remove column 0")
|
||||
return
|
||||
}
|
||||
var column = columnModel.get(index).columnItem
|
||||
columnModel.remove(index, 1)
|
||||
column.destroy()
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod void BasicTableView::moveColumn(int from, int to)
|
||||
|
||||
Moves a column \a from index \a to another.
|
||||
*/
|
||||
function moveColumn(from, to) {
|
||||
if (from < 0 || from >= columnCount || to < 0 || to >= columnCount) {
|
||||
console.warn(__viewTypeName + "::moveColumn(): invalid argument")
|
||||
return
|
||||
}
|
||||
if (__isTreeView && to === 0) {
|
||||
console.warn(__viewTypeName + "::moveColumn(): Can't move column 0")
|
||||
return
|
||||
}
|
||||
if (sortIndicatorColumn === from)
|
||||
sortIndicatorColumn = to
|
||||
columnModel.move(from, to, 1)
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod TableViewColumn BasicTableView::getColumn(int index)
|
||||
|
||||
Returns the column at the given \a index
|
||||
or \c null if the \a index is invalid.
|
||||
*/
|
||||
function getColumn(index) {
|
||||
if (index < 0 || index >= columnCount)
|
||||
return null
|
||||
return columnModel.get(index).columnItem
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod void BasicTableView::resizeColumnsToContents()
|
||||
|
||||
Resizes all columns to ensure that the column contents and the headers will fit.
|
||||
\since QtQuick.Controls 1.2
|
||||
*/
|
||||
function resizeColumnsToContents () {
|
||||
for (var i = 0; i < __columns.length; ++i) {
|
||||
var col = getColumn(i)
|
||||
var header = __listView.headerItem.headerRepeater.itemAt(i)
|
||||
if (col) {
|
||||
col.resizeToContents()
|
||||
if (col.width < header.implicitWidth)
|
||||
col.width = header.implicitWidth
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Internal stuff. Do not look
|
||||
|
||||
Component.onCompleted: {
|
||||
for (var i = 0; i < __columns.length; ++i) {
|
||||
var column = __columns[i]
|
||||
if (column.Accessible.role === Accessible.ColumnHeader)
|
||||
addColumn(column)
|
||||
}
|
||||
}
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
implicitWidth: 200
|
||||
implicitHeight: 150
|
||||
|
||||
frameVisible: true
|
||||
__scrollBarTopMargin: headerVisible && (listView.transientScrollBars || Qt.platform.os === "osx")
|
||||
? listView.headerItem.height : 0
|
||||
|
||||
/*! \internal
|
||||
Use this to display user-friendly messages in TableView and TreeView common functions.
|
||||
*/
|
||||
property string __viewTypeName
|
||||
|
||||
/*! \internal */
|
||||
readonly property bool __isTreeView: __viewTypeName === "TreeView"
|
||||
|
||||
/*! \internal */
|
||||
default property alias __columns: root.data
|
||||
|
||||
/*! \internal */
|
||||
property alias __currentRowItem: listView.currentItem
|
||||
|
||||
/*! \internal
|
||||
This property is forwarded to TableView::currentRow, but not to any TreeView property.
|
||||
*/
|
||||
property alias __currentRow: listView.currentIndex
|
||||
|
||||
/*! \internal */
|
||||
readonly property alias __listView: listView
|
||||
|
||||
/*! \internal */
|
||||
property Component __itemDelegateLoader: null
|
||||
|
||||
/*! \internal
|
||||
Allows to override the model property in cases like TreeView,
|
||||
where we want to use a proxy/adaptor model between the user's model
|
||||
and whatever a ListView can swallow.
|
||||
*/
|
||||
property var __model
|
||||
|
||||
/*! \internal */
|
||||
property bool __activateItemOnSingleClick: __style ? __style.activateItemOnSingleClick : false
|
||||
|
||||
/*! \internal */
|
||||
property Item __mouseArea
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
focus: true
|
||||
activeFocusOnTab: false
|
||||
Keys.forwardTo: [__mouseArea]
|
||||
anchors.fill: parent
|
||||
contentWidth: headerItem.headerRow.width + listView.vScrollbarPadding
|
||||
// ### FIXME Late configuration of the header item requires
|
||||
// this binding to get the header visible after creation
|
||||
contentY: -headerItem.height
|
||||
|
||||
currentIndex: -1
|
||||
visible: columnCount > 0
|
||||
interactive: Settings.hasTouchScreen
|
||||
property var rowItemStack: [] // Used as a cache for rowDelegates
|
||||
|
||||
readonly property bool transientScrollBars: __style && !!__style.transientScrollBars
|
||||
readonly property real vScrollbarPadding: __scroller.verticalScrollBar.visible
|
||||
&& !transientScrollBars && Qt.platform.os === "osx" ?
|
||||
__verticalScrollBar.width + __scroller.scrollBarSpacing + root.__style.padding.right : 0
|
||||
|
||||
Binding {
|
||||
// On Mac, we reserve the vSB space in the contentItem because the vSB should
|
||||
// appear under the header. Unfortunately, the ListView header won't expand
|
||||
// beyond the ListView's boundaries, that's why we need to ressort to this.
|
||||
target: root.__scroller
|
||||
when: Qt.platform.os === "osx"
|
||||
property: "verticalScrollbarOffset"
|
||||
value: 0
|
||||
}
|
||||
|
||||
function incrementCurrentIndexBlocking() {
|
||||
var oldIndex = __listView.currentIndex
|
||||
__scroller.blockUpdates = true;
|
||||
incrementCurrentIndex();
|
||||
__scroller.blockUpdates = false;
|
||||
return oldIndex !== __listView.currentIndex
|
||||
}
|
||||
|
||||
function decrementCurrentIndexBlocking() {
|
||||
var oldIndex = __listView.currentIndex
|
||||
__scroller.blockUpdates = true;
|
||||
decrementCurrentIndex();
|
||||
__scroller.blockUpdates = false;
|
||||
return oldIndex !== __listView.currentIndex
|
||||
}
|
||||
|
||||
function scrollIfNeeded(key) {
|
||||
var diff = key === Qt.Key_PageDown ? height :
|
||||
key === Qt.Key_PageUp ? -height : 0
|
||||
if (diff !== 0)
|
||||
__verticalScrollBar.value += diff
|
||||
}
|
||||
|
||||
SystemPalette {
|
||||
id: palette
|
||||
colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: colorRect
|
||||
parent: viewport
|
||||
anchors.fill: parent
|
||||
color: __style ? __style.backgroundColor : palette.base
|
||||
z: -2
|
||||
}
|
||||
|
||||
// Fills extra rows with alternate color
|
||||
Column {
|
||||
id: rowfiller
|
||||
Loader {
|
||||
id: rowSizeItem
|
||||
sourceComponent: root.rowDelegate
|
||||
visible: false
|
||||
property QtObject styleData: QtObject {
|
||||
property bool alternate: false
|
||||
property bool selected: false
|
||||
property bool hasActiveFocus: false
|
||||
property bool pressed: false
|
||||
}
|
||||
}
|
||||
property int rowHeight: Math.floor(rowSizeItem.implicitHeight)
|
||||
property int paddedRowCount: rowHeight != 0 ? height/rowHeight : 0
|
||||
|
||||
y: listView.contentHeight - listView.contentY + listView.originY
|
||||
width: parent.width
|
||||
visible: alternatingRowColors
|
||||
height: viewport.height - listView.contentHeight
|
||||
Repeater {
|
||||
model: visible ? parent.paddedRowCount : 0
|
||||
Loader {
|
||||
width: rowfiller.width
|
||||
height: rowfiller.rowHeight
|
||||
sourceComponent: root.rowDelegate
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property bool alternate: (index + __listView.count) % 2 === 1
|
||||
readonly property bool selected: false
|
||||
readonly property bool hasActiveFocus: false
|
||||
readonly property bool pressed: false
|
||||
}
|
||||
readonly property var model: null
|
||||
readonly property var modelData: null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: columnModel
|
||||
}
|
||||
|
||||
highlightFollowsCurrentItem: true
|
||||
model: root.__model
|
||||
|
||||
delegate: FocusScope {
|
||||
id: rowItemContainer
|
||||
|
||||
activeFocusOnTab: false
|
||||
z: rowItem.activeFocus ? 0.7 : rowItem.itemSelected ? 0.5 : 0
|
||||
|
||||
property Item rowItem
|
||||
// We recycle instantiated row items to speed up list scrolling
|
||||
|
||||
Component.onDestruction: {
|
||||
// move the rowItem back in cache
|
||||
if (rowItem) {
|
||||
rowItem.visible = false;
|
||||
rowItem.parent = null;
|
||||
rowItem.rowIndex = -1;
|
||||
listView.rowItemStack.push(rowItem); // return rowItem to cache
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// retrieve row item from cache
|
||||
if (listView.rowItemStack.length > 0)
|
||||
rowItem = listView.rowItemStack.pop();
|
||||
else
|
||||
rowItem = rowComponent.createObject(listView);
|
||||
|
||||
// Bind container to item size
|
||||
rowItemContainer.width = Qt.binding( function() { return rowItem.width });
|
||||
rowItemContainer.height = Qt.binding( function() { return rowItem.height });
|
||||
|
||||
// Reassign row-specific bindings
|
||||
rowItem.rowIndex = Qt.binding( function() { return model.index });
|
||||
rowItem.itemModelData = Qt.binding( function() { return typeof modelData === "undefined" ? null : modelData });
|
||||
rowItem.itemModel = Qt.binding( function() { return model });
|
||||
rowItem.parent = rowItemContainer;
|
||||
rowItem.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: rowComponent
|
||||
|
||||
FocusScope {
|
||||
id: rowitem
|
||||
visible: false
|
||||
|
||||
property int rowIndex
|
||||
property var itemModelData
|
||||
property var itemModel
|
||||
property bool itemSelected: __mouseArea.selected(rowIndex)
|
||||
property bool alternate: alternatingRowColors && rowIndex % 2 === 1
|
||||
readonly property color itemTextColor: itemSelected ? __style.highlightedTextColor : __style.textColor
|
||||
property Item branchDecoration: null
|
||||
|
||||
width: itemrow.width
|
||||
height: rowstyle.height
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus)
|
||||
listView.currentIndex = rowIndex
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: rowstyle
|
||||
// row delegate
|
||||
sourceComponent: rowitem.itemModel !== undefined ? root.rowDelegate : null
|
||||
// Row fills the view width regardless of item size
|
||||
// But scrollbar should not adjust to it
|
||||
height: item ? item.height : 16
|
||||
width: parent.width + __horizontalScrollBar.width
|
||||
x: listView.contentX
|
||||
|
||||
// these properties are exposed to the row delegate
|
||||
// Note: these properties should be mirrored in the row filler as well
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property int row: rowitem.rowIndex
|
||||
readonly property bool alternate: rowitem.alternate
|
||||
readonly property bool selected: rowitem.itemSelected
|
||||
readonly property bool hasActiveFocus: rowitem.activeFocus
|
||||
readonly property bool pressed: rowitem.rowIndex === __mouseArea.pressedRow
|
||||
}
|
||||
readonly property var model: rowitem.itemModel
|
||||
readonly property var modelData: rowitem.itemModelData
|
||||
}
|
||||
Row {
|
||||
id: itemrow
|
||||
height: parent.height
|
||||
Repeater {
|
||||
model: columnModel
|
||||
|
||||
delegate: __itemDelegateLoader
|
||||
|
||||
onItemAdded: {
|
||||
var columnItem = columnModel.get(index).columnItem
|
||||
item.__rowItem = rowitem
|
||||
item.__column = columnItem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headerPositioning: ListView.OverlayHeader
|
||||
header: Item {
|
||||
id: tableHeader
|
||||
visible: headerVisible
|
||||
width: Math.max(headerRow.width + listView.vScrollbarPadding, root.viewport.width)
|
||||
height: visible ? headerRow.height : 0
|
||||
|
||||
property alias headerRow: row
|
||||
property alias headerRepeater: repeater
|
||||
Row {
|
||||
id: row
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
|
||||
property int targetIndex: -1
|
||||
property int dragIndex: -1
|
||||
|
||||
model: columnModel
|
||||
|
||||
delegate: Item {
|
||||
id: headerRowDelegate
|
||||
readonly property int column: index
|
||||
z:-index
|
||||
width: modelData.width
|
||||
implicitWidth: columnCount === 1 ? viewport.width + __verticalScrollBar.width : headerStyle.implicitWidth
|
||||
visible: modelData.visible
|
||||
height: headerStyle.height
|
||||
|
||||
readonly property bool treeViewMovable: !__isTreeView || index > 0
|
||||
|
||||
Loader {
|
||||
id: headerStyle
|
||||
sourceComponent: root.headerDelegate
|
||||
width: parent.width
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property string value: modelData.title
|
||||
readonly property bool pressed: headerClickArea.pressed
|
||||
readonly property bool containsMouse: headerClickArea.containsMouse
|
||||
readonly property int column: index
|
||||
readonly property int textAlignment: modelData.horizontalAlignment
|
||||
readonly property bool resizable: modelData.resizable
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id: targetmark
|
||||
width: parent.width
|
||||
height:parent.height
|
||||
opacity: (treeViewMovable && index === repeater.targetIndex && repeater.targetIndex !== repeater.dragIndex) ? 0.5 : 0
|
||||
Behavior on opacity { NumberAnimation { duration: 160 } }
|
||||
color: palette.highlight
|
||||
visible: modelData.movable
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
id: headerClickArea
|
||||
drag.axis: Qt.YAxis
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (sortIndicatorColumn === index)
|
||||
sortIndicatorOrder = sortIndicatorOrder === Qt.AscendingOrder ? Qt.DescendingOrder : Qt.AscendingOrder
|
||||
sortIndicatorColumn = index
|
||||
}
|
||||
// Here we handle moving header sections
|
||||
// NOTE: the direction is different from the master branch
|
||||
// so this indicates that I am using an invalid assumption on item ordering
|
||||
onPositionChanged: {
|
||||
if (drag.active && modelData.movable && pressed && columnCount > 1) { // only do this while dragging
|
||||
for (var h = columnCount-1 ; h >= 0 ; --h) {
|
||||
if (headerRow.children[h].visible && drag.target.x + headerRowDelegate.width/2 > headerRow.children[h].x) {
|
||||
repeater.targetIndex = h
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
repeater.dragIndex = index
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
if (repeater.targetIndex >= 0 && repeater.targetIndex !== index ) {
|
||||
var targetColumn = columnModel.get(repeater.targetIndex).columnItem
|
||||
if (targetColumn.movable && (!__isTreeView || repeater.targetIndex > 0)) {
|
||||
if (sortIndicatorColumn === index)
|
||||
sortIndicatorColumn = repeater.targetIndex
|
||||
columnModel.move(index, repeater.targetIndex, 1)
|
||||
}
|
||||
}
|
||||
repeater.targetIndex = -1
|
||||
repeater.dragIndex = -1
|
||||
}
|
||||
drag.target: treeViewMovable && modelData.movable && columnCount > 1 ? draghandle : null
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: draghandle
|
||||
property QtObject styleData: QtObject{
|
||||
readonly property string value: modelData.title
|
||||
readonly property bool pressed: headerClickArea.pressed
|
||||
readonly property bool containsMouse: headerClickArea.containsMouse
|
||||
readonly property int column: index
|
||||
readonly property int textAlignment: modelData.horizontalAlignment
|
||||
}
|
||||
parent: tableHeader
|
||||
x: __implicitX
|
||||
property double __implicitX: headerRowDelegate.x
|
||||
width: modelData.width
|
||||
height: parent.height
|
||||
sourceComponent: root.headerDelegate
|
||||
visible: headerClickArea.pressed
|
||||
onVisibleChanged: {
|
||||
if (!visible)
|
||||
x = Qt.binding(function () { return __implicitX })
|
||||
}
|
||||
opacity: 0.5
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: headerResizeHandle
|
||||
property int offset: 0
|
||||
readonly property int minimumSize: 20
|
||||
preventStealing: true
|
||||
anchors.rightMargin: -width/2
|
||||
width: Settings.hasTouchScreen ? Screen.pixelDensity * 3.5 : 16
|
||||
height: parent.height
|
||||
anchors.right: parent.right
|
||||
enabled: modelData.resizable && columnCount > 0
|
||||
onPositionChanged: {
|
||||
var newHeaderWidth = modelData.width + (mouseX - offset)
|
||||
modelData.width = Math.max(minimumSize, newHeaderWidth)
|
||||
}
|
||||
|
||||
onDoubleClicked: getColumn(index).resizeToContents()
|
||||
onPressedChanged: if (pressed) offset=mouseX
|
||||
cursorShape: enabled && repeater.dragIndex==-1 ? Qt.SplitHCursor : Qt.ArrowCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
property QtObject styleData: QtObject{
|
||||
readonly property string value: ""
|
||||
readonly property bool pressed: false
|
||||
readonly property bool containsMouse: false
|
||||
readonly property int column: -1
|
||||
readonly property int textAlignment: Text.AlignLeft
|
||||
}
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: headerRow.bottom
|
||||
sourceComponent: root.headerDelegate
|
||||
readonly property real __remainingWidth: parent.width - headerRow.width
|
||||
visible: __remainingWidth > 0
|
||||
width: __remainingWidth
|
||||
z:-1
|
||||
}
|
||||
}
|
||||
|
||||
function columnAt(offset) {
|
||||
var item = listView.headerItem.headerRow.childAt(offset, 0)
|
||||
return item ? item.column : -1
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
/*
|
||||
CalendarHeaderModel contains a list of the days of a week,
|
||||
according to a \l locale. The \l locale affects which day of the week
|
||||
is first in the model.
|
||||
|
||||
The only role provided by the model is \c dayOfWeek, which is one of the
|
||||
following JavaScript 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
|
||||
*/
|
||||
|
||||
ListModel {
|
||||
id: root
|
||||
|
||||
/*
|
||||
The locale that this model should be based on.
|
||||
This affects which day of the week is first in the model.
|
||||
*/
|
||||
property var locale
|
||||
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Sunday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Monday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Tuesday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Wednesday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Thursday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Friday
|
||||
}
|
||||
ListElement {
|
||||
dayOfWeek: Locale.Saturday
|
||||
}
|
||||
|
||||
Component.onCompleted: updateFirstDayOfWeek()
|
||||
onLocaleChanged: updateFirstDayOfWeek()
|
||||
|
||||
function updateFirstDayOfWeek() {
|
||||
var daysOfWeek = [Locale.Sunday, Locale.Monday, Locale.Tuesday,
|
||||
Locale.Wednesday, Locale.Thursday, Locale.Friday, Locale.Saturday];
|
||||
var firstDayOfWeek = root.locale.firstDayOfWeek;
|
||||
|
||||
var shifted = daysOfWeek.splice(firstDayOfWeek, daysOfWeek.length - firstDayOfWeek);
|
||||
daysOfWeek = shifted.concat(daysOfWeek)
|
||||
|
||||
if (firstDayOfWeek !== root.get(0).dayOfWeek) {
|
||||
for (var i = 0; i < daysOfWeek.length; ++i) {
|
||||
root.setProperty(i, "dayOfWeek", daysOfWeek[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
.pragma library
|
||||
|
||||
var daysInAWeek = 7;
|
||||
var monthsInAYear = 12;
|
||||
|
||||
// Not the number of weeks per month, but the number of weeks that are
|
||||
// shown on a typical calendar.
|
||||
var weeksOnACalendarMonth = 6;
|
||||
|
||||
// Can't create year 1 directly...
|
||||
var minimumCalendarDate = new Date(-1, 0, 1);
|
||||
minimumCalendarDate.setFullYear(minimumCalendarDate.getFullYear() + 2);
|
||||
var maximumCalendarDate = new Date(275759, 9, 25);
|
||||
|
||||
function daysInMonth(date) {
|
||||
// Passing 0 as the day will give us the previous month, which will be
|
||||
// date.getMonth() since we added 1 to it.
|
||||
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a copy of \a date with its month set to \a month, keeping the same
|
||||
day if possible. Does not modify \a date.
|
||||
*/
|
||||
function setMonth(date, month) {
|
||||
var oldDay = date.getDate();
|
||||
var newDate = new Date(date);
|
||||
// Set the day first, because setting the month could cause it to skip ahead
|
||||
// a month if the day is larger than the latest day in that month.
|
||||
newDate.setDate(1);
|
||||
newDate.setMonth(month);
|
||||
// We'd like to have the previous day still selected when we change
|
||||
// months, but it might not be possible, so use the smallest of the two.
|
||||
newDate.setDate(Math.min(oldDay, daysInMonth(newDate)));
|
||||
return newDate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the cell rectangle for the cell at the given \a index, assuming
|
||||
that the grid has a number of columns equal to \a columns and rows
|
||||
equal to \a rows, with an available width of \a availableWidth and height
|
||||
of \a availableHeight.
|
||||
|
||||
If \a gridLineWidth is greater than \c 0, the cell rectangle will be
|
||||
calculated under the assumption that there is a grid between the cells:
|
||||
|
||||
31 | 1 | 2 | 3 | 4 | 5 | 6
|
||||
--------------------------------
|
||||
7 | 8 | 9 | 10 | 11 | 12 | 13
|
||||
--------------------------------
|
||||
14 | 15 | 16 | 17 | 18 | 19 | 20
|
||||
--------------------------------
|
||||
21 | 22 | 23 | 24 | 25 | 26 | 27
|
||||
--------------------------------
|
||||
28 | 29 | 30 | 31 | 1 | 2 | 3
|
||||
--------------------------------
|
||||
4 | 5 | 6 | 7 | 8 | 9 | 10
|
||||
*/
|
||||
function cellRectAt(index, columns, rows, availableWidth, availableHeight, gridLineWidth) {
|
||||
var col = Math.floor(index % columns);
|
||||
var row = Math.floor(index / columns);
|
||||
|
||||
var availableWidthMinusGridLines = availableWidth - ((columns - 1) * gridLineWidth);
|
||||
var availableHeightMinusGridLines = availableHeight - ((rows - 1) * gridLineWidth);
|
||||
var remainingHorizontalSpace = Math.floor(availableWidthMinusGridLines % columns);
|
||||
var remainingVerticalSpace = Math.floor(availableHeightMinusGridLines % rows);
|
||||
var baseCellWidth = Math.floor(availableWidthMinusGridLines / columns);
|
||||
var baseCellHeight = Math.floor(availableHeightMinusGridLines / rows);
|
||||
|
||||
var rect = Qt.rect(0, 0, 0, 0);
|
||||
|
||||
rect.x = baseCellWidth * col;
|
||||
rect.width = baseCellWidth;
|
||||
if (remainingHorizontalSpace > 0) {
|
||||
if (col < remainingHorizontalSpace) {
|
||||
++rect.width;
|
||||
}
|
||||
|
||||
// This cell's x position should be increased by 1 for every column above it.
|
||||
rect.x += Math.min(remainingHorizontalSpace, col);
|
||||
}
|
||||
|
||||
rect.y = baseCellHeight * row;
|
||||
rect.height = baseCellHeight;
|
||||
if (remainingVerticalSpace > 0) {
|
||||
if (row < remainingVerticalSpace) {
|
||||
++rect.height;
|
||||
}
|
||||
|
||||
// This cell's y position should be increased by 1 for every row above it.
|
||||
rect.y += Math.min(remainingVerticalSpace, row);
|
||||
}
|
||||
|
||||
rect.x += col * gridLineWidth;
|
||||
rect.y += row * gridLineWidth;
|
||||
|
||||
return rect;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,250 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
Item {
|
||||
id: content
|
||||
|
||||
property Component menuItemDelegate
|
||||
property Component scrollIndicatorStyle
|
||||
property Component scrollerStyle
|
||||
property var itemsModel
|
||||
property int minWidth: 100
|
||||
property real maxHeight: 800
|
||||
readonly property bool mousePressed: hoverArea.pressed
|
||||
|
||||
signal triggered(var item)
|
||||
|
||||
function menuItemAt(index) {
|
||||
list.currentIndex = index
|
||||
return list.currentItem
|
||||
}
|
||||
|
||||
width: Math.max(list.contentWidth, minWidth)
|
||||
height: Math.min(list.contentHeight, fittedMaxHeight)
|
||||
|
||||
readonly property int currentIndex: __menu.__currentIndex
|
||||
property Item currentItem: null
|
||||
property int itemHeight: 23
|
||||
|
||||
Component.onCompleted: {
|
||||
var children = list.contentItem.children
|
||||
for (var i = 0; i < list.count; i++) {
|
||||
var child = children[i]
|
||||
if (child.visible && child.styleData.type === MenuItemType.Item) {
|
||||
itemHeight = children[i].height
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property int fittingItems: Math.floor((maxHeight - downScroller.height) / itemHeight)
|
||||
readonly property real fittedMaxHeight: itemHeight * fittingItems + downScroller.height
|
||||
readonly property bool shouldUseScrollers: scrollView.style === emptyScrollerStyle && itemsModel.length > fittingItems
|
||||
readonly property real upScrollerHeight: upScroller.visible ? upScroller.height : 0
|
||||
readonly property real downScrollerHeight: downScroller.visible ? downScroller.height : 0
|
||||
property var oldMousePos: undefined
|
||||
property var openedSubmenu: null
|
||||
|
||||
function updateCurrentItem(mouse) {
|
||||
var pos = mapToItem(list.contentItem, mouse.x, mouse.y)
|
||||
var dx = 0
|
||||
var dy = 0
|
||||
var dist = 0
|
||||
if (openedSubmenu && oldMousePos !== undefined) {
|
||||
dx = mouse.x - oldMousePos.x
|
||||
dy = mouse.y - oldMousePos.y
|
||||
dist = Math.sqrt(dx * dx + dy * dy)
|
||||
}
|
||||
oldMousePos = mouse
|
||||
if (openedSubmenu && dist > 5) {
|
||||
var menuRect = __menu.__popupGeometry
|
||||
var submenuRect = openedSubmenu.__popupGeometry
|
||||
var angle = Math.atan2(dy, dx)
|
||||
var ds = 0
|
||||
if (submenuRect.x > menuRect.x) {
|
||||
ds = menuRect.width - oldMousePos.x
|
||||
} else {
|
||||
angle = Math.PI - angle
|
||||
ds = oldMousePos.x
|
||||
}
|
||||
var above = submenuRect.y - menuRect.y - oldMousePos.y
|
||||
var below = submenuRect.height - above
|
||||
var minAngle = Math.atan2(above, ds)
|
||||
var maxAngle = Math.atan2(below, ds)
|
||||
// This tests that the current mouse position is in
|
||||
// the triangle defined by the previous mouse position
|
||||
// and the submenu's top-left and bottom-left corners.
|
||||
if (minAngle < angle && angle < maxAngle) {
|
||||
sloppyTimer.start()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentItem || !currentItem.contains(Qt.point(pos.x - currentItem.x, pos.y - currentItem.y))) {
|
||||
if (currentItem && !hoverArea.pressed
|
||||
&& currentItem.styleData.type === MenuItemType.Menu) {
|
||||
currentItem.__closeSubMenu()
|
||||
openedSubmenu = null
|
||||
}
|
||||
currentItem = list.itemAt(pos.x, pos.y)
|
||||
if (currentItem) {
|
||||
__menu.__currentIndex = currentItem.__menuItemIndex
|
||||
if (currentItem.styleData.type === MenuItemType.Menu) {
|
||||
showCurrentItemSubMenu(false)
|
||||
}
|
||||
} else {
|
||||
__menu.__currentIndex = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showCurrentItemSubMenu(immediately) {
|
||||
if (!currentItem.__menuItem.__popupVisible) {
|
||||
currentItem.__showSubMenu(immediately)
|
||||
openedSubmenu = currentItem.__menuItem
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: sloppyTimer
|
||||
interval: 1000
|
||||
|
||||
// Stop timer as soon as we hover one of the submenu items
|
||||
property int currentIndex: openedSubmenu ? openedSubmenu.__currentIndex : -1
|
||||
onCurrentIndexChanged: if (currentIndex !== -1) stop()
|
||||
|
||||
onTriggered: {
|
||||
if (openedSubmenu && openedSubmenu.__currentIndex === -1)
|
||||
updateCurrentItem(oldMousePos)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: emptyScrollerStyle
|
||||
Style {
|
||||
padding { left: 0; right: 0; top: 0; bottom: 0 }
|
||||
property bool scrollToClickedPosition: false
|
||||
property Component frame: Item { visible: false }
|
||||
property Component corner: Item { visible: false }
|
||||
property Component __scrollbar: Item { visible: false }
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
id: scrollView
|
||||
anchors {
|
||||
fill: parent
|
||||
topMargin: upScrollerHeight
|
||||
bottomMargin: downScrollerHeight
|
||||
}
|
||||
|
||||
style: scrollerStyle || emptyScrollerStyle
|
||||
__wheelAreaScrollSpeed: itemHeight
|
||||
|
||||
ListView {
|
||||
id: list
|
||||
model: itemsModel
|
||||
delegate: menuItemDelegate
|
||||
snapMode: ListView.SnapToItem
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
highlightFollowsCurrentItem: true
|
||||
highlightMoveDuration: 0
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: hoverArea
|
||||
anchors.left: scrollView.left
|
||||
width: scrollView.width - scrollView.__verticalScrollBar.width
|
||||
height: parent.height
|
||||
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
acceptedButtons: Qt.AllButtons
|
||||
|
||||
onPositionChanged: updateCurrentItem({ "x": mouse.x, "y": mouse.y })
|
||||
onPressed: updateCurrentItem({ "x": mouse.x, "y": mouse.y })
|
||||
onReleased: {
|
||||
if (currentItem && currentItem.__menuItem.enabled) {
|
||||
if (currentItem.styleData.type === MenuItemType.Menu) {
|
||||
showCurrentItemSubMenu(true)
|
||||
} else {
|
||||
content.triggered(currentItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
if (currentItem && !currentItem.__menuItem.__popupVisible) {
|
||||
currentItem = null
|
||||
__menu.__currentIndex = -1
|
||||
}
|
||||
}
|
||||
|
||||
MenuContentScroller {
|
||||
id: upScroller
|
||||
direction: Qt.UpArrow
|
||||
visible: shouldUseScrollers && !list.atYBeginning
|
||||
function scrollABit() { list.contentY -= itemHeight }
|
||||
}
|
||||
|
||||
MenuContentScroller {
|
||||
id: downScroller
|
||||
direction: Qt.DownArrow
|
||||
visible: shouldUseScrollers && !list.atYEnd
|
||||
function scrollABit() { list.contentY += itemHeight }
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1
|
||||
running: true
|
||||
repeat: false
|
||||
onTriggered: list.positionViewAtIndex(currentIndex, !scrollView.__style
|
||||
? ListView.Center : ListView.Beginning)
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: scrollView.__verticalScrollBar
|
||||
property: "singleStep"
|
||||
value: itemHeight
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.Layouts 1.1
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
property real minimumWidth: __calcMinimum('Width')
|
||||
property real minimumHeight: __calcMinimum('Height')
|
||||
property real maximumWidth: Number.POSITIVE_INFINITY
|
||||
property real maximumHeight: Number.POSITIVE_INFINITY
|
||||
implicitWidth: __calcImplicitWidth()
|
||||
implicitHeight: __calcImplicitHeight()
|
||||
|
||||
/*! \internal */
|
||||
property Item __layoutItem: contentItem.visibleChildren.length === 1 ? contentItem.visibleChildren[0] : null
|
||||
/*! \internal */
|
||||
property real __marginsWidth: __layoutItem ? __layoutItem.anchors.leftMargin + __layoutItem.anchors.rightMargin : 0
|
||||
/*! \internal */
|
||||
property real __marginsHeight: __layoutItem ? __layoutItem.anchors.topMargin + __layoutItem.anchors.bottomMargin : 0
|
||||
|
||||
/*! \internal */
|
||||
property bool __noMinimumWidthGiven : false
|
||||
/*! \internal */
|
||||
property bool __noMinimumHeightGiven : false
|
||||
/*! \internal */
|
||||
property bool __noImplicitWidthGiven : false
|
||||
/*! \internal */
|
||||
property bool __noImplicitHeightGiven : false
|
||||
|
||||
function __calcImplicitWidth() {
|
||||
if (__layoutItem && __layoutItem.anchors.fill)
|
||||
return __calcImplicit('Width')
|
||||
return contentItem.childrenRect.x + contentItem.childrenRect.width
|
||||
}
|
||||
|
||||
function __calcImplicitHeight() {
|
||||
if (__layoutItem && __layoutItem.anchors.fill)
|
||||
return __calcImplicit('Height')
|
||||
return contentItem.childrenRect.y + contentItem.childrenRect.height
|
||||
}
|
||||
|
||||
function __calcImplicit(hw) {
|
||||
var pref = __layoutItem.Layout['preferred' + hw]
|
||||
if (pref < 0) {
|
||||
pref = __layoutItem['implicit' + hw]
|
||||
}
|
||||
contentItem['__noImplicit' + hw + 'Given'] = (pref === 0 ? true : false)
|
||||
pref += contentItem['__margins' + hw]
|
||||
return pref
|
||||
}
|
||||
|
||||
function __calcMinimum(hw) { // hw is 'Width' or 'Height'
|
||||
return (__layoutItem && __layoutItem.anchors.fill) ? __calcMinMax('minimum', hw) : 0
|
||||
}
|
||||
|
||||
function __calcMaximum(hw) { // hw is 'Width' or 'Height'
|
||||
return (__layoutItem && __layoutItem.anchors.fill) ? __calcMinMax('maximum', hw) : Number.POSITIVE_INFINITY
|
||||
}
|
||||
|
||||
function __calcMinMax(minMaxConstraint, hw) {
|
||||
var attachedPropName = minMaxConstraint + hw
|
||||
var extent = __layoutItem.Layout[attachedPropName]
|
||||
|
||||
if (minMaxConstraint === 'minimum')
|
||||
contentItem['__noMinimum' + hw + 'Given'] = (extent === 0 ? true : false)
|
||||
|
||||
extent += contentItem['__margins' + hw]
|
||||
return extent
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -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 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.Styles 1.1
|
||||
|
||||
/*!
|
||||
\qmltype Control
|
||||
\internal
|
||||
\qmlabstract
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
/*! \qmlproperty Component Control::style
|
||||
|
||||
The style Component for this control.
|
||||
\sa {Qt Quick Controls Styles QML Types}
|
||||
|
||||
*/
|
||||
property Component style
|
||||
|
||||
/*! \internal */
|
||||
property QtObject __style: styleLoader.item
|
||||
|
||||
/*! \internal */
|
||||
property Item __panel: panelLoader.item
|
||||
|
||||
/*! \internal */
|
||||
property var styleHints
|
||||
|
||||
implicitWidth: __panel ? __panel.implicitWidth: 0
|
||||
implicitHeight: __panel ? __panel.implicitHeight: 0
|
||||
baselineOffset: __panel ? __panel.baselineOffset: 0
|
||||
activeFocusOnTab: false
|
||||
|
||||
/*! \internal */
|
||||
property alias __styleData: styleLoader.styleData
|
||||
|
||||
Loader {
|
||||
id: styleLoader
|
||||
sourceComponent: style
|
||||
property Item __control: root
|
||||
property QtObject styleData: null
|
||||
onStatusChanged: {
|
||||
if (status === Loader.Error)
|
||||
console.error("Failed to load Style for", root)
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: panelLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: __style ? __style.panel : null
|
||||
onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
Loader {
|
||||
property Item control
|
||||
property Item input
|
||||
property Item cursorHandle
|
||||
property Item selectionHandle
|
||||
property Flickable flickable
|
||||
property Component defaultMenu: item && item.defaultMenu ? item.defaultMenu : null
|
||||
property QtObject menuInstance: null
|
||||
property MouseArea mouseArea
|
||||
property QtObject style: __style
|
||||
|
||||
Connections {
|
||||
target: control
|
||||
onMenuChanged: {
|
||||
if (menuInstance !== null) {
|
||||
menuInstance.destroy()
|
||||
menuInstance = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getMenuInstance()
|
||||
{
|
||||
// Lazy load menu when first requested
|
||||
if (!menuInstance && control.menu) {
|
||||
menuInstance = control.menu.createObject(input);
|
||||
}
|
||||
return menuInstance;
|
||||
}
|
||||
|
||||
function syncStyle() {
|
||||
if (!style)
|
||||
return;
|
||||
|
||||
if (style.__editMenu)
|
||||
sourceComponent = style.__editMenu;
|
||||
else {
|
||||
// todo: get ios/android/base menus from style as well
|
||||
source = (Qt.resolvedUrl(Qt.platform.os === "ios" ? ""
|
||||
: Qt.platform.os === "android" ? "" : "EditMenu_base.qml"));
|
||||
}
|
||||
}
|
||||
onStyleChanged: syncStyle();
|
||||
Component.onCompleted: syncStyle();
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,173 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
Item {
|
||||
id: editMenuBase
|
||||
anchors.fill: parent
|
||||
|
||||
Component {
|
||||
id: undoAction
|
||||
Action {
|
||||
text: qsTr("&Undo")
|
||||
shortcut: StandardKey.Undo
|
||||
iconName: "edit-undo"
|
||||
enabled: input.canUndo
|
||||
onTriggered: input.undo()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: redoAction
|
||||
Action {
|
||||
text: qsTr("&Redo")
|
||||
shortcut: StandardKey.Redo
|
||||
iconName: "edit-redo"
|
||||
enabled: input.canRedo
|
||||
onTriggered: input.redo()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: cutAction
|
||||
Action {
|
||||
text: qsTr("Cu&t")
|
||||
shortcut: StandardKey.Cut
|
||||
iconName: "edit-cut"
|
||||
enabled: !input.readOnly && selectionStart !== selectionEnd
|
||||
onTriggered: {
|
||||
input.cut();
|
||||
input.select(input.cursorPosition, input.cursorPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: copyAction
|
||||
Action {
|
||||
text: qsTr("&Copy")
|
||||
shortcut: StandardKey.Copy
|
||||
iconName: "edit-copy"
|
||||
enabled: input.selectionStart !== input.selectionEnd
|
||||
onTriggered: {
|
||||
input.copy();
|
||||
input.select(input.cursorPosition, input.cursorPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: pasteAction
|
||||
Action {
|
||||
text: qsTr("&Paste")
|
||||
shortcut: StandardKey.Paste
|
||||
iconName: "edit-paste"
|
||||
enabled: input.canPaste
|
||||
onTriggered: input.paste()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: deleteAction
|
||||
Action {
|
||||
text: qsTr("Delete")
|
||||
shortcut: StandardKey.Delete
|
||||
iconName: "edit-delete"
|
||||
enabled: !input.readOnly && input.selectionStart !== input.selectionEnd
|
||||
onTriggered: input.remove(input.selectionStart, input.selectionEnd)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: clearAction
|
||||
Action {
|
||||
text: qsTr("Clear")
|
||||
shortcut: StandardKey.DeleteCompleteLine
|
||||
iconName: "edit-clear"
|
||||
enabled: !input.readOnly && input.length > 0
|
||||
onTriggered: input.remove(0, input.length)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: selectAllAction
|
||||
Action {
|
||||
text: qsTr("Select All")
|
||||
shortcut: StandardKey.SelectAll
|
||||
enabled: !(input.selectionStart === 0 && input.selectionEnd === input.length)
|
||||
onTriggered: input.selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
property Component defaultMenu: Menu {
|
||||
MenuItem { action: undoAction.createObject(editMenuBase) }
|
||||
MenuItem { action: redoAction.createObject(editMenuBase) }
|
||||
MenuSeparator {}
|
||||
MenuItem { action: cutAction.createObject(editMenuBase) }
|
||||
MenuItem { action: copyAction.createObject(editMenuBase) }
|
||||
MenuItem { action: pasteAction.createObject(editMenuBase) }
|
||||
MenuItem { action: deleteAction.createObject(editMenuBase) }
|
||||
MenuItem { action: clearAction.createObject(editMenuBase) }
|
||||
MenuSeparator {}
|
||||
MenuItem { action: selectAllAction.createObject(editMenuBase) }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: mouseArea
|
||||
|
||||
onClicked: {
|
||||
if (input.selectionStart === input.selectionEnd) {
|
||||
var cursorPos = input.positionAt(mouse.x, mouse.y)
|
||||
input.moveHandles(cursorPos, cursorPos)
|
||||
}
|
||||
|
||||
input.activate()
|
||||
|
||||
if (control.menu) {
|
||||
var menu = getMenuInstance();
|
||||
menu.__dismissAndDestroy();
|
||||
var menuPos = mapToItem(null, mouse.x, mouse.y)
|
||||
menu.__popup(Qt.rect(menuPos.x, menuPos.y, 0, 0), -1, MenuPrivate.EditMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,330 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.4
|
||||
|
||||
Item {
|
||||
id: rootItem
|
||||
property variant source
|
||||
property real spread: 0.0
|
||||
property real blur: 0.0
|
||||
property color color: "white"
|
||||
property bool transparentBorder: false
|
||||
property bool cached: false
|
||||
|
||||
SourceProxy {
|
||||
id: sourceProxy
|
||||
input: rootItem.source
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: cacheItem
|
||||
anchors.fill: shaderItem
|
||||
visible: rootItem.cached
|
||||
smooth: true
|
||||
sourceItem: shaderItem
|
||||
live: true
|
||||
hideSource: visible
|
||||
}
|
||||
|
||||
property string __internalBlurVertexShader: "qrc:/QtQuick/Controls/Shaders/blur.vert"
|
||||
|
||||
property string __internalBlurFragmentShader: "qrc:/QtQuick/Controls/Shaders/blur.frag"
|
||||
|
||||
ShaderEffect {
|
||||
id: level0
|
||||
property variant source: sourceProxy.output
|
||||
anchors.fill: parent
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level1
|
||||
width: Math.ceil(shaderItem.width / 32) * 32
|
||||
height: Math.ceil(shaderItem.height / 32) * 32
|
||||
sourceItem: level0
|
||||
hideSource: rootItem.visible
|
||||
sourceRect: transparentBorder ? Qt.rect(-64, -64, shaderItem.width, shaderItem.height) : Qt.rect(0,0,0,0)
|
||||
smooth: true
|
||||
visible: false
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: effect1
|
||||
property variant source: level1
|
||||
property real yStep: 1/height
|
||||
property real xStep: 1/width
|
||||
anchors.fill: level2
|
||||
visible: false
|
||||
smooth: true
|
||||
vertexShader: __internalBlurVertexShader
|
||||
fragmentShader: __internalBlurFragmentShader
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level2
|
||||
width: level1.width / 2
|
||||
height: level1.height / 2
|
||||
sourceItem: effect1
|
||||
hideSource: rootItem.visible
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: effect2
|
||||
property variant source: level2
|
||||
property real yStep: 1/height
|
||||
property real xStep: 1/width
|
||||
anchors.fill: level3
|
||||
visible: false
|
||||
smooth: true
|
||||
vertexShader: __internalBlurVertexShader
|
||||
fragmentShader: __internalBlurFragmentShader
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level3
|
||||
width: level2.width / 2
|
||||
height: level2.height / 2
|
||||
sourceItem: effect2
|
||||
hideSource: rootItem.visible
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: effect3
|
||||
property variant source: level3
|
||||
property real yStep: 1/height
|
||||
property real xStep: 1/width
|
||||
anchors.fill: level4
|
||||
visible: false
|
||||
smooth: true
|
||||
vertexShader: __internalBlurVertexShader
|
||||
fragmentShader: __internalBlurFragmentShader
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level4
|
||||
width: level3.width / 2
|
||||
height: level3.height / 2
|
||||
sourceItem: effect3
|
||||
hideSource: rootItem.visible
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: effect4
|
||||
property variant source: level4
|
||||
property real yStep: 1/height
|
||||
property real xStep: 1/width
|
||||
anchors.fill: level5
|
||||
visible: false
|
||||
smooth: true
|
||||
vertexShader: __internalBlurVertexShader
|
||||
fragmentShader: __internalBlurFragmentShader
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level5
|
||||
width: level4.width / 2
|
||||
height: level4.height / 2
|
||||
sourceItem: effect4
|
||||
hideSource: rootItem.visible
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: effect5
|
||||
property variant source: level5
|
||||
property real yStep: 1/height
|
||||
property real xStep: 1/width
|
||||
anchors.fill: level6
|
||||
visible: false
|
||||
smooth: true
|
||||
vertexShader: __internalBlurVertexShader
|
||||
fragmentShader: __internalBlurFragmentShader
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: level6
|
||||
width: level5.width / 2
|
||||
height: level5.height / 2
|
||||
sourceItem: effect5
|
||||
hideSource: rootItem.visible
|
||||
visible: false
|
||||
smooth: true
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dummysource
|
||||
width: 1
|
||||
height: 1
|
||||
visible: false
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: dummy
|
||||
width: 1
|
||||
height: 1
|
||||
sourceItem: dummysource
|
||||
visible: false
|
||||
smooth: false
|
||||
live: false
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: shaderItem
|
||||
x: transparentBorder ? -64 : 0
|
||||
y: transparentBorder ? -64 : 0
|
||||
width: transparentBorder ? parent.width + 128 : parent.width
|
||||
height: transparentBorder ? parent.height + 128 : parent.height
|
||||
|
||||
property variant source1: level1
|
||||
property variant source2: level2
|
||||
property variant source3: level3
|
||||
property variant source4: level4
|
||||
property variant source5: level5
|
||||
property variant source6: level6
|
||||
property real lod: rootItem.blur
|
||||
|
||||
property real weight1;
|
||||
property real weight2;
|
||||
property real weight3;
|
||||
property real weight4;
|
||||
property real weight5;
|
||||
property real weight6;
|
||||
|
||||
property real spread: 1.0 - (rootItem.spread * 0.98)
|
||||
property alias color: rootItem.color
|
||||
|
||||
function weight(v) {
|
||||
if (v <= 0.0)
|
||||
return 1
|
||||
if (v >= 0.5)
|
||||
return 0
|
||||
|
||||
return 1.0 - v / 0.5
|
||||
}
|
||||
|
||||
function calculateWeights() {
|
||||
|
||||
var w1 = weight(Math.abs(lod - 0.100))
|
||||
var w2 = weight(Math.abs(lod - 0.300))
|
||||
var w3 = weight(Math.abs(lod - 0.500))
|
||||
var w4 = weight(Math.abs(lod - 0.700))
|
||||
var w5 = weight(Math.abs(lod - 0.900))
|
||||
var w6 = weight(Math.abs(lod - 1.100))
|
||||
|
||||
var sum = w1 + w2 + w3 + w4 + w5 + w6;
|
||||
weight1 = w1 / sum;
|
||||
weight2 = w2 / sum;
|
||||
weight3 = w3 / sum;
|
||||
weight4 = w4 / sum;
|
||||
weight5 = w5 / sum;
|
||||
weight6 = w6 / sum;
|
||||
|
||||
upateSources()
|
||||
}
|
||||
|
||||
function upateSources() {
|
||||
var sources = new Array();
|
||||
var weights = new Array();
|
||||
|
||||
if (weight1 > 0) {
|
||||
sources.push(level1)
|
||||
weights.push(weight1)
|
||||
}
|
||||
|
||||
if (weight2 > 0) {
|
||||
sources.push(level2)
|
||||
weights.push(weight2)
|
||||
}
|
||||
|
||||
if (weight3 > 0) {
|
||||
sources.push(level3)
|
||||
weights.push(weight3)
|
||||
}
|
||||
|
||||
if (weight4 > 0) {
|
||||
sources.push(level4)
|
||||
weights.push(weight4)
|
||||
}
|
||||
|
||||
if (weight5 > 0) {
|
||||
sources.push(level5)
|
||||
weights.push(weight5)
|
||||
}
|
||||
|
||||
if (weight6 > 0) {
|
||||
sources.push(level6)
|
||||
weights.push(weight6)
|
||||
}
|
||||
|
||||
for (var j = sources.length; j < 6; j++) {
|
||||
sources.push(dummy)
|
||||
weights.push(0.0)
|
||||
}
|
||||
|
||||
source1 = sources[0]
|
||||
source2 = sources[1]
|
||||
source3 = sources[2]
|
||||
source4 = sources[3]
|
||||
source5 = sources[4]
|
||||
source6 = sources[5]
|
||||
|
||||
weight1 = weights[0]
|
||||
weight2 = weights[1]
|
||||
weight3 = weights[2]
|
||||
weight4 = weights[3]
|
||||
weight5 = weights[4]
|
||||
weight6 = weights[5]
|
||||
}
|
||||
|
||||
Component.onCompleted: calculateWeights()
|
||||
|
||||
onLodChanged: calculateWeights()
|
||||
|
||||
fragmentShader: "qrc:/QtQuick/Controls/Shaders/glow.frag"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 FocusFrame
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
Item {
|
||||
id: root
|
||||
activeFocusOnTab: false
|
||||
Accessible.role: Accessible.StatusBar
|
||||
|
||||
anchors.topMargin: focusMargin
|
||||
anchors.leftMargin: focusMargin
|
||||
anchors.rightMargin: focusMargin
|
||||
anchors.bottomMargin: focusMargin
|
||||
|
||||
property int focusMargin: loader.item ? loader.item.margin : -3
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
z: 2
|
||||
anchors.fill: parent
|
||||
sourceComponent: Settings.styleComponent(Settings.style, "FocusFrameStyle.qml", root)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
Item {
|
||||
id: button
|
||||
property alias source: image.source
|
||||
signal clicked
|
||||
|
||||
Rectangle {
|
||||
id: fillRect
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
opacity: mouse.pressed ? 0.07 : mouse.containsMouse ? 0.02 : 0.0
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
border.color: gridColor
|
||||
anchors.fill: parent
|
||||
anchors.margins: -1
|
||||
color: "transparent"
|
||||
opacity: fillRect.opacity * 10
|
||||
}
|
||||
|
||||
Image {
|
||||
id: image
|
||||
width: Math.min(implicitWidth, parent.width * 0.4)
|
||||
height: Math.min(implicitHeight, parent.height * 0.4)
|
||||
anchors.centerIn: parent
|
||||
fillMode: Image.PreserveAspectFit
|
||||
opacity: 0.6
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: parent
|
||||
onClicked: button.clicked()
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,279 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.Styles 1.1
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
Loader {
|
||||
id: menuFrameLoader
|
||||
|
||||
property var __menu
|
||||
|
||||
Accessible.role: Accessible.PopupMenu
|
||||
|
||||
visible: status === Loader.Ready
|
||||
width: content.width + (d.style ? d.style.padding.left + d.style.padding.right : 0)
|
||||
height: content.height + (d.style ? d.style.padding.top + d.style.padding.bottom : 0)
|
||||
|
||||
Loader {
|
||||
id: styleLoader
|
||||
active: !__menu.isNative
|
||||
sourceComponent: __menu.style
|
||||
property alias __control: menuFrameLoader
|
||||
onStatusChanged: {
|
||||
if (status === Loader.Error)
|
||||
console.error("Failed to load Style for", __menu)
|
||||
}
|
||||
}
|
||||
sourceComponent: d.style ? d.style.frame : undefined
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
property var mnemonicsMap: ({})
|
||||
readonly property Style style: styleLoader.item
|
||||
readonly property Component menuItemPanel: style ? style.menuItemPanel : null
|
||||
|
||||
function canBeHovered(index) {
|
||||
var item = content.menuItemAt(index)
|
||||
if (item && item.visible && item.styleData.type !== MenuItemType.Separator && item.styleData.enabled) {
|
||||
__menu.__currentIndex = index
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function triggerCurrent() {
|
||||
var item = content.menuItemAt(__menu.__currentIndex)
|
||||
if (item)
|
||||
triggerAndDismiss(item)
|
||||
}
|
||||
|
||||
function triggerAndDismiss(item) {
|
||||
if (!item)
|
||||
return;
|
||||
if (item.styleData.type === MenuItemType.Separator)
|
||||
__menu.__dismissAndDestroy()
|
||||
else if (item.styleData.type === MenuItemType.Item)
|
||||
item.__menuItem.trigger()
|
||||
}
|
||||
}
|
||||
|
||||
focus: true
|
||||
|
||||
Keys.onPressed: {
|
||||
var item = null
|
||||
if (!(event.modifiers & Qt.AltModifier)
|
||||
&& (item = d.mnemonicsMap[event.text.toUpperCase()])) {
|
||||
if (item.styleData.type === MenuItemType.Menu) {
|
||||
__menu.__currentIndex = item.__menuItemIndex
|
||||
item.__showSubMenu(true)
|
||||
item.__menuItem.__currentIndex = 0
|
||||
} else {
|
||||
d.triggerAndDismiss(item)
|
||||
}
|
||||
event.accepted = true
|
||||
} else {
|
||||
event.accepted = false
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: __menu.__dismissAndDestroy()
|
||||
|
||||
Keys.onDownPressed: {
|
||||
if (__menu.__currentIndex < 0)
|
||||
__menu.__currentIndex = -1
|
||||
|
||||
for (var i = __menu.__currentIndex + 1;
|
||||
i < __menu.items.length && !d.canBeHovered(i); i++)
|
||||
;
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
Keys.onUpPressed: {
|
||||
for (var i = __menu.__currentIndex - 1;
|
||||
i >= 0 && !d.canBeHovered(i); i--)
|
||||
;
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
Keys.onLeftPressed: {
|
||||
if ((event.accepted = __menu.__parentMenu.hasOwnProperty("title")))
|
||||
__menu.__closeAndDestroy()
|
||||
}
|
||||
|
||||
Keys.onRightPressed: {
|
||||
var item = content.menuItemAt(__menu.__currentIndex)
|
||||
if (item && item.styleData.type === MenuItemType.Menu
|
||||
&& !item.__menuItem.__popupVisible) {
|
||||
item.__showSubMenu(true)
|
||||
item.__menuItem.__currentIndex = 0
|
||||
event.accepted = true
|
||||
} else {
|
||||
event.accepted = false
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onSpacePressed: d.triggerCurrent()
|
||||
Keys.onReturnPressed: d.triggerCurrent()
|
||||
Keys.onEnterPressed: d.triggerCurrent()
|
||||
|
||||
Binding {
|
||||
// Make sure the styled frame is in the background
|
||||
target: item
|
||||
property: "z"
|
||||
value: content.z - 1
|
||||
}
|
||||
|
||||
ColumnMenuContent {
|
||||
id: content
|
||||
x: d.style ? d.style.padding.left : 0
|
||||
y: d.style ? d.style.padding.top : 0
|
||||
menuItemDelegate: menuItemComponent
|
||||
scrollIndicatorStyle: d.style && d.style.scrollIndicator || null
|
||||
scrollerStyle: d.style && d.style.__scrollerStyle
|
||||
itemsModel: __menu.items
|
||||
minWidth: __menu.__minimumWidth
|
||||
maxHeight: d.style ? d.style.__maxPopupHeight : 0
|
||||
onTriggered: d.triggerAndDismiss(item)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: menuItemComponent
|
||||
Loader {
|
||||
id: menuItemLoader
|
||||
|
||||
Accessible.role: opts.type === MenuItemType.Item || opts.type === MenuItemType.Menu ?
|
||||
Accessible.MenuItem : Accessible.NoRole
|
||||
Accessible.name: StyleHelpers.removeMnemonics(opts.text)
|
||||
Accessible.checkable: opts.checkable
|
||||
Accessible.checked: opts.checked
|
||||
Accessible.onPressAction: {
|
||||
if (opts.type === MenuItemType.Item) {
|
||||
d.triggerAndDismiss(menuItemLoader)
|
||||
} else if (opts.type === MenuItemType.Menu) {
|
||||
__showSubMenu(true /*immediately*/)
|
||||
}
|
||||
}
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
id: opts
|
||||
readonly property int index: __menuItemIndex
|
||||
readonly property int type: __menuItem ? __menuItem.type : -1
|
||||
readonly property bool selected: type !== MenuItemType.Separator && __menu.__currentIndex === index
|
||||
readonly property bool pressed: type !== MenuItemType.Separator && __menu.__currentIndex === index
|
||||
&& content.mousePressed // TODO Add key pressed condition once we get delayed menu closing
|
||||
readonly property string text: type === MenuItemType.Menu ? __menuItem.title :
|
||||
type !== MenuItemType.Separator ? __menuItem.text : ""
|
||||
readonly property bool underlineMnemonic: __menu.__contentItem.altPressed
|
||||
readonly property string shortcut: !!__menuItem && __menuItem["shortcut"] || ""
|
||||
readonly property var iconSource: !!__menuItem && __menuItem["iconSource"] || undefined
|
||||
readonly property bool enabled: type !== MenuItemType.Separator && !!__menuItem && __menuItem.enabled
|
||||
readonly property bool checked: !!__menuItem && !!__menuItem["checked"]
|
||||
readonly property bool checkable: !!__menuItem && !!__menuItem["checkable"]
|
||||
readonly property bool exclusive: !!__menuItem && !!__menuItem["exclusiveGroup"]
|
||||
readonly property int scrollerDirection: Qt.NoArrow
|
||||
}
|
||||
|
||||
readonly property var __menuItem: modelData
|
||||
readonly property int __menuItemIndex: index
|
||||
|
||||
sourceComponent: d.menuItemPanel
|
||||
enabled: visible && opts.enabled
|
||||
visible: !!__menuItem && __menuItem.visible
|
||||
active: visible
|
||||
|
||||
function __showSubMenu(immediately) {
|
||||
if (!__menuItem.enabled)
|
||||
return;
|
||||
if (immediately) {
|
||||
if (__menu.__currentIndex === __menuItemIndex) {
|
||||
if (__menuItem.__usingDefaultStyle)
|
||||
__menuItem.style = __menu.style
|
||||
__menuItem.__popup(Qt.rect(menuFrameLoader.width - (d.style.submenuOverlap + d.style.padding.right), -d.style.padding.top, 0, 0), -1)
|
||||
}
|
||||
} else {
|
||||
openMenuTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: openMenuTimer
|
||||
interval: d.style.submenuPopupDelay
|
||||
onTriggered: menuItemLoader.__showSubMenu(true)
|
||||
}
|
||||
|
||||
function __closeSubMenu() {
|
||||
if (openMenuTimer.running)
|
||||
openMenuTimer.stop()
|
||||
else if (__menuItem.__popupVisible)
|
||||
closeMenuTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: closeMenuTimer
|
||||
interval: 1
|
||||
onTriggered: {
|
||||
if (__menu.__currentIndex !== __menuItemIndex)
|
||||
__menuItem.__closeAndDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
__menuItem.__visualItem = menuItemLoader
|
||||
|
||||
if (content.width < item.implicitWidth)
|
||||
content.width = item.implicitWidth
|
||||
|
||||
var title = opts.text
|
||||
var ampersandPos = title.indexOf("&")
|
||||
if (ampersandPos !== -1)
|
||||
d.mnemonicsMap[title[ampersandPos + 1].toUpperCase()] = menuItemLoader
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: menuItemLoader.item
|
||||
property: "width"
|
||||
property alias menuItem: menuItemLoader.item
|
||||
value: menuItem ? Math.max(__menu.__minimumWidth, content.width) - 2 * menuItem.x : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
MouseArea {
|
||||
id: scrollIndicator
|
||||
property int direction: 0
|
||||
|
||||
anchors {
|
||||
top: direction === Qt.UpArrow ? parent.top : undefined
|
||||
bottom: direction === Qt.DownArrow ? parent.bottom : undefined
|
||||
}
|
||||
|
||||
hoverEnabled: visible && Settings.hoverEnabled
|
||||
height: scrollerLoader.height
|
||||
width: parent.width
|
||||
|
||||
Loader {
|
||||
id: scrollerLoader
|
||||
|
||||
width: parent.width
|
||||
sourceComponent: scrollIndicatorStyle
|
||||
// Extra property values for desktop style
|
||||
property var __menuItem: null
|
||||
property var styleData: {
|
||||
"index": -1,
|
||||
"type": MenuItemType.ScrollIndicator,
|
||||
"text": "",
|
||||
"selected": scrollIndicator.containsMouse,
|
||||
"scrollerDirection": scrollIndicator.direction,
|
||||
"checkable": false,
|
||||
"checked": false,
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 100
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
running: parent.containsMouse
|
||||
onTriggered: scrollABit()
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
QtObject {
|
||||
property Component background: null
|
||||
property Component label: null
|
||||
property Component submenuIndicator: null
|
||||
property Component shortcut: null
|
||||
property Component checkmarkIndicator: null
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,134 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
// KNOWN ISSUES
|
||||
// none
|
||||
|
||||
/*!
|
||||
\qmltype ModalPopupBehavior
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
Item {
|
||||
id: popupBehavior
|
||||
|
||||
property bool showing: false
|
||||
property bool whenAlso: true // modifier to the "showing" property
|
||||
property bool consumeCancelClick: true
|
||||
property int delay: 0 // delay before popout becomes visible
|
||||
property int deallocationDelay: 3000 // 3 seconds
|
||||
|
||||
property Component popupComponent
|
||||
|
||||
property alias popup: popupLoader.item // read-only
|
||||
property alias window: popupBehavior.root // read-only
|
||||
|
||||
signal prepareToShow
|
||||
signal prepareToHide
|
||||
signal cancelledByClick
|
||||
|
||||
// implementation
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
onShowingChanged: notifyChange()
|
||||
onWhenAlsoChanged: notifyChange()
|
||||
function notifyChange() {
|
||||
if(showing && whenAlso) {
|
||||
if(popupLoader.sourceComponent == undefined) {
|
||||
popupLoader.sourceComponent = popupComponent;
|
||||
}
|
||||
} else {
|
||||
mouseArea.enabled = false; // disable before opacity is changed in case it has fading behavior
|
||||
if(Qt.isQtObject(popupLoader.item)) {
|
||||
popupBehavior.prepareToHide();
|
||||
popupLoader.item.opacity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Item root: findRoot()
|
||||
function findRoot() {
|
||||
var p = parent;
|
||||
while(p.parent != undefined)
|
||||
p = p.parent;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
enabled: false // enabled only when popout is showing
|
||||
onPressed: {
|
||||
popupBehavior.showing = false;
|
||||
mouse.accepted = consumeCancelClick;
|
||||
cancelledByClick();
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: popupLoader
|
||||
}
|
||||
|
||||
Timer { // visibility timer
|
||||
running: Qt.isQtObject(popupLoader.item) && showing && whenAlso
|
||||
interval: delay
|
||||
onTriggered: {
|
||||
popupBehavior.prepareToShow();
|
||||
mouseArea.enabled = true;
|
||||
popup.opacity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Timer { // deallocation timer
|
||||
running: Qt.isQtObject(popupLoader.item) && popupLoader.item.opacity == 0
|
||||
interval: deallocationDelay
|
||||
onTriggered: popupLoader.sourceComponent = undefined
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "active"
|
||||
when: Qt.isQtObject(popupLoader.item) && popupLoader.item.opacity > 0
|
||||
ParentChange { target: popupBehavior; parent: root }
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,237 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ScrollBar
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
Item {
|
||||
id: scrollbar
|
||||
|
||||
property bool isTransient: false
|
||||
property bool active: false
|
||||
property int orientation: Qt.Horizontal
|
||||
property alias minimumValue: slider.minimumValue
|
||||
property alias maximumValue: slider.maximumValue
|
||||
property alias value: slider.value
|
||||
property int singleStep: 20
|
||||
|
||||
activeFocusOnTab: false
|
||||
|
||||
Accessible.role: Accessible.ScrollBar
|
||||
implicitWidth: panelLoader.implicitWidth
|
||||
implicitHeight: panelLoader.implicitHeight
|
||||
|
||||
property bool upPressed
|
||||
property bool downPressed
|
||||
property bool pageUpPressed
|
||||
property bool pageDownPressed
|
||||
property bool handlePressed
|
||||
|
||||
|
||||
property Item __panel: panelLoader.item
|
||||
Loader {
|
||||
id: panelLoader
|
||||
anchors.fill: parent
|
||||
sourceComponent: __style ? __style.__scrollbar : null
|
||||
onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
|
||||
property alias __control: scrollbar
|
||||
property QtObject __styleData: QtObject {
|
||||
readonly property alias horizontal: internal.horizontal
|
||||
readonly property alias upPressed: scrollbar.upPressed
|
||||
readonly property alias downPressed: scrollbar.downPressed
|
||||
readonly property alias handlePressed: scrollbar.handlePressed
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: internal
|
||||
property bool horizontal: orientation === Qt.Horizontal
|
||||
property int pageStep: internal.horizontal ? width : height
|
||||
property bool scrollToClickposition: internal.scrollToClickPosition
|
||||
anchors.fill: parent
|
||||
cursorShape: __panel && __panel.visible ? Qt.ArrowCursor : Qt.IBeamCursor // forces a cursor change
|
||||
|
||||
property bool autoincrement: false
|
||||
property bool scrollToClickPosition: __style ? __style.scrollToClickedPosition : 0
|
||||
|
||||
// Update hover item
|
||||
onEntered: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY)
|
||||
onExited: if (!pressed) __panel.activeControl = "none"
|
||||
onMouseXChanged: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY)
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
preventStealing: true
|
||||
property var pressedX
|
||||
property var pressedY
|
||||
property int oldPosition
|
||||
property int grooveSize
|
||||
|
||||
Timer {
|
||||
running: upPressed || downPressed || pageUpPressed || pageDownPressed
|
||||
interval: 350
|
||||
onTriggered: internal.autoincrement = true
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: internal.autoincrement
|
||||
interval: 60
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (upPressed && internal.containsMouse)
|
||||
internal.decrement();
|
||||
else if (downPressed && internal.containsMouse)
|
||||
internal.increment();
|
||||
else if (pageUpPressed)
|
||||
internal.decrementPage();
|
||||
else if (pageDownPressed)
|
||||
internal.incrementPage();
|
||||
}
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
if (handlePressed) {
|
||||
if (!horizontal)
|
||||
slider.position = oldPosition + (mouseY - pressedY)
|
||||
else
|
||||
slider.position = oldPosition + (mouseX - pressedX)
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
if (mouse.source !== Qt.MouseEventNotSynthesized) {
|
||||
mouse.accepted = false
|
||||
return
|
||||
}
|
||||
__panel.activeControl = __panel.hitTest(mouseX, mouseY)
|
||||
scrollToClickposition = scrollToClickPosition
|
||||
var handleRect = __panel.subControlRect("handle")
|
||||
var grooveRect = __panel.subControlRect("groove")
|
||||
grooveSize = horizontal ? grooveRect.width - handleRect.width:
|
||||
grooveRect.height - handleRect.height;
|
||||
if (__panel.activeControl === "handle") {
|
||||
pressedX = mouseX;
|
||||
pressedY = mouseY;
|
||||
handlePressed = true;
|
||||
oldPosition = slider.position;
|
||||
} else if (__panel.activeControl === "up") {
|
||||
decrement();
|
||||
upPressed = Qt.binding(function() {return containsMouse});
|
||||
} else if (__panel.activeControl === "down") {
|
||||
increment();
|
||||
downPressed = Qt.binding(function() {return containsMouse});
|
||||
} else if (!scrollToClickposition){
|
||||
if (__panel.activeControl === "upPage") {
|
||||
decrementPage();
|
||||
pageUpPressed = true;
|
||||
} else if (__panel.activeControl === "downPage") {
|
||||
incrementPage();
|
||||
pageDownPressed = true;
|
||||
}
|
||||
} else { // scroll to click position
|
||||
slider.position = horizontal ? mouseX - handleRect.width/2 - grooveRect.x
|
||||
: mouseY - handleRect.height/2 - grooveRect.y
|
||||
pressedX = mouseX;
|
||||
pressedY = mouseY;
|
||||
handlePressed = true;
|
||||
oldPosition = slider.position;
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
__panel.activeControl = __panel.hitTest(mouseX, mouseY);
|
||||
autoincrement = false;
|
||||
upPressed = false;
|
||||
downPressed = false;
|
||||
handlePressed = false;
|
||||
pageUpPressed = false;
|
||||
pageDownPressed = false;
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
var stepCount = -(wheel.angleDelta.x ? wheel.angleDelta.x : wheel.angleDelta.y) / 120
|
||||
if (stepCount != 0) {
|
||||
if (wheel.modifiers & Qt.ControlModifier || wheel.modifiers & Qt.ShiftModifier)
|
||||
incrementPage(stepCount)
|
||||
else
|
||||
increment(stepCount)
|
||||
}
|
||||
}
|
||||
|
||||
function incrementPage(stepCount) {
|
||||
value = boundValue(value + getSteps(pageStep, stepCount))
|
||||
}
|
||||
|
||||
function decrementPage(stepCount) {
|
||||
value = boundValue(value - getSteps(pageStep, stepCount))
|
||||
}
|
||||
|
||||
function increment(stepCount) {
|
||||
value = boundValue(value + getSteps(singleStep, stepCount))
|
||||
}
|
||||
|
||||
function decrement(stepCount) {
|
||||
value = boundValue(value - getSteps(singleStep, stepCount))
|
||||
}
|
||||
|
||||
function boundValue(val) {
|
||||
return Math.min(Math.max(val, minimumValue), maximumValue)
|
||||
}
|
||||
|
||||
function getSteps(step, count) {
|
||||
if (count)
|
||||
step *= count
|
||||
return step
|
||||
}
|
||||
|
||||
RangeModel {
|
||||
id: slider
|
||||
minimumValue: 0.0
|
||||
maximumValue: 1.0
|
||||
value: 0
|
||||
stepSize: 0.0
|
||||
inverted: false
|
||||
positionAtMaximum: internal.grooveSize
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,229 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ScrollViewHeader
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
Item {
|
||||
id: scrollHelper
|
||||
|
||||
property alias horizontalScrollBar: hscrollbar
|
||||
property alias verticalScrollBar: vscrollbar
|
||||
property bool blockUpdates: false
|
||||
property int availableHeight
|
||||
property int availableWidth
|
||||
property int contentHeight
|
||||
property int contentWidth
|
||||
property bool active
|
||||
property int horizontalScrollBarPolicy: Qt.ScrollBarAsNeeded
|
||||
property int verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
|
||||
|
||||
|
||||
property int leftMargin: outerFrame && root.__style ? root.__style.padding.left : 0
|
||||
property int rightMargin: outerFrame && root.__style ? root.__style.padding.right : 0
|
||||
property int topMargin: outerFrame && root.__style ? root.__style.padding.top : 0
|
||||
property int bottomMargin: outerFrame && root.__style ? root.__style.padding.bottom : 0
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
Timer {
|
||||
id: layoutTimer
|
||||
interval: 0;
|
||||
onTriggered: {
|
||||
blockUpdates = true;
|
||||
scrollHelper.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
|
||||
scrollHelper.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
|
||||
scrollHelper.availableWidth = viewport.width
|
||||
scrollHelper.availableHeight = viewport.height
|
||||
blockUpdates = false;
|
||||
hscrollbar.valueChanged();
|
||||
vscrollbar.valueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: viewport
|
||||
onWidthChanged: layoutTimer.running = true
|
||||
onHeightChanged: layoutTimer.running = true
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: flickableItem
|
||||
onContentWidthChanged: layoutTimer.running = true
|
||||
onContentHeightChanged: layoutTimer.running = true
|
||||
onContentXChanged: {
|
||||
hscrollbar.flash()
|
||||
vscrollbar.flash()
|
||||
}
|
||||
onContentYChanged: {
|
||||
hscrollbar.flash()
|
||||
vscrollbar.flash()
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: cornerFill
|
||||
z: 1
|
||||
sourceComponent: __style ? __style.corner : null
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: bottomMargin
|
||||
anchors.rightMargin: rightMargin
|
||||
width: visible ? vscrollbar.width : 0
|
||||
height: visible ? hscrollbar.height : 0
|
||||
visible: hscrollbar.visible && !hscrollbar.isTransient && vscrollbar.visible && !vscrollbar.isTransient
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
id: hscrollbar
|
||||
readonly property int scrollAmount: contentWidth - availableWidth
|
||||
readonly property bool scrollable: scrollAmount > 0
|
||||
isTransient: !!__panel && !!__panel.isTransient
|
||||
active: !!__panel && (__panel.sunken || __panel.activeControl !== "none")
|
||||
enabled: !isTransient || __panel.visible
|
||||
orientation: Qt.Horizontal
|
||||
visible: horizontalScrollBarPolicy == Qt.ScrollBarAsNeeded ? scrollable : horizontalScrollBarPolicy == Qt.ScrollBarAlwaysOn
|
||||
height: visible ? implicitHeight : 0
|
||||
z: 1
|
||||
maximumValue: scrollable ? scrollAmount : 0
|
||||
minimumValue: 0
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: cornerFill.left
|
||||
anchors.leftMargin: leftMargin
|
||||
anchors.bottomMargin: bottomMargin
|
||||
onScrollAmountChanged: {
|
||||
var scrollableAmount = scrollable ? scrollAmount : 0
|
||||
if (flickableItem && (flickableItem.atXBeginning || flickableItem.atXEnd)) {
|
||||
value = Math.min(scrollableAmount, flickableItem.contentX - flickableItem.originX);
|
||||
} else if (value > scrollableAmount) {
|
||||
value = scrollableAmount;
|
||||
}
|
||||
}
|
||||
onValueChanged: {
|
||||
if (!blockUpdates) {
|
||||
flickableItem.contentX = value + flickableItem.originX
|
||||
}
|
||||
}
|
||||
Binding {
|
||||
target: hscrollbar.__panel
|
||||
property: "raised"
|
||||
value: vscrollbar.active || scrollHelper.active
|
||||
when: hscrollbar.isTransient
|
||||
}
|
||||
Binding {
|
||||
target: hscrollbar.__panel
|
||||
property: "visible"
|
||||
value: true
|
||||
when: !hscrollbar.isTransient || scrollHelper.active
|
||||
}
|
||||
function flash() {
|
||||
if (hscrollbar.isTransient) {
|
||||
hscrollbar.__panel.on = true
|
||||
hscrollbar.__panel.visible = true
|
||||
hFlasher.start()
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: hFlasher
|
||||
interval: 10
|
||||
onTriggered: hscrollbar.__panel.on = false
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
id: vscrollbar
|
||||
readonly property int scrollAmount: contentHeight - availableHeight
|
||||
readonly property bool scrollable: scrollAmount > 0
|
||||
isTransient: !!__panel && !!__panel.isTransient
|
||||
active: !!__panel && (__panel.sunken || __panel.activeControl !== "none")
|
||||
enabled: !isTransient || __panel.visible
|
||||
orientation: Qt.Vertical
|
||||
visible: verticalScrollBarPolicy === Qt.ScrollBarAsNeeded ? scrollable : verticalScrollBarPolicy === Qt.ScrollBarAlwaysOn
|
||||
width: visible ? implicitWidth : 0
|
||||
z: 1
|
||||
anchors.bottom: cornerFill.top
|
||||
maximumValue: scrollable ? scrollAmount + __viewTopMargin : 0
|
||||
minimumValue: 0
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: __scrollBarTopMargin + topMargin
|
||||
anchors.rightMargin: rightMargin
|
||||
onScrollAmountChanged: {
|
||||
if (flickableItem && (flickableItem.atYBeginning || flickableItem.atYEnd)) {
|
||||
value = flickableItem.contentY - flickableItem.originY
|
||||
}
|
||||
}
|
||||
onValueChanged: {
|
||||
if (flickableItem && !blockUpdates && enabled) {
|
||||
flickableItem.contentY = value + flickableItem.originY
|
||||
}
|
||||
}
|
||||
Binding {
|
||||
target: vscrollbar.__panel
|
||||
property: "raised"
|
||||
value: hscrollbar.active || scrollHelper.active
|
||||
when: vscrollbar.isTransient
|
||||
}
|
||||
Binding {
|
||||
target: vscrollbar.__panel
|
||||
property: "visible"
|
||||
value: true
|
||||
when: !vscrollbar.isTransient || scrollHelper.active
|
||||
}
|
||||
function flash() {
|
||||
if (vscrollbar.isTransient) {
|
||||
vscrollbar.__panel.on = true
|
||||
vscrollbar.__panel.visible = true
|
||||
vFlasher.start()
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
id: vFlasher
|
||||
interval: 10
|
||||
onTriggered: vscrollbar.__panel.on = false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
Item {
|
||||
id: rootItem
|
||||
property variant input
|
||||
property variant output
|
||||
property variant sourceRect
|
||||
visible: false
|
||||
|
||||
Component.onCompleted: evaluateInput()
|
||||
|
||||
onInputChanged: evaluateInput()
|
||||
|
||||
onSourceRectChanged: evaluateInput()
|
||||
|
||||
function evaluateInput() {
|
||||
if (input == undefined) {
|
||||
output = input
|
||||
}
|
||||
else if (sourceRect != undefined && sourceRect != Qt.rect(0, 0, 0, 0) && !isQQuickShaderEffectSource(input)) {
|
||||
proxySource.sourceItem = input
|
||||
output = proxySource
|
||||
proxySource.sourceRect = sourceRect
|
||||
}
|
||||
else if (isQQuickItemLayerEnabled(input)) {
|
||||
output = input
|
||||
}
|
||||
else if ((isQQuickImage(input) && !hasTileMode(input) && !hasChildren(input))) {
|
||||
output = input
|
||||
}
|
||||
else if (isQQuickShaderEffectSource(input)) {
|
||||
output = input
|
||||
}
|
||||
else {
|
||||
proxySource.sourceItem = input
|
||||
output = proxySource
|
||||
proxySource.sourceRect = Qt.rect(0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
function isQQuickItemLayerEnabled(item) {
|
||||
if (item.hasOwnProperty("layer")) {
|
||||
var l = item["layer"]
|
||||
if (l.hasOwnProperty("enabled") && l["enabled"].toString() == "true")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function isQQuickImage(item) {
|
||||
var imageProperties = [ "fillMode", "progress", "asynchronous", "sourceSize", "status", "smooth" ]
|
||||
return hasProperties(item, imageProperties)
|
||||
}
|
||||
|
||||
function isQQuickShaderEffectSource(item) {
|
||||
var shaderEffectSourceProperties = [ "hideSource", "format", "sourceItem", "mipmap", "wrapMode", "live", "recursive", "sourceRect" ]
|
||||
return hasProperties(item, shaderEffectSourceProperties)
|
||||
}
|
||||
|
||||
function hasProperties(item, properties) {
|
||||
var counter = 0
|
||||
for (var j = 0; j < properties.length; j++) {
|
||||
if (item.hasOwnProperty(properties [j]))
|
||||
counter++
|
||||
}
|
||||
return properties.length == counter
|
||||
}
|
||||
|
||||
function hasChildren(item) {
|
||||
if (item.hasOwnProperty("childrenRect")) {
|
||||
if (item["childrenRect"].toString() != "QRectF(0, 0, 0, 0)")
|
||||
return true
|
||||
else
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function hasTileMode(item) {
|
||||
if (item.hasOwnProperty("fillMode")) {
|
||||
if (item["fillMode"].toString() != "0")
|
||||
return true
|
||||
else
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: proxySource
|
||||
live: rootItem.input != rootItem.output
|
||||
hideSource: false
|
||||
smooth: true
|
||||
visible: false
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
var stackView = [];
|
||||
|
||||
function push(p)
|
||||
{
|
||||
if (!p)
|
||||
return
|
||||
stackView.push(p)
|
||||
__depth++
|
||||
return p
|
||||
}
|
||||
|
||||
function pop()
|
||||
{
|
||||
if (stackView.length === 0)
|
||||
return null
|
||||
var p = stackView.pop()
|
||||
__depth--
|
||||
return p
|
||||
}
|
||||
|
||||
function current()
|
||||
{
|
||||
if (stackView.length === 0)
|
||||
return null
|
||||
return stackView[stackView.length-1]
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,141 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
/*!
|
||||
\qmltype StackViewSlideTransition
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
StackViewDelegate {
|
||||
id: root
|
||||
|
||||
property bool horizontal: true
|
||||
|
||||
function getTransition(properties)
|
||||
{
|
||||
return root[horizontal ? "horizontalSlide" : "verticalSlide"][properties.name]
|
||||
}
|
||||
|
||||
function transitionFinished(properties)
|
||||
{
|
||||
properties.exitItem.x = 0
|
||||
properties.exitItem.y = 0
|
||||
}
|
||||
|
||||
property QtObject horizontalSlide: QtObject {
|
||||
property Component pushTransition: StackViewTransition {
|
||||
PropertyAnimation {
|
||||
target: enterItem
|
||||
property: "x"
|
||||
from: target.width
|
||||
to: 0
|
||||
duration: 400
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: exitItem
|
||||
property: "x"
|
||||
from: 0
|
||||
to: -target.width
|
||||
duration: 400
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
property Component popTransition: StackViewTransition {
|
||||
PropertyAnimation {
|
||||
target: enterItem
|
||||
property: "x"
|
||||
from: -target.width
|
||||
to: 0
|
||||
duration: 400
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: exitItem
|
||||
property: "x"
|
||||
from: 0
|
||||
to: target.width
|
||||
duration: 400
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
property Component replaceTransition: pushTransition
|
||||
}
|
||||
|
||||
property QtObject verticalSlide: QtObject {
|
||||
property Component pushTransition: StackViewTransition {
|
||||
PropertyAnimation {
|
||||
target: enterItem
|
||||
property: "y"
|
||||
from: target.height
|
||||
to: 0
|
||||
duration: 300
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: exitItem
|
||||
property: "y"
|
||||
from: 0
|
||||
to: -target.height
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
|
||||
property Component popTransition: StackViewTransition {
|
||||
PropertyAnimation {
|
||||
target: enterItem
|
||||
property: "y"
|
||||
from: -target.height
|
||||
to: 0
|
||||
duration: 300
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: exitItem
|
||||
property: "y"
|
||||
from: 0
|
||||
to: target.height
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
property Component replaceTransition: pushTransition
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 Style
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
|
||||
AbstractStyle {
|
||||
/*! The control this style is attached to. */
|
||||
readonly property Item control: __control
|
||||
}
|
||||
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/Style.qmlc
Normal file
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/Style.qmlc
Normal file
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
pragma Singleton
|
||||
import QtQuick 2.2
|
||||
|
||||
QtObject {
|
||||
property SystemPalette active: SystemPalette { colorGroup: SystemPalette.Active }
|
||||
property SystemPalette disabled: SystemPalette { colorGroup: SystemPalette.Disabled }
|
||||
|
||||
function alternateBase(enabled) { return enabled ? active.alternateBase : disabled.alternateBase }
|
||||
function base(enabled) { return enabled ? active.base : disabled.base }
|
||||
function button(enabled) { return enabled ? active.button : disabled.button }
|
||||
function buttonText(enabled) { return enabled ? active.buttonText : disabled.buttonText }
|
||||
function dark(enabled) { return enabled ? active.dark : disabled.dark }
|
||||
function highlight(enabled) { return enabled ? active.highlight : disabled.highlight }
|
||||
function highlightedText(enabled) { return enabled ? active.highlightedText : disabled.highlightedText }
|
||||
function light(enabled) { return enabled ? active.light : disabled.light }
|
||||
function mid(enabled) { return enabled ? active.mid : disabled.mid }
|
||||
function midlight(enabled) { return enabled ? active.midlight : disabled.midlight }
|
||||
function shadow(enabled) { return enabled ? active.shadow : disabled.shadow }
|
||||
function text(enabled) { return enabled ? active.text : disabled.text }
|
||||
function window(enabled) { return enabled ? active.window : disabled.window }
|
||||
function windowText(enabled) { return enabled ? active.windowText : disabled.windowText }
|
||||
}
|
||||
Binary file not shown.
329
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/TabBar.qml
Normal file
329
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/TabBar.qml
Normal file
@@ -0,0 +1,329 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 TabBar
|
||||
\internal
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
FocusScope {
|
||||
id: tabbar
|
||||
height: Math.max(tabrow.height, Math.max(leftCorner.height, rightCorner.height))
|
||||
width: tabView.width
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
Keys.onRightPressed: {
|
||||
if (tabView && tabView.currentIndex < tabView.count - 1)
|
||||
tabView.currentIndex = tabView.currentIndex + 1
|
||||
}
|
||||
Keys.onLeftPressed: {
|
||||
if (tabView && tabView.currentIndex > 0)
|
||||
tabView.currentIndex = tabView.currentIndex - 1
|
||||
}
|
||||
|
||||
onTabViewChanged: parent = tabView
|
||||
visible: tabView ? tabView.tabsVisible : true
|
||||
|
||||
property var tabView
|
||||
property var style
|
||||
property var styleItem: tabView.__styleItem ? tabView.__styleItem : null
|
||||
|
||||
property bool tabsMovable: styleItem ? styleItem.tabsMovable : false
|
||||
|
||||
property int tabsAlignment: styleItem ? styleItem.tabsAlignment : Qt.AlignLeft
|
||||
|
||||
property int tabOverlap: styleItem ? styleItem.tabOverlap : 0
|
||||
|
||||
property int elide: Text.ElideRight
|
||||
|
||||
property real availableWidth: tabbar.width - leftCorner.width - rightCorner.width
|
||||
|
||||
property var __selectedTabRect
|
||||
|
||||
function tab(index) {
|
||||
for (var i = 0; i < tabrow.children.length; ++i) {
|
||||
if (tabrow.children[i].tabindex == index) {
|
||||
return tabrow.children[i]
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
function __isAncestorOf(item, child) {
|
||||
//TODO: maybe removed from 5.2 if the function was merged in qtdeclarative
|
||||
if (child === item)
|
||||
return false;
|
||||
|
||||
while (child) {
|
||||
child = child.parent;
|
||||
if (child === item)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loader {
|
||||
id: background
|
||||
anchors.fill: parent
|
||||
sourceComponent: styleItem ? styleItem.tabBar : undefined
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: tabrow
|
||||
objectName: "tabrow"
|
||||
Accessible.role: Accessible.PageTabList
|
||||
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
||||
spacing: -tabOverlap
|
||||
orientation: Qt.Horizontal
|
||||
interactive: false
|
||||
focus: true
|
||||
clip: true
|
||||
|
||||
// Note this will silence the binding loop warnings caused by QTBUG-35038
|
||||
// and should be removed when this issue is resolved.
|
||||
property int contentWidthWorkaround: contentWidth > 0 ? contentWidth: 0
|
||||
width: Math.min(availableWidth, count ? contentWidthWorkaround : availableWidth)
|
||||
height: currentItem ? currentItem.height : 0
|
||||
|
||||
highlightMoveDuration: 0
|
||||
|
||||
// We cannot bind directly to the currentIndex because the actual model is
|
||||
// populated after the listview is completed, resulting in an invalid contentItem
|
||||
currentIndex: tabView.currentIndex < model.count ? tabView.currentIndex : -1
|
||||
onCurrentIndexChanged: tabrow.positionViewAtIndex(currentIndex, ListView.Contain)
|
||||
|
||||
moveDisplaced: Transition {
|
||||
NumberAnimation {
|
||||
property: "x"
|
||||
duration: 125
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "left"
|
||||
when: tabsAlignment === Qt.AlignLeft
|
||||
AnchorChanges { target:tabrow ; anchors.left: parent.left }
|
||||
PropertyChanges { target:tabrow ; anchors.leftMargin: leftCorner.width }
|
||||
},
|
||||
State {
|
||||
name: "center"
|
||||
when: tabsAlignment === Qt.AlignHCenter
|
||||
AnchorChanges { target:tabrow ; anchors.horizontalCenter: tabbar.horizontalCenter }
|
||||
},
|
||||
State {
|
||||
name: "right"
|
||||
when: tabsAlignment === Qt.AlignRight
|
||||
AnchorChanges { target:tabrow ; anchors.right: parent.right }
|
||||
PropertyChanges { target:tabrow ; anchors.rightMargin: rightCorner.width }
|
||||
}
|
||||
]
|
||||
|
||||
model: tabView.__tabs
|
||||
|
||||
delegate: MouseArea {
|
||||
id: tabitem
|
||||
objectName: "mousearea"
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
focus: true
|
||||
enabled: modelData.enabled
|
||||
|
||||
Binding {
|
||||
target: tabbar
|
||||
when: selected
|
||||
property: "__selectedTabRect"
|
||||
value: Qt.rect(x, y, width, height)
|
||||
}
|
||||
|
||||
drag.target: tabsMovable ? tabloader : null
|
||||
drag.axis: Drag.XAxis
|
||||
drag.minimumX: drag.active ? 0 : -Number.MAX_VALUE
|
||||
drag.maximumX: tabrow.width - tabitem.width
|
||||
|
||||
property int tabindex: index
|
||||
property bool selected : tabView.currentIndex === index
|
||||
property string title: modelData.title
|
||||
property bool nextSelected: tabView.currentIndex === index + 1
|
||||
property bool previousSelected: tabView.currentIndex === index - 1
|
||||
|
||||
property bool keyPressed: false
|
||||
property bool effectivePressed: pressed && containsMouse || keyPressed
|
||||
|
||||
z: selected ? 1 : -index
|
||||
implicitWidth: tabloader.implicitWidth
|
||||
implicitHeight: tabloader.implicitHeight
|
||||
|
||||
function changeTab() {
|
||||
tabView.currentIndex = index;
|
||||
var next = tabbar.nextItemInFocusChain(true);
|
||||
if (__isAncestorOf(tabView.getTab(currentIndex), next))
|
||||
next.forceActiveFocus();
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (tabrow.interactive) {
|
||||
changeTab()
|
||||
}
|
||||
}
|
||||
onPressed: {
|
||||
if (!tabrow.interactive) {
|
||||
changeTab()
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && !tabitem.pressed)
|
||||
tabitem.keyPressed = true
|
||||
}
|
||||
Keys.onReleased: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && tabitem.keyPressed)
|
||||
tabitem.keyPressed = false
|
||||
}
|
||||
onFocusChanged: if (!focus) tabitem.keyPressed = false
|
||||
|
||||
Loader {
|
||||
id: tabloader
|
||||
|
||||
property Item control: tabView
|
||||
property int index: tabindex
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias index: tabitem.tabindex
|
||||
readonly property alias selected: tabitem.selected
|
||||
readonly property alias title: tabitem.title
|
||||
readonly property alias nextSelected: tabitem.nextSelected
|
||||
readonly property alias previousSelected: tabitem.previousSelected
|
||||
readonly property alias pressed: tabitem.effectivePressed
|
||||
readonly property alias hovered: tabitem.containsMouse
|
||||
readonly property alias enabled: tabitem.enabled
|
||||
readonly property bool activeFocus: tabitem.activeFocus
|
||||
readonly property real availableWidth: tabbar.availableWidth
|
||||
readonly property real totalWidth: tabrow.contentWidth
|
||||
}
|
||||
|
||||
sourceComponent: loader.item ? loader.item.tab : null
|
||||
|
||||
Drag.keys: "application/x-tabbartab"
|
||||
Drag.active: tabitem.drag.active
|
||||
Drag.source: tabitem
|
||||
|
||||
property real __prevX: 0
|
||||
property real __dragX: 0
|
||||
onXChanged: {
|
||||
if (Drag.active) {
|
||||
// keep track for the snap back animation
|
||||
__dragX = tabitem.mapFromItem(tabrow, tabloader.x, 0).x
|
||||
|
||||
// when moving to the left, the hot spot is the left edge and vice versa
|
||||
Drag.hotSpot.x = x < __prevX ? 0 : width
|
||||
__prevX = x
|
||||
}
|
||||
}
|
||||
|
||||
width: tabitem.width
|
||||
state: Drag.active ? "drag" : ""
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "drag"
|
||||
PropertyAction { target: tabloader; property: "parent"; value: tabrow }
|
||||
},
|
||||
Transition {
|
||||
from: "drag"
|
||||
SequentialAnimation {
|
||||
PropertyAction { target: tabloader; property: "parent"; value: tabitem }
|
||||
NumberAnimation {
|
||||
target: tabloader
|
||||
duration: 50
|
||||
easing.type: Easing.OutQuad
|
||||
property: "x"
|
||||
from: tabloader.__dragX
|
||||
to: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Accessible.role: Accessible.PageTab
|
||||
Accessible.name: modelData.title
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: leftCorner
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
sourceComponent: styleItem ? styleItem.leftCorner : undefined
|
||||
width: item ? item.implicitWidth : 0
|
||||
height: item ? item.implicitHeight : 0
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: rightCorner
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
sourceComponent: styleItem ? styleItem.rightCorner : undefined
|
||||
width: item ? item.implicitWidth : 0
|
||||
height: item ? item.implicitHeight : 0
|
||||
}
|
||||
|
||||
DropArea {
|
||||
anchors.fill: tabrow
|
||||
keys: "application/x-tabbartab"
|
||||
onPositionChanged: {
|
||||
var source = drag.source
|
||||
var target = tabrow.itemAt(drag.x, drag.y)
|
||||
if (source && target && source !== target) {
|
||||
source = source.drag.target
|
||||
target = target.drag.target
|
||||
var center = target.parent.x + target.width / 2
|
||||
if ((source.index > target.index && source.x < center)
|
||||
|| (source.index < target.index && source.x + source.width > center))
|
||||
tabView.moveTab(source.index, target.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/TabBar.qmlc
Normal file
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/TabBar.qmlc
Normal file
Binary file not shown.
@@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
/*!
|
||||
\qmltype TableViewItemDelegateLoader
|
||||
\internal
|
||||
\qmlabstract
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
|
||||
Loader {
|
||||
id: itemDelegateLoader
|
||||
|
||||
width: __column ? __column.width : 0
|
||||
height: parent ? parent.height : 0
|
||||
visible: __column ? __column.visible : false
|
||||
|
||||
property bool isValid: false
|
||||
sourceComponent: (__model === undefined || !isValid) ? null
|
||||
: __column && __column.delegate ? __column.delegate : __itemDelegate
|
||||
|
||||
// All these properties are internal
|
||||
property int __index: index
|
||||
property Item __rowItem: null
|
||||
property var __model: __rowItem ? __rowItem.itemModel : undefined
|
||||
property var __modelData: __rowItem ? __rowItem.itemModelData : undefined
|
||||
property TableViewColumn __column: null
|
||||
property Component __itemDelegate: null
|
||||
property var __mouseArea: null
|
||||
property var __style: null
|
||||
|
||||
// These properties are exposed to the item delegate
|
||||
readonly property var model: __model
|
||||
readonly property var modelData: __modelData
|
||||
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property int row: __rowItem ? __rowItem.rowIndex : -1
|
||||
readonly property int column: __index
|
||||
readonly property int elideMode: __column ? __column.elideMode : Text.ElideLeft
|
||||
readonly property int textAlignment: __column ? __column.horizontalAlignment : Text.AlignLeft
|
||||
readonly property bool selected: __rowItem ? __rowItem.itemSelected : false
|
||||
readonly property bool hasActiveFocus: __rowItem ? __rowItem.activeFocus : false
|
||||
readonly property bool pressed: __mouseArea && row === __mouseArea.pressedRow && column === __mouseArea.pressedColumn
|
||||
readonly property color textColor: __rowItem ? __rowItem.itemTextColor : "black"
|
||||
readonly property string role: __column ? __column.role : ""
|
||||
readonly property var value: model && model.hasOwnProperty(role) ? model[role] // Qml ListModel and QAbstractItemModel
|
||||
: modelData && modelData.hasOwnProperty(role) ? modelData[role] // QObjectList / QObject
|
||||
: modelData != undefined ? modelData : "" // Models without role
|
||||
onRowChanged: if (row !== -1) itemDelegateLoader.isValid = true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,196 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
QtObject {
|
||||
|
||||
property int count: 0
|
||||
signal selectionChanged
|
||||
|
||||
property bool __dirty: false
|
||||
property var __ranges: []
|
||||
|
||||
function forEach (callback) {
|
||||
if (!(callback instanceof Function)) {
|
||||
console.warn("TableViewSelection.forEach: argument is not a function")
|
||||
return;
|
||||
}
|
||||
__forEach(callback, -1)
|
||||
}
|
||||
|
||||
function contains(index) {
|
||||
for (var i = 0 ; i < __ranges.length ; ++i) {
|
||||
if (__ranges[i][0] <= index && index <= __ranges[i][1])
|
||||
return true;
|
||||
else if (__ranges[i][0] > index)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function clear() {
|
||||
__ranges = []
|
||||
__dirty = true
|
||||
count = 0
|
||||
selectionChanged()
|
||||
}
|
||||
|
||||
function selectAll() { select(0, rowCount - 1) }
|
||||
function select(first, last) { __select(true, first, last) }
|
||||
function deselect(first, last) { __select(false, first, last) }
|
||||
|
||||
// --- private section ---
|
||||
|
||||
function __printRanges() {
|
||||
var out = ""
|
||||
for (var i = 0 ; i < __ranges.length ; ++ i)
|
||||
out += ("{" + __ranges[i][0] + "," + __ranges[i][1] + "} ")
|
||||
print(out)
|
||||
}
|
||||
|
||||
function __count() {
|
||||
var sum = 0
|
||||
for (var i = 0 ; i < __ranges.length ; ++i) {
|
||||
sum += (1 + __ranges[i][1] - __ranges[i][0])
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
function __forEach (callback, startIndex) {
|
||||
__dirty = false
|
||||
var i, j
|
||||
|
||||
for (i = 0 ; i < __ranges.length && !__dirty ; ++i) {
|
||||
for (j = __ranges[i][0] ; !__dirty && j <= __ranges[i][1] ; ++j) {
|
||||
if (j >= startIndex)
|
||||
callback.call(this, j)
|
||||
}
|
||||
}
|
||||
|
||||
// Restart iteration at last index if selection changed
|
||||
if (__dirty)
|
||||
return __forEach(callback, j)
|
||||
}
|
||||
|
||||
function __selectOne(index) {
|
||||
__ranges = [[index, index]]
|
||||
__dirty = true
|
||||
count = 1
|
||||
selectionChanged();
|
||||
}
|
||||
|
||||
function __select(select, first, last) {
|
||||
|
||||
var i, range
|
||||
var start = first
|
||||
var stop = first
|
||||
var startRangeIndex = -1
|
||||
var stopRangeIndex = -1
|
||||
var newRangePos = 0
|
||||
|
||||
if (first < 0 || last < 0 || first >= rowCount || last >=rowCount) {
|
||||
console.warn("TableViewSelection: index out of range")
|
||||
return
|
||||
}
|
||||
|
||||
if (last !== undefined) {
|
||||
start = first <= last ? first : last
|
||||
stop = first <= last ? last : first
|
||||
}
|
||||
|
||||
if (select) {
|
||||
|
||||
// Find beginning and end ranges
|
||||
for (i = 0 ; i < __ranges.length; ++ i) {
|
||||
range = __ranges[i]
|
||||
if (range[0] > stop + 1) continue; // above range
|
||||
if (range[1] < start - 1) { // below range
|
||||
newRangePos = i + 1
|
||||
continue;
|
||||
}
|
||||
if (startRangeIndex === -1)
|
||||
startRangeIndex = i
|
||||
stopRangeIndex = i
|
||||
}
|
||||
|
||||
if (startRangeIndex !== -1)
|
||||
start = Math.min(__ranges[startRangeIndex][0], start)
|
||||
if (stopRangeIndex !== -1)
|
||||
stop = Math.max(__ranges[stopRangeIndex][1], stop)
|
||||
|
||||
if (startRangeIndex === -1)
|
||||
startRangeIndex = newRangePos
|
||||
|
||||
__ranges.splice(Math.max(0, startRangeIndex),
|
||||
1 + stopRangeIndex - startRangeIndex, [start, stop])
|
||||
|
||||
} else {
|
||||
|
||||
// Find beginning and end ranges
|
||||
for (i = 0 ; i < __ranges.length; ++ i) {
|
||||
range = __ranges[i]
|
||||
if (range[1] < start) continue; // below range
|
||||
if (range[0] > stop) continue; // above range
|
||||
if (startRangeIndex === -1)
|
||||
startRangeIndex = i
|
||||
stopRangeIndex = i
|
||||
}
|
||||
|
||||
// Slice ranges accordingly
|
||||
if (startRangeIndex >= 0 && stopRangeIndex >= 0) {
|
||||
var startRange = __ranges[startRangeIndex]
|
||||
var stopRange = __ranges[stopRangeIndex]
|
||||
var length = 1 + stopRangeIndex - startRangeIndex
|
||||
if (start <= startRange[0] && stop >= stopRange[1]) { //remove
|
||||
__ranges.splice(startRangeIndex, length)
|
||||
} else if (start - 1 < startRange[0] && stop <= stopRange[1]) { //cut front
|
||||
__ranges.splice(startRangeIndex, length, [stop + 1, stopRange[1]])
|
||||
} else if (start - 1 < startRange[1] && stop >= stopRange[1]) { // cut back
|
||||
__ranges.splice(startRangeIndex, length, [startRange[0], start - 1])
|
||||
} else { //split
|
||||
__ranges.splice(startRangeIndex, length, [startRange[0], start - 1], [stop + 1, stopRange[1]])
|
||||
}
|
||||
}
|
||||
}
|
||||
__dirty = true
|
||||
count = __count() // forces a re-evaluation of indexes in the delegates
|
||||
selectionChanged()
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
Loader {
|
||||
id: handle
|
||||
|
||||
property Item editor
|
||||
property int minimum: -1
|
||||
property int maximum: -1
|
||||
property int position: -1
|
||||
property alias delegate: handle.sourceComponent
|
||||
|
||||
readonly property alias pressed: mouse.pressed
|
||||
|
||||
readonly property real handleX: x + (item ? item.x : 0)
|
||||
readonly property real handleY: y + (item ? item.y : 0)
|
||||
readonly property real handleWidth: item ? item.width : 0
|
||||
readonly property real handleHeight: item ? item.height : 0
|
||||
|
||||
property Item control
|
||||
property QtObject styleData: QtObject {
|
||||
id: styleData
|
||||
signal activated()
|
||||
readonly property alias pressed: mouse.pressed
|
||||
readonly property alias position: handle.position
|
||||
readonly property bool hasSelection: editor.selectionStart !== editor.selectionEnd
|
||||
readonly property real lineHeight: position !== -1 ? editor.positionToRectangle(position).height
|
||||
: editor.cursorRectangle.height
|
||||
}
|
||||
|
||||
function activate() {
|
||||
styleData.activated()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: item
|
||||
enabled: item && item.visible
|
||||
preventStealing: true
|
||||
property real pressX
|
||||
property point offset
|
||||
property bool handleDragged: false
|
||||
|
||||
onPressed: {
|
||||
Qt.inputMethod.commit()
|
||||
handleDragged = false
|
||||
pressX = mouse.x
|
||||
var handleRect = editor.positionToRectangle(handle.position)
|
||||
var centerX = handleRect.x + (handleRect.width / 2)
|
||||
var centerY = handleRect.y + (handleRect.height / 2)
|
||||
var center = mapFromItem(editor, centerX, centerY)
|
||||
offset = Qt.point(mouseX - center.x, mouseY - center.y)
|
||||
}
|
||||
onReleased: {
|
||||
if (!handleDragged) {
|
||||
// The user just clicked on the handle. In that
|
||||
// case clear the selection.
|
||||
var mousePos = editor.mapFromItem(item, mouse.x, mouse.y)
|
||||
var editorPos = editor.positionAt(mousePos.x, mousePos.y)
|
||||
editor.select(editorPos, editorPos)
|
||||
}
|
||||
}
|
||||
onPositionChanged: {
|
||||
handleDragged = true
|
||||
var pt = mapToItem(editor, mouse.x - offset.x, mouse.y - offset.y)
|
||||
|
||||
// limit vertically within mix/max coordinates or content bounds
|
||||
var min = (minimum !== -1) ? minimum : 0
|
||||
var max = (maximum !== -1) ? maximum : editor.length
|
||||
pt.y = Math.max(pt.y, editor.positionToRectangle(min).y)
|
||||
pt.y = Math.min(pt.y, editor.positionToRectangle(max).y)
|
||||
|
||||
var pos = editor.positionAt(pt.x, pt.y)
|
||||
|
||||
// limit horizontally within min/max character positions
|
||||
if (minimum !== -1)
|
||||
pos = Math.max(pos, minimum)
|
||||
pos = Math.max(pos, 0)
|
||||
if (maximum !== -1)
|
||||
pos = Math.min(pos, maximum)
|
||||
pos = Math.min(pos, editor.length)
|
||||
|
||||
handle.position = pos
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,201 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.2
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
TextInput {
|
||||
id: input
|
||||
|
||||
property Item control
|
||||
property alias cursorHandle: cursorHandle.delegate
|
||||
property alias selectionHandle: selectionHandle.delegate
|
||||
|
||||
property bool blockRecursion: false
|
||||
property bool hasSelection: selectionStart !== selectionEnd
|
||||
readonly property int selectionPosition: selectionStart !== cursorPosition ? selectionStart : selectionEnd
|
||||
readonly property alias containsMouse: mouseArea.containsMouse
|
||||
property alias editMenu: editMenu
|
||||
cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null
|
||||
|
||||
selectByMouse: control.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate)
|
||||
|
||||
// force re-evaluation when selection moves:
|
||||
// - cursorRectangle changes => content scrolled
|
||||
// - contentWidth changes => text layout changed
|
||||
property rect selectionRectangle: cursorRectangle.x && contentWidth ? positionToRectangle(selectionPosition)
|
||||
: positionToRectangle(selectionPosition)
|
||||
|
||||
onSelectionStartChanged: syncHandlesWithSelection()
|
||||
onCursorPositionChanged: syncHandlesWithSelection()
|
||||
|
||||
function syncHandlesWithSelection()
|
||||
{
|
||||
if (!blockRecursion && selectionHandle.delegate) {
|
||||
blockRecursion = true
|
||||
// We cannot use property selectionPosition since it gets updated after onSelectionStartChanged
|
||||
cursorHandle.position = cursorPosition
|
||||
selectionHandle.position = (selectionStart !== cursorPosition) ? selectionStart : selectionEnd
|
||||
blockRecursion = false
|
||||
}
|
||||
}
|
||||
|
||||
function activate() {
|
||||
if (activeFocusOnPress) {
|
||||
forceActiveFocus()
|
||||
if (!readOnly)
|
||||
Qt.inputMethod.show()
|
||||
}
|
||||
cursorHandle.activate()
|
||||
selectionHandle.activate()
|
||||
}
|
||||
|
||||
function moveHandles(cursor, selection) {
|
||||
blockRecursion = true
|
||||
cursorPosition = cursor
|
||||
if (selection === -1) {
|
||||
selectWord()
|
||||
selection = selectionStart
|
||||
}
|
||||
selectionHandle.position = selection
|
||||
cursorHandle.position = cursorPosition
|
||||
blockRecursion = false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
cursorShape: Qt.IBeamCursor
|
||||
acceptedButtons: (input.selectByMouse ? Qt.NoButton : Qt.LeftButton) | (control.menu ? Qt.RightButton : Qt.NoButton)
|
||||
onClicked: {
|
||||
if (editMenu.item)
|
||||
return;
|
||||
var pos = input.positionAt(mouse.x, mouse.y)
|
||||
input.moveHandles(pos, pos)
|
||||
input.activate()
|
||||
}
|
||||
onPressAndHold: {
|
||||
if (editMenu.item)
|
||||
return;
|
||||
var pos = input.positionAt(mouse.x, mouse.y)
|
||||
input.moveHandles(pos, control.selectByMouse ? -1 : pos)
|
||||
input.activate()
|
||||
}
|
||||
}
|
||||
|
||||
EditMenu {
|
||||
id: editMenu
|
||||
input: parent
|
||||
mouseArea: mouseArea
|
||||
control: parent.control
|
||||
cursorHandle: cursorHandle
|
||||
selectionHandle: selectionHandle
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
ScenePosListener {
|
||||
id: listener
|
||||
item: input
|
||||
enabled: input.activeFocus && Qt.platform.os !== "ios" && Settings.isMobile
|
||||
}
|
||||
|
||||
TextHandle {
|
||||
id: selectionHandle
|
||||
|
||||
editor: input
|
||||
z: 1000001 // DefaultWindowDecoration+1
|
||||
parent: !input.activeFocus || Qt.platform.os === "ios" ? control : Window.contentItem // float (QTBUG-42538)
|
||||
control: input.control
|
||||
active: control.selectByMouse && Settings.isMobile
|
||||
maximum: cursorHandle.position - 1
|
||||
|
||||
readonly property var mappedOrigin: editor.mapToItem(parent, 0,0)
|
||||
|
||||
// Mention scenePos in the mappedPos binding to force re-evaluation if it changes
|
||||
readonly property var mappedPos: listener.scenePos.x !== listener.scenePos.y !== Number.MAX_VALUE ?
|
||||
editor.mapToItem(parent, editor.selectionRectangle.x, editor.selectionRectangle.y) : -1
|
||||
x: mappedPos.x
|
||||
y: mappedPos.y
|
||||
|
||||
visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX - mappedOrigin.x <= control.width + 1)
|
||||
|
||||
onPositionChanged: {
|
||||
if (!input.blockRecursion) {
|
||||
input.blockRecursion = true
|
||||
input.select(selectionHandle.position, cursorHandle.position)
|
||||
if (pressed)
|
||||
input.ensureVisible(position)
|
||||
input.blockRecursion = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextHandle {
|
||||
id: cursorHandle
|
||||
|
||||
editor: input
|
||||
z: 1000001 // DefaultWindowDecoration+1
|
||||
parent: !input.activeFocus || Qt.platform.os === "ios" ? control : Window.contentItem // float (QTBUG-42538)
|
||||
control: input.control
|
||||
active: control.selectByMouse && Settings.isMobile
|
||||
minimum: input.hasSelection ? selectionHandle.position + 1 : -1
|
||||
|
||||
readonly property var mappedOrigin: editor.mapToItem(parent, 0,0)
|
||||
|
||||
// Mention scenePos in the mappedPos binding to force re-evaluation if it changes
|
||||
readonly property var mappedPos: listener.scenePos.x !== listener.scenePos.y !== Number.MAX_VALUE ?
|
||||
editor.mapToItem(parent, editor.cursorRectangle.x, editor.cursorRectangle.y) : -1
|
||||
x: mappedPos.x
|
||||
y: mappedPos.y
|
||||
|
||||
visible: pressed || ((input.cursorVisible || input.hasSelection) && handleX + handleWidth >= -1 && handleX - mappedOrigin.x <= control.width + 1)
|
||||
|
||||
onPositionChanged: {
|
||||
if (!input.blockRecursion) {
|
||||
input.blockRecursion = true
|
||||
if (!input.hasSelection)
|
||||
selectionHandle.position = cursorHandle.position
|
||||
input.select(selectionHandle.position, cursorHandle.position)
|
||||
input.blockRecursion = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,43 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
pragma Singleton
|
||||
import QtQuick 2.2
|
||||
Text {
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.4
|
||||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
FocusScope {
|
||||
id: button
|
||||
|
||||
property Menu menu
|
||||
readonly property bool pressed: behavior.containsPress || behavior.keyPressed
|
||||
readonly property alias hovered: behavior.containsMouse
|
||||
|
||||
property alias panel: loader.sourceComponent
|
||||
property alias __panel: loader.item
|
||||
|
||||
activeFocusOnTab: true
|
||||
Accessible.role: Accessible.Button
|
||||
implicitWidth: __panel ? __panel.implicitWidth : 0
|
||||
implicitHeight: __panel ? __panel.implicitHeight : 0
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
property QtObject styleData: QtObject {
|
||||
readonly property alias pressed: button.pressed
|
||||
readonly property alias hovered: button.hovered
|
||||
readonly property alias activeFocus: button.activeFocus
|
||||
}
|
||||
onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", button)
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && !behavior.keyPressed)
|
||||
behavior.keyPressed = true
|
||||
}
|
||||
Keys.onReleased: {
|
||||
if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed)
|
||||
behavior.keyPressed = false
|
||||
}
|
||||
onFocusChanged: {
|
||||
if (!focus)
|
||||
behavior.keyPressed = false
|
||||
}
|
||||
onPressedChanged: {
|
||||
if (!Settings.hasTouchScreen && !pressed && menu)
|
||||
popupMenuTimer.start()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: behavior
|
||||
property bool keyPressed: false
|
||||
|
||||
anchors.fill: parent
|
||||
enabled: !keyPressed
|
||||
hoverEnabled: Settings.hoverEnabled
|
||||
|
||||
onReleased: {
|
||||
if (Settings.hasTouchScreen && containsMouse && menu)
|
||||
popupMenuTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: popupMenuTimer
|
||||
interval: 10
|
||||
onTriggered: {
|
||||
behavior.keyPressed = false
|
||||
if (Qt.application.layoutDirection === Qt.RightToLeft)
|
||||
menu.__popup(Qt.rect(button.width, button.height, 0, 0), 0)
|
||||
else
|
||||
menu.__popup(Qt.rect(0, 0, button.width, button.height), 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: menu
|
||||
property: "__minimumWidth"
|
||||
value: button.width
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: menu
|
||||
property: "__visualItem"
|
||||
value: button
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Controls.Private 1.0
|
||||
|
||||
/*!
|
||||
\qmltype TreeViewItemDelegateLoader
|
||||
\internal
|
||||
\qmlabstract
|
||||
\inqmlmodule QtQuick.Controls.Private
|
||||
*/
|
||||
|
||||
TableViewItemDelegateLoader {
|
||||
id: itemDelegateLoader
|
||||
|
||||
/* \internal */
|
||||
readonly property int __itemIndentation: __style && __index === 0
|
||||
? __style.__indentation * (styleData.depth + 1) : 0
|
||||
/* \internal */
|
||||
property TreeModelAdaptor __treeModel: null
|
||||
|
||||
// Exposed to the item delegate
|
||||
styleData: QtObject {
|
||||
readonly property int row: __rowItem ? __rowItem.rowIndex : -1
|
||||
readonly property int column: __index
|
||||
readonly property int elideMode: __column ? __column.elideMode : Text.ElideLeft
|
||||
readonly property int textAlignment: __column ? __column.horizontalAlignment : Text.AlignLeft
|
||||
readonly property bool selected: __rowItem ? __rowItem.itemSelected : false
|
||||
readonly property bool hasActiveFocus: __rowItem ? __rowItem.activeFocus : false
|
||||
readonly property bool pressed: __mouseArea && row === __mouseArea.pressedRow && column === __mouseArea.pressedColumn
|
||||
readonly property color textColor: __rowItem ? __rowItem.itemTextColor : "black"
|
||||
readonly property string role: __column ? __column.role : ""
|
||||
readonly property var value: model && model.hasOwnProperty(role) ? model[role] : ""
|
||||
readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null)
|
||||
readonly property int depth: model && column === 0 ? model["_q_TreeView_ItemDepth"] : 0
|
||||
readonly property bool hasChildren: model ? model["_q_TreeView_HasChildren"] : false
|
||||
readonly property bool hasSibling: model ? model["_q_TreeView_HasSibling"] : false
|
||||
readonly property bool isExpanded: model ? model["_q_TreeView_ItemExpanded"] : false
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
item.x = Qt.binding(function() { return __itemIndentation})
|
||||
item.width = Qt.binding(function() { return width - __itemIndentation })
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: branchDelegateLoader
|
||||
active: __model !== undefined
|
||||
&& __index === 0
|
||||
&& styleData.hasChildren
|
||||
visible: itemDelegateLoader.width > __itemIndentation
|
||||
sourceComponent: __style && __style.__branchDelegate || null
|
||||
anchors.right: parent.item ? parent.item.left : undefined
|
||||
anchors.rightMargin: __style.__indentation > width ? (__style.__indentation - width) / 2 : 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
property QtObject styleData: itemDelegateLoader.styleData
|
||||
onLoaded: if (__rowItem) __rowItem.branchDecoration = item
|
||||
}
|
||||
}
|
||||
Binary file not shown.
37
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/qmldir
Normal file
37
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/qmldir
Normal file
@@ -0,0 +1,37 @@
|
||||
module QtQuick.Controls.Private
|
||||
AbstractCheckable 1.0 AbstractCheckable.qml
|
||||
CalendarHeaderModel 1.0 CalendarHeaderModel.qml
|
||||
Control 1.0 Control.qml
|
||||
CalendarUtils 1.0 CalendarUtils.js
|
||||
FocusFrame 1.0 FocusFrame.qml
|
||||
Margins 1.0 Margins.qml
|
||||
BasicButton 1.0 BasicButton.qml
|
||||
ScrollBar 1.0 ScrollBar.qml
|
||||
ScrollViewHelper 1.0 ScrollViewHelper.qml
|
||||
Style 1.0 Style.qml
|
||||
MenuItemSubControls 1.0 MenuItemSubControls.qml
|
||||
TabBar 1.0 TabBar.qml
|
||||
StackViewSlideDelegate 1.0 StackViewSlideDelegate.qml
|
||||
StyleHelpers 1.0 style.js
|
||||
JSArray 1.0 StackView.js
|
||||
TableViewSelection 1.0 TableViewSelection.qml
|
||||
FastGlow 1.0 FastGlow.qml
|
||||
SourceProxy 1.0 SourceProxy.qml
|
||||
GroupBoxStyle 1.0 ../Styles/Base/GroupBoxStyle.qml
|
||||
FocusFrameStyle 1.0 ../Styles/Base/FocusFrameStyle.qml
|
||||
ToolButtonStyle 1.0 ../Styles/Base/ToolButtonStyle.qml
|
||||
MenuContentItem 1.0 MenuContentItem.qml
|
||||
MenuContentScroller 1.0 MenuContentScroller.qml
|
||||
ColumnMenuContent 1.0 ColumnMenuContent.qml
|
||||
ContentItem 1.0 ContentItem.qml
|
||||
HoverButton 1.0 HoverButton.qml
|
||||
singleton SystemPaletteSingleton 1.0 SystemPaletteSingleton.qml
|
||||
singleton TextSingleton 1.0 TextSingleton.qml
|
||||
TextHandle 1.0 TextHandle.qml
|
||||
TextInputWithHandles 1.0 TextInputWithHandles.qml
|
||||
EditMenu 1.0 EditMenu.qml
|
||||
EditMenu_base 1.0 EditMenu_base.qml
|
||||
ToolMenuButton 1.0 ToolMenuButton.qml
|
||||
BasicTableView 1.0 BasicTableView.qml
|
||||
TableViewItemDelegateLoader 1.0 TableViewItemDelegateLoader.qml
|
||||
TreeViewItemDelegateLoader 1.0 TreeViewItemDelegateLoader.qml
|
||||
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
.pragma library
|
||||
|
||||
function underlineAmpersands(match, p1, p2, p3) {
|
||||
if (p2 === "&")
|
||||
return p1.concat(p2, p3)
|
||||
return p1.concat("<u>", p2, "</u>", p3)
|
||||
}
|
||||
|
||||
function removeAmpersands(match, p1, p2, p3) {
|
||||
return p1.concat(p2, p3)
|
||||
}
|
||||
|
||||
function replaceAmpersands(text, replaceFunction) {
|
||||
return text.replace(/([^&]*)&(.)([^&]*)/g, replaceFunction)
|
||||
}
|
||||
|
||||
function stylizeMnemonics(text) {
|
||||
return replaceAmpersands(text, underlineAmpersands)
|
||||
}
|
||||
|
||||
function removeMnemonics(text) {
|
||||
return replaceAmpersands(text, removeAmpersands)
|
||||
}
|
||||
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/style.jsc
Normal file
BIN
ZBD_IIIDL_S_Project/release/QtQuick/Controls/Private/style.jsc
Normal file
Binary file not shown.
Reference in New Issue
Block a user