forked from qt-creator/qt-creator
QmlDesigner: Fix UrlChooser reset behavior
* Cleanup ColorLogic (imports and source) * Shifting a value from Constants.js to Values.qml * Add a property alias on AbstractButton to allow changing the font family Change-Id: I51542f69f8f2190030a97164167d71d277147391 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
4c9ef26817
commit
b4d8e67e0d
@@ -24,61 +24,42 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.1
|
import QtQuick 2.1
|
||||||
import QtQuick.Controls 1.1 as Controls
|
|
||||||
import QtQuick.Controls.Styles 1.0
|
|
||||||
import QtQuickDesignerTheme 1.0
|
|
||||||
import "Constants.js" as Constants
|
|
||||||
import StudioTheme 1.0 as StudioTheme
|
import StudioTheme 1.0 as StudioTheme
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: innerObject
|
id: innerObject
|
||||||
|
|
||||||
property variant backendValue
|
property variant backendValue
|
||||||
property color textColor: StudioTheme.Values.themeTextColor//Theme.color(Theme.PanelTextColorLight)
|
property color textColor: StudioTheme.Values.themeTextColor
|
||||||
property variant valueFromBackend: backendValue.value;
|
property variant valueFromBackend: backendValue.value;
|
||||||
property bool baseStateFlag: isBaseState;
|
property bool baseStateFlag: isBaseState;
|
||||||
property bool isInModel: backendValue.isInModel;
|
property bool isInModel: backendValue.isInModel;
|
||||||
property bool isInSubState: backendValue.isInSubState;
|
property bool isInSubState: backendValue.isInSubState;
|
||||||
property bool highlight: textColor === __changedTextColor
|
property bool highlight: textColor === __changedTextColor
|
||||||
|
|
||||||
property color __defaultTextColor: StudioTheme.Values.themeTextColor//Theme.color(Theme.PanelTextColorLight)
|
property color __defaultTextColor: StudioTheme.Values.themeTextColor
|
||||||
readonly property color __changedTextColor: StudioTheme.Values.themeInteraction//Theme.color(Theme.QmlDesigner_HighlightColor)
|
readonly property color __changedTextColor: StudioTheme.Values.themeInteraction
|
||||||
|
|
||||||
onBackendValueChanged: {
|
onBackendValueChanged: evaluate()
|
||||||
evaluate();
|
onValueFromBackendChanged: evaluate()
|
||||||
}
|
onBaseStateFlagChanged: evaluate()
|
||||||
|
onIsInModelChanged: evaluate()
|
||||||
onValueFromBackendChanged: {
|
onIsInSubStateChanged: evaluate()
|
||||||
evaluate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onBaseStateFlagChanged: {
|
|
||||||
evaluate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onIsInModelChanged: {
|
|
||||||
evaluate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onIsInSubStateChanged: {
|
|
||||||
evaluate();
|
|
||||||
}
|
|
||||||
|
|
||||||
function evaluate() {
|
function evaluate() {
|
||||||
if (innerObject.backendValue === undefined)
|
if (innerObject.backendValue === undefined)
|
||||||
return;
|
return
|
||||||
|
|
||||||
if (baseStateFlag) {
|
if (innerObject.baseStateFlag) {
|
||||||
if (innerObject.backendValue.isInModel)
|
if (innerObject.backendValue.isInModel)
|
||||||
innerObject.textColor = __changedTextColor
|
innerObject.textColor = __changedTextColor
|
||||||
else
|
else
|
||||||
innerObject.textColor = Theme.color(Theme.PanelTextColorLight)
|
innerObject.textColor = __defaultTextColor
|
||||||
} else {
|
} else {
|
||||||
if (innerObject.backendValue.isInSubState)
|
if (innerObject.backendValue.isInSubState)
|
||||||
innerObject.textColor = Constants.colorsChangedStateText
|
innerObject.textColor = StudioTheme.Values.themeChangedStateText
|
||||||
else
|
else
|
||||||
innerObject.textColor = Theme.color(Theme.PanelTextColorLight)
|
innerObject.textColor = __defaultTextColor
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,16 +31,15 @@ import QtQuick.Controls.Styles 1.1
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: urlChooser
|
id: urlChooser
|
||||||
|
|
||||||
property variant backendValue
|
property variant backendValue
|
||||||
|
|
||||||
property color textColor: colorLogic.highlight ? colorLogic.textColor : "white"
|
property color textColor: colorLogic.highlight ? colorLogic.textColor : "white"
|
||||||
|
property string filter: "*.png *.gif *.jpg *.bmp *.jpeg *.svg *.pbm *.pgm *.ppm *.xbm *.xpm"
|
||||||
property string filter: "*.png *.gif *.jpg *.bmp *.jpeg *.svg"
|
|
||||||
|
|
||||||
FileResourcesModel {
|
FileResourcesModel {
|
||||||
|
id: fileModel
|
||||||
modelNodeBackendProperty: modelNodeBackend
|
modelNodeBackendProperty: modelNodeBackend
|
||||||
filter: urlChooser.filter
|
filter: urlChooser.filter
|
||||||
id: fileModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorLogic {
|
ColorLogic {
|
||||||
@@ -57,35 +56,31 @@ RowLayout {
|
|||||||
|
|
||||||
ExtendedFunctionLogic {
|
ExtendedFunctionLogic {
|
||||||
id: extFuncLogic
|
id: extFuncLogic
|
||||||
backendValue: comboBox.backendValue
|
backendValue: urlChooser.backendValue
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool isComplete: false
|
property bool isComplete: false
|
||||||
|
|
||||||
property bool dirty: false
|
property bool dirty: false
|
||||||
|
|
||||||
onEditTextChanged: comboBox.dirty = true
|
onEditTextChanged: comboBox.dirty = true
|
||||||
|
|
||||||
function setCurrentText(text) {
|
function setCurrentText(text) {
|
||||||
if (text === "")
|
|
||||||
return
|
|
||||||
|
|
||||||
var index = comboBox.find(text)
|
var index = comboBox.find(text)
|
||||||
if (index === -1)
|
if (index === -1)
|
||||||
currentIndex = -1
|
currentIndex = -1
|
||||||
|
|
||||||
editText = text
|
comboBox.editText = text
|
||||||
comboBox.dirty = false
|
comboBox.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
property string textValue: {
|
property string textValue: {
|
||||||
if (backendValue.isBound)
|
if (urlChooser.backendValue.isBound)
|
||||||
return backendValue.expression
|
return urlChooser.backendValue.expression
|
||||||
|
|
||||||
return backendValue.valueToString
|
return urlChooser.backendValue.valueToString
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextValueChanged: setCurrentText(textValue)
|
onTextValueChanged: comboBox.setCurrentText(comboBox.textValue)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
@@ -95,27 +90,27 @@ RowLayout {
|
|||||||
|
|
||||||
onModelChanged: {
|
onModelChanged: {
|
||||||
if (!comboBox.isComplete)
|
if (!comboBox.isComplete)
|
||||||
return;
|
return
|
||||||
|
|
||||||
setCurrentText(textValue)
|
comboBox.setCurrentText(comboBox.textValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (!comboBox.isComplete)
|
if (!comboBox.isComplete)
|
||||||
return;
|
return
|
||||||
|
|
||||||
if (backendValue.value !== editText)
|
if (comboBox.backendValue.value !== comboBox.editText)
|
||||||
backendValue.value = editText;
|
comboBox.backendValue.value = comboBox.editText
|
||||||
|
|
||||||
comboBox.dirty = false
|
comboBox.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if (comboBox.dirty)
|
if (comboBox.dirty)
|
||||||
handleActivate(comboBox.currentIndex)
|
comboBox.handleActivate(comboBox.currentIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivated: handleActivate(index)
|
onActivated: comboBox.handleActivate(index)
|
||||||
|
|
||||||
function handleActivate(index)
|
function handleActivate(index)
|
||||||
{
|
{
|
||||||
@@ -125,19 +120,19 @@ RowLayout {
|
|||||||
cText = comboBox.editText
|
cText = comboBox.editText
|
||||||
|
|
||||||
if (urlChooser.backendValue === undefined)
|
if (urlChooser.backendValue === undefined)
|
||||||
return;
|
return
|
||||||
|
|
||||||
if (!comboBox.isComplete)
|
if (!comboBox.isComplete)
|
||||||
return;
|
return
|
||||||
|
|
||||||
if (urlChooser.backendValue.value !== cText)
|
if (urlChooser.backendValue.value !== cText)
|
||||||
urlChooser.backendValue.value = cText;
|
urlChooser.backendValue.value = cText
|
||||||
|
|
||||||
comboBox.dirty = false
|
comboBox.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
//Hack to style the text input
|
// Hack to style the text input
|
||||||
for (var i = 0; i < comboBox.children.length; i++) {
|
for (var i = 0; i < comboBox.children.length; i++) {
|
||||||
if (comboBox.children[i].text !== undefined) {
|
if (comboBox.children[i].text !== undefined) {
|
||||||
comboBox.children[i].color = urlChooser.textColor
|
comboBox.children[i].color = urlChooser.textColor
|
||||||
@@ -145,55 +140,18 @@ RowLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
comboBox.isComplete = true
|
comboBox.isComplete = true
|
||||||
setCurrentText(textValue)
|
comboBox.setCurrentText(comboBox.textValue)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
RoundedPanel {
|
|
||||||
roundLeft: true
|
|
||||||
roundRight: true
|
|
||||||
width: 24
|
|
||||||
height: 18
|
|
||||||
|
|
||||||
RoundedPanel {
|
|
||||||
id: darkPanel
|
|
||||||
roundLeft: true
|
|
||||||
roundRight: true
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
PropertyAnimation {
|
|
||||||
duration: 100
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StudioControls.AbstractButton {
|
||||||
gradient: Gradient {
|
buttonIcon: "..."
|
||||||
GradientStop {color: '#444' ; position: 0}
|
iconFont: StudioTheme.Constants.font.family
|
||||||
GradientStop {color: '#333' ; position: 1}
|
iconColor: urlChooser.textColor
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
text: "..."
|
|
||||||
color: urlChooser.textColor
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
darkPanel.opacity = 1
|
|
||||||
fileModel.openFileDialog()
|
fileModel.openFileDialog()
|
||||||
if (fileModel.fileName != "")
|
if (fileModel.fileName !== "")
|
||||||
backendValue.value = fileModel.fileName
|
urlChooser.backendValue.value = fileModel.fileName
|
||||||
darkPanel.opacity = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ T.AbstractButton {
|
|||||||
|
|
||||||
property alias buttonIcon: buttonIcon.text
|
property alias buttonIcon: buttonIcon.text
|
||||||
property alias iconColor: buttonIcon.color
|
property alias iconColor: buttonIcon.color
|
||||||
|
property alias iconFont: buttonIcon.font.family
|
||||||
property alias backgroundVisible: buttonBackground.visible
|
property alias backgroundVisible: buttonBackground.visible
|
||||||
property alias backgroundRadius: buttonBackground.radius
|
property alias backgroundRadius: buttonBackground.radius
|
||||||
|
|
||||||
|
@@ -122,4 +122,7 @@ QtObject {
|
|||||||
property string themeControlBackgroundInteraction: "#404040" // TODO Name. Right now themeFocusEdit is used for all 'edit' states. Is that correct? Different color!
|
property string themeControlBackgroundInteraction: "#404040" // TODO Name. Right now themeFocusEdit is used for all 'edit' states. Is that correct? Different color!
|
||||||
|
|
||||||
property string themeTranslationIndicatorBorder: "#7f7f7f"
|
property string themeTranslationIndicatorBorder: "#7f7f7f"
|
||||||
|
|
||||||
|
// Taken out of Constants.js
|
||||||
|
property string themeChangedStateText: "#99ccff"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user