Fix bad behavior of ColorButton and ColorDialog.

This commit is contained in:
Filippo Scognamiglio 2014-12-29 12:09:24 +01:00
parent 9364aa3536
commit f6fc65bffd
2 changed files with 14 additions and 12 deletions

View File

@ -22,8 +22,8 @@ import QtQuick 2.2
import QtQuick.Dialogs 1.1
Item {
signal colorSelected (color color)
property color button_color
id: rootItem
property alias color: colorDialog.color
property string name
ColorDialog {
@ -31,15 +31,11 @@ Item {
title: qsTr("Choose a color")
modality: Qt.ApplicationModal
visible: false
//This is a workaround to a Qt 5.2 bug.
onCurrentColorChanged: colorDialog.color = colorDialog.currentColor;
onAccepted: colorSelected(color)
}
Rectangle{
anchors.fill: parent
radius: 10
color: button_color
color: rootItem.color
border.color: "black"
Glossy {}
Rectangle {
@ -52,7 +48,7 @@ Item {
Text{
anchors.centerIn: parent
z: parent.z + 1
text: name + ": " + button_color
text: name + ": " + rootItem.color
}
}
MouseArea{

View File

@ -121,18 +121,24 @@ Tab{
RowLayout{
Layout.fillWidth: true
ColorButton{
property color settingsColor: appSettings._fontColor
onSettingsColorChanged: color = settingsColor
name: qsTr("Font")
height: 50
Layout.fillWidth: true
onColorSelected: appSettings._fontColor = color;
button_color: appSettings._fontColor
onColorChanged: appSettings._fontColor = color
Component.onCompleted: { color = settingsColor; }
}
ColorButton{
property color settingsColor: appSettings._backgroundColor
onSettingsColorChanged: color = settingsColor
name: qsTr("Background")
height: 50
Layout.fillWidth: true
onColorSelected: appSettings._backgroundColor = color;
button_color: appSettings._backgroundColor
onColorChanged: appSettings._backgroundColor = color
Component.onCompleted: { color = settingsColor;}
}
}
}