diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-08-05 10:42:21 +0200 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-08-05 10:42:21 +0200 |
commit | 1d3b9db5b54d8ae99c6b149c8d3d91eda19b5838 (patch) | |
tree | 9ffbf9d6d2ed6b0aef6155215767c56655ff405b /src/imports | |
parent | 45792359f25813af18b7416e4c18737ed4b20bff (diff) | |
parent | 0316506d9ddbc3ca9f26f880b9e7fb5d5b0fec36 (diff) |
Merge branch 'stable' into dev
Conflicts:
.qmake.conf
Change-Id: I06f79bcbde13c7b12905492a17dbcbb4a594e557
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/dialogs/DefaultColorDialog.qml | 27 | ||||
-rw-r--r-- | src/imports/dialogs/qquickabstractcolordialog_p.h | 8 | ||||
-rw-r--r-- | src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 16 |
3 files changed, 33 insertions, 18 deletions
diff --git a/src/imports/dialogs/DefaultColorDialog.qml b/src/imports/dialogs/DefaultColorDialog.qml index 8636259957..44af99bf18 100644 --- a/src/imports/dialogs/DefaultColorDialog.qml +++ b/src/imports/dialogs/DefaultColorDialog.qml @@ -45,11 +45,23 @@ import "qml" AbstractColorDialog { id: root + property bool _valueSet: true // guard to prevent binding loops + function _setControlsFromColor() { + _valueSet = false + hueSlider.value = root.hue + saturationSlider.value = root.saturation + lightnessSlider.value = root.lightness + alphaSlider.value = root.alpha + crosshairs.x = root.lightness * paletteMap.width + crosshairs.y = (1.0 - root.saturation) * paletteMap.height + _valueSet = true + } + onColorChanged: _setControlsFromColor() Rectangle { id: content property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - implicitHeight: Math.max(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 10 : 5)) + implicitHeight: Math.min(maxSize, Screen.logicalPixelDensity * (usePaletteMap ? 100 : 50)) implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5 color: palette.window property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3 @@ -62,12 +74,6 @@ AbstractColorDialog { SystemPalette { id: palette } - Binding { - target: root - property: "color" - value: Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) - } - Item { id: paletteFrame visible: content.usePaletteMap @@ -83,6 +89,7 @@ AbstractColorDialog { id: paletteMap x: (parent.width - width) / 2 width: height + onWidthChanged: root._setControlsFromColor() height: parent.height source: "images/checkers.png" fillMode: Image.Tile @@ -197,6 +204,7 @@ AbstractColorDialog { ColorSlider { id: hueSlider value: 0.5 + onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Hue") trackDelegate: Rectangle { rotation: -90 @@ -217,6 +225,7 @@ AbstractColorDialog { id: saturationSlider visible: !content.usePaletteMap value: 0.5 + onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Saturation") trackDelegate: Rectangle { rotation: -90 @@ -232,6 +241,7 @@ AbstractColorDialog { id: lightnessSlider visible: !content.usePaletteMap value: 0.5 + onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Luminosity") trackDelegate: Rectangle { rotation: -90 @@ -249,6 +259,7 @@ AbstractColorDialog { minimum: 0.0 maximum: 1.0 value: 1.0 + onValueChanged: if (_valueSet) root.color = Qt.hsla(hueSlider.value, saturationSlider.value, lightnessSlider.value, alphaSlider.value) text: qsTr("Alpha") visible: root.showAlphaChannel trackDelegate: Item { @@ -273,7 +284,7 @@ AbstractColorDialog { Item { id: buttonRow - height: buttonsOnly.height + height: Math.max(buttonsOnly.height, copyIcon.height) width: parent.width anchors { left: parent.left diff --git a/src/imports/dialogs/qquickabstractcolordialog_p.h b/src/imports/dialogs/qquickabstractcolordialog_p.h index 46f0f84acb..bd23e0d1a4 100644 --- a/src/imports/dialogs/qquickabstractcolordialog_p.h +++ b/src/imports/dialogs/qquickabstractcolordialog_p.h @@ -66,6 +66,10 @@ class QQuickAbstractColorDialog : public QQuickAbstractDialog Q_OBJECT Q_PROPERTY(bool showAlphaChannel READ showAlphaChannel WRITE setShowAlphaChannel NOTIFY showAlphaChannelChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(qreal hue READ hue NOTIFY colorChanged) + Q_PROPERTY(qreal saturation READ saturation NOTIFY colorChanged) + Q_PROPERTY(qreal lightness READ lightness NOTIFY colorChanged) + Q_PROPERTY(qreal alpha READ alpha NOTIFY colorChanged) public: QQuickAbstractColorDialog(QObject *parent = 0); @@ -74,6 +78,10 @@ public: virtual QString title() const; bool showAlphaChannel() const; QColor color() const { return m_color; } + qreal hue() const { return m_color.hslHueF(); } + qreal saturation() const { return m_color.hslSaturationF(); } + qreal lightness() const { return m_color.lightnessF(); } + qreal alpha() const { return m_color.alphaF(); } public Q_SLOTS: void setVisible(bool v); diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 2f9c07cf20..bb65ddbccc 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -488,16 +488,12 @@ QUrl QQuickFolderListModel::parentFolder() const QString localFile = d->currentDir.toLocalFile(); if (!localFile.isEmpty()) { QDir dir(localFile); -#if defined(Q_OS_WIN) - if (dir.isRoot()) - dir.setPath(""); - else -#endif - dir.cdUp(); + if (dir.isRoot() || !dir.cdUp()) + return QUrl(); localFile = dir.path(); } else { - int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/')); - if (pos == -1) + const int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/')); + if (pos <= 0) return QUrl(); localFile = d->currentDir.path().left(pos); } @@ -541,8 +537,8 @@ void QQuickFolderListModel::componentComplete() { Q_D(QQuickFolderListModel); - if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile())) - setFolder(QUrl(QLatin1String("file://")+QDir::currentPath())); + if (!d->currentDir.isValid() || !d->currentDir.isLocalFile() || !QDir().exists(d->currentDir.toLocalFile())) + setFolder(QUrl::fromLocalFile(QDir::currentPath())); } /*! |