summaryrefslogtreecommitdiffstats
path: root/src/controls/Private
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/Private')
-rw-r--r--src/controls/Private/AbstractCheckable.qml10
-rw-r--r--src/controls/Private/BasicButton.qml4
-rw-r--r--src/controls/Private/EditMenu.qml4
-rw-r--r--src/controls/Private/EditMenu_base.qml6
-rw-r--r--src/controls/Private/EditMenu_ios.qml11
-rw-r--r--src/controls/Private/ScrollBar.qml2
-rw-r--r--src/controls/Private/TextHandle.qml2
-rw-r--r--src/controls/Private/TextInputWithHandles.qml18
-rw-r--r--src/controls/Private/qquickcontrolsettings.cpp27
-rw-r--r--src/controls/Private/qquickspinboxvalidator.cpp4
-rw-r--r--src/controls/Private/qquickstyleitem.cpp2
-rw-r--r--src/controls/Private/qquicktooltip.cpp2
12 files changed, 69 insertions, 23 deletions
diff --git a/src/controls/Private/AbstractCheckable.qml b/src/controls/Private/AbstractCheckable.qml
index 1909e05c2..f1dbe9621 100644
--- a/src/controls/Private/AbstractCheckable.qml
+++ b/src/controls/Private/AbstractCheckable.qml
@@ -148,4 +148,14 @@ Control {
clicked();
}
}
+
+ Action {
+ // handle mnemonic
+ text: abstractCheckable.text
+ onTriggered: {
+ if (!abstractCheckable.exclusiveGroup || !abstractCheckable.checked)
+ abstractCheckable.__cycleStatesHandler();
+ abstractCheckable.clicked();
+ }
+ }
}
diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml
index f482ad72f..f0c9c63ea 100644
--- a/src/controls/Private/BasicButton.qml
+++ b/src/controls/Private/BasicButton.qml
@@ -152,6 +152,10 @@ Control {
id: ownAction
iconSource: !button.action || __iconOverriden ? button.iconSource : ""
iconName: !button.action || __iconOverriden ? button.iconName : ""
+
+ // let ownAction handle mnemonic if and only if the button does
+ // not already have an action assigned to avoid ambiguous shortcuts
+ text: button.action ? "" : button.text
}
Connections {
diff --git a/src/controls/Private/EditMenu.qml b/src/controls/Private/EditMenu.qml
index f4d80bd5f..70b6b9b24 100644
--- a/src/controls/Private/EditMenu.qml
+++ b/src/controls/Private/EditMenu.qml
@@ -49,6 +49,7 @@ Loader {
property Flickable flickable
property Component defaultMenu: item && item.defaultMenu ? item.defaultMenu : null
property Menu menuInstance: null
+ property MouseArea mouseArea
Connections {
target: control
@@ -69,5 +70,6 @@ Loader {
return menuInstance;
}
- source: Qt.resolvedUrl("EditMenu_" + (Qt.platform.os === "ios" ? "ios" : "base") + ".qml")
+ source: Qt.resolvedUrl(Qt.platform.os === "ios" ? "EditMenu_ios.qml"
+ : Qt.platform.os === "android" ? "" : "EditMenu_base.qml")
}
diff --git a/src/controls/Private/EditMenu_base.qml b/src/controls/Private/EditMenu_base.qml
index 597541bc2..3745d9f48 100644
--- a/src/controls/Private/EditMenu_base.qml
+++ b/src/controls/Private/EditMenu_base.qml
@@ -90,10 +90,8 @@ Item {
MenuItem { action: pasteAction.createObject(editMenuBase) }
}
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- acceptedButtons: Qt.RightButton
+ Connections {
+ target: mouseArea
onClicked: {
if (input.selectionStart === input.selectionEnd) {
diff --git a/src/controls/Private/EditMenu_ios.qml b/src/controls/Private/EditMenu_ios.qml
index aeb21b03f..44ff7709f 100644
--- a/src/controls/Private/EditMenu_ios.qml
+++ b/src/controls/Private/EditMenu_ios.qml
@@ -75,7 +75,7 @@ Item {
}
MenuItem {
text: "select"
- visible: selectionStart === selectionEnd
+ visible: selectionStart === selectionEnd && input.length > 0
onTriggered: selectWord();
}
MenuItem {
@@ -85,9 +85,8 @@ Item {
}
}
- MouseArea {
- id: mouseArea
- anchors.fill: parent
+ Connections {
+ target: mouseArea
function clearFocusFromOtherItems()
{
@@ -115,7 +114,8 @@ Item {
onPressAndHold: {
var pos = input.positionAt(mouseArea.mouseX, mouseArea.mouseY);
input.select(pos, pos);
- if (!control.menu || !input.activeFocus || (selectionStart != selectionEnd)) {
+ var hasSelection = selectionStart != selectionEnd;
+ if (!control.menu || (input.length > 0 && (!input.activeFocus || hasSelection))) {
selectWord();
} else {
// We don't select anything at this point, the
@@ -170,6 +170,7 @@ Item {
return;
if ((__showMenuFromTouchAndHold || selectionStart !== selectionEnd)
+ && control.activeFocus
&& (!cursorHandle.pressed && !selectionHandle.pressed)
&& (!flickable || !flickable.moving)
&& (cursorHandle.delegate)) {
diff --git a/src/controls/Private/ScrollBar.qml b/src/controls/Private/ScrollBar.qml
index 827504121..3bd0a1640 100644
--- a/src/controls/Private/ScrollBar.qml
+++ b/src/controls/Private/ScrollBar.qml
@@ -102,7 +102,7 @@ Item {
onExited: if (!pressed) __panel.activeControl = "none"
onMouseXChanged: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY)
hoverEnabled: !Settings.hasTouchScreen
- enabled: !Settings.hasTouchScreen // TODO: touch on desktop?
+ enabled: !Settings.isMobile || !Settings.hasTouchScreen // ### Not ideal, but will usually behave as expected...
preventStealing: true
property var pressedX
property var pressedY
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml
index 19fc19a6d..8656dcfd8 100644
--- a/src/controls/Private/TextHandle.qml
+++ b/src/controls/Private/TextHandle.qml
@@ -75,7 +75,7 @@ Loader {
MouseArea {
id: mouse
anchors.fill: item
- enabled: handle.active
+ enabled: item && item.visible
preventStealing: true
property real pressX
property point offset
diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml
index f33487743..75ca947f7 100644
--- a/src/controls/Private/TextInputWithHandles.qml
+++ b/src/controls/Private/TextInputWithHandles.qml
@@ -52,9 +52,9 @@ TextInput {
readonly property int selectionPosition: selectionStart !== cursorPosition ? selectionStart : selectionEnd
readonly property alias containsMouse: mouseArea.containsMouse
property alias editMenu: editMenu
- cursorDelegate: __style && __style.cursorDelegate ? __style.cursorDelegate : null
+ cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null
- selectByMouse: control.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate)
+ selectByMouse: control.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate)
// force re-evaluation when selection moves:
// - cursorRectangle changes => content scrolled
@@ -104,13 +104,17 @@ TextInput {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.IBeamCursor
- acceptedButtons: input.selectByMouse ? Qt.NoButton : Qt.LeftButton
+ acceptedButtons: (input.selectByMouse ? Qt.NoButton : Qt.LeftButton) | (control.menu ? Qt.RightButton : Qt.NoButton)
onClicked: {
+ if (editMenu.item)
+ return;
var pos = input.positionAt(mouse.x, mouse.y)
input.moveHandles(pos, pos)
input.activate()
}
onPressAndHold: {
+ if (editMenu.item)
+ return;
var pos = input.positionAt(mouse.x, mouse.y)
input.moveHandles(pos, control.selectByMouse ? -1 : pos)
input.activate()
@@ -120,6 +124,7 @@ TextInput {
EditMenu {
id: editMenu
input: parent
+ mouseArea: mouseArea
control: parent.control
cursorHandle: cursorHandle
selectionHandle: selectionHandle
@@ -132,7 +137,7 @@ TextInput {
editor: input
parent: control
control: input.control
- active: control.selectByMouse
+ active: control.selectByMouse && Settings.isMobile
maximum: cursorHandle.position - 1
property var mappedPos: parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y)
@@ -158,15 +163,14 @@ TextInput {
editor: input
parent: control
control: input.control
- active: control.selectByMouse
- delegate: style.cursorHandle
+ active: control.selectByMouse && Settings.isMobile
minimum: input.hasSelection ? selectionHandle.position + 1 : -1
property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y)
x: mappedPos.x
y: mappedPos.y
- visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX <= control.width + 1)
+ visible: pressed || ((input.cursorVisible || input.hasSelection) && handleX + handleWidth >= -1 && handleX <= control.width + 1)
onPositionChanged: {
if (!input.blockRecursion) {
diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp
index bd02b87d8..b73a7d43a 100644
--- a/src/controls/Private/qquickcontrolsettings.cpp
+++ b/src/controls/Private/qquickcontrolsettings.cpp
@@ -35,10 +35,14 @@
#include <qquickitem.h>
#include <qcoreapplication.h>
#include <qqmlengine.h>
+#include <qlibrary.h>
#include <qdir.h>
#include <QTouchDevice>
#include <QGuiApplication>
#include <QStyleHints>
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+#include <private/qjnihelpers_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -49,7 +53,8 @@ static QString defaultStyleName()
if (QCoreApplication::instance()->inherits("QApplication"))
return QLatin1String("Desktop");
#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
- return QLatin1String("Android");
+ if (QtAndroidPrivate::androidSdkVersion() >= 11)
+ return QLatin1String("Android");
#elif defined(Q_OS_IOS)
return QLatin1String("iOS");
#elif defined(Q_OS_WINRT)
@@ -126,11 +131,29 @@ QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine)
QString path = styleFilePath();
- if (!QDir(path).exists()) {
+ QDir dir(path);
+ if (!dir.exists()) {
QString unknownStyle = m_name;
m_name = defaultStyleName();
m_path = styleImportPath(engine, m_name);
qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath();
+ } else {
+ typedef bool (*StyleInitFunc)();
+ typedef const char *(*StylePathFunc)();
+
+ foreach (const QString &fileName, dir.entryList()) {
+ if (QLibrary::isLibrary(fileName)) {
+ QLibrary lib(dir.absoluteFilePath(fileName));
+ StyleInitFunc initFunc = (StyleInitFunc) lib.resolve("qt_quick_controls_style_init");
+ if (initFunc)
+ initFunc();
+ StylePathFunc pathFunc = (StylePathFunc) lib.resolve("qt_quick_controls_style_path");
+ if (pathFunc)
+ m_path = QString::fromLocal8Bit(pathFunc());
+ if (initFunc || pathFunc)
+ break;
+ }
+ }
}
connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged()));
diff --git a/src/controls/Private/qquickspinboxvalidator.cpp b/src/controls/Private/qquickspinboxvalidator.cpp
index afbc866c8..2fec79e82 100644
--- a/src/controls/Private/qquickspinboxvalidator.cpp
+++ b/src/controls/Private/qquickspinboxvalidator.cpp
@@ -200,7 +200,9 @@ QValidator::State QQuickSpinBoxValidator::validate(QString &input, int &pos) con
bool ok = false;
qreal val = locale().toDouble(value, &ok);
if (ok) {
- if (state == QValidator::Acceptable) {
+ if (state == QValidator::Acceptable ||
+ (state == QValidator::Intermediate && val >= 0 && val <= m_validator.top()) ||
+ (state == QValidator::Intermediate && val < 0 && val >= m_validator.bottom())) {
const_cast<QQuickSpinBoxValidator *>(this)->setValue(val);
if (input != textFromValue(val))
state = QValidator::Intermediate;
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index edb33212e..fb49e6e3f 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -354,6 +354,8 @@ void QQuickStyleItem::initStyleOption()
opt->features = QStyleOptionViewItem::HasDisplay;
opt->text = text();
opt->textElideMode = Qt::ElideRight;
+ opt->displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
+ opt->decorationAlignment = Qt::AlignCenter;
resolvePalette();
needsResolvePalette = false;
QPalette pal = m_styleoption->palette;
diff --git a/src/controls/Private/qquicktooltip.cpp b/src/controls/Private/qquicktooltip.cpp
index b93b4a534..6f81b5b82 100644
--- a/src/controls/Private/qquicktooltip.cpp
+++ b/src/controls/Private/qquicktooltip.cpp
@@ -36,7 +36,7 @@
#include <qquickitem.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
-#include <QtQuick/private/qquickrendercontrol_p.h>
+#include <QtQuick/QQuickRenderControl>
#ifdef QT_WIDGETS_LIB
#include <qtooltip.h>