Source

Target

Commits (26)
Showing with 423 additions and 356 deletions
......@@ -180,6 +180,14 @@ Item {
height: parent.height - group1.height - group2.height - 2 * parent.spacing
anchors { right: parent.right }
}
MouseArea {
id: contextMenu
parent: area.viewport
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: editmenu.popup()
}
}
}
}
......@@ -76,7 +76,6 @@ Item {
GridLayout {
id: gridLayout
anchors.fill: parent
anchors.margins: 4
rows: 3
flow: GridLayout.TopToBottom
......
......@@ -45,127 +45,132 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
import QtQuick.Dialogs 1.0
import QtQuick.Layouts 1.0
Item {
id: root
width: 300
height: 200
ColorDialog {
id: colorDialog
color: "#afe"
property color last: "#afe"
onRejected: color = last
onVisibleChanged: if (visible) last = color
}
Column {
anchors.margins: 20
anchors.horizontalCenter: parent.horizontalCenter
property int columnWidth: 120
GridLayout {
rowSpacing: 12
columnSpacing: 30
anchors.top: parent.top
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
anchors.margins: 30
Row {
spacing: 8
Button {
text: "Set color…"
style: ButtonStyle { }
onClicked: colorDialog.open()
}
Button {
text: "Push me"
style: ButtonStyle { }
}
Button {
text: "Push me"
style: buttonStyle
}
Button {
text: "Push me"
style: ButtonStyle { }
onClicked: colorDialog.open()
implicitWidth: columnWidth
}
Row {
spacing: 8
TextField {
style: TextFieldStyle { }
}
TextField {
style: TextFieldStyle { }
}
TextField {
style: textfieldStyle
}
Button {
text: "Push me"
style: ButtonStyle { }
implicitWidth: columnWidth
}
Button {
text: "Push me"
style: buttonStyle
implicitWidth: columnWidth
}
Row {
spacing: 8
Slider {
value: 50
maximumValue: 100
width: 100
style: SliderStyle { }
}
Slider {
value: 50
maximumValue: 100
width: 100
style: SliderStyle { }
}
Slider {
value: 50
maximumValue: 100
width: 100
style: sliderStyle
}
TextField {
Layout.row: 1
style: TextFieldStyle { }
implicitWidth: columnWidth
}
TextField {
style: TextFieldStyle { }
implicitWidth: columnWidth
}
TextField {
style: textfieldStyle
implicitWidth: columnWidth
}
Row {
spacing: 8
ProgressBar {
value: 50
maximumValue: 100
width: 100
style: ProgressBarStyle{ }
}
ProgressBar {
value: 50
maximumValue: 100
width: 100
style: ProgressBarStyle{ }
}
ProgressBar {
value: 50
maximumValue: 100
width: 100
style: progressbarStyle
}
Slider {
Layout.row: 2
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: SliderStyle { }
}
Slider {
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: SliderStyle { }
}
Slider {
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: sliderStyle
}
Row {
spacing: 8
CheckBox {
text: "CheckBox"
style: CheckBoxStyle{}
}
RadioButton {
style: RadioButtonStyle{}
text: "RadioButton"
}
ProgressBar {
Layout.row: 3
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: ProgressBarStyle{ }
}
ProgressBar {
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: ProgressBarStyle{ }
}
ProgressBar {
value: 50
maximumValue: 100
implicitWidth: columnWidth
style: progressbarStyle
}
ComboBox {
model: ["Paris", "Oslo", "New York"]
style: ComboBoxStyle{}
}
CheckBox {
text: "CheckBox"
style: CheckBoxStyle{}
Layout.row: 4
implicitWidth: columnWidth
}
RadioButton {
style: RadioButtonStyle{}
text: "RadioButton"
implicitWidth: columnWidth
}
Row {
TabView {
width: 400
height: 30
Tab { title: "One" ; Item {}}
Tab { title: "Two" ; Item {}}
Tab { title: "Three" ; Item {}}
Tab { title: "Four" ; Item {}}
style: tabViewStyle
}
ComboBox {
model: ["Paris", "Oslo", "New York"]
style: ComboBoxStyle{}
implicitWidth: columnWidth
}
TabView {
Layout.row: 5
Layout.columnSpan: 3
Layout.fillWidth: true
implicitHeight: 30
Tab { title: "One" ; Item {}}
Tab { title: "Two" ; Item {}}
Tab { title: "Three" ; Item {}}
Tab { title: "Four" ; Item {}}
style: TabViewStyle {}
}
TabView {
Layout.row: 6
Layout.columnSpan: 3
Layout.fillWidth: true
implicitHeight: 30
Tab { title: "One" ; Item {}}
Tab { title: "Two" ; Item {}}
Tab { title: "Three" ; Item {}}
Tab { title: "Four" ; Item {}}
style: tabViewStyle
}
}
......@@ -174,7 +179,7 @@ Item {
property Component buttonStyle: ButtonStyle {
background: Rectangle {
implicitHeight: 20
implicitWidth: 100
implicitWidth: columnWidth
color: control.pressed ? "darkGray" : "lightGray"
antialiasing: true
border.color: "gray"
......@@ -184,7 +189,7 @@ Item {
property Component textfieldStyle: TextFieldStyle {
background: Rectangle {
implicitWidth: 100
implicitWidth: columnWidth
implicitHeight: 20
color: "#f0f0f0"
antialiasing: true
......@@ -205,7 +210,7 @@ Item {
groove: Rectangle {
height: 8
implicitWidth: 100
implicitWidth: columnWidth
implicitHeight: 20
antialiasing: true
......@@ -217,7 +222,7 @@ Item {
property Component progressbarStyle: ProgressBarStyle {
background: Rectangle {
implicitWidth: 100
implicitWidth: columnWidth
implicitHeight: 20
color: "#f0f0f0"
border.color: "gray"
......@@ -225,7 +230,7 @@ Item {
radius: height/2
}
progress: Rectangle {
implicitWidth: 100
implicitWidth: columnWidth
implicitHeight: 20
color: "#c0c0c0"
border.color: "gray"
......@@ -246,18 +251,18 @@ Item {
}
border.color: "#898989"
Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" }
}
tab: Item {
implicitWidth: image.sourceSize.width
property int totalOverlap: tabOverlap * (control.count - 1)
implicitWidth: Math.min ((styleData.availableWidth + totalOverlap)/control.count - 4, image.sourceSize.width)
implicitHeight: image.sourceSize.height
BorderImage {
id: image
anchors.fill: parent
source: styleData.selected ? "../images/tab_selected.png" : "../images/tab.png"
border.left: 50
border.left: 30
smooth: false
border.right: 50
border.right: 30
}
Text {
text: styleData.title
......
......@@ -51,10 +51,11 @@ import "content"
ApplicationWindow {
title: "Component Gallery"
width: 580
width: 600
height: 400
minimumHeight: 400
minimumWidth: 340
minimumWidth: 570
property string loremIpsum:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
......@@ -69,150 +70,112 @@ ApplicationWindow {
onAccepted: imageViewer.open(fileUrl)
}
toolBar: ToolBar {
id: toolbar
RowLayout {
spacing: 2
anchors.verticalCenter: parent.verticalCenter
ToolButton {
iconSource: "images/window-new.png"
anchors.verticalCenter: parent.verticalCenter
onClicked: window1.visible = !window1.visible
Accessible.name: "New window"
tooltip: "Toggle visibility of the second window"
}
ToolButton {
action: openAction
}
ToolButton {
iconSource: "images/document-save-as.png"
anchors.verticalCenter: parent.verticalCenter
tooltip: "(Pretend to) save as..."
}
}
Action {
id: openAction
text: "&Open"
shortcut: "Ctrl+O"
iconSource: "images/document-open.png"
onTriggered: fileDialog.open()
tooltip: "open an image"
}
ChildWindow { id: window1 }
Action {
id: copyAction
text: "&Copy"
shortcut: "Ctrl+C"
iconName: "edit-copy"
enabled: (!!activeFocusItem && !!activeFocusItem["copy"])
onTriggered: activeFocusItem.copy()
}
Action {
id: openAction
text: "&Open"
shortcut: "Ctrl+O"
iconSource: "images/document-open.png"
onTriggered: fileDialog.open()
tooltip: "open an image"
}
Action {
id: cutAction
text: "Cu&t"
shortcut: "Ctrl+X"
iconName: "edit-cut"
enabled: (!!activeFocusItem && !!activeFocusItem["cut"])
onTriggered: activeFocusItem.cut()
}
Action {
id: pasteAction
text: "&Paste"
shortcut: "Ctrl+V"
iconName: "edit-paste"
enabled: (!!activeFocusItem && !!activeFocusItem["paste"])
onTriggered: activeFocusItem.paste()
}
ExclusiveGroup {
id: textFormatGroup
Action {
id: copyAction
text: "&Copy"
shortcut: "Ctrl+C"
iconName: "edit-copy"
enabled: (!!activeFocusItem && !!activeFocusItem["copy"])
onTriggered: activeFocusItem.copy()
id: a1
text: "Align Left"
checkable: true
Component.onCompleted: checked = true
}
Action {
id: cutAction
text: "Cu&t"
shortcut: "Ctrl+X"
iconName: "edit-cut"
enabled: (!!activeFocusItem && !!activeFocusItem["cut"])
onTriggered: activeFocusItem.cut()
id: a2
text: "Center"
checkable: true
}
Action {
id: pasteAction
text: "&Paste"
shortcut: "Ctrl+V"
iconName: "edit-paste"
enabled: (!!activeFocusItem && !!activeFocusItem["paste"])
onTriggered: activeFocusItem.paste()
id: a3
text: "Align Right"
checkable: true
}
}
ExclusiveGroup {
id: textFormatGroup
Action {
id: a1
text: "Align Left"
checkable: true
Component.onCompleted: checked = true
}
Action {
id: a2
text: "Center"
checkable: true
}
Action {
id: a3
text: "Align Right"
checkable: true
}
}
ChildWindow { id: window1 }
Menu {
id: editmenu
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator {}
Menu {
id: editmenu
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator {}
Menu {
title: "Text Format"
MenuItem { action: a1 }
MenuItem { action: a2 }
MenuItem { action: a3 }
MenuSeparator { }
MenuItem { text: "Allow Hyphenation"; checkable: true }
MenuSeparator { }
Menu {
title: "More Stuff"
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator { }
Menu {
title: "More Stuff"
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator { }
Menu {
title: "More Stuff"
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator { }
Menu {
title: "More Stuff"
MenuItem { action: cutAction }
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
}
}
}
}
}
Menu {
title: "Font Style"
MenuItem { text: "Bold"; checkable: true }
MenuItem { text: "Italic"; checkable: true }
MenuItem { text: "Underline"; checkable: true }
}
title: "Text Format"
MenuItem { action: a1 }
MenuItem { action: a2 }
MenuItem { action: a3 }
MenuSeparator { }
MenuItem { text: "Allow Hyphenation"; checkable: true }
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: editmenu.popup()
Menu {
title: "Font Style"
MenuItem { text: "Bold"; checkable: true }
MenuItem { text: "Italic"; checkable: true }
MenuItem { text: "Underline"; checkable: true }
}
}
CheckBox {
id: enabledCheck
text: "Enabled"
checked: true
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
toolBar: ToolBar {
id: toolbar
RowLayout {
id: toolbarLayout
spacing: 0
width: parent.width
ToolButton {
iconSource: "images/window-new.png"
onClicked: window1.visible = !window1.visible
Accessible.name: "New window"
tooltip: "Toggle visibility of the second window"
}
ToolButton { action: openAction }
ToolButton {
iconSource: "images/document-save-as.png"
tooltip: "(Pretend to) save as..."
}
Item { Layout.fillWidth: true }
CheckBox {
id: enabledCheck
text: "Enabled"
checked: true
}
}
}
......
......@@ -61,14 +61,6 @@ ApplicationWindow {
color: "lightsteelblue"
}
Rectangle {
id: column1
width: 200
Layout.minimumWidth: 100
Layout.maximumWidth: 300
color: "lightsteelblue"
}
SplitView {
orientation: Qt.Vertical
Layout.fillWidth: true
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.1
Item {
width: 8
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 6
Rectangle {
width: 1
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
color: "#22000000"
}
Rectangle {
width: 1
height: parent.height
anchors.horizontalCenterOffset: 1
anchors.horizontalCenter: parent.horizontalCenter
color: "#33ffffff"
}
}
......@@ -42,6 +42,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import QtQuick.Window 2.1
import org.qtproject.example 1.0
ApplicationWindow {
......@@ -52,6 +53,37 @@ ApplicationWindow {
title: document.documentTitle + " - Text Editor Example"
ApplicationWindow {
id: aboutBox
width: 280
height: 120
title: "About Text"
ColumnLayout {
anchors.fill: parent
anchors.margins: 8
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Label {
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
text: "This is a basic text editor \nwritten with Qt Quick Controls"
}
}
Button {
text: "Ok"
isDefault: true
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
onClicked: aboutBox.close()
}
Keys.onReturnPressed: aboutBox.close()
focus: true
}
}
Action {
id: cut
text: "Cut"
......@@ -142,12 +174,6 @@ ApplicationWindow {
checkable: true
checked: document.underline
}
Action {
id: color
text: "&Color ..."
iconSource: "images/textcolor.png"
iconName: "format-text-color"
}
FileDialog {
id: file
......@@ -185,13 +211,10 @@ ApplicationWindow {
MenuItem { action: alignCenter }
MenuItem { action: alignRight }
MenuItem { action: alignJustify }
MenuSeparator {}
MenuItem { action: color }
}
Menu {
title: "&Help"
MenuItem { text: "About..." }
MenuItem { text: "About Qt" }
MenuItem { text: "About..." ; onTriggered: aboutBox.show() }
}
}
......@@ -200,19 +223,23 @@ ApplicationWindow {
width: parent.width
RowLayout {
anchors.fill: parent
spacing: 1
spacing: 0
ToolButton { action: fileOpen }
Item { width: 4 }
ToolBarSeparator {}
ToolButton { action: copy }
ToolButton { action: cut }
ToolButton { action: paste }
Item { width: 4 }
ToolBarSeparator {}
ToolButton { action: bold }
ToolButton { action: italic }
ToolButton { action: underline }
Item { width: 4 }
ToolBarSeparator {}
ToolButton { action: alignLeft }
ToolButton { action: alignCenter }
ToolButton { action: alignRight }
......@@ -220,28 +247,13 @@ ApplicationWindow {
Item { Layout.fillWidth: true }
}
}
ToolBar {
id: secondaryToolBar
width: parent.width
RowLayout {
anchors.fill: parent
anchors.margins: 4
ComboBox {
model: document.defaultFontSizes
onCurrentTextChanged: document.fontSize = currentText
currentIndex: document.defaultFontSizes.indexOf(document.fontSize + "")
}
TextField { id: fontEdit; enabled: false }
Item { Layout.fillWidth: true }
}
}
TextArea {
Accessible.name: "document"
id: textArea
frameVisible: false
width: parent.width
anchors.top: secondaryToolBar.bottom
anchors.top: parent.top
anchors.bottom: parent.bottom
text: document.text
textFormat: Qt.RichText
......@@ -254,8 +266,5 @@ ApplicationWindow {
cursorPosition: textArea.cursorPosition
selectionStart: textArea.selectionStart
selectionEnd: textArea.selectionEnd
onCurrentFontChanged: {
fontEdit.text = currentFont.family
}
}
}
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/ToolBarSeparator.qml</file>
<file>qml/images/logo32.png</file>
<file>qml/images/editcopy.png</file>
<file>qml/images/editcut.png</file>
......
......@@ -166,13 +166,11 @@ void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format
void DocumentHandler::setSelectionStart(int position)
{
m_selectionStart = position;
// emit selectionStartChanged();
}
void DocumentHandler::setSelectionEnd(int position)
{
m_selectionEnd = position;
// emit selectionEndChanged();
}
void DocumentHandler::setAlignment(Qt::Alignment a)
......@@ -188,10 +186,8 @@ void DocumentHandler::setAlignment(Qt::Alignment a)
Qt::Alignment DocumentHandler::alignment() const
{
// if (!m_doc || m_doc->isEmpty() || m_cursorPosition < 0)
// return Qt::AlignLeft;
QTextCursor cursor = textCursor();
if (cursor.isNull() || cursor.blockNumber() == 0)
if (cursor.isNull())
return Qt::AlignLeft;
return textCursor().blockFormat().alignment();
}
......@@ -199,7 +195,7 @@ Qt::Alignment DocumentHandler::alignment() const
bool DocumentHandler::bold() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull() || cursor.blockNumber() == 0)
if (cursor.isNull())
return false;
return textCursor().charFormat().fontWeight() == QFont::Bold;
}
......@@ -207,7 +203,7 @@ bool DocumentHandler::bold() const
bool DocumentHandler::italic() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull() || cursor.blockNumber() == 0)
if (cursor.isNull())
return false;
return textCursor().charFormat().fontItalic();
}
......@@ -215,7 +211,7 @@ bool DocumentHandler::italic() const
bool DocumentHandler::underline() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull() || cursor.blockNumber() == 0)
if (cursor.isNull())
return false;
return textCursor().charFormat().fontUnderline();
}
......
......@@ -7,7 +7,8 @@ qtHaveModule(widgets) {
include(src/src.pri)
OTHER_FILES += \
qml/main.qml
qml/main.qml \
qml/ToolBarSeparator.qml
RESOURCES += \
resources.qrc
......@@ -86,7 +86,7 @@ Item {
anchors.margins: 20
style: touchStyle
text: "Dont press me"
onClicked: if (pageStack) pageStack.pop()
onClicked: if (stackView) stackView.pop()
}
}
......
......@@ -54,8 +54,8 @@ ApplicationWindow {
// Implements back key navigation
Keys.onReleased: {
if (event.key === Qt.Key_Back) {
if (pageStack.depth > 1) {
pageStack.pop();
if (stackView.depth > 1) {
stackView.pop();
event.accepted = true;
} else { Qt.quit(); }
}
......@@ -72,7 +72,7 @@ ApplicationWindow {
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: pageStack.depth > 1 ? 1 : 0
opacity: stackView.depth > 1 ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
......@@ -87,7 +87,7 @@ ApplicationWindow {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: pageStack.pop()
onClicked: stackView.pop()
}
}
......@@ -126,7 +126,7 @@ ApplicationWindow {
}
StackView {
id: pageStack
id: stackView
anchors.fill: parent
initialItem: Item {
......@@ -137,7 +137,7 @@ ApplicationWindow {
anchors.fill: parent
delegate: AndroidDelegate {
text: title
onClicked: pageStack.push(Qt.resolvedUrl(page))
onClicked: stackView.push(Qt.resolvedUrl(page))
}
}
}
......
......@@ -80,13 +80,19 @@ import QtQuick.Controls.Private 1.0
Control {
id: comboBox
/*! The model to populate the ComboBox from. */
/*! \qmlproperty model ComboBox::model
The model to populate the ComboBox from. */
property alias model: popupItems.model
/*! The model role used for populating the ComboBox. */
property string textRole: ""
/*! The index of the currently selected item in the ComboBox. */
/*! \qmlproperty int ComboBox::currentIndex
The index of the currently selected item in the ComboBox. */
property alias currentIndex: popup.__selectedIndex
/*! The text of the currently selected item in the ComboBox. */
/*! \qmlproperty string ComboBox::currentText
The text of the currently selected item in the ComboBox. */
readonly property alias currentText: popup.selectedText
/*! This property specifies whether the combobox should gain active focus when pressed.
......
......@@ -159,7 +159,8 @@ Item {
/*! \internal */
property alias __style: styleLoader.item
implicitWidth: (!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin
implicitWidth: Math.max((!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin,
sizeHint.implicitWidth + (checkable ? 24 : 6))
implicitHeight: (!anchors.fill ? container.calcHeight() : 0) + loader.topMargin + loader.bottomMargin
Layout.minimumWidth: implicitWidth
......@@ -181,6 +182,7 @@ Item {
property int rightMargin: __style ? __style.padding.right : 0
sourceComponent: styleLoader.item ? styleLoader.item.panel : null
onLoaded: item.z = -1
Text { id: sizeHint ; visible: false ; text: title }
Loader {
id: styleLoader
property alias __control: groupbox
......
......@@ -123,7 +123,7 @@ Control {
implicitWidth:(__panel ? __panel.implicitWidth : 0)
implicitHeight: (__panel ? __panel.implicitHeight: 0)
/* \internal */
/*! \internal */
function setValue(v) {
var newval = parseFloat(v)
if (!isNaN(newval)) {
......
......@@ -146,8 +146,8 @@ FocusScope {
/*! \internal */
property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root)
/* \internal */
property PaddedStyle __style: styleLoader.item
/*! \internal */
property Style __style: styleLoader.item
activeFocusOnTab: true
......
......@@ -174,19 +174,6 @@ Control {
Accessible.role: Accessible.Slider
Accessible.name: value
/*!
\qmlmethod Slider::formatValue
This method returns the current slider value in a way that is more suitable
for user display, such as the \l value rounded to only two decimal places.
By default this function returns the nearest \c int value.
*/
function formatValue(v) {
return Math.round(v);
}
style: Qt.createComponent(Settings.style + "/SliderStyle.qml", slider)
Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0
......
......@@ -75,6 +75,8 @@ Control {
id: spinbox
/*!
\qmlproperty real SpinBox::value
The value of this SpinBox, clamped to \l minimumValue and \l maximumValue.
The default value is \c{0.0}.
......@@ -82,6 +84,8 @@ Control {
property alias value: validator.value
/*!
\qmlproperty real SpinBox::minimumValue
The minimum value of the SpinBox range.
The \l value is clamped to this value.
......@@ -90,6 +94,8 @@ Control {
property alias minimumValue: validator.minimumValue
/*!
\qmlproperty real SpinBox::maximumValue
The maximum value of the SpinBox range.
The \l value is clamped to this value. If maximumValue is smaller than
\l minimumValue, \l minimumValue will be enforced.
......@@ -98,7 +104,7 @@ Control {
*/
property alias maximumValue: validator.maximumValue
/*!
/*! \qmlproperty real SpinBox::stepSize
The amount by which the \l value is incremented/decremented when a
spin button is pressed.
......@@ -106,13 +112,16 @@ Control {
*/
property alias stepSize: validator.stepSize
/*! The suffix for the value. I.e "cm" */
/*! \qmlproperty string SpinBox::suffix
The suffix for the value. I.e "cm" */
property alias suffix: validator.suffix
/*! The prefix for the value. I.e "$" */
/*! \qmlproperty string SpinBox::prefix
The prefix for the value. I.e "$" */
property alias prefix: validator.prefix
/*! This property indicates the amount of decimals.
/*! \qmlproperty int SpinBox::decimals
This property indicates the amount of decimals.
Note that if you enter more decimals than specified, they will
be truncated to the specified amount of decimal places.
The default value is \c{0}.
......@@ -157,7 +166,7 @@ Control {
readonly property alias downPressed: mouseDown.pressed
readonly property alias downHovered: mouseDown.containsMouse
readonly property alias containsMouse: mouseArea.containsMouse
readonly property alias hovered: mouseArea.containsMouse
readonly property int contentHeight: Math.max(input.implicitHeight, 16)
readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth)
......
......@@ -53,13 +53,14 @@ import QtQuick.Controls.Private 1.0 as Private
SplitView is a control that lays out items horizontally or
vertically with a draggable splitter between each item.
There will always be one (and only one) item in the SplitView that has \l {Layout}{Layout.fillWidth}
set to \c true (or Layout.fillHeight, if orientation is Qt.Vertical). This means that the
There will always be one (and only one) item in the SplitView that has \l{Layout::fillWidth}{Layout.fillWidth}
set to \c true (or \l{Layout::fillHeight}{Layout.fillHeight}, if orientation is Qt.Vertical). This means that the
item will get all leftover space when other items have been laid out.
By default, the last visible child of the SplitView will have this set, but
it can be changed by explicitly setting fillWidth to \c true on another item.
As the fillWidth item will automatically be resized to fit the extra space, explicit assignments
to width and height will be ignored (but Layout.minimumWidth and Layout.maximumWidth will still be respected).
to width and height will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and
\l{Layout::maximumWidth}{Layout.maximumWidth} will still be respected).
A handle can belong to the item either on the left or top side, or on the right or bottom side:
\list
......@@ -69,9 +70,19 @@ import QtQuick.Controls.Private 1.0 as Private
This will again control which item gets resized when the user drags a handle,
and which handle gets hidden when an item is told to hide.
SplitView supports setting attached \l Layout properties on child items, which means that you
can control minimumWidth, minimumHeight, maximumWidth and maximumHeight (in addition
to fillWidth/fillHeight) for each child.
SplitView supports setting attached Layout properties on child items, which
means that you can set the following attached properties for each child:
\list
\li \l{Layout::minimumWidth}{Layout.minimumWidth}
\li \l{Layout::minimumHeight}{Layout.minimumHeight}
\li \l{Layout::preferredWidth}{Layout.preferredWidth}
\li \l{Layout::preferredHeight}{Layout.preferredHeight}
\li \l{Layout::maximumWidth}{Layout.maximumWidth}
\li \l{Layout::maximumHeight}{Layout.maximumHeight}
\li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child)
\li \l{Layout::fillHeight}{Layout.fillHeight} (\c true for only one child)
\endlist
Example:
......@@ -117,14 +128,17 @@ Item {
/*!
This property holds the delegate that will be instantiated between each
child item. Inside the delegate the following properties are available:
\list
\li int \c handleIndex - specifies the index of the splitter handle. The handle
between the first and the second item will get index 0,
the next handle index 1 etc.
\li bool \c pressed: the handle is being pressed.
\li bool \c resizing: the handle is being dragged.
\endlist
*/
\table
\li readonly property bool styleData.index - Specifies the index of the splitter handle. The handle
between the first and the second item will get index 0,
the next handle index 1 etc.
\li readonly property bool styleData.hovered - The handle is being hovered.
\li readonly property bool styleData.pressed - The handle is being pressed.
\li readonly property bool styleData.resizing - The handle is being dragged.
\endtable
*/
property Component handleDelegate: Rectangle {
width: 1
height: 1
......@@ -176,7 +190,7 @@ Item {
continue
if (splitterItems.children.length > 0)
handleLoader.createObject(splitterHandles, {"handleIndex":splitterItems.children.length - 1})
handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1})
item.parent = splitterItems
i-- // item was removed from list
item.widthChanged.connect(d.updateLayout)
......@@ -319,18 +333,21 @@ Item {
id: handleLoader
Loader {
id: itemHandle
property int handleIndex: -1
property alias containsMouse: mouseArea.containsMouse
property alias pressed: mouseArea.pressed
property bool resizing: mouseArea.drag.active
visible: __items[handleIndex + ((d.fillIndex >= handleIndex) ? 0 : 1)].visible
property int __handleIndex: -1
property QtObject styleData: QtObject {
readonly property int index: __handleIndex
readonly property alias hovered: mouseArea.containsMouse
readonly property alias pressed: mouseArea.pressed
readonly property bool resizing: mouseArea.drag.active
onResizingChanged: root.resizing = resizing
}
visible: __items[__handleIndex + ((d.fillIndex >= __handleIndex) ? 0 : 1)].visible
sourceComponent: handleDelegate
onWidthChanged: d.updateLayout()
onHeightChanged: d.updateLayout()
onXChanged: moveHandle()
onYChanged: moveHandle()
onResizingChanged: root.resizing = resizing
MouseArea {
id: mouseArea
......@@ -357,12 +374,12 @@ Item {
var leftEdge, rightEdge, newWidth, leftStopX, rightStopX
var i
if (d.fillIndex > handleIndex) {
if (d.fillIndex > __handleIndex) {
// Resize item to the left.
// Ensure that the handle is not crossing other handles. So
// find the first visible handle to the left to determine the left edge:
leftEdge = 0
for (i=handleIndex-1; i>=0; --i) {
for (i=__handleIndex-1; i>=0; --i) {
leftHandle = __handles[i]
if (leftHandle.visible) {
leftEdge = leftHandle[d.offset] + leftHandle[d.size]
......@@ -371,13 +388,13 @@ Item {
}
// Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX
var min = d.accumulatedSize(handleIndex+1, __items.length, true)
var min = d.accumulatedSize(__handleIndex+1, __items.length, true)
rightStopX = root[d.size] - min - itemHandle[d.size]
leftStopX = Math.max(leftEdge, itemHandle[d.offset])
itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset]))
newWidth = itemHandle[d.offset] - leftEdge
leftItem = __items[handleIndex]
leftItem = __items[__handleIndex]
// The next line will trigger 'updateLayout':
leftItem[d.size] = newWidth
} else {
......@@ -385,7 +402,7 @@ Item {
// Ensure that the handle is not crossing other handles. So
// find the first visible handle to the right to determine the right edge:
rightEdge = root[d.size]
for (i=handleIndex+1; i<__handles.length; ++i) {
for (i=__handleIndex+1; i<__handles.length; ++i) {
rightHandle = __handles[i]
if (rightHandle.visible) {
rightEdge = rightHandle[d.offset]
......@@ -394,13 +411,13 @@ Item {
}
// Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX
min = d.accumulatedSize(0, handleIndex+1, true)
min = d.accumulatedSize(0, __handleIndex+1, true)
leftStopX = min - itemHandle[d.size]
rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset])
itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX))
newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size])
rightItem = __items[handleIndex+1]
rightItem = __items[__handleIndex+1]
// The next line will trigger 'updateLayout':
rightItem[d.size] = newWidth
}
......
......@@ -65,6 +65,8 @@ import "Private/StackView.js" as JSArray
The stack can then be used by invoking its navigation methods. The first item
to show in the StackView is commonly loaded assigning it to \l initialItem.
\note Items pushed onto the stack view have \l{Supported Attached Properties}{Stack attached properties}.
\section1 Basic Navigation
There are three primary navigation operations in StackView: push(), pop() and
replace (you replace by specifying argument \c replace to push()).
......@@ -435,6 +437,15 @@ import "Private/StackView.js" as JSArray
}
}
\endqml
\section1 Supported Attached Properties
Items in a StackView support these attached properties:
\list
\li \l{Stack::index}{Stack.index} - Contains the index of the item inside the StackView
\li \l{Stack::view}{Stack.view} - Contains the StackView the item is in
\li \l{Stack::status}{Stack.status} - Contains the status of the item
\endlist
*/
Item {
......@@ -797,7 +808,7 @@ Item {
}
element.item.Stack.__index = element.index
element.item.Stack.__stackView = root
element.item.Stack.__view = root
// Let item fill all available space by default:
element.item.width = Qt.binding(function() { return root.width })
element.item.height = Qt.binding(function() { return root.height })
......@@ -842,7 +853,7 @@ Item {
// might reenter on pop if pushed several times:
item.visible = false
__setStatus(item, Stack.Inactive)
item.Stack.__stackView = null
item.Stack.__view = null
item.Stack.__index = -1
if (element.originalParent)
item.parent = element.originalParent
......@@ -871,7 +882,7 @@ Item {
// Since an item can be pushed several times, we need to update its properties:
enterItem.parent = root
enterItem.Stack.__stackView = root
enterItem.Stack.__view = root
enterItem.Stack.__index = transition.inElement.index
__currentItem = enterItem
......