forked from qt-creator/qt-creator
QmlDesigner: Pill redesign
Change-Id: I3c28599c3cbc1555fbdb206e387dccf6f45a77cd Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
fedb38a0f5
commit
55034b1cde
@@ -33,15 +33,10 @@ FocusScope {
|
|||||||
readonly property int margin: StudioTheme.Values.flowPillMargin
|
readonly property int margin: StudioTheme.Values.flowPillMargin
|
||||||
property var operatorModel
|
property var operatorModel
|
||||||
|
|
||||||
width: {
|
property bool hovered: rootMouseArea.containsMouse
|
||||||
if (root.isEditable()) {
|
property bool selected: root.focus
|
||||||
if (root.isInvalid())
|
|
||||||
return textInput.width + 1 + 2 * root.margin
|
width: row.width
|
||||||
else
|
|
||||||
return textInput.width + 1
|
|
||||||
}
|
|
||||||
return textItem.contentWidth + icon.width + root.margin
|
|
||||||
}
|
|
||||||
height: StudioTheme.Values.flowPillHeight
|
height: StudioTheme.Values.flowPillHeight
|
||||||
|
|
||||||
onActiveFocusChanged: {
|
onActiveFocusChanged: {
|
||||||
@@ -69,14 +64,34 @@ FocusScope {
|
|||||||
id: pill
|
id: pill
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: {
|
color: {
|
||||||
if (root.isShadow())
|
if (root.isIntermediate())
|
||||||
return StudioTheme.Values.themeInteraction
|
|
||||||
if (root.isEditable())
|
|
||||||
return "transparent"
|
return "transparent"
|
||||||
|
|
||||||
return StudioTheme.Values.themePillBackground
|
if (root.isShadow())
|
||||||
|
return StudioTheme.Values.themePillShadowBackground
|
||||||
|
|
||||||
|
if (root.isInvalid() && root.selected)
|
||||||
|
return StudioTheme.Values.themeWarning
|
||||||
|
|
||||||
|
if (root.hovered) {
|
||||||
|
if (root.isOperator())
|
||||||
|
return StudioTheme.Values.themePillOperatorBackgroundHover
|
||||||
|
if (root.isLiteral())
|
||||||
|
return StudioTheme.Values.themePillLiteralBackgroundHover
|
||||||
|
|
||||||
|
return StudioTheme.Values.themePillDefaultBackgroundHover
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.isLiteral())
|
||||||
|
return StudioTheme.Values.themePillLiteralBackgroundIdle
|
||||||
|
|
||||||
|
if (root.isOperator())
|
||||||
|
return StudioTheme.Values.themePillOperatorBackgroundIdle
|
||||||
|
|
||||||
|
return StudioTheme.Values.themePillDefaultBackgroundIdle
|
||||||
}
|
}
|
||||||
border.color: root.isInvalid() ? StudioTheme.Values.themeWarning : "white" // TODO colors
|
border.color: root.isInvalid() ? StudioTheme.Values.themeWarning
|
||||||
|
: StudioTheme.Values.themePillOutline
|
||||||
border.width: {
|
border.width: {
|
||||||
if (root.isShadow())
|
if (root.isShadow())
|
||||||
return 0
|
return 0
|
||||||
@@ -84,7 +99,7 @@ FocusScope {
|
|||||||
return 1
|
return 1
|
||||||
if (root.isEditable())
|
if (root.isEditable())
|
||||||
return 0
|
return 0
|
||||||
if (rootMouseArea.containsMouse || root.focus)
|
if (root.selected)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -93,31 +108,60 @@ FocusScope {
|
|||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: row
|
id: row
|
||||||
anchors.left: parent.left
|
leftPadding: root.margin
|
||||||
anchors.leftMargin: root.margin
|
rightPadding: icon.visible ? 0 : root.margin
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
visible: root.isOperator() || root.isProperty() || root.isShadow()
|
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: textItem
|
id: textItem
|
||||||
|
height: StudioTheme.Values.flowPillHeight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||||
color: root.isShadow() ? StudioTheme.Values.themeTextSelectedTextColor
|
color: root.isShadow() ? StudioTheme.Values.themeTextSelectedTextColor
|
||||||
: StudioTheme.Values.themeTextColor
|
: StudioTheme.Values.themeTextColor
|
||||||
text: root.isOperator() ? root.operatorModel.convertValueToName(root.value)
|
text: root.isOperator() ? root.operatorModel.convertValueToName(root.value)
|
||||||
: root.value
|
: root.value
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
visible: root.isOperator() || root.isProperty() || root.isShadow()
|
||||||
|
}
|
||||||
|
|
||||||
|
TextInput {
|
||||||
|
id: textInput
|
||||||
|
|
||||||
|
x: root.isInvalid() ? root.margin : 0
|
||||||
|
height: StudioTheme.Values.flowPillHeight
|
||||||
|
topPadding: 1
|
||||||
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||||
|
color: root.isInvalid() && root.selected ? StudioTheme.Values.themeTextSelectedTextColor
|
||||||
|
: StudioTheme.Values.themeTextColor
|
||||||
|
text: root.value
|
||||||
|
visible: !textItem.visible
|
||||||
|
enabled: root.isEditable()
|
||||||
|
|
||||||
|
onEditingFinished: {
|
||||||
|
root.update(textInput.text) // emit
|
||||||
|
root.submit(textInput.cursorPosition) // emit
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onPressed: function (event) {
|
||||||
|
if (event.key === Qt.Key_Backspace) {
|
||||||
|
if (textInput.text !== "")
|
||||||
|
return
|
||||||
|
|
||||||
|
root.remove() // emit
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: icon
|
id: icon
|
||||||
width: root.isShadow() ? root.margin : StudioTheme.Values.flowPillHeight
|
width: StudioTheme.Values.flowPillHeight
|
||||||
height: StudioTheme.Values.flowPillHeight
|
height: StudioTheme.Values.flowPillHeight
|
||||||
visible: !root.isShadow()
|
visible: !root.isShadow() && !root.isIntermediate()
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
font.family: StudioTheme.Constants.iconFont.family
|
font.family: StudioTheme.Constants.iconFont.family
|
||||||
font.pixelSize: StudioTheme.Values.smallIconFontSize
|
font.pixelSize: StudioTheme.Values.smallIconFontSize
|
||||||
color: StudioTheme.Values.themeIconColor
|
color: root.isInvalid() && root.selected ? StudioTheme.Values.themeTextSelectedTextColor
|
||||||
|
: StudioTheme.Values.themeTextColor
|
||||||
text: StudioTheme.Constants.close_small
|
text: StudioTheme.Constants.close_small
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
@@ -129,35 +173,5 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextInput {
|
|
||||||
id: textInput
|
|
||||||
|
|
||||||
x: root.isInvalid() ? root.margin : 0
|
|
||||||
height: StudioTheme.Values.flowPillHeight
|
|
||||||
topPadding: 1
|
|
||||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
|
||||||
color: (rootMouseArea.containsMouse || textInput.activeFocus) ? StudioTheme.Values.themeIconColor
|
|
||||||
: StudioTheme.Values.themeTextColor
|
|
||||||
text: root.value
|
|
||||||
visible: root.isEditable()
|
|
||||||
enabled: root.isEditable()
|
|
||||||
|
|
||||||
//validator: RegularExpressionValidator { regularExpression: /^\S+/ }
|
|
||||||
|
|
||||||
onEditingFinished: {
|
|
||||||
root.update(textInput.text) // emit
|
|
||||||
root.submit(textInput.cursorPosition) // emit
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onPressed: function (event) {
|
|
||||||
if (event.key === Qt.Key_Backspace) {
|
|
||||||
if (textInput.text !== "")
|
|
||||||
return
|
|
||||||
|
|
||||||
root.remove() // emit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -442,7 +442,16 @@ QtObject {
|
|||||||
property color themeDialogOutline: values.themeInteraction
|
property color themeDialogOutline: values.themeInteraction
|
||||||
|
|
||||||
// Expression Builder
|
// Expression Builder
|
||||||
property color themePillBackground: Theme.color(Theme.DSdockWidgetSplitter)
|
property color themePillDefaultBackgroundIdle: "#ff000000"
|
||||||
|
property color themePillDefaultBackgroundHover: "#ff2c2c2c"
|
||||||
|
property color themePillOperatorBackgroundIdle: "#ff6b2a7b"
|
||||||
|
property color themePillOperatorBackgroundHover: "#ff7e478b"
|
||||||
|
property color themePillLiteralBackgroundIdle: "#ffb2005c"
|
||||||
|
property color themePillLiteralBackgroundHover: "#ffb24e81"
|
||||||
|
|
||||||
|
property color themePillShadowBackground: values.themeInteraction
|
||||||
|
|
||||||
|
property color themePillOutline: "#ffffffff"
|
||||||
|
|
||||||
|
|
||||||
// Control Style Mapping
|
// Control Style Mapping
|
||||||
|
Reference in New Issue
Block a user