From: Shawn Rutledge Date: Tue, 12 Nov 2013 07:57:35 +0000 (+0100) Subject: QtQuick.Dialogs: hide internal functions and properties X-Git-Tag: upstream/5.2.1~1^2~13^2~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19d64a89a6f8d6b7f40c86a04e4198dd86739de2;p=platform%2Fupstream%2Fqtdeclarative.git QtQuick.Dialogs: hide internal functions and properties with double-underscores Change-Id: If397bfaf50e0878516296eb4237bcf012eb8dae4 Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> Reviewed-by: Shawn Rutledge --- diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml index a0efb6c..4913e33 100644 --- a/src/imports/dialogs/DefaultColorDialog.qml +++ b/src/imports/dialogs/DefaultColorDialog.qml @@ -45,18 +45,18 @@ import "qml" AbstractColorDialog { id: root - property bool _valueSet: true // guard to prevent binding loops - function _setControlsFromColor() { - _valueSet = false + property bool __valueSet: true // guard to prevent binding loops + function __setControlsFromColor() { + __valueSet = false hueSlider.value = root.currentHue saturationSlider.value = root.currentSaturation lightnessSlider.value = root.currentLightness alphaSlider.value = root.currentAlpha crosshairs.x = root.currentLightness * paletteMap.width crosshairs.y = (1.0 - root.currentSaturation) * paletteMap.height - _valueSet = true + __valueSet = true } - onCurrentColorChanged: _setControlsFromColor() + onCurrentColorChanged: __setControlsFromColor() onSelectionAccepted: root.color = root.currentColor Rectangle { @@ -119,7 +119,7 @@ AbstractColorDialog { id: paletteMap x: (parent.width - width) / 2 width: height - onWidthChanged: root._setControlsFromColor() + onWidthChanged: root.__setControlsFromColor() height: parent.height source: "images/checkers.png" fillMode: Image.Tile @@ -234,7 +234,7 @@ AbstractColorDialog { ColorSlider { id: hueSlider value: 0.5 - onValueChanged: if (_valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) + onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Hue") trackDelegate: Rectangle { rotation: -90 @@ -255,7 +255,7 @@ AbstractColorDialog { id: saturationSlider visible: !content.usePaletteMap value: 0.5 - onValueChanged: if (_valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) + onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Saturation") trackDelegate: Rectangle { rotation: -90 @@ -271,7 +271,7 @@ AbstractColorDialog { id: lightnessSlider visible: !content.usePaletteMap value: 0.5 - onValueChanged: if (_valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) + onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Luminosity") trackDelegate: Rectangle { rotation: -90 @@ -289,7 +289,7 @@ AbstractColorDialog { minimum: 0.0 maximum: 1.0 value: 1.0 - onValueChanged: if (_valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) + onValueChanged: if (__valueSet) root.currentColor = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Alpha") visible: root.showAlphaChannel trackDelegate: Item { diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml index 8eb7696..0a5eabd 100644 --- a/src/imports/dialogs/DefaultFileDialog.qml +++ b/src/imports/dialogs/DefaultFileDialog.qml @@ -48,63 +48,62 @@ AbstractFileDialog { id: root onVisibleChanged: { if (visible) { - selectedIndices = [] - lastClickedIdx = -1 + __selectedIndices = [] + __lastClickedIdx = -1 currentPathField.visible = false } } onFolderChanged: view.model.folder = folder - property bool showFocusHighlight: false - property real textX: titleBar.height - property SystemPalette palette - property var selectedIndices: [] - property int lastClickedIdx: -1 + property real __textX: titleBar.height + property SystemPalette __palette + property var __selectedIndices: [] + property int __lastClickedIdx: -1 - function dirDown(path) { + function __dirDown(path) { view.model.folder = path - lastClickedIdx = -1 - selectedIndices = [] + __lastClickedIdx = -1 + __selectedIndices = [] } - function dirUp() { + function __dirUp() { view.model.folder = view.model.parentFolder - lastClickedIdx = -1 - selectedIndices = [] + __lastClickedIdx = -1 + __selectedIndices = [] } - function up(extend) { + function __up(extend) { if (view.currentIndex > 0) --view.currentIndex else view.currentIndex = 0 if (extend) { - if (selectedIndices.indexOf(view.currentIndex) < 0) { - var selCopy = selectedIndices + if (__selectedIndices.indexOf(view.currentIndex) < 0) { + var selCopy = __selectedIndices selCopy.push(view.currentIndex) - selectedIndices = selCopy + __selectedIndices = selCopy } } else - selectedIndices = [view.currentIndex] + __selectedIndices = [view.currentIndex] } - function down(extend) { + function __down(extend) { if (view.currentIndex < view.model.count - 1) ++view.currentIndex else view.currentIndex = view.model.count - 1 if (extend) { - if (selectedIndices.indexOf(view.currentIndex) < 0) { - var selCopy = selectedIndices + if (__selectedIndices.indexOf(view.currentIndex) < 0) { + var selCopy = __selectedIndices selCopy.push(view.currentIndex) - selectedIndices = selCopy + __selectedIndices = selCopy } } else - selectedIndices = [view.currentIndex] + __selectedIndices = [view.currentIndex] } - function acceptSelection() { + function __acceptSelection() { clearSelection() - if (selectFolder && selectedIndices.length == 0) + if (selectFolder && __selectedIndices.length == 0) addSelection(folder) - else if (selectedIndices.length > 0) { - selectedIndices.map(function(idx) { + else if (__selectedIndices.length > 0) { + __selectedIndices.map(function(idx) { if (view.model.isFolder(idx)) { if (selectFolder) addSelection(view.model.get(idx, "fileURL")) @@ -125,11 +124,11 @@ AbstractFileDialog { // TODO: QTBUG-29817 geometry from AbstractFileDialog implicitWidth: Math.min(maxSize, Screen.pixelDensity * 100) implicitHeight: Math.min(maxSize, Screen.pixelDensity * 80) - color: palette.window + color: __palette.window focus: root.visible && !currentPathField.visible property real spacing: 6 property real outerSpacing: 12 - SystemPalette { id: palette } + SystemPalette { id: __palette } Component { id: folderDelegate @@ -137,9 +136,9 @@ AbstractFileDialog { id: wrapper function launch() { if (view.model.isFolder(index)) { - dirDown(filePath) + __dirDown(filePath) } else { - root.acceptSelection() + root.__acceptSelection() } } width: content.width @@ -147,15 +146,15 @@ AbstractFileDialog { color: "transparent" Rectangle { id: itemHighlight - visible: root.selectedIndices.indexOf(index) >= 0 + visible: root.__selectedIndices.indexOf(index) >= 0 anchors.fill: parent - color: palette.highlight + color: __palette.highlight } Image { id: icon source: "images/folder.png" height: wrapper.height - y * 2; width: height - x: (root.textX - width) / 2 + x: (root.__textX - width) / 2 y: 2 visible: view.model.isFolder(index) } @@ -163,45 +162,45 @@ AbstractFileDialog { id: nameText anchors.fill: parent; verticalAlignment: Text.AlignVCenter text: fileName - anchors.leftMargin: root.textX - color: itemHighlight.visible ? palette.highlightedText : palette.windowText + anchors.leftMargin: root.__textX + color: itemHighlight.visible ? __palette.highlightedText : __palette.windowText elide: Text.ElideRight } MouseArea { id: mouseRegion anchors.fill: parent onDoubleClicked: { - selectedIndices = [index] - root.lastClickedIdx = index + __selectedIndices = [index] + root.__lastClickedIdx = index launch() } onClicked: { view.currentIndex = index if (mouse.modifiers & Qt.ControlModifier && root.selectMultiple) { - // modifying the contents of selectedIndices doesn't notify, + // modifying the contents of __selectedIndices doesn't notify, // so we have to re-assign the variable - var selCopy = selectedIndices + var selCopy = __selectedIndices var existingIdx = selCopy.indexOf(index) if (existingIdx >= 0) selCopy.splice(existingIdx, 1) else selCopy.push(index) - selectedIndices = selCopy + __selectedIndices = selCopy } else if (mouse.modifiers & Qt.ShiftModifier && root.selectMultiple) { - if (root.lastClickedIdx >= 0) { + if (root.__lastClickedIdx >= 0) { var sel = [] - if (index > lastClickedIdx) { - for (var i = root.lastClickedIdx; i <= index; i++) + if (index > __lastClickedIdx) { + for (var i = root.__lastClickedIdx; i <= index; i++) sel.push(i) } else { - for (var i = root.lastClickedIdx; i >= index; i--) + for (var i = root.__lastClickedIdx; i >= index; i--) sel.push(i) } - selectedIndices = sel + __selectedIndices = sel } } else { - selectedIndices = [index] - root.lastClickedIdx = index + __selectedIndices = [index] + root.__lastClickedIdx = index } } } @@ -212,13 +211,13 @@ AbstractFileDialog { event.accepted = true switch (event.key) { case Qt.Key_Up: - root.up(event.modifiers & Qt.ShiftModifier && root.selectMultiple) + root.__up(event.modifiers & Qt.ShiftModifier && root.selectMultiple) break case Qt.Key_Down: - root.down(event.modifiers & Qt.ShiftModifier && root.selectMultiple) + root.__down(event.modifiers & Qt.ShiftModifier && root.selectMultiple) break case Qt.Key_Left: - root.dirUp() + root.__dirUp() break case Qt.Key_Return: case Qt.Key_Select: @@ -226,7 +225,7 @@ AbstractFileDialog { if (view.currentItem) view.currentItem.launch() else - root.acceptSelection() + root.__acceptSelection() break case Qt.Key_Back: case Qt.Key_Escape: @@ -265,7 +264,7 @@ AbstractFileDialog { delegate: folderDelegate highlight: Rectangle { color: "transparent" - border.color: Qt.darker(palette.window, 1.3) + border.color: Qt.darker(__palette.window, 1.3) } highlightMoveDuration: 0 highlightMoveVelocity: -1 @@ -284,12 +283,12 @@ AbstractFileDialog { height: currentPathField.height * 1.5 Rectangle { anchors.fill: parent - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) + color: Qt.darker(__palette.window, 1.1) + border.color: Qt.darker(__palette.window, 1.3) } Rectangle { id: upButton - width: root.textX + width: root.__textX height: titleBar.height color: "transparent" @@ -300,22 +299,22 @@ AbstractFileDialog { MouseArea { id: upRegion; anchors.centerIn: parent width: 56 height: parent.height - onClicked: if (view.model.parentFolder != "") dirUp() + onClicked: if (view.model.parentFolder !== "") __dirUp() } states: [ State { name: "pressed" when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } + PropertyChanges { target: upButton; color: __palette.highlight } } ] } Text { id: currentPathText anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: textX; anchors.rightMargin: content.spacing + anchors.leftMargin: __textX; anchors.rightMargin: content.spacing text: root.urlToPath(view.model.folder) - color: palette.text + color: __palette.text elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter MouseArea { anchors.fill: parent @@ -325,7 +324,7 @@ AbstractFileDialog { TextField { id: currentPathField anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: textX; anchors.rightMargin: content.spacing + anchors.leftMargin: __textX; anchors.rightMargin: content.spacing visible: false focus: visible onAccepted: { @@ -345,8 +344,8 @@ AbstractFileDialog { width: parent.width height: buttonRow.height + buttonRow.spacing * 2 anchors.bottom: parent.bottom - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) + color: Qt.darker(__palette.window, 1.1) + border.color: Qt.darker(__palette.window, 1.3) Row { id: buttonRow @@ -375,9 +374,9 @@ AbstractFileDialog { text: "OK" onClicked: { if (view.model.isFolder(view.currentIndex) && !selectFolder) - dirDown(view.model.get(view.currentIndex, "filePath")) + __dirDown(view.model.get(view.currentIndex, "filePath")) else - root.acceptSelection() + root.__acceptSelection() } } }