diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2014-10-29 17:29:16 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2014-10-30 10:43:16 +0100 |
commit | 3a851dfd4078b3ca9f9c1b06424b136cc6f852c5 (patch) | |
tree | 8df32ef561f75be2b50fb95a04bb44463b34b0f0 | |
parent | 052dea3003b393d2ebb6754d0ed2fd7329cd8d26 (diff) |
Make the cursor and selection handle delegates private for now
The API is not ideal, we don't want to lock this thing down like as it
is now. All styles implemented so far created CursorHandleStyle.qml and
SelectionHandleStyle.qml so perhaps that's the better way to go.
Furthermore, there's never going to be multiple occurrences of the
handle pairs, so it should be one shared instance. Thus, the relevant
style delegates probably shouldn't be sprinkled around various control
styles...
So, for now, the most pragmatic solution is to make the handles and
cursors internal since we don't have time to revamp it before 5.4.0.
Change-Id: Ib9fcc4a431bb510c8c55a760159f4d6a631554b3
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
-rw-r--r-- | src/controls/ComboBox.qml | 4 | ||||
-rw-r--r-- | src/controls/Private/TextInputWithHandles.qml | 3 | ||||
-rw-r--r-- | src/controls/SpinBox.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/Android/ComboBoxStyle.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/Android/SpinBoxStyle.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/Android/TextAreaStyle.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/Android/TextFieldStyle.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/Base/ComboBoxStyle.qml | 15 | ||||
-rw-r--r-- | src/controls/Styles/Base/SpinBoxStyle.qml | 15 | ||||
-rw-r--r-- | src/controls/Styles/Base/TextAreaStyle.qml | 15 | ||||
-rw-r--r-- | src/controls/Styles/Base/TextFieldStyle.qml | 15 | ||||
-rw-r--r-- | src/controls/Styles/iOS/ComboBoxStyle.qml | 6 | ||||
-rw-r--r-- | src/controls/Styles/iOS/SpinBoxStyle.qml | 6 | ||||
-rw-r--r-- | src/controls/Styles/iOS/TextAreaStyle.qml | 6 | ||||
-rw-r--r-- | src/controls/Styles/iOS/TextFieldStyle.qml | 6 | ||||
-rw-r--r-- | src/controls/TextArea.qml | 6 | ||||
-rw-r--r-- | src/controls/TextField.qml | 4 | ||||
-rw-r--r-- | tests/manual/texthandles/main.qml | 16 |
18 files changed, 74 insertions, 63 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 68429483c..f2f37a0a5 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -401,8 +401,8 @@ Control { clip: contentWidth > width control: comboBox - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined anchors.fill: parent anchors.leftMargin: __style ? __style.padding.left : 0 diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index 3c8351a3d..ceb63084f 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -52,7 +52,7 @@ 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) @@ -164,7 +164,6 @@ TextInput { parent: control control: input.control active: control.selectByMouse - delegate: style.cursorHandle minimum: input.hasSelection ? selectionHandle.position + 1 : -1 property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y) diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index f13e81dc4..66a210274 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -291,8 +291,8 @@ Control { anchors.bottomMargin: __style ? __style.padding.bottom: 0 control: spinbox - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined focus: true activeFocusOnPress: spinbox.activeFocusOnPress diff --git a/src/controls/Styles/Android/ComboBoxStyle.qml b/src/controls/Styles/Android/ComboBoxStyle.qml index 715dd9f69..b6ff1c307 100644 --- a/src/controls/Styles/Android/ComboBoxStyle.qml +++ b/src/controls/Styles/Android/ComboBoxStyle.qml @@ -105,11 +105,11 @@ Style { property Component __popupStyle: null property Component __dropDownStyle: null - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/SpinBoxStyle.qml b/src/controls/Styles/Android/SpinBoxStyle.qml index 86fce0349..5c05774fa 100644 --- a/src/controls/Styles/Android/SpinBoxStyle.qml +++ b/src/controls/Styles/Android/SpinBoxStyle.qml @@ -98,11 +98,11 @@ Style { } } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/TextAreaStyle.qml b/src/controls/Styles/Android/TextAreaStyle.qml index 61ea9fb85..85950efa0 100644 --- a/src/controls/Styles/Android/TextAreaStyle.qml +++ b/src/controls/Styles/Android/TextAreaStyle.qml @@ -72,11 +72,11 @@ ScrollViewStyle { styleDef: style.styleDef } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/TextFieldStyle.qml b/src/controls/Styles/Android/TextFieldStyle.qml index e7eec32c6..67cd3b786 100644 --- a/src/controls/Styles/Android/TextFieldStyle.qml +++ b/src/controls/Styles/Android/TextFieldStyle.qml @@ -91,11 +91,11 @@ Style { } } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Base/ComboBoxStyle.qml b/src/controls/Styles/Base/ComboBoxStyle.qml index 77d2e91e1..1a810772a 100644 --- a/src/controls/Styles/Base/ComboBoxStyle.qml +++ b/src/controls/Styles/Base/ComboBoxStyle.qml @@ -280,7 +280,8 @@ Style { property Component __scrollerStyle: null } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -297,9 +298,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -316,10 +318,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml index 1bcb6b5cf..d821940a5 100644 --- a/src/controls/Styles/Base/SpinBoxStyle.qml +++ b/src/controls/Styles/Base/SpinBoxStyle.qml @@ -210,7 +210,8 @@ Style { } } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -227,9 +228,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -246,10 +248,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/TextAreaStyle.qml b/src/controls/Styles/Base/TextAreaStyle.qml index bd3ed31ea..56a1ec58f 100644 --- a/src/controls/Styles/Base/TextAreaStyle.qml +++ b/src/controls/Styles/Base/TextAreaStyle.qml @@ -104,7 +104,8 @@ ScrollViewStyle { \sa TextArea::textMargin */ property real textMargin: 4 - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -121,9 +122,10 @@ ScrollViewStyle { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -140,10 +142,11 @@ ScrollViewStyle { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index c1e7a69f6..4d0a66eba 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -157,7 +157,8 @@ Style { } } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -174,9 +175,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -193,10 +195,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/iOS/ComboBoxStyle.qml b/src/controls/Styles/iOS/ComboBoxStyle.qml index 147fd7fdb..ba657298e 100644 --- a/src/controls/Styles/iOS/ComboBoxStyle.qml +++ b/src/controls/Styles/iOS/ComboBoxStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 ComboBoxStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/SpinBoxStyle.qml b/src/controls/Styles/iOS/SpinBoxStyle.qml index a764cb79d..c898e5e9f 100644 --- a/src/controls/Styles/iOS/SpinBoxStyle.qml +++ b/src/controls/Styles/iOS/SpinBoxStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 SpinBoxStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/TextAreaStyle.qml b/src/controls/Styles/iOS/TextAreaStyle.qml index 6b8a18003..6be12be68 100644 --- a/src/controls/Styles/iOS/TextAreaStyle.qml +++ b/src/controls/Styles/iOS/TextAreaStyle.qml @@ -51,7 +51,7 @@ ScrollViewStyle { property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled) property color backgroundColor: control.backgroundVisible ? SystemPaletteSingleton.base(control.enabled) : "transparent" property int renderType: Text.QtRendering - property Component selectionHandle: SelectionHandleStyle{} - property Component cursorHandle: CursorHandleStyle{} - property Component cursorDelegate: CursorDelegate{} + property Component __selectionHandle: SelectionHandleStyle{} + property Component __cursorHandle: CursorHandleStyle{} + property Component __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/TextFieldStyle.qml b/src/controls/Styles/iOS/TextFieldStyle.qml index 28ad692ff..ca237a0a2 100644 --- a/src/controls/Styles/iOS/TextFieldStyle.qml +++ b/src/controls/Styles/iOS/TextFieldStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 TextFieldStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 8acdb6dc5..c644230de 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -718,7 +718,7 @@ ScrollView { TextEdit { id: edit focus: true - cursorDelegate: __style && __style.cursorDelegate ? __style.cursorDelegate : null + cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null Rectangle { id: colorRect @@ -885,7 +885,7 @@ ScrollView { z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip active: area.selectByMouse - delegate: __style.selectionHandle + delegate: __style.__selectionHandle maximum: cursorHandle.position - 1 // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change @@ -921,7 +921,7 @@ ScrollView { z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip active: area.selectByMouse - delegate: __style.cursorHandle + delegate: __style.__cursorHandle minimum: edit.hasSelection ? selectionHandle.position + 1 : -1 // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index a7aa67eb7..5c1e5e516 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -633,8 +633,8 @@ Control { selectedTextColor: __panel ? __panel.selectedTextColor : "white" control: textfield - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined font: __panel ? __panel.font : TextSingleton.font anchors.leftMargin: __panel ? __panel.leftMargin : 0 diff --git a/tests/manual/texthandles/main.qml b/tests/manual/texthandles/main.qml index ab10b861b..5a520d170 100644 --- a/tests/manual/texthandles/main.qml +++ b/tests/manual/texthandles/main.qml @@ -105,8 +105,8 @@ ApplicationWindow { selectByMouse: selectBox.checked style: TextFieldStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -121,8 +121,8 @@ ApplicationWindow { horizontalAlignment: Qt.AlignHCenter style: SpinBoxStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -148,8 +148,8 @@ ApplicationWindow { } style: ComboBoxStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -164,8 +164,8 @@ ApplicationWindow { text: loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum style: TextAreaStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } } |