summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-03-25 10:11:02 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-25 10:11:02 +0100
commitcc7c4ba902ae6ab3b5eba80d7075ad8d6183a7ec (patch)
tree3533a1dee0103a35e1881fe2e9c7a73f6f2d95de /src
parent76dd99c448ae69cb12a0465facc5dd743b94e624 (diff)
parentff5d39f0a8f34cdb034df703e7b2a769c945e1ed (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src')
-rw-r--r--src/controls/ApplicationWindow.qml20
-rw-r--r--src/controls/Calendar.qml15
-rw-r--r--src/controls/CheckBox.qml14
-rw-r--r--src/controls/ComboBox.qml4
-rw-r--r--src/controls/Label.qml2
-rw-r--r--src/controls/Private/ColumnMenuContent.qml74
-rw-r--r--src/controls/Private/ContentItem.qml4
-rw-r--r--src/controls/Private/HoverButton.qml77
-rw-r--r--src/controls/Private/MenuContentItem.qml9
-rw-r--r--src/controls/Private/TabBar.qml1
-rw-r--r--src/controls/Private/private.pri1
-rw-r--r--src/controls/Private/qmldir1
-rw-r--r--src/controls/Private/qquickcontrolsettings.cpp7
-rw-r--r--src/controls/Private/qquickcontrolsettings_p.h2
-rw-r--r--src/controls/Private/qquickstyleitem.cpp84
-rw-r--r--src/controls/Private/qquickstyleitem_p.h1
-rw-r--r--src/controls/ScrollView.qml2
-rw-r--r--src/controls/Slider.qml17
-rw-r--r--src/controls/SpinBox.qml6
-rw-r--r--src/controls/StackView.qml2
-rw-r--r--src/controls/Styles/Base/ButtonStyle.qml2
-rw-r--r--src/controls/Styles/Base/CalendarStyle.qml120
-rw-r--r--src/controls/Styles/Base/MenuStyle.qml3
-rw-r--r--src/controls/Styles/Base/ProgressBarStyle.qml36
-rw-r--r--src/controls/Styles/Base/SpinBoxStyle.qml2
-rw-r--r--src/controls/Styles/Base/SwitchStyle.qml9
-rw-r--r--src/controls/Styles/Base/TabViewStyle.qml1
-rw-r--r--src/controls/Styles/Base/TableViewStyle.qml2
-rw-r--r--src/controls/Styles/Base/TextFieldStyle.qml2
-rw-r--r--src/controls/Styles/Base/images/leftanglearrow.pngbin0 -> 2864 bytes
-rw-r--r--src/controls/Styles/Base/images/rightanglearrow.pngbin0 -> 2886 bytes
-rw-r--r--src/controls/Styles/Desktop/ComboBoxStyle.qml1
-rw-r--r--src/controls/Styles/Desktop/MenuBarStyle.qml22
-rw-r--r--src/controls/Styles/Desktop/MenuStyle.qml25
-rw-r--r--src/controls/Styles/Desktop/TableViewStyle.qml2
-rw-r--r--src/controls/Styles/styles.pri2
-rw-r--r--src/controls/Switch.qml12
-rw-r--r--src/controls/TableView.qml16
-rw-r--r--src/controls/TextArea.qml4
-rw-r--r--src/controls/TextField.qml7
-rw-r--r--src/controls/doc/src/qtquickcontrols.qdoc4
-rw-r--r--src/controls/qquickaction.cpp4
-rw-r--r--src/controls/qquickmenu.cpp9
-rw-r--r--src/controls/qquickmenu_p.h4
-rw-r--r--src/controls/qquickmenuitem.cpp26
-rw-r--r--src/controls/qquickmenuitem_p.h1
-rw-r--r--src/controls/qquickmenupopupwindow.cpp1
-rw-r--r--src/controls/qquickpopupwindow.cpp10
-rw-r--r--src/controls/qquickpopupwindow_p.h2
-rw-r--r--src/dialogs/DefaultDialogWrapper.qml8
-rw-r--r--src/dialogs/DefaultFontDialog.qml2
-rw-r--r--src/dialogs/DefaultMessageDialog.qml4
-rw-r--r--src/dialogs/plugin.cpp1
-rw-r--r--src/dialogs/qquickabstractcolordialog_p.h1
-rw-r--r--src/dialogs/qquickabstractdialog_p.h2
-rw-r--r--src/dialogs/qquickabstractfiledialog_p.h1
-rw-r--r--src/dialogs/qquickabstractfontdialog_p.h1
-rw-r--r--src/dialogs/qquickabstractmessagedialog.cpp4
-rw-r--r--src/dialogs/qquickabstractmessagedialog_p.h3
-rw-r--r--src/dialogs/qquickcolordialog.cpp4
-rw-r--r--src/dialogs/qquickdialog.cpp8
-rw-r--r--src/dialogs/qquickdialog_p.h1
-rw-r--r--src/dialogs/qquickfiledialog.cpp5
-rw-r--r--src/dialogs/qquickfiledialog_p.h2
-rw-r--r--src/dialogs/qquickfontdialog.cpp4
-rw-r--r--src/dialogs/qquickmessagedialog.cpp4
-rw-r--r--src/dialogs/qquickplatformcolordialog.cpp8
-rw-r--r--src/dialogs/qquickplatformfiledialog.cpp8
-rw-r--r--src/dialogs/qquickplatformfontdialog.cpp4
-rw-r--r--src/dialogs/qquickplatformmessagedialog.cpp36
-rw-r--r--src/layouts/qquickgridlayoutengine.cpp10
-rw-r--r--src/layouts/qquickgridlayoutengine_p.h12
-rw-r--r--src/widgets/qmessageboxhelper_p.h24
-rw-r--r--src/widgets/qquickqcolordialog.cpp4
-rw-r--r--src/widgets/qquickqfiledialog.cpp4
-rw-r--r--src/widgets/qquickqfontdialog.cpp4
-rw-r--r--src/widgets/qquickqmessagebox.cpp8
77 files changed, 684 insertions, 165 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index df29e5e23..c8e374adb 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -149,8 +149,24 @@ Window {
*/
readonly property real __qwindowsize_max: (1 << 24) - 1
- width: contentArea.__noImplicitWidthGiven ? 0 : Math.min(Math.max(minimumWidth, contentArea.implicitWidth), maximumWidth)
- height: contentArea.__noImplicitHeightGiven ? 0 : Math.min(Math.max(minimumHeight, contentArea.implicitHeight + __topBottomMargins), maximumHeight)
+ /*! \internal */
+ property real __width: 0
+ Binding {
+ target: root
+ property: "__width"
+ when: root.minimumWidth <= root.maximumWidth
+ value: Math.max(Math.min(root.maximumWidth, contentArea.implicitWidth), root.minimumWidth)
+ }
+ /*! \internal */
+ property real __height: 0
+ Binding {
+ target: root
+ property: "__height"
+ when: root.minimumHeight <= root.maximumHeight
+ value: Math.max(Math.min(root.maximumHeight, contentArea.implicitHeight), root.minimumHeight)
+ }
+ width: contentArea.__noImplicitWidthGiven ? 0 : __width
+ height: contentArea.__noImplicitHeightGiven ? 0 : __height
minimumWidth: contentArea.__noMinimumWidthGiven ? 0 : contentArea.minimumWidth
minimumHeight: contentArea.__noMinimumHeightGiven ? 0 : (contentArea.minimumHeight + __topBottomMargins)
diff --git a/src/controls/Calendar.qml b/src/controls/Calendar.qml
index 07e9b4adf..5b56dc761 100644
--- a/src/controls/Calendar.qml
+++ b/src/controls/Calendar.qml
@@ -156,11 +156,12 @@ Control {
}
/*!
- This property determines the visibility of the grid.
+ This property determines the visibility of the frame
+ surrounding the calendar.
The default value is \c true.
*/
- property bool gridVisible: true
+ property bool frameVisible: true
/*!
This property determines the visibility of week numbers.
@@ -216,6 +217,8 @@ Control {
Emitted when the mouse hovers over a valid date in the calendar.
\a date is the date that was hovered over.
+
+ The corresponding handler is \c onHovered.
*/
signal hovered(date date)
@@ -227,6 +230,8 @@ Control {
This is also emitted when dragging the mouse to another date while it is pressed.
\a date is the date that the mouse was pressed on.
+
+ The corresponding handler is \c onPressed.
*/
signal pressed(date date)
@@ -236,6 +241,8 @@ Control {
Emitted when the mouse is released over a valid date in the calendar.
\a date is the date that the mouse was released over.
+
+ The corresponding handler is \c onReleased.
*/
signal released(date date)
@@ -245,6 +252,8 @@ Control {
Emitted when the mouse is clicked on a valid date in the calendar.
\a date is the date that the mouse was clicked on.
+
+ The corresponding handler is \c onClicked.
*/
signal clicked(date date)
@@ -254,6 +263,8 @@ Control {
Emitted when the mouse is double-clicked on a valid date in the calendar.
\a date is the date that the mouse was double-clicked on.
+
+ The corresponding handler is \c onDoubleClicked.
*/
signal doubleClicked(date date)
diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml
index 00671755c..e96e64fd6 100644
--- a/src/controls/CheckBox.qml
+++ b/src/controls/CheckBox.qml
@@ -132,6 +132,13 @@ AbstractCheckable {
*/
property bool __ignoreChecked: false
+ /*!
+ \internal
+ True if onCheckedStateChanged should be ignored because we were reacting
+ to onCheckedChanged.
+ */
+ property bool __ignoreCheckedState: false
+
style: Qt.createComponent(Settings.style + "/CheckBoxStyle.qml", checkBox)
activeFocusOnTab: true
@@ -142,8 +149,11 @@ AbstractCheckable {
__cycleStatesHandler: __cycleCheckBoxStates
onCheckedChanged: {
- if (!__ignoreChecked)
+ if (!__ignoreChecked) {
+ __ignoreCheckedState = true;
checkedState = checked ? Qt.Checked : Qt.Unchecked;
+ __ignoreCheckedState = false;
+ }
}
onCheckedStateChanged: {
@@ -151,7 +161,7 @@ AbstractCheckable {
if (checkedState === Qt.PartiallyChecked) {
partiallyCheckedEnabled = true;
checked = false;
- } else {
+ } else if (!__ignoreCheckedState) {
checked = checkedState === Qt.Checked;
}
__ignoreChecked = false;
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index f3cde537e..5ce5bf071 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -245,6 +245,8 @@ Control {
\note If there is a \l validator set on the combobox,
the signal will only be emitted if the input is in an acceptable state.
+
+ The corresponding handler is \c onAccepted.
*/
signal accepted
@@ -257,6 +259,8 @@ Control {
This signal is similar to currentIndex changed, but will only
be emitted if the combo box index was changed by the user and not
when set programatically.
+
+ The corresponding handler is \c onActivated.
*/
signal activated(int index)
diff --git a/src/controls/Label.qml b/src/controls/Label.qml
index 8a1020111..658772a83 100644
--- a/src/controls/Label.qml
+++ b/src/controls/Label.qml
@@ -81,7 +81,7 @@ Text {
*/
id: label
- color: pal.text
+ color: pal.windowText
activeFocusOnTab: false
renderType: Text.NativeRendering
SystemPalette {
diff --git a/src/controls/Private/ColumnMenuContent.qml b/src/controls/Private/ColumnMenuContent.qml
index 5a56b007c..40fc907b6 100644
--- a/src/controls/Private/ColumnMenuContent.qml
+++ b/src/controls/Private/ColumnMenuContent.qml
@@ -63,31 +63,96 @@ Item {
readonly property int currentIndex: __menu.__currentIndex
property Item currentItem: null
- readonly property int itemHeight: (list.count > 0 && list.contentItem.children[0]) ? list.contentItem.children[0].height : 23
+ 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.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
- && !currentItem.__menuItem.__popupVisible)
+ && !currentItem.__menuItem.__popupVisible) {
currentItem.__showSubMenu(false)
+ openedSubmenu = currentItem.__menuItem
+ }
} else {
__menu.__currentIndex = -1
}
}
}
+ 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 {
@@ -130,7 +195,8 @@ Item {
hoverEnabled: true
acceptedButtons: Qt.AllButtons
- onPositionChanged: updateCurrentItem(mouse)
+ onPositionChanged: updateCurrentItem({ "x": mouse.x, "y": mouse.y })
+ onPressed: updateCurrentItem({ "x": mouse.x, "y": mouse.y })
onReleased: content.triggered(currentItem)
onExited: {
if (currentItem && !currentItem.__menuItem.__popupVisible) {
diff --git a/src/controls/Private/ContentItem.qml b/src/controls/Private/ContentItem.qml
index dbb4a50e2..edfd309d2 100644
--- a/src/controls/Private/ContentItem.qml
+++ b/src/controls/Private/ContentItem.qml
@@ -45,8 +45,8 @@ Item {
id: contentItem
property real minimumWidth: __calcMinimum('Width')
property real minimumHeight: __calcMinimum('Height')
- property real maximumWidth: __calcMaximum('Width')
- property real maximumHeight: __calcMaximum('Height')
+ property real maximumWidth: Number.POSITIVE_INFINITY
+ property real maximumHeight: Number.POSITIVE_INFINITY
implicitWidth: __calcImplicitWidth()
implicitHeight: __calcImplicitHeight()
diff --git a/src/controls/Private/HoverButton.qml b/src/controls/Private/HoverButton.qml
new file mode 100644
index 000000000..1b79e087a
--- /dev/null
+++ b/src/controls/Private/HoverButton.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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.2
+
+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: implicitWidth/2
+ height: implicitHeight/2
+ anchors.centerIn: parent
+ opacity: 0.6
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: button.clicked()
+ hoverEnabled: true
+ }
+}
diff --git a/src/controls/Private/MenuContentItem.qml b/src/controls/Private/MenuContentItem.qml
index d5d6f69df..f55077a0e 100644
--- a/src/controls/Private/MenuContentItem.qml
+++ b/src/controls/Private/MenuContentItem.qml
@@ -212,11 +212,16 @@ Loader {
Timer {
id: openMenuTimer
- interval: 50
+ interval: d.style.submenuPopupDelay
onTriggered: menuItemLoader.__showSubMenu(true)
}
- function __closeSubMenu() { closeMenuTimer.start() }
+ function __closeSubMenu() {
+ if (openMenuTimer.running)
+ openMenuTimer.stop()
+ else if (__menuItem.__popupVisible)
+ closeMenuTimer.start()
+ }
Timer {
id: closeMenuTimer
diff --git a/src/controls/Private/TabBar.qml b/src/controls/Private/TabBar.qml
index 06bcc2bef..6dc98d1a9 100644
--- a/src/controls/Private/TabBar.qml
+++ b/src/controls/Private/TabBar.qml
@@ -222,6 +222,7 @@ FocusScope {
readonly property alias enabled: tabitem.enabled
readonly property bool activeFocus: tabbar.activeFocus
readonly property real availableWidth: tabbar.availableWidth
+ readonly property real totalWidth: tabrow.contentWidth
}
sourceComponent: loader.item ? loader.item.tab : null
diff --git a/src/controls/Private/private.pri b/src/controls/Private/private.pri
index 49227c9d3..f94468540 100644
--- a/src/controls/Private/private.pri
+++ b/src/controls/Private/private.pri
@@ -53,6 +53,7 @@ PRIVATE_QML_FILES += \
$$PWD/MenuContentItem.qml \
$$PWD/MenuContentScroller.qml \
$$PWD/ContentItem.qml \
+ $$PWD/HoverButton.qml \
$$PWD/qmldir
QML_FILES += $$PRIVATE_QML_FILES
diff --git a/src/controls/Private/qmldir b/src/controls/Private/qmldir
index 997401900..d31483e31 100644
--- a/src/controls/Private/qmldir
+++ b/src/controls/Private/qmldir
@@ -23,4 +23,5 @@ 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 TextSingleton 1.0 TextSingleton.qml
diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp
index d89ffc1ea..e1d0cabb7 100644
--- a/src/controls/Private/qquickcontrolsettings.cpp
+++ b/src/controls/Private/qquickcontrolsettings.cpp
@@ -45,6 +45,8 @@
#include <qqmlengine.h>
#include <qdir.h>
#include <QTouchDevice>
+#include <QGuiApplication>
+#include <QStyleHints>
QT_BEGIN_NAMESPACE
@@ -175,5 +177,10 @@ qreal QQuickControlSettings::dpiScaleFactor() const
return 1.0;
}
+qreal QQuickControlSettings::dragThreshold() const
+{
+ return qApp->styleHints()->startDragDistance();
+}
+
QT_END_NAMESPACE
diff --git a/src/controls/Private/qquickcontrolsettings_p.h b/src/controls/Private/qquickcontrolsettings_p.h
index 2b36e6620..0687e209e 100644
--- a/src/controls/Private/qquickcontrolsettings_p.h
+++ b/src/controls/Private/qquickcontrolsettings_p.h
@@ -56,6 +56,7 @@ class QQuickControlSettings : public QObject
Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged)
Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged)
Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT)
+ Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT)
Q_PROPERTY(bool hasTouchScreen READ hasTouchScreen CONSTANT)
public:
@@ -70,6 +71,7 @@ public:
void setStylePath(const QString &path);
qreal dpiScaleFactor() const;
+ qreal dragThreshold() const;
bool hasTouchScreen() const;
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index 958adbdd9..49baa1fda 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -264,6 +264,8 @@ void QQuickStyleItem::initStyleOption()
(sizeHint == "small") ? QPlatformTheme::SmallFont :
QPlatformTheme::SystemFont;
+ bool needsResolvePalette = true;
+
switch (m_itemType) {
case Button: {
if (!m_styleoption)
@@ -330,6 +332,8 @@ void QQuickStyleItem::initStyleOption()
opt->features = QStyleOptionViewItem::HasDisplay;
opt->text = text();
opt->textElideMode = Qt::ElideRight;
+ resolvePalette();
+ needsResolvePalette = false;
QPalette pal = m_styleoption->palette;
pal.setBrush(QPalette::Base, Qt::NoBrush);
m_styleoption->palette = pal;
@@ -345,6 +349,7 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionHeader *opt = qstyleoption_cast<QStyleOptionHeader*>(m_styleoption);
opt->text = text();
+ opt->textAlignment = static_cast<Qt::AlignmentFlag>(m_properties.value("textalignment").toInt());
opt->sortIndicator = activeControl() == "down" ?
QStyleOptionHeader::SortDown
: activeControl() == "up" ?
@@ -714,6 +719,9 @@ void QQuickStyleItem::initStyleOption()
if (!m_styleoption)
m_styleoption = new QStyleOption();
+ if (needsResolvePalette)
+ resolvePalette();
+
m_styleoption->styleObject = this;
m_styleoption->direction = qApp->layoutDirection();
@@ -755,6 +763,62 @@ void QQuickStyleItem::initStyleOption()
}
+void QQuickStyleItem::resolvePalette()
+{
+ QPlatformTheme::Palette paletteType = QPlatformTheme::SystemPalette;
+ switch (m_itemType) {
+ case Button:
+ paletteType = QPlatformTheme::ButtonPalette;
+ break;
+ case RadioButton:
+ paletteType = QPlatformTheme::RadioButtonPalette;
+ break;
+ case CheckBox:
+ paletteType = QPlatformTheme::CheckBoxPalette;
+ break;
+ case ComboBox:
+ case ComboBoxItem:
+ paletteType = QPlatformTheme::ComboBoxPalette;
+ break;
+ case ToolBar:
+ case ToolButton:
+ paletteType = QPlatformTheme::ToolButtonPalette;
+ break;
+ case Tab:
+ case TabFrame:
+ paletteType = QPlatformTheme::TabBarPalette;
+ break;
+ case Edit:
+ paletteType = QPlatformTheme::TextEditPalette;
+ break;
+ case GroupBox:
+ paletteType = QPlatformTheme::GroupBoxPalette;
+ break;
+ case Header:
+ paletteType = QPlatformTheme::HeaderPalette;
+ break;
+ case Item:
+ case ItemRow:
+ paletteType = QPlatformTheme::ItemViewPalette;
+ break;
+ case Menu:
+ case MenuItem:
+ paletteType = QPlatformTheme::MenuPalette;
+ break;
+ case MenuBar:
+ case MenuBarItem:
+ paletteType = QPlatformTheme::MenuBarPalette;
+ break;
+ default:
+ break;
+ }
+
+ const QPalette *platformPalette = QGuiApplicationPrivate::platformTheme()->palette(paletteType);
+ if (platformPalette)
+ m_styleoption->palette = *platformPalette;
+ // Defaults to SystemPalette otherwise
+}
+
/*
* Property style
*
@@ -1124,11 +1188,9 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
if (metric == "comboboxpopup") {
return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption);
} else if (metric == "highlightedTextColor") {
- QPalette pal = QApplication::palette("QAbstractItemView");
- pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
- return pal.highlightedText().color().name();
+ return m_styleoption->palette.highlightedText().color().name();
} else if (metric == "textColor") {
- QPalette pal = qApp->palette();
+ QPalette pal = m_styleoption->palette;
pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive);
return pal.text().color().name();
} else if (metric == "focuswidget") {
@@ -1144,9 +1206,11 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
return qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition);
else if (metric == "activateItemOnSingleClick")
return qApp->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick);
+ else if (metric == "submenupopupdelay")
+ return qApp->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, m_styleoption);
return 0;
- // Add SH_Menu_SpaceActivatesItem, SH_Menu_SubMenuPopupDelay
+ // Add SH_Menu_SpaceActivatesItem
}
void QQuickStyleItem::setHints(const QVariantMap &str)
@@ -1533,6 +1597,15 @@ void QQuickStyleItem::paint(QPainter *painter)
painter->setPen(pen);
} break;
case SpinBox:
+#ifdef Q_OS_MAC
+ // macstyle depends on the embedded qlineedit to fill the editfield background
+ if (style() == "mac") {
+ QRect editRect = qApp->style()->subControlRect(QStyle::CC_SpinBox,
+ qstyleoption_cast<QStyleOptionComplex*>(m_styleoption),
+ QStyle::SC_SpinBoxEditField);
+ painter->fillRect(editRect.adjusted(-1, -1, 1, 1), m_styleoption->palette.base());
+ }
+#endif
qApp->style()->drawComplexControl(QStyle::CC_SpinBox,
qstyleoption_cast<QStyleOptionComplex*>(m_styleoption),
painter);
@@ -1596,6 +1669,7 @@ void QQuickStyleItem::paint(QPainter *painter)
frame.midLineWidth = 0;
frame.rect = m_styleoption->rect;
frame.styleObject = this;
+ frame.palette = m_styleoption->palette;
qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter);
}
}
diff --git a/src/controls/Private/qquickstyleitem_p.h b/src/controls/Private/qquickstyleitem_p.h
index a13cd4ccf..8d296f257 100644
--- a/src/controls/Private/qquickstyleitem_p.h
+++ b/src/controls/Private/qquickstyleitem_p.h
@@ -192,6 +192,7 @@ public:
void setContentHeight(int arg);
virtual void initStyleOption ();
+ void resolvePalette();
Q_INVOKABLE qreal textWidth(const QString &);
Q_INVOKABLE qreal textHeight(const QString &);
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml
index 7e6163922..af6a077e0 100644
--- a/src/controls/ScrollView.qml
+++ b/src/controls/ScrollView.qml
@@ -237,7 +237,7 @@ FocusScope {
anchors.fill: parent
property int acceleration: 40
- property int flickThreshold: 20
+ property int flickThreshold: Settings.dragThreshold
property real speedThreshold: 3
property real ignored: 0.001 // ## flick() does not work with 0 yVelocity
property int maxFlick: 400
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml
index e09fa1e1c..c2869563a 100644
--- a/src/controls/Slider.qml
+++ b/src/controls/Slider.qml
@@ -216,15 +216,11 @@ Control {
MouseArea {
id: mouseArea
+ anchors.fill: parent
hoverEnabled: true
- anchors.centerIn: parent
-
- preventStealing: true
-
- width: parent.width
- height: parent.height
-
property int clickOffset: 0
+ property real pressX: 0
+ property real pressY: 0
function clamp ( val ) {
return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val))
@@ -234,6 +230,8 @@ Control {
if (pressed && __horizontal) {
var pos = clamp (mouse.x + clickOffset - fakeHandle.width/2)
fakeHandle.x = pos
+ if (Math.abs(mouse.x - pressX) >= Settings.dragThreshold)
+ preventStealing = true
}
}
@@ -241,6 +239,8 @@ Control {
if (pressed && !__horizontal) {
var pos = clamp (mouse.y + clickOffset- fakeHandle.height/2)
fakeHandle.y = pos
+ if (Math.abs(mouse.y - pressY) >= Settings.dragThreshold)
+ preventStealing = true
}
}
@@ -252,6 +252,8 @@ Control {
if (fakeHandle.contains(Qt.point(point.x, point.y))) {
clickOffset = __horizontal ? fakeHandle.width/2 - point.x : fakeHandle.height/2 - point.y
}
+ pressX = mouse.x
+ pressY = mouse.y
}
onReleased: {
@@ -260,6 +262,7 @@ Control {
if (!slider.updateValueWhileDragging)
range.position = __horizontal ? fakeHandle.x : fakeHandle.y;
clickOffset = 0
+ preventStealing = false
}
}
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index 8fc964a06..26ba41b0c 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -172,6 +172,8 @@ Control {
the control loses focus. Note that if there is a validator
set on the control and enter/return is pressed, this signal will
only be emitted if the validator returns an acceptable state.
+
+ The corresponding handler is \c onEditingFinished.
*/
signal editingFinished()
@@ -194,6 +196,9 @@ Control {
/*! \internal */
property alias __text: input.text
+ /*! \internal */
+ property alias __baselineOffset: input.baselineOffset
+
__styleData: QtObject {
readonly property bool upEnabled: value != maximumValue;
readonly property alias upHovered: mouseUp.containsMouse
@@ -256,6 +261,7 @@ Control {
horizontalAlignment: spinbox.horizontalAlignment
verticalAlignment: __panel ? __panel.verticalAlignment : Qt.AlignVCenter
selectByMouse: activeFocus || activeFocusOnPress
+ inputMethodHints: Qt.ImhFormattedNumbersOnly
validator: SpinBoxValidator {
id: validator
diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml
index 2397e5e40..11e2d1825 100644
--- a/src/controls/StackView.qml
+++ b/src/controls/StackView.qml
@@ -819,7 +819,7 @@ Item {
/*! \internal */
function __resolveComponent(unknownObjectType, element)
{
- // We need this extra resolve function since we dont really
+ // We need this extra resolve function since we don't really
// know what kind of object the user pushed. So we try to
// figure it out by inspecting the object:
if (unknownObjectType.hasOwnProperty("createObject")) {
diff --git a/src/controls/Styles/Base/ButtonStyle.qml b/src/controls/Styles/Base/ButtonStyle.qml
index 237b0df0a..35f6bd9bb 100644
--- a/src/controls/Styles/Base/ButtonStyle.qml
+++ b/src/controls/Styles/Base/ButtonStyle.qml
@@ -149,7 +149,7 @@ Style {
renderType: Text.NativeRendering
anchors.verticalCenter: parent.verticalCenter
text: control.text
- color: __syspal.text
+ color: __syspal.buttonText
}
}
}
diff --git a/src/controls/Styles/Base/CalendarStyle.qml b/src/controls/Styles/Base/CalendarStyle.qml
index 40d03636a..34f6eb05a 100644
--- a/src/controls/Styles/Base/CalendarStyle.qml
+++ b/src/controls/Styles/Base/CalendarStyle.qml
@@ -77,9 +77,9 @@ import QtQuick.Controls.Private 1.0
\qml
Calendar {
anchors.centerIn: parent
- gridVisible: false
style: CalendarStyle {
+ gridVisible: false
dayDelegate: Rectangle {
gradient: Gradient {
GradientStop {
@@ -132,7 +132,14 @@ Style {
/*!
The color of the grid lines.
*/
- property color gridColor: "#f0f0f0"
+ property color gridColor: "#d3d3d3"
+
+ /*!
+ This property determines the visibility of the grid.
+
+ The default value is \c true.
+ */
+ property bool gridVisible: true
/*!
\internal
@@ -165,18 +172,29 @@ Style {
Styles the bar at the top of the calendar that contains the
next month/previous month buttons and the selected date label.
*/
- property Component navigationBar: Item {
- height: 50
+ property Component navigationBar: Rectangle {
+ height: 41
+ color: "#f9f9f9"
+
+ Rectangle {
+ color: Qt.rgba(1,1,1,0.6)
+ height: 1
+ width: parent.width
+ }
- Button {
+ Rectangle {
+ anchors.bottom: parent.bottom
+ height: 1
+ width: parent.width
+ color: "#ddd"
+ }
+ HoverButton {
id: previousMonth
- width: parent.height * 0.6
+ width: parent.height
height: width
- anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- anchors.leftMargin: (parent.height - height) / 2
- iconSource: "images/arrow-left.png"
-
+ anchors.left: parent.left
+ source: "images/leftanglearrow.png"
onClicked: control.showPreviousMonth()
}
Label {
@@ -184,7 +202,6 @@ Style {
text: styleData.title
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
font.pointSize: 14
anchors.verticalCenter: parent.verticalCenter
anchors.left: previousMonth.right
@@ -192,15 +209,13 @@ Style {
anchors.right: nextMonth.left
anchors.rightMargin: 2
}
- Button {
+ HoverButton {
id: nextMonth
- width: parent.height * 0.6
+ width: parent.height
height: width
- anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
- anchors.rightMargin: (parent.height - height) / 2
- iconSource: "images/arrow-right.png"
-
+ anchors.right: parent.right
+ source: "images/rightanglearrow.png"
onClicked: control.showNextMonth()
}
}
@@ -232,18 +247,20 @@ Style {
\endtable
*/
property Component dayDelegate: Rectangle {
- color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "white"/*"transparent"*/
- readonly property color sameMonthDateTextColor: "black"
- readonly property color selectedDateColor: __syspal.highlight
+ anchors.fill: parent
+ anchors.margins: styleData.selected ? -1 : 0
+ color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "transparent"
+ readonly property color sameMonthDateTextColor: "#444"
+ readonly property color selectedDateColor: Qt.platform.os === "osx" ? "#3778d0" : __syspal.highlight
readonly property color selectedDateTextColor: "white"
- readonly property color differentMonthDateTextColor: Qt.darker("darkgrey", 1.4);
+ readonly property color differentMonthDateTextColor: "#bbb"
readonly property color invalidDateColor: "#dddddd"
-
Label {
id: dayDelegateText
text: styleData.date.getDate()
anchors.centerIn: parent
horizontalAlignment: Text.AlignRight
+ font.pixelSize: Math.min(parent.height/3, parent.width/3)
color: {
var theColor = invalidDateColor;
if (styleData.valid) {
@@ -261,7 +278,7 @@ Style {
The delegate that styles each weekday.
*/
property Component dayOfWeekDelegate: Rectangle {
- color: "white"
+ color: gridVisible ? "#fcfcfc" : "transparent"
Label {
text: control.__locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat)
anchors.centerIn: parent
@@ -272,10 +289,10 @@ Style {
The delegate that styles each week number.
*/
property Component weekNumberDelegate: Rectangle {
- color: "white"
Label {
text: styleData.weekNumber
anchors.centerIn: parent
+ color: "#444"
}
}
@@ -295,8 +312,8 @@ Style {
readonly property int columns: CalendarUtils.daysInAWeek
// The combined available width and height to be shared amongst each cell.
- readonly property real availableWidth: (viewContainer.width - (control.gridVisible ? __gridLineWidth : 0))
- readonly property real availableHeight: (viewContainer.height - (control.gridVisible ? __gridLineWidth : 0))
+ readonly property real availableWidth: (viewContainer.width - (control.frameVisible ? 2 * __gridLineWidth : 0))
+ readonly property real availableHeight: (viewContainer.height - (control.frameVisible ? 2 * __gridLineWidth : 0))
property int hoveredCellIndex: -1
property int pressedCellIndex: -1
@@ -312,6 +329,7 @@ Style {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
+ anchors.margins: control.frameVisible ? 1 : 0
sourceComponent: navigationBar
property QtObject styleData: QtObject {
@@ -322,10 +340,9 @@ Style {
Row {
id: dayOfWeekHeaderRow
- spacing: (control.gridVisible ? __gridLineWidth : 0)
anchors.top: navigationBarLoader.bottom
anchors.left: parent.left
- anchors.leftMargin: (control.weekNumbersVisible ? weekNumbersItem.width : 0) + (control.gridVisible ? __gridLineWidth : 0)
+ anchors.leftMargin: (control.weekNumbersVisible ? weekNumbersItem.width : 0)
anchors.right: parent.right
height: dayOfWeekHeaderRowHeight
@@ -337,7 +354,7 @@ Style {
Loader {
id: dayOfWeekDelegateLoader
sourceComponent: dayOfWeekDelegate
- width: __cellRectAt(index).width - (control.gridVisible ? __gridLineWidth : 0)
+ width: __cellRectAt(index).width
height: dayOfWeekHeaderRow.height
readonly property var __dayOfWeek: dayOfWeek
@@ -360,16 +377,15 @@ Style {
visible: control.weekNumbersVisible
width: 30
height: viewContainer.height
-
Repeater {
id: weekNumberRepeater
model: panelItem.weeksToShow
Loader {
id: weekNumberDelegateLoader
- y: __cellRectAt(index * panelItem.columns).y + (control.gridVisible ? __gridLineWidth : 0)
+ y: __cellRectAt(index * panelItem.columns).y + (gridVisible ? __gridLineWidth : 0)
width: weekNumbersItem.width
- height: __cellRectAt(index * panelItem.columns).height - (control.gridVisible ? __gridLineWidth : 0)
+ height: __cellRectAt(index * panelItem.columns).height - (control.frameVisible ? __gridLineWidth : 0)
sourceComponent: weekNumberDelegate
readonly property int __index: index
@@ -392,6 +408,17 @@ Style {
}
}
}
+ Rectangle {
+ anchors.topMargin: - navigationBarLoader.height
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+
+ width: 1
+ anchors.rightMargin: -1
+ anchors.right: parent.right
+ color: gridColor
+ }
+
}
// Contains the grid lines and the grid itself.
@@ -402,23 +429,23 @@ Style {
Repeater {
id: verticalGridLineRepeater
- model: panelItem.columns + 1
+ model: panelItem.columns - 1
delegate: Rectangle {
// The last line will be an invalid index, so we must handle it
x: index < panelItem.columns
- ? __cellRectAt(index).x
- : __cellRectAt(panelItem.columns - 1).x + __cellRectAt(panelItem.columns - 1).width
+ ? __cellRectAt(index + 1).x
+ : __cellRectAt(panelItem.columns).x + __cellRectAt(panelItem.columns).width
y: 0
width: __gridLineWidth
height: viewContainer.height
color: gridColor
- visible: control.gridVisible
+ visible: gridVisible
}
}
Repeater {
id: horizontalGridLineRepeater
- model: panelItem.rows + 1
+ model: panelItem.rows
delegate: Rectangle {
x: 0
// The last line will be an invalid index, so we must handle it
@@ -428,7 +455,7 @@ Style {
width: viewContainer.width
height: __gridLineWidth
color: gridColor
- visible: control.gridVisible
+ visible: gridVisible
}
}
@@ -549,11 +576,11 @@ Style {
delegate: Loader {
id: delegateLoader
- x: __cellRectAt(index).x + (control.gridVisible ? __gridLineWidth : 0)
- y: __cellRectAt(index).y + (control.gridVisible ? __gridLineWidth : 0)
- width: __cellRectAt(index).width - (control.gridVisible ? __gridLineWidth : 0)
- height: __cellRectAt(index).height - (control.gridVisible ? __gridLineWidth : 0)
-
+ x: __cellRectAt(index).x + (gridVisible ? __gridLineWidth : 0)
+ y: __cellRectAt(index).y + (gridVisible ? __gridLineWidth : 0)
+ width: __cellRectAt(index).width - (gridVisible ? __gridLineWidth : 0)
+ height: __cellRectAt(index).height - (gridVisible ? __gridLineWidth : 0)
+ z: styleData.selected ? 1 : 0
sourceComponent: dayDelegate
readonly property int __index: index
@@ -579,5 +606,12 @@ Style {
}
}
}
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ border.color: gridColor
+ visible: control.frameVisible
+ }
+
}
}
diff --git a/src/controls/Styles/Base/MenuStyle.qml b/src/controls/Styles/Base/MenuStyle.qml
index bec8410b7..67aed5e5d 100644
--- a/src/controls/Styles/Base/MenuStyle.qml
+++ b/src/controls/Styles/Base/MenuStyle.qml
@@ -93,6 +93,9 @@ Style {
/*! The amount of pixels by which a submenu popup overlaps horizontally its parent menu. */
property int submenuOverlap: 1
+ /*! The number of milliseconds to wait before opening a submenu. */
+ property int submenuPopupDelay: 200
+
/*! Returns a rich-text string to render mnemonics for a given menu item.
The mnemonic character is prefixed by an ampersand in the original string.
diff --git a/src/controls/Styles/Base/ProgressBarStyle.qml b/src/controls/Styles/Base/ProgressBarStyle.qml
index d8ff8140e..d0fa9a355 100644
--- a/src/controls/Styles/Base/ProgressBarStyle.qml
+++ b/src/controls/Styles/Base/ProgressBarStyle.qml
@@ -70,6 +70,42 @@ import QtQuick.Controls.Private 1.0
}
}
\endqml
+
+ Note that the example above is somewhat simplified and will not animate
+ an indeterminate progress bar. The following snippet demonstrates
+ how you can incorporate a custom animation for the indeterminate
+ state as well.
+
+ \code
+ progress: Rectangle {
+ border.color: "steelblue"
+ color: "lightsteelblue"
+
+ // Indeterminate animation by animating alternating stripes:
+ Item {
+ anchors.fill: parent
+ anchors.margins: 1
+ visible: control.indeterminate
+ clip: true
+ Row {
+ Repeater {
+ Rectangle {
+ color: index % 2 ? "steelblue" : "lightsteelblue"
+ width: 20 ; height: control.height
+ }
+ model: control.width / 20 + 2
+ }
+ XAnimator on x {
+ from: 0 ; to: -40
+ loops: Animation.Infinite
+ running: control.indeterminate
+ }
+ }
+ }
+ }
+ \endcode
+
+
*/
Style {
diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml
index 9cedf2b98..183b36b8b 100644
--- a/src/controls/Styles/Base/SpinBoxStyle.qml
+++ b/src/controls/Styles/Base/SpinBoxStyle.qml
@@ -142,6 +142,7 @@ Style {
property Component background: Item {
implicitHeight: Math.max(25, Math.round(styleData.contentHeight * 1.2))
implicitWidth: styleData.contentWidth + padding.left + padding.right
+ baselineOffset: control.__baselineOffset
Rectangle {
anchors.fill: parent
anchors.bottomMargin: -1
@@ -166,6 +167,7 @@ Style {
id: styleitem
implicitWidth: backgroundLoader.implicitWidth
implicitHeight: backgroundLoader.implicitHeight
+ baselineOffset: backgroundLoader.item ? backgroundLoader.item.baselineOffset : 0
property color foregroundColor: spinboxStyle.textColor
property color selectionColor: spinboxStyle.selectionColor
diff --git a/src/controls/Styles/Base/SwitchStyle.qml b/src/controls/Styles/Base/SwitchStyle.qml
index 687966453..94e862704 100644
--- a/src/controls/Styles/Base/SwitchStyle.qml
+++ b/src/controls/Styles/Base/SwitchStyle.qml
@@ -125,9 +125,9 @@ Style {
implicitWidth: Math.round(grooveLoader.width + padding.left + padding.right)
implicitHeight: grooveLoader.implicitHeight + padding.top + padding.bottom
- property var __groove: grooveLoader
property var __handle: handleLoader
- property bool enableAnimation: false
+ property int min: padding.left
+ property int max: grooveLoader.width - handleLoader.width - padding.right
Loader {
id: grooveLoader
@@ -142,6 +142,9 @@ Style {
id: handleLoader
z:1
+
+ x: control.checked ? max : min
+
anchors.top: grooveLoader.top
anchors.bottom: grooveLoader.bottom
anchors.topMargin: padding.top
@@ -149,7 +152,7 @@ Style {
Behavior on x {
id: behavior
- enabled: enableAnimation
+ enabled: handleLoader.status === Loader.Ready
NumberAnimation {
duration: 150
easing.type: Easing.OutCubic
diff --git a/src/controls/Styles/Base/TabViewStyle.qml b/src/controls/Styles/Base/TabViewStyle.qml
index ce00da5f3..448a2feb5 100644
--- a/src/controls/Styles/Base/TabViewStyle.qml
+++ b/src/controls/Styles/Base/TabViewStyle.qml
@@ -132,6 +132,7 @@ Style {
\row \li readonly property bool \b styleData.enabled \li The tab is enabled. (since QtQuick.Controls.Styles 1.2)
\row \li readonly property bool \b styleData.activeFocus \li The tab button has keyboard focus.
\row \li readonly property bool \b styleData.availableWidth \li The available width for the tabs.
+ \row \li readonly property bool \b styleData.totalWidth \li The total width of the tabs. (since QtQuick.Controls.Styles 1.2)
\endtable
*/
property Component tab: Item {
diff --git a/src/controls/Styles/Base/TableViewStyle.qml b/src/controls/Styles/Base/TableViewStyle.qml
index 512b0cfef..0c01cfee8 100644
--- a/src/controls/Styles/Base/TableViewStyle.qml
+++ b/src/controls/Styles/Base/TableViewStyle.qml
@@ -87,7 +87,7 @@ ScrollViewStyle {
id: textItem
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignLeft
+ horizontalAlignment: styleData.textAlignment
anchors.leftMargin: 12
text: styleData.value
elide: Text.ElideRight
diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml
index 4713130f3..1b732cee7 100644
--- a/src/controls/Styles/Base/TextFieldStyle.qml
+++ b/src/controls/Styles/Base/TextFieldStyle.qml
@@ -116,6 +116,7 @@ Style {
property Component background: Item {
implicitWidth: Math.round(control.__contentHeight * 8)
implicitHeight: Math.max(25, Math.round(control.__contentHeight * 1.2))
+ baselineOffset: control.__baselineOffset
Rectangle {
anchors.fill: parent
anchors.bottomMargin: -1
@@ -150,6 +151,7 @@ Style {
implicitWidth: backgroundLoader.implicitWidth ? backgroundLoader.implicitWidth : 100
implicitHeight: backgroundLoader.implicitHeight ? backgroundLoader.implicitHeight : 20
+ baselineOffset: backgroundLoader.item ? padding.top + backgroundLoader.item.baselineOffset : 0
property color placeholderTextColor: style.placeholderTextColor
property font font: style.font
diff --git a/src/controls/Styles/Base/images/leftanglearrow.png b/src/controls/Styles/Base/images/leftanglearrow.png
new file mode 100644
index 000000000..d4e85ae05
--- /dev/null
+++ b/src/controls/Styles/Base/images/leftanglearrow.png
Binary files differ
diff --git a/src/controls/Styles/Base/images/rightanglearrow.png b/src/controls/Styles/Base/images/rightanglearrow.png
new file mode 100644
index 000000000..a81575385
--- /dev/null
+++ b/src/controls/Styles/Base/images/rightanglearrow.png
Binary files differ
diff --git a/src/controls/Styles/Desktop/ComboBoxStyle.qml b/src/controls/Styles/Desktop/ComboBoxStyle.qml
index 613bba04e..12376ff7d 100644
--- a/src/controls/Styles/Desktop/ComboBoxStyle.qml
+++ b/src/controls/Styles/Desktop/ComboBoxStyle.qml
@@ -87,6 +87,7 @@ Style {
property Component __dropDownStyle: Style {
property int __maxPopupHeight: 600
property int submenuOverlap: 0
+ property int submenuPopupDelay: 0
property Component frame: StyleItem {
elementType: "frame"
diff --git a/src/controls/Styles/Desktop/MenuBarStyle.qml b/src/controls/Styles/Desktop/MenuBarStyle.qml
index c032a7c0b..6135bbdb1 100644
--- a/src/controls/Styles/Desktop/MenuBarStyle.qml
+++ b/src/controls/Styles/Desktop/MenuBarStyle.qml
@@ -44,30 +44,38 @@ import QtQuick.Controls.Private 1.0
import "." as Desktop
Style {
+ id: styleRoot
+
property Component background: StyleItem {
elementType: "menubar"
- width: implicitWidth + 2 * (pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth"))
- height: implicitHeight + 2 * (pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth"))
- + pixelMetric("spacebelowmenubar")
Accessible.role: Accessible.MenuBar
+
+ Component.onCompleted: {
+ styleRoot.padding.left = pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth")
+ styleRoot.padding.right = pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth")
+ styleRoot.padding.top = pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth")
+ styleRoot.padding.bottom = pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth")
+ }
}
property Component itemDelegate: StyleItem {
elementType: "menubaritem"
text: styleData.text
- contentWidth: textWidth(text)
- contentHeight: textHeight(text)
- width: implicitWidth + pixelMetric("menubaritemspacing")
+ property string plainText: StyleHelpers.removeMnemonics(text)
+ contentWidth: textWidth(plainText)
+ contentHeight: textHeight(plainText)
+ width: implicitWidth
enabled: styleData.enabled
sunken: styleData.open
+ selected: (parent && styleData.selected) || sunken
hints: { "showUnderlined": styleData.underlineMnemonic }
Accessible.role: Accessible.MenuItem
- Accessible.name: StyleHelpers.removeMnemonics(text)
+ Accessible.name: plainText
}
property Component menuStyle: Desktop.MenuStyle { }
diff --git a/src/controls/Styles/Desktop/MenuStyle.qml b/src/controls/Styles/Desktop/MenuStyle.qml
index b44dd70d7..6cf67b1c7 100644
--- a/src/controls/Styles/Desktop/MenuStyle.qml
+++ b/src/controls/Styles/Desktop/MenuStyle.qml
@@ -49,15 +49,12 @@ Style {
property string __menuItemType: "menuitem"
property int submenuOverlap: 0
+ property int submenuPopupDelay: 0
property int __maxPopupHeight: 0
property Component frame: StyleItem {
elementType: "menu"
- contentWidth: parent ? Math.round(parent.contentWidth) : 0
- contentHeight: parent ? Math.round(parent.contentHeight) : 0
- width: implicitWidth + 2 * (pixelMetric("menuhmargin") + pixelMetric("menupanelwidth"))
- height: implicitHeight + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
Rectangle {
visible: anchors.margins > 0
anchors {
@@ -69,16 +66,16 @@ Style {
Accessible.role: Accessible.PopupMenu
- Binding {
- target: styleRoot
- property: "submenuOverlap"
- value: 2 * pixelMetric("menupanelwidth")
- }
-
- Binding {
- target: styleRoot
- property: "margin"
- value: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
+ Component.onCompleted: {
+ var menuHMargin = pixelMetric("menuhmargin")
+ var menuVMargin = pixelMetric("menuvmargin")
+ var menuPanelWidth = pixelMetric("menupanelwidth")
+ styleRoot.padding.left = menuHMargin + menuPanelWidth
+ styleRoot.padding.right = menuHMargin + menuPanelWidth
+ styleRoot.padding.top = menuVMargin + menuPanelWidth
+ styleRoot.padding.bottom = menuVMargin + menuPanelWidth
+ styleRoot.submenuOverlap = 2 * menuPanelWidth
+ styleRoot.submenuPopupDelay = styleHint("submenupopupdelay")
}
// ### The Screen attached property can only be set on an Item,
diff --git a/src/controls/Styles/Desktop/TableViewStyle.qml b/src/controls/Styles/Desktop/TableViewStyle.qml
index 88611ab5c..b9891b317 100644
--- a/src/controls/Styles/Desktop/TableViewStyle.qml
+++ b/src/controls/Styles/Desktop/TableViewStyle.qml
@@ -75,7 +75,7 @@ ScrollViewStyle {
text: styleData.value
hover: styleData.containsMouse
hints: control.styleHints
- properties: {"headerpos": headerPosition}
+ properties: {"headerpos": headerPosition, "textalignment": styleData.textAlignment}
property string itemSort: (control.sortIndicatorVisible && styleData.column === control.sortIndicatorColumn) ? (control.sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
property string headerPosition: control.columnCount === 1 ? "only" :
styleData.column === control.columnCount-1 ? "end" :
diff --git a/src/controls/Styles/styles.pri b/src/controls/Styles/styles.pri
index 9199dfc58..ddc867a59 100644
--- a/src/controls/Styles/styles.pri
+++ b/src/controls/Styles/styles.pri
@@ -75,6 +75,8 @@ STYLES_QML_FILES += \
$$PWD/Base/images/arrow-left@2x.png \
$$PWD/Base/images/arrow-right.png \
$$PWD/Base/images/arrow-right@2x.png \
+ $$PWD/Base/images/leftanglearrow.png \
+ $$PWD/Base/images/rightanglearrow.png \
$$PWD/Base/images/spinner_small.png \
$$PWD/Base/images/spinner_medium.png \
$$PWD/Base/images/spinner_large.png \
diff --git a/src/controls/Switch.qml b/src/controls/Switch.qml
index bed46a844..668ee22f4 100644
--- a/src/controls/Switch.qml
+++ b/src/controls/Switch.qml
@@ -102,10 +102,9 @@ Control {
MouseArea {
id: internal
- property Item handle: __panel ? __panel.__handle : null
- property int min: __style ? __style.padding.left : 0
- property int max: handle.parent.width - (handle ? handle.width : 0) -
- ( __style ? __style.padding.right : 0)
+ property Item handle: __panel.__handle
+ property int min: __panel.min
+ property int max: __panel.max
focus: true
anchors.fill: parent
drag.threshold: 0
@@ -129,11 +128,6 @@ Control {
}
}
- Component.onCompleted: {
- internal.handle.x = checked ? internal.max : internal.min
- __panel.enableAnimation = true
- }
-
onCheckedChanged: {
if (internal.handle)
internal.handle.x = checked ? internal.max : internal.min
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index 4a1f6a624..3eb73cf67 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -255,6 +255,8 @@ ScrollView {
\a row int provides access to the activated row index.
\note This signal is only emitted for mouse interaction that is not blocked in the row or item delegate.
+
+ The corresponding handler is \c onActivated.
*/
signal activated(int row)
@@ -265,6 +267,8 @@ ScrollView {
\a row int provides access to the clicked row index.
\note This signal is only emitted if the row or item delegate does not accept mouse events.
+
+ The corresponding handler is \c onClicked.
*/
signal clicked(int row)
@@ -275,6 +279,8 @@ ScrollView {
\a row int provides access to the clicked row index.
\note This signal is only emitted if the row or item delegate does not accept mouse events.
+
+ The corresponding handler is \c onDoubleClicked.
*/
signal doubleClicked(int row)
@@ -536,7 +542,7 @@ ScrollView {
ListView {
id: listView
focus: true
- activeFocusOnTab: true
+ activeFocusOnTab: root.activeFocusOnTab
anchors.topMargin: tableHeader.height
anchors.fill: parent
currentIndex: -1
@@ -873,7 +879,7 @@ ScrollView {
sourceComponent: columnItem.delegate ? columnItem.delegate : itemDelegate
// these properties are exposed to the item delegate
- readonly property var model: listView.model
+ readonly property var model: itemModel
readonly property var modelData: itemModelData
property QtObject styleData: QtObject {
@@ -929,6 +935,7 @@ ScrollView {
model: columnModel
delegate: Item {
+ id: headerRowDelegate
z:-index
width: columnCount === 1 ? viewport.width + __verticalScrollBar.width : modelData.width
implicitWidth: headerStyle.implicitWidth
@@ -974,7 +981,7 @@ ScrollView {
onPositionChanged: {
if (modelData.movable && pressed && columnCount > 1) { // only do this while dragging
for (var h = columnCount-1 ; h >= 0 ; --h) {
- if (drag.target.x > headerrow.children[h].x) {
+ if (drag.target.x + listView.contentX + headerRowDelegate.width/2 > headerrow.children[h].x) {
repeater.targetIndex = h
break
}
@@ -984,7 +991,6 @@ ScrollView {
onPressed: {
repeater.dragIndex = index
- draghandle.x = parent.x
}
onReleased: {
@@ -1012,8 +1018,8 @@ ScrollView {
readonly property int column: index
readonly property int textAlignment: modelData.horizontalAlignment
}
-
parent: tableHeader
+ x: headerRowDelegate.x - listView.contentX
width: modelData.width
height: parent.height
sourceComponent: root.headerDelegate
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 751e7ce0c..876a2270f 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -383,6 +383,8 @@ ScrollView {
This signal is emitted when the user clicks on a link embedded in the text.
The link must be in rich text or HTML format and the
\a link string provides access to the particular link.
+
+ The corresponding handler is \c onLinkActivated.
*/
signal linkActivated(string link)
@@ -395,6 +397,8 @@ ScrollView {
\a link string provides access to the particular link.
\sa hoveredLink
+
+ The corresponding handler is \c onLinkHovered.
*/
signal linkHovered(string link)
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
index b173c95db..7217caa21 100644
--- a/src/controls/TextField.qml
+++ b/src/controls/TextField.qml
@@ -401,6 +401,8 @@ Control {
Note that if there is a \l validator or \l inputMask set on the text
field, the signal will only be emitted if the input is in an acceptable
state.
+
+ The corresponding handler is \c onAccepted.
*/
signal accepted()
@@ -413,6 +415,8 @@ Control {
inputMask set on the text field and enter/return is pressed, this
signal will only be emitted if the input follows
the inputMask and the validator returns an acceptable state.
+
+ The corresponding handler is \c onEditingFinished.
*/
signal editingFinished()
@@ -549,6 +553,9 @@ Control {
/*! \internal */
property alias __contentWidth: textInput.contentWidth
+ /*! \internal */
+ property alias __baselineOffset: textInput.baselineOffset
+
style: Qt.createComponent(Settings.style + "/TextFieldStyle.qml", textInput)
activeFocusOnTab: true
diff --git a/src/controls/doc/src/qtquickcontrols.qdoc b/src/controls/doc/src/qtquickcontrols.qdoc
index 05d9593a8..bc18bbb80 100644
--- a/src/controls/doc/src/qtquickcontrols.qdoc
+++ b/src/controls/doc/src/qtquickcontrols.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \qmlmodule QtQuick.Controls 1.1
+ \qmlmodule QtQuick.Controls 1.2
\title Qt Quick Controls QML Types
\ingroup qmlmodules
\brief Provides QML types for user interfaces.
@@ -41,7 +41,7 @@
following import statement in your .qml file.
\code
- import QtQuick.Controls 1.1
+ import QtQuick.Controls 1.2
\endcode
*/
diff --git a/src/controls/qquickaction.cpp b/src/controls/qquickaction.cpp
index 3c4bfed6b..541e9a5d3 100644
--- a/src/controls/qquickaction.cpp
+++ b/src/controls/qquickaction.cpp
@@ -178,6 +178,8 @@ QT_BEGIN_NAMESPACE
Emitted when either the menu item or its bound action have been activated. Includes
the object that triggered the event if relevant (e.g. a Button or MenuItem).
You shouldn't need to emit this signal, use \l trigger() instead.
+
+ The corresponding handler is \c onTriggered.
*/
/*! \qmlmethod Action::trigger(QObject *source)
@@ -191,6 +193,8 @@ QT_BEGIN_NAMESPACE
Emitted whenever a action's \l checked property changes.
This usually happens at the same time as \l triggered.
+
+ The corresponding handler is \c onToggled.
*/
QQuickAction::QQuickAction(QObject *parent)
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index 7aa52d56a..bb4c79b64 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -398,6 +398,7 @@ void QQuickMenu::__popup(qreal x, qreal y, int atItemIndex)
m_popupWindow->setItemAt(atItem ? atItem->visualItem() : 0);
connect(m_popupWindow, SIGNAL(visibleChanged(bool)), this, SLOT(windowVisibleChanged(bool)));
+ connect(m_popupWindow, SIGNAL(geometryChanged()), this, SIGNAL(__popupGeometryChanged()));
m_popupWindow->setPosition(x + m_xOffset, y + m_yOffset);
m_popupWindow->show();
@@ -420,6 +421,14 @@ void QQuickMenu::setPopupVisible(bool v)
}
}
+QRect QQuickMenu::popupGeometry() const
+{
+ if (!m_popupWindow || !m_popupVisible)
+ return QRect();
+
+ return m_popupWindow->geometry();
+}
+
void QQuickMenu::__closeMenu()
{
setPopupVisible(false);
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index c6bf24e29..85cc0107f 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -74,6 +74,7 @@ class QQuickMenu : public QQuickMenuText
Q_PROPERTY(qreal __xOffset READ xOffset WRITE setXOffset)
Q_PROPERTY(qreal __yOffset READ yOffset WRITE setYOffset)
Q_PROPERTY(QQuickAction *__action READ action CONSTANT)
+ Q_PROPERTY(QRect __popupGeometry READ popupGeometry NOTIFY __popupGeometryChanged)
public:
Q_INVOKABLE void popup();
@@ -99,6 +100,7 @@ Q_SIGNALS:
void __selectedIndexChanged();
void __menuClosed();
void popupVisibleChanged();
+ void __popupGeometryChanged();
void menuContentItemChanged();
void minimumWidthChanged();
@@ -134,6 +136,8 @@ public:
bool isNative() { return m_platformMenu != 0; }
+ QRect popupGeometry() const;
+
protected Q_SLOTS:
void updateSelectedIndex();
diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp
index 2f2f578fb..0167bebd1 100644
--- a/src/controls/qquickmenuitem.cpp
+++ b/src/controls/qquickmenuitem.cpp
@@ -342,6 +342,8 @@ void QQuickMenuText::updateIcon()
Emitted when either the menu item or its bound action have been activated.
\sa trigger(), Action::triggered, Action::toggled
+
+ The corresponding handler is \c onTriggered.
*/
/*! \qmlmethod MenuItem::trigger()
@@ -404,6 +406,8 @@ void QQuickMenuText::updateIcon()
This usually happens at the same time as \l triggered.
\sa checked, triggered, Action::triggered, Action::toggled
+
+ The corresponding handler is \c onToggled.
*/
/*!
@@ -426,6 +430,7 @@ QQuickMenuItem::QQuickMenuItem(QObject *parent)
connect(action(), SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered()));
+ connect(action(), SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
if (platformItem())
connect(platformItem(), SIGNAL(activated()), this, SLOT(trigger()), Qt::QueuedConnection);
@@ -457,7 +462,7 @@ void QQuickMenuItem::bindToAction(QQuickAction *action)
connect(m_boundAction, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
connect(m_boundAction, SIGNAL(textChanged()), this, SLOT(updateText()));
connect(m_boundAction, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
- connect(m_boundAction, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ connect(m_boundAction, SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
connect(m_boundAction, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
connect(m_boundAction, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
@@ -493,7 +498,7 @@ void QQuickMenuItem::unbindFromAction(QObject *o)
disconnect(action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
disconnect(action, SIGNAL(textChanged()), this, SLOT(updateText()));
disconnect(action, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
- disconnect(action, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ disconnect(action, SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
disconnect(action, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
disconnect(action, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
disconnect(action, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
@@ -512,12 +517,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a)
if (a == m_boundAction)
return;
- if (m_boundAction) {
- if (m_boundAction->parent() == this)
- delete m_boundAction;
- else
- unbindFromAction(m_boundAction);
- }
+ unbindFromAction(m_boundAction);
bindToAction(a);
emit actionChanged();
@@ -592,6 +592,16 @@ void QQuickMenuItem::setCheckable(bool checkable)
action()->setCheckable(checkable);
}
+void QQuickMenuItem::updateCheckable()
+{
+ if (platformItem()) {
+ platformItem()->setCheckable(checkable());
+ syncWithPlatformMenu();
+ }
+
+ emit checkableChanged();
+}
+
bool QQuickMenuItem::checked() const
{
return action()->isChecked();
diff --git a/src/controls/qquickmenuitem_p.h b/src/controls/qquickmenuitem_p.h
index a2e74d7f5..bb1686f7f 100644
--- a/src/controls/qquickmenuitem_p.h
+++ b/src/controls/qquickmenuitem_p.h
@@ -225,6 +225,7 @@ public:
protected Q_SLOTS:
void updateShortcut();
+ void updateCheckable();
void updateChecked();
void bindToAction(QQuickAction *action);
void unbindFromAction(QObject *action);
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index 1c2ea15c2..ec33b0c14 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -117,6 +117,7 @@ void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
posy = qBound(g.top(), posy, g.bottom() - h);
QQuickWindow::setGeometry(posx, posy, w, h);
+ emit geometryChanged();
}
void QQuickMenuPopupWindow::updateSize()
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 02c50a85a..27f4b34a1 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -54,6 +54,14 @@ QQuickPopupWindow::QQuickPopupWindow() :
{
setFlags(Qt::Popup);
setModality(Qt::ApplicationModal);
+ connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
+ this, SLOT(applicationStateChanged(Qt::ApplicationState)));
+}
+
+void QQuickPopupWindow::applicationStateChanged(Qt::ApplicationState state)
+{
+ if (state != Qt::ApplicationActive)
+ dismissPopup();
}
void QQuickPopupWindow::show()
@@ -86,6 +94,7 @@ void QQuickPopupWindow::show()
} else {
setPosition(posx, posy);
}
+ emit geometryChanged();
if (!qobject_cast<QQuickPopupWindow *>(transientParent())) // No need for parent menu windows
if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent()))
@@ -119,6 +128,7 @@ void QQuickPopupWindow::updateSize()
{
QSize contentSize = popupContentItem()->childrenRect().size().toSize();
setGeometry(x(), y(), contentSize.width(), contentSize.height());
+ emit geometryChanged();
}
void QQuickPopupWindow::dismissPopup()
diff --git a/src/controls/qquickpopupwindow_p.h b/src/controls/qquickpopupwindow_p.h
index 65ce01a06..d48a375ed 100644
--- a/src/controls/qquickpopupwindow_p.h
+++ b/src/controls/qquickpopupwindow_p.h
@@ -70,6 +70,7 @@ public Q_SLOTS:
Q_SIGNALS:
void popupDismissed();
+ void geometryChanged();
protected:
void mousePressEvent(QMouseEvent *);
@@ -80,6 +81,7 @@ protected:
protected Q_SLOTS:
void updateSize();
+ void applicationStateChanged(Qt::ApplicationState state);
private:
void forwardEventToTransientParent(QMouseEvent *);
diff --git a/src/dialogs/DefaultDialogWrapper.qml b/src/dialogs/DefaultDialogWrapper.qml
index 673ffd6f1..2cf157ab8 100644
--- a/src/dialogs/DefaultDialogWrapper.qml
+++ b/src/dialogs/DefaultDialogWrapper.qml
@@ -57,8 +57,7 @@ AbstractDialog {
property bool buttonsInSingleRow: contentItem.width >= buttonsRowImplicitWidth
property real minimumHeight: implicitHeight
property real minimumWidth: Screen.pixelDensity * 50
- implicitHeight: contentItem.implicitHeight + spacing + outerSpacing * 2 +
- (buttonsInSingleRow ? moreButton.implicitHeight : moreButton.implicitHeight * 2 + spacing)
+ implicitHeight: contentItem.implicitHeight + spacing + outerSpacing * 2 + buttonsRight.implicitHeight
implicitWidth: Math.min(Screen.desktopAvailableWidth * 0.9, Math.max(
contentItem.implicitWidth, buttonsRowImplicitWidth, Screen.pixelDensity * 50) + outerSpacing * 2);
color: palette.window
@@ -103,7 +102,6 @@ AbstractDialog {
Repeater {
model: standardButtonsLeftModel
- onCountChanged: calculateImplicitWidth()
Button {
text: standardButtonsLeftModel[index].text
onClicked: root.click(standardButtonsLeftModel[index].standardButton)
@@ -130,7 +128,6 @@ AbstractDialog {
Repeater {
model: standardButtonsRightModel
- onCountChanged: calculateImplicitWidth()
// TODO maybe: insert gaps if the button requires it (destructive buttons only)
Button {
text: standardButtonsRightModel[index].text
@@ -140,7 +137,7 @@ AbstractDialog {
}
}
function calculateImplicitWidth() {
- if (buttonsRight.visibleChildren.length < 2)
+ if (standardButtonsRightModel.length < 2)
return;
var calcWidth = 0;
@@ -160,5 +157,6 @@ AbstractDialog {
calculateForButton(i, buttonsLeft.visibleChildren[i])
content.buttonsRowImplicitWidth = calcWidth + content.spacing
}
+ onStandardButtonsChanged: calculateImplicitWidth()
Component.onCompleted: calculateImplicitWidth()
}
diff --git a/src/dialogs/DefaultFontDialog.qml b/src/dialogs/DefaultFontDialog.qml
index 25d71e926..881bf664b 100644
--- a/src/dialogs/DefaultFontDialog.qml
+++ b/src/dialogs/DefaultFontDialog.qml
@@ -58,7 +58,7 @@ AbstractFontDialog {
SystemPalette { id: palette }
property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight)
- implicitWidth: Math.min(maxSize, Math.max(Screen.pixelDensity * 60, mainLayout.implicitWidth))
+ implicitWidth: Math.min(maxSize, Math.max(Screen.pixelDensity * 60, mainLayout.implicitWidth + outerSpacing * 2))
implicitHeight: Math.min(maxSize, Math.max(Screen.pixelDensity * 40, mainLayout.implicitHeight + outerSpacing * 2))
property real spacing: 6
property real outerSpacing: 12
diff --git a/src/dialogs/DefaultMessageDialog.qml b/src/dialogs/DefaultMessageDialog.qml
index 36ec507fc..0b46f9f3a 100644
--- a/src/dialogs/DefaultMessageDialog.qml
+++ b/src/dialogs/DefaultMessageDialog.qml
@@ -69,6 +69,10 @@ AbstractMessageDialog {
case Qt.Key_C:
detailedText.copy()
break
+ case Qt.Key_Period:
+ if (Qt.platform.os === "osx")
+ reject()
+ break
} else switch (event.key) {
case Qt.Key_Escape:
case Qt.Key_Back:
diff --git a/src/dialogs/plugin.cpp b/src/dialogs/plugin.cpp
index 7c8c6bea0..74672f657 100644
--- a/src/dialogs/plugin.cpp
+++ b/src/dialogs/plugin.cpp
@@ -41,6 +41,7 @@
#include <QtQml/qqml.h>
#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqmlcomponent.h>
#include "qquickmessagedialog_p.h"
#include "qquickabstractmessagedialog_p.h"
#include "qquickdialogassets_p.h"
diff --git a/src/dialogs/qquickabstractcolordialog_p.h b/src/dialogs/qquickabstractcolordialog_p.h
index ad2c7ce1e..ca6a433c8 100644
--- a/src/dialogs/qquickabstractcolordialog_p.h
+++ b/src/dialogs/qquickabstractcolordialog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-#include <QtQml>
#include <QQuickView>
#include <QtGui/qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
diff --git a/src/dialogs/qquickabstractdialog_p.h b/src/dialogs/qquickabstractdialog_p.h
index 5a408530c..79283c19d 100644
--- a/src/dialogs/qquickabstractdialog_p.h
+++ b/src/dialogs/qquickabstractdialog_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtQml>
+#include <QtQml/qqml.h>
#include <QQuickView>
#include <QtGui/qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
diff --git a/src/dialogs/qquickabstractfiledialog_p.h b/src/dialogs/qquickabstractfiledialog_p.h
index 0860ce362..412f418a8 100644
--- a/src/dialogs/qquickabstractfiledialog_p.h
+++ b/src/dialogs/qquickabstractfiledialog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-#include <QtQml>
#include <QQuickView>
#include <QtGui/qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
diff --git a/src/dialogs/qquickabstractfontdialog_p.h b/src/dialogs/qquickabstractfontdialog_p.h
index 2156eb793..d7ab1d477 100644
--- a/src/dialogs/qquickabstractfontdialog_p.h
+++ b/src/dialogs/qquickabstractfontdialog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-#include <QtQml>
#include <QQuickView>
#include <QtGui/qpa/qplatformdialoghelper.h>
#include <QtGui/qfont.h>
diff --git a/src/dialogs/qquickabstractmessagedialog.cpp b/src/dialogs/qquickabstractmessagedialog.cpp
index ebaed414b..b13c53386 100644
--- a/src/dialogs/qquickabstractmessagedialog.cpp
+++ b/src/dialogs/qquickabstractmessagedialog.cpp
@@ -141,10 +141,10 @@ void QQuickAbstractMessageDialog::click(QPlatformDialogHelper::StandardButton bu
emit buttonClicked();
switch (role) {
case QPlatformDialogHelper::AcceptRole:
- emit accept();
+ accept();
break;
case QPlatformDialogHelper::RejectRole:
- emit reject();
+ reject();
break;
case QPlatformDialogHelper::DestructiveRole:
emit discard();
diff --git a/src/dialogs/qquickabstractmessagedialog_p.h b/src/dialogs/qquickabstractmessagedialog_p.h
index 3cf8ee47b..de18cbe5f 100644
--- a/src/dialogs/qquickabstractmessagedialog_p.h
+++ b/src/dialogs/qquickabstractmessagedialog_p.h
@@ -53,7 +53,6 @@
// We mean it.
//
-#include <QtQml>
#include <QQuickView>
#include <QtGui/qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
@@ -124,7 +123,7 @@ Q_SIGNALS:
void apply();
void reset();
-protected:
+protected Q_SLOTS:
void click(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole);
protected:
diff --git a/src/dialogs/qquickcolordialog.cpp b/src/dialogs/qquickcolordialog.cpp
index 58e357205..48935767e 100644
--- a/src/dialogs/qquickcolordialog.cpp
+++ b/src/dialogs/qquickcolordialog.cpp
@@ -65,12 +65,16 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick::Dialogs::AbstractColorDialog::accepted
This signal is emitted by \l accept().
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractColorDialog::rejected
This signal is emitted by \l reject().
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickdialog.cpp b/src/dialogs/qquickdialog.cpp
index 2af1bdc52..9e726ccdf 100644
--- a/src/dialogs/qquickdialog.cpp
+++ b/src/dialogs/qquickdialog.cpp
@@ -41,6 +41,8 @@
#include "qquickdialog_p.h"
#include <QQuickItem>
+#include <QQmlEngine>
+#include <QStandardPaths>
#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -62,12 +64,16 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick::Dialogs::Dialog::accepted
This signal is emitted by \l accept().
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::Dialog::rejected
This signal is emitted by \l reject().
+
+ The corresponding handler is \c onRejected.
*/
/*!
@@ -212,7 +218,7 @@ void QQuickDialog::click(QPlatformDialogHelper::StandardButton button, QPlatform
emit reset();
break;
default:
- qWarning("unhandled MessageDialog button %d with role %ld", button, role);
+ qWarning("unhandled MessageDialog button %d with role %d", (int)button, (int)role);
}
}
diff --git a/src/dialogs/qquickdialog_p.h b/src/dialogs/qquickdialog_p.h
index e9a96612d..547182215 100644
--- a/src/dialogs/qquickdialog_p.h
+++ b/src/dialogs/qquickdialog_p.h
@@ -54,6 +54,7 @@
//
#include "qquickabstractmessagedialog_p.h"
+#include <QJSValue>
QT_BEGIN_NAMESPACE
diff --git a/src/dialogs/qquickfiledialog.cpp b/src/dialogs/qquickfiledialog.cpp
index 3891308da..4704b5b82 100644
--- a/src/dialogs/qquickfiledialog.cpp
+++ b/src/dialogs/qquickfiledialog.cpp
@@ -41,6 +41,7 @@
#include "qquickfiledialog_p.h"
#include <QQuickItem>
+#include <QQmlEngine>
#include <private/qguiapplication_p.h>
#include <private/qv4object_p.h>
@@ -68,12 +69,16 @@ using namespace QV4;
\qmlsignal QtQuick::Dialogs::AbstractFileDialog::accepted
This signal is emitted by \l accept().
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractFileDialog::rejected
This signal is emitted by \l reject().
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickfiledialog_p.h b/src/dialogs/qquickfiledialog_p.h
index 19d8cac07..0cfef4720 100644
--- a/src/dialogs/qquickfiledialog_p.h
+++ b/src/dialogs/qquickfiledialog_p.h
@@ -54,6 +54,8 @@
//
#include "qquickabstractfiledialog_p.h"
+#include <QJSValue>
+#include <QStandardPaths>
QT_BEGIN_NAMESPACE
diff --git a/src/dialogs/qquickfontdialog.cpp b/src/dialogs/qquickfontdialog.cpp
index d17ce986e..802ab33ca 100644
--- a/src/dialogs/qquickfontdialog.cpp
+++ b/src/dialogs/qquickfontdialog.cpp
@@ -66,12 +66,16 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick::Dialogs::AbstractFontDialog::accepted
The \a accepted signal is emitted by \l accept().
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractFontDialog::rejected
The \a accepted signal is emitted by \l reject().
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickmessagedialog.cpp b/src/dialogs/qquickmessagedialog.cpp
index 43b6ca09b..f5ff79af5 100644
--- a/src/dialogs/qquickmessagedialog.cpp
+++ b/src/dialogs/qquickmessagedialog.cpp
@@ -65,12 +65,16 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick::Dialogs::AbstractMessageDialog::accepted
This signal is emitted by \l accept().
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::AbstractMessageDialog::rejected
This signal is emitted by \l reject().
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickplatformcolordialog.cpp b/src/dialogs/qquickplatformcolordialog.cpp
index 11ddbfe6c..9e4083c8c 100644
--- a/src/dialogs/qquickplatformcolordialog.cpp
+++ b/src/dialogs/qquickplatformcolordialog.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::ColorDialog::accepted
- This handler is called when the user has finished using the
+ This signal is emitted when the user has finished using the
dialog. You can then inspect the \l color property to get the selection.
Example:
@@ -112,13 +112,17 @@ QT_BEGIN_NAMESPACE
onAccepted: { console.log("Selected color: " + color) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::ColorDialog::rejected
- This handler is called when the user has dismissed the dialog,
+ This signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickplatformfiledialog.cpp b/src/dialogs/qquickplatformfiledialog.cpp
index 066aabe33..99bfc3924 100644
--- a/src/dialogs/qquickplatformfiledialog.cpp
+++ b/src/dialogs/qquickplatformfiledialog.cpp
@@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal QtQuick::Dialogs::FileDialog::accepted
- This handler is called when the user has finished using the
+ This signal is emitted when the user has finished using the
dialog. You can then inspect the \l fileUrl or \l fileUrls properties to
get the selection.
@@ -114,13 +114,17 @@ QT_BEGIN_NAMESPACE
onAccepted: { console.log("Selected file: " + fileUrl) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal QtQuick::Dialogs::FileDialog::rejected
- This handler is called when the user has dismissed the dialog,
+ This signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickplatformfontdialog.cpp b/src/dialogs/qquickplatformfontdialog.cpp
index 961d776d3..04650a710 100644
--- a/src/dialogs/qquickplatformfontdialog.cpp
+++ b/src/dialogs/qquickplatformfontdialog.cpp
@@ -114,6 +114,8 @@ QT_BEGIN_NAMESPACE
onAccepted: { console.log("Selected font: " + font) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
@@ -121,6 +123,8 @@ QT_BEGIN_NAMESPACE
The \a rejected signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/dialogs/qquickplatformmessagedialog.cpp b/src/dialogs/qquickplatformmessagedialog.cpp
index 4dcb9335a..42c32dcf6 100644
--- a/src/dialogs/qquickplatformmessagedialog.cpp
+++ b/src/dialogs/qquickplatformmessagedialog.cpp
@@ -105,62 +105,78 @@ QT_BEGIN_NAMESPACE
/*!
\qmlsignal MessageDialog::accepted()
- This handler is called when the user has pressed any button which has the
+ This signal is emitted when the user has pressed any button which has the
\l {QMessageBox::AcceptRole} {AcceptRole}: \gui OK, \gui Open, \gui Save,
\gui {Save All}, \gui Retry or \gui Ignore.
+
+ The corresponding handler is \c onAccepted.
*/
/*!
\qmlsignal MessageDialog::rejected()
- This handler is called when the user has dismissed the dialog, by closing
+ This signal is emitted when the user has dismissed the dialog, by closing
the dialog window, by pressing a \gui Cancel, \gui Close or \gui Abort
button on the dialog, or by pressing the back button or the escape key.
+
+ The corresponding handler is \c onRejected.
*/
/*!
\qmlsignal MessageDialog::discard()
- This handler is called when the user has pressed the \gui Discard button.
+ This signal is emitted when the user has pressed the \gui Discard button.
+
+ The corresponding handler is \c onDiscard.
*/
/*!
\qmlsignal MessageDialog::help()
- This handler is called when the user has pressed the \gui Help button.
+ This signal is emitted when the user has pressed the \gui Help button.
Depending on platform, the dialog may not be automatically dismissed
because the help that your application provides may need to be relevant to
the text shown in this dialog in order to assist the user in making a
decision. However on other platforms it's not possible to show a dialog and
a help window at the same time. If you want to be sure that the dialog will
close, you can set \l visible to \c false in your handler.
+
+ The corresponding handler is \c onHelp.
*/
/*!
\qmlsignal MessageDialog::yes()
- This handler is called when the user has pressed any button which has
+ This signal is emitted when the user has pressed any button which has
the \l {QMessageBox::YesRole} {YesRole}: \gui Yes or \gui {Yes to All}.
+
+ The corresponding handler is \c onYes.
*/
/*!
\qmlsignal MessageDialog::no()
- This handler is called when the user has pressed any button which has
+ This signal is emitted when the user has pressed any button which has
the \l {QMessageBox::NoRole} {NoRole}: \gui No or \gui {No to All}.
+
+ The corresponding handler is \c onNo.
*/
/*!
\qmlsignal MessageDialog::apply()
- This handler is called when the user has pressed the \gui Apply button.
+ This signal is emitted when the user has pressed the \gui Apply button.
+
+ The corresponding handler is \c onApply.
*/
/*!
\qmlsignal MessageDialog::reset()
- This handler is called when the user has pressed any button which has
+ This signal is emitted when the user has pressed any button which has
the \l {QMessageBox::ResetRole} {ResetRole}: \gui Reset or \gui {Restore Defaults}.
+
+ The corresponding handler is \c onReset.
*/
/*!
@@ -210,8 +226,8 @@ QPlatformMessageDialogHelper *QQuickPlatformMessageDialog::helper()
// dismissed by closing the window rather than by one of its button widgets.
connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
- connect(m_dlgHelper, SIGNAL(clicked(QMessageDialogOptions::StandardButton,QMessageDialogOptions::ButtonRole)),
- this, SLOT(click(QMessageDialogOptions::StandardButton,QMessageDialogOptions::ButtonRole)));
+ connect(m_dlgHelper, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)),
+ this, SLOT(click(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));
}
return m_dlgHelper;
diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp
index 419a81df7..09684b5d3 100644
--- a/src/layouts/qquickgridlayoutengine.cpp
+++ b/src/layouts/qquickgridlayoutengine.cpp
@@ -142,6 +142,8 @@ static inline void combineImplicitHints(QQuickLayoutAttached *info, Qt::SizeHint
explicitly or implicitly set with QQuickLayoutAttached::isExtentExplicitlySet(). This
determines if it should be used as a USER or as a HINT value.
+ Fractional size hints will be ceiled to the closest integer. This is in order to give some
+ slack when the items are snapped to the pixel grid.
| *Minimum* | *Preferred* | *Maximum* |
+----------------+----------------------+-----------------------+--------------------------+
@@ -173,12 +175,12 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c
Q_ASSERT(getter);
if (info->isExtentExplicitlySet(Qt::Horizontal, (Qt::SizeHint)i))
- cachedSizeHints[i].setWidth((info->*getter)());
+ cachedSizeHints[i].setWidth(qCeil((info->*getter)()));
getter = verGetters.call[i];
Q_ASSERT(getter);
if (info->isExtentExplicitlySet(Qt::Vertical, (Qt::SizeHint)i))
- cachedSizeHints[i].setHeight((info->*getter)());
+ cachedSizeHints[i].setHeight(qCeil((info->*getter)()));
}
}
@@ -213,9 +215,9 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c
qreal &prefWidth = prefS.rwidth();
qreal &prefHeight = prefS.rheight();
if (prefWidth < 0 && item->implicitWidth() > 0)
- prefWidth = item->implicitWidth();
+ prefWidth = qCeil(item->implicitWidth());
if (prefHeight < 0 && item->implicitHeight() > 0)
- prefHeight = item->implicitHeight();
+ prefHeight = qCeil(item->implicitHeight());
// If that fails, make an ultimate fallback to width/height
diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h
index 94b8677ac..f1dba1e91 100644
--- a/src/layouts/qquickgridlayoutengine_p.h
+++ b/src/layouts/qquickgridlayoutengine_p.h
@@ -113,15 +113,15 @@ public:
void setGeometry(const QRectF &rect)
{
- const QPoint innerTopLeft(qCeil(rect.left()), qCeil(rect.top()));
- const QPoint innerBottomRight(qFloor(rect.right()), qFloor(rect.bottom()));
- const QSize newSize(innerBottomRight.x() - innerTopLeft.x(), innerBottomRight.y() - innerTopLeft.y());
- m_item->setPosition(innerTopLeft);
- QSizeF oldSize(m_item->width(), m_item->height());
+ const QSizeF oldSize(m_item->width(), m_item->height());
+ const QSizeF newSize = rect.size();
+ const QPointF topLeft(qCeil(rect.x()), qCeil(rect.y()));
+ m_item->setPosition(topLeft);
if (newSize == oldSize) {
- if (QQuickLayout *lay = qobject_cast<QQuickLayout *>(m_item))
+ if (QQuickLayout *lay = qobject_cast<QQuickLayout *>(m_item)) {
if (lay->arrangementIsDirty())
lay->rearrange(newSize);
+ }
} else {
m_item->setSize(newSize);
}
diff --git a/src/widgets/qmessageboxhelper_p.h b/src/widgets/qmessageboxhelper_p.h
index bf3eef32d..cb02332b7 100644
--- a/src/widgets/qmessageboxhelper_p.h
+++ b/src/widgets/qmessageboxhelper_p.h
@@ -58,6 +58,28 @@
QT_BEGIN_NAMESPACE
+class QCloseableMessageBox : public QMessageBox
+{
+public:
+ QCloseableMessageBox(QWidget *parent = 0) : QMessageBox(parent) { }
+
+ void closeEvent(QCloseEvent *e) {
+ // QTBUG-36227: Bypass QMessageBox::closeEvent()
+ QDialog::closeEvent(e);
+ }
+
+ void keyPressEvent(QKeyEvent *e) {
+ QMessageBox::keyPressEvent(e);
+ // QTBUG-36227: reject on escape or cmd-period even if there's no cancel button
+ if ((isVisible() && e->key() == Qt::Key_Escape)
+#ifdef Q_OS_MAC
+ || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period)
+#endif
+ )
+ reject();
+ }
+};
+
class QMessageBoxHelper : public QPlatformMessageDialogHelper
{
Q_OBJECT
@@ -93,7 +115,7 @@ public:
virtual void hide() { m_dialog.hide(); }
- QMessageBox m_dialog;
+ QCloseableMessageBox m_dialog;
public Q_SLOTS:
void buttonClicked(QAbstractButton* button) {
diff --git a/src/widgets/qquickqcolordialog.cpp b/src/widgets/qquickqcolordialog.cpp
index aa88aaebc..4359bc6db 100644
--- a/src/widgets/qquickqcolordialog.cpp
+++ b/src/widgets/qquickqcolordialog.cpp
@@ -118,6 +118,8 @@ private:
onAccepted: { console.log("Selected color: " + color) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
@@ -125,6 +127,8 @@ private:
The \a rejected signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/widgets/qquickqfiledialog.cpp b/src/widgets/qquickqfiledialog.cpp
index 9dc967dd9..b37ec769a 100644
--- a/src/widgets/qquickqfiledialog.cpp
+++ b/src/widgets/qquickqfiledialog.cpp
@@ -83,6 +83,8 @@ QT_BEGIN_NAMESPACE
onAccepted: { console.log("Selected file: " + fileUrl) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
@@ -90,6 +92,8 @@ QT_BEGIN_NAMESPACE
The \a rejected signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/widgets/qquickqfontdialog.cpp b/src/widgets/qquickqfontdialog.cpp
index 6936aff78..bc889e07c 100644
--- a/src/widgets/qquickqfontdialog.cpp
+++ b/src/widgets/qquickqfontdialog.cpp
@@ -121,6 +121,8 @@ private:
onAccepted: { console.log("Selected file: " + filePath) }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
@@ -128,6 +130,8 @@ private:
The \a rejected signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
diff --git a/src/widgets/qquickqmessagebox.cpp b/src/widgets/qquickqmessagebox.cpp
index 5d7340115..c959fd748 100644
--- a/src/widgets/qquickqmessagebox.cpp
+++ b/src/widgets/qquickqmessagebox.cpp
@@ -84,6 +84,8 @@ QT_BEGIN_NAMESPACE
onAccepted: { console.log("accepted") }
}
\endqml
+
+ The corresponding handler is \c onAccepted.
*/
/*!
@@ -91,6 +93,8 @@ QT_BEGIN_NAMESPACE
The \a rejected signal is emitted when the user has dismissed the dialog,
either by closing the dialog window or by pressing the Cancel button.
+
+ The corresponding handler is \c onRejected.
*/
/*!
@@ -134,8 +138,8 @@ QPlatformDialogHelper *QQuickQMessageBox::helper()
// dismissed by closing the window rather than by one of its button widgets.
connect(helper, SIGNAL(accept()), this, SLOT(accept()));
connect(helper, SIGNAL(reject()), this, SLOT(reject()));
- connect(helper, SIGNAL(clicked(QMessageDialogOptions::StandardButton,QMessageDialogOptions::ButtonRole)),
- this, SLOT(click(QMessageDialogOptions::StandardButton,QMessageDialogOptions::ButtonRole)));
+ connect(helper, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)),
+ this, SLOT(click(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));
}
return QQuickAbstractMessageDialog::m_dlgHelper;