Source

Target

Showing with 231 additions and 145 deletions
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\group navigation
\title Application Navigation
*/
......@@ -70,29 +70,6 @@
vertically with a draggable splitter between each item.
*/
/*!
\example ApplicationTemplate
\title Qt Quick Controls - Application Template
\ingroup qtquickcontrols_examples
\brief A simple application template with a few basic UI components.
\image qtquickcontrols-example-applicationtemplate.png
This is a simple, easily extensible template project for a
desktop application using \l{Qt Quick Controls}.
*/
/*!
\example stackview
\title Qt Quick Controls - Stack View Example
\ingroup qtquickcontrols_examples
\brief An example for a stack-based navigation model.
\image qtquickcontrols-example-stackview.png
This example shows how to implement a stack-based navigation model
in a Qt Quick application using a \l{StackView} component from
\l{Qt Quick Controls}.
*/
/*!
\example tableview
\title Qt Quick Controls - Table View Example
......
......@@ -36,6 +36,8 @@
The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1.
\note \l{Qt Quick Layouts} can be used to arrange Qt Quick Controls in a user interface.
\note The current focus is on desktop, but in the long term Qt Quick Controls
are expected to be supported on mobile platforms too.
......@@ -59,10 +61,9 @@
Controls are typically items that are used to present or receive input from the user.
\annotatedlist controls
\section1 Layouts
\l{Qt Quick Layouts}{Layouts} can be used to have dynamic user interfaces where the UI
adapts to the available geometry.
\annotatedlist layouts
\section1 Menus
Types that can be used to build menus.
\annotatedlist menus
\section1 Related information
......
......@@ -32,10 +32,10 @@
\brief Provides QML types for user interfaces.
The \l{Qt Quick Controls} module provides QML types for creating user
interfaces. These QML types work in conjunction with \l{Qt Quick} and
interfaces. These QML types work in conjunction with \l{Qt Quick} and
\l{Qt Quick Layouts}.
The QML types can be imported into your applciation using the
The QML types can be imported into your application using the
following import statement in your .qml file.
\code
......
......@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype Action
\instantiates QQuickAction
\ingroup applicationwindow
\inqmlmodule QtQuick.Controls 1.0
\brief Action provides an abstract user interface action that can be bound to items
......@@ -65,6 +66,19 @@ QT_BEGIN_NAMESPACE
automatically be checked.
QtQuick Controls supports actions in \l Button, \l ToolButton, and \l MenuItem.
Example:
\qml
Action {
id: openAction
text: "&Open"
shortcut: "Ctrl+O"
iconSource: "images/document-open.png"
onTriggered: fileDialog.open()
tooltip: "Open an Image"
}
\endqml
*/
/*!
......
......@@ -66,6 +66,7 @@ static bool isChecked(const QObject *o)
/*!
\qmltype ExclusiveGroup
\instantiates QQuickExclusiveGroup
\ingroup controls
\inqmlmodule QtQuick.Controls 1.0
\brief ExclusiveGroup provides a way to declare several checkable controls as mutually exclusive.
......
......@@ -24,7 +24,7 @@ qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:hea
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.type = manual
depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts
depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols
exampledirs += ../../../examples/quick/controls/
......
......@@ -204,9 +204,8 @@ Fixed | Layout.fillWidth | Expanding if layout, Fixed if item |
}
}
//--- GATHER MAXIMUM SIZE HINTS ---
// They are always q_declarativeLayoutMaxSize
combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), q_declarativeLayoutMaxSize);
combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), q_declarativeLayoutMaxSize);
combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), std::numeric_limits<qreal>::infinity());
combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), std::numeric_limits<qreal>::infinity());
//--- GATHER DESCENT
// ### Not implemented
......
......@@ -111,8 +111,9 @@ public:
void setGeometry(const QRectF &rect)
{
m_item->setPosition(rect.topLeft());
m_item->setSize(rect.size());
const QRect r(rect.toRect());
m_item->setPosition(r.topLeft());
m_item->setSize(r.size());
}
QQuickItem *layoutItem() const { return m_item; }
......
......@@ -43,6 +43,7 @@
#include <QEvent>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qnumeric.h>
#include <limits>
/*!
\qmltype Layout
......@@ -78,8 +79,8 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
m_minimumHeight(0),
m_preferredWidth(-1),
m_preferredHeight(-1),
m_maximumWidth(-1),
m_maximumHeight(-1),
m_maximumWidth(std::numeric_limits<qreal>::infinity()),
m_maximumHeight(std::numeric_limits<qreal>::infinity()),
m_row(-1),
m_column(-1),
m_rowSpan(1),
......@@ -101,8 +102,15 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
/*!
\qmlproperty real Layout::minimumWidth
This property holds the minimum width of an item in a layout.
The default is \c 0.
This property holds the maximum width of an item in a layout.
The default value is the items implicit minimum width.
If the item is a layout, the implicit minimum width will be the minimum width the layout can
have without any of its items shrink beyond their minimum width.
The implicit minimum width for any other item is \c 0.
Setting this value to -1 will reset the width back to its implicit minimum width.
\sa preferredWidth
\sa maximumWidth
......@@ -123,8 +131,13 @@ void QQuickLayoutAttached::setMinimumWidth(qreal width)
/*!
\qmlproperty real Layout::minimumHeight
This property holds the minimum height of an item in a layout.
The default is \c 0.
The default value is the items implicit minimum height.
If the item is a layout, the implicit minimum height will be the minimum height the layout can
have without any of its items shrink beyond their minimum height.
The implicit minimum height for any other item is \c 0.
Setting this value to -1 will reset the height back to its implicit minimum height.
\sa preferredHeight
\sa maximumHeight
......@@ -147,7 +160,7 @@ void QQuickLayoutAttached::setMinimumHeight(qreal height)
This property holds the preferred width of an item in a layout.
If the preferred width is -1 it will be ignored, and the layout
will use {Item::implicitWidth}{implicitWidth} instead.
will use \l{Item::implicitWidth}{implicitWidth} instead.
The default is \c -1.
\sa minimumWidth
......@@ -168,7 +181,7 @@ void QQuickLayoutAttached::setPreferredWidth(qreal width)
This property holds the preferred height of an item in a layout.
If the preferred height is -1 it will be ignored, and the layout
will use {Item::implicitHeight}{implicitHeight} instead.
will use \l{Item::implicitHeight}{implicitHeight} instead.
The default is \c -1.
\sa minimumHeight
......@@ -188,10 +201,13 @@ void QQuickLayoutAttached::setPreferredHeight(qreal height)
\qmlproperty real Layout::maximumWidth
This property holds the maximum width of an item in a layout.
The default is \c -1, which means it there is no limit on the maxiumum width.
The default value is the items implicit maximum width.
If the item is a layout, the implicit maximum width will be the maximum width the layout can
have without any of its items grow beyond their maximum width.
The implicit maximum width for any other item is \c Number.POSITIVE_INFINITE.
\note There is actually a limit on the maximum width, but it's set to such a
large number that the arrangement is virtually the same as if it didn't have a limit.
Setting this value to -1 will reset the width back to its implicit maximum width.
\sa minimumWidth
\sa preferredWidth
......@@ -212,11 +228,13 @@ void QQuickLayoutAttached::setMaximumWidth(qreal width)
/*!
\qmlproperty real Layout::maximumHeight
This property holds the maximum height of an item in a layout.
The default is \c -1, which means it there is no limit on the maxiumum height.
The default value is the items implicit maximum height.
\note There is actually a limit on the maximum height, but it's set to such a
large number that the arrangement is virtually the same as if it didn't have a limit.
If the item is a layout, the implicit maximum height will be the maximum height the layout can
have without any of its items grow beyond their maximum height.
The implicit maximum height for any other item is \c Number.POSITIVE_INFINITE.
Setting this value to -1 will reset the height back to its implicit maximum height.
\sa minimumHeight
\sa preferredHeight
......@@ -389,6 +407,20 @@ void QQuickLayoutAttached::setColumn(int column)
\sa column
*/
qreal QQuickLayoutAttached::sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const
{
qreal result = 0;
if (QQuickLayout *layout = qobject_cast<QQuickLayout *>(item())) {
const QSizeF sz = layout->sizeHint(which);
result = (orientation == Qt::Horizontal ? sz.width() : sz.height());
} else {
if (which == Qt::MaximumSize)
result = std::numeric_limits<qreal>::infinity();
}
return result;
}
void QQuickLayoutAttached::invalidateItem()
{
if (!m_changesNotificationEnabled)
......
......@@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE
class QQuickLayoutAttached;
static const qreal q_declarativeLayoutMaxSize = 10e8;
#if 0 && !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_OUTPUT)
# define quickLayoutDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug
#else
......@@ -77,6 +75,7 @@ public:
void componentComplete();
virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0;
virtual void invalidate(QQuickItem * childItem = 0);
protected:
bool event(QEvent *e);
......@@ -123,10 +122,10 @@ class QQuickLayoutAttached : public QObject
public:
QQuickLayoutAttached(QObject *object);
qreal minimumWidth() const { return m_minimumWidth; }
qreal minimumWidth() const { return m_minimumWidth < 0 ? sizeHint(Qt::MinimumSize, Qt::Horizontal) : m_minimumWidth; }
void setMinimumWidth(qreal width);
qreal minimumHeight() const { return m_minimumHeight; }
qreal minimumHeight() const { return m_minimumHeight < 0 ? sizeHint(Qt::MinimumSize, Qt::Vertical) : m_minimumHeight; }
void setMinimumHeight(qreal height);
qreal preferredWidth() const { return m_preferredWidth; }
......@@ -135,10 +134,10 @@ public:
qreal preferredHeight() const { return m_preferredHeight; }
void setPreferredHeight(qreal width);
qreal maximumWidth() const { return m_maximumWidth; }
qreal maximumWidth() const { return m_maximumWidth < 0 ? sizeHint(Qt::MaximumSize, Qt::Horizontal) : m_maximumWidth; }
void setMaximumWidth(qreal width);
qreal maximumHeight() const { return m_maximumHeight; }
qreal maximumHeight() const { return m_maximumHeight < 0 ? sizeHint(Qt::MaximumSize, Qt::Vertical) : m_maximumHeight; }
void setMaximumHeight(qreal height);
void setMinimumImplicitSize(const QSizeF &sz);
......@@ -174,6 +173,8 @@ public:
return old;
}
qreal sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const;
signals:
void minimumWidthChanged();
void minimumHeightChanged();
......
......@@ -171,6 +171,12 @@ void QQuickGridLayoutBase::setOrientation(Qt::Orientation orientation)
invalidate();
}
QSizeF QQuickGridLayoutBase::sizeHint(Qt::SizeHint whichSizeHint) const
{
Q_D(const QQuickGridLayoutBase);
return d->engine.sizeHint(whichSizeHint, QSizeF());
}
void QQuickGridLayoutBase::componentComplete()
{
Q_D(QQuickGridLayoutBase);
......@@ -241,9 +247,9 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
QQuickLayoutAttached *info = attachedLayoutObject(this);
const QSizeF min = d->engine.sizeHint(Qt::MinimumSize, QSizeF());
const QSizeF pref = d->engine.sizeHint(Qt::PreferredSize, QSizeF());
const QSizeF max = d->engine.sizeHint(Qt::MaximumSize, QSizeF());
const QSizeF min = sizeHint(Qt::MinimumSize);
const QSizeF pref = sizeHint(Qt::PreferredSize);
const QSizeF max = sizeHint(Qt::MaximumSize);
const bool old = info->setChangesNotificationEnabled(false);
info->setMinimumImplicitSize(min);
......@@ -378,7 +384,7 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
bool QQuickGridLayoutBase::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&info, QSizeF *sizeHints)
{
Q_D(QQuickGridLayoutBase);
bool ignoreItem = false;
bool ignoreItem = true;
if (child->isVisible()) {
QQuickGridLayoutItem::effectiveSizeHints_helper(child, sizeHints, &info, true);
QSizeF effectiveMaxSize = sizeHints[Qt::MaximumSize];
......
......@@ -68,6 +68,7 @@ public:
void invalidate(QQuickItem *childItem = 0);
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orientation);
QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE;
protected:
void updateLayoutItems();
......
......@@ -69,6 +69,8 @@ FocusScope {
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
......@@ -84,11 +86,25 @@ FocusScope {
return null;
}
Row {
ListView {
id: tabrow
objectName: "tabrow"
Accessible.role: Accessible.PageTabList
spacing: -tabOverlap
orientation: Qt.Horizontal
interactive: false
focus: true
width: contentItem ? contentItem.width : 0
height: currentItem ? currentItem.height : 0
displaced: Transition {
NumberAnimation {
property: "x"
duration: 125
easing.type: Easing.OutQuad
}
}
states: [
State {
......@@ -110,60 +126,113 @@ FocusScope {
}
]
model: tabView.__tabs
Repeater {
id: repeater
objectName: "repeater"
delegate: MouseArea {
id: tabitem
objectName: "mousearea"
hoverEnabled: true
focus: true
model: tabView.__tabs
delegate: Item {
id: tabitem
focus: true
property int tabindex: index
property bool selected : tabView.currentIndex === index
property bool hover: mousearea.containsMouse
property string title: modelData.title
property bool nextSelected: tabView.currentIndex === index + 1
property bool previousSelected: tabView.currentIndex === index - 1
z: selected ? 1 : -index
implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/repeater.count) + 1
implicitHeight: tabloader.implicitHeight
Loader {
id: tabloader
sourceComponent: loader.item ? loader.item.tab : null
anchors.fill: parent
property Item control: tabView
property int index: tabindex
property QtObject tab: 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 previsousSelected: tabitem.previousSelected
readonly property alias hovered: tabitem.hover
readonly property bool activeFocus: tabbar.activeFocus
}
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 bool hover: containsMouse
property string title: modelData.title
property bool nextSelected: tabView.currentIndex === index + 1
property bool previousSelected: tabView.currentIndex === index - 1
z: selected ? 1 : -index
implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/tabrow.count) + 1
implicitHeight: tabloader.implicitHeight
onPressed: {
tabView.currentIndex = index;
tabbar.nextItemInFocusChain(true).forceActiveFocus();
}
Loader {
id: tabloader
property Item control: tabView
property int index: tabindex
property QtObject tab: 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 previsousSelected: tabitem.previousSelected
readonly property alias hovered: tabitem.hover
readonly property bool activeFocus: tabbar.activeFocus
}
MouseArea {
id: mousearea
objectName: "mousearea"
anchors.fill: parent
hoverEnabled: true
onPressed: {
tabView.currentIndex = index;
tabbar.nextItemInFocusChain(true).forceActiveFocus();
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
}
}
Accessible.role: Accessible.PageTab
Accessible.name: modelData.title
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
}
}
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)
}
}
}
......
......@@ -543,7 +543,7 @@ void QQuickStyleItem::initStyleOption()
if (opt->tickPosition != QSlider::NoTicks)
opt->subControls |= QStyle::SC_SliderTickmarks;
opt->activeSubControls = QStyle::SC_None;
opt->activeSubControls = QStyle::SC_SliderHandle;
}
break;
case ProgressBar: {
......
......@@ -51,11 +51,14 @@ Style {
maximum: control.maximumValue*100
minimum: control.minimumValue*100
step: control.stepSize*100
value: control.value*100
value: control.__handlePos*100
horizontal: control.orientation === Qt.Horizontal
enabled: control.enabled
hasFocus: control.activeFocus
hints: control.styleHints
activeControl: control.tickmarksEnabled ? "ticks" : ""
property int handleWidth: 15
property int handleHeight: 15
}
property Margins padding: Margins { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
}
......@@ -44,6 +44,7 @@ import QtQuick.Controls.Styles 1.0
Style {
id: root
property bool tabsMovable: false
property int tabsLeftPadding: 0
property int tabsRightPadding: 0
property int tabsAlignment: __barstyle.styleHint("tabbaralignment") === "center" ? Qt.AlignHCenter : Qt.AlignLeft;
......
......@@ -139,6 +139,9 @@ Style {
*/
property Component panel: Item {
id: root
property int handleWidth: handleLoader.width
property int handleHeight: handleLoader.height
property bool horizontal : control.orientation === Qt.Horizontal
property int horizontalSize: grooveLoader.implicitWidth + padding.left + padding.right
property int verticalSize: Math.max(handleLoader.implicitHeight, grooveLoader.implicitHeight) + padding.top + padding.bottom
......@@ -166,7 +169,7 @@ Style {
id: handleLoader
sourceComponent: handle
anchors.verticalCenter: grooveLoader.verticalCenter
x: Math.round(control.value / control.maximumValue * ((horizontal ? root.width : root.height)- item.width))
x: Math.round(control.__handlePos / control.maximumValue * ((horizontal ? root.width : root.height) - item.width))
}
}
}
......
......@@ -83,6 +83,10 @@ Style {
/*! The \l ScrollView attached to this style. */
readonly property TabView control: __control
/*! This property holds whether the user can move the tabs.
Tabs are not movable by default. */
property bool tabsMovable: false
/*! This property holds the horizontal alignment of
the tab buttons. Supported values are:
\list
......
......@@ -44,8 +44,8 @@ import QtQuick.Controls 1.0
Item {
id: main
objectName: "main"
width: 800
height: 600
width: 400
height: 800
focus: true
Component.onCompleted: button1.focus = true
Column {
......@@ -197,6 +197,10 @@ Item {
objectName: "textfield"
text: "abc"
}
TableView {
id: tableview
objectName: "tableview"
}
TextArea {
id: textarea
objectName: "textarea"
......