QmlDesigner: Use studio controls for property editor

* CheckBox
 * ComboBox
 * LineEdit

Adjusting some details in property editor.

Change-Id: I8f9d6ef87c187f5a3be7c5fb368a1813e6dba92c
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2019-06-05 16:28:52 +02:00
parent a18d3d1f9a
commit 029884c80e
13 changed files with 97 additions and 128 deletions

View File

@@ -73,7 +73,7 @@ Column {
SpinBox { SpinBox {
backendValue: backendValues.border_width backendValue: backendValues.border_width
hasSlider: true hasSlider: true
Layout.preferredWidth: 80 Layout.preferredWidth: 120
} }
ExpandingSpacer { ExpandingSpacer {
@@ -86,7 +86,7 @@ Column {
SpinBox { SpinBox {
backendValue: backendValues.radius backendValue: backendValues.radius
hasSlider: true hasSlider: true
Layout.preferredWidth: 80 Layout.preferredWidth: 120
minimumValue: 0 minimumValue: 0
maximumValue: Math.min(backendValues.height.value, backendValues.width.value) / 2 maximumValue: Math.min(backendValues.height.value, backendValues.width.value) / 2
} }

View File

@@ -24,26 +24,25 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.1 as Controls import StudioControls 1.0 as Controls
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
Controls.CheckBox { Controls.CheckBox {
id: checkBox id: checkBox
property color textColor: colorLogic.textColor
opacity: enabled ? 1 : 0.5
property variant backendValue property variant backendValue
property string tooltip
ExtendedFunctionButton { ExtendedFunctionLogic {
x: 22 id: extFuncLogic
anchors.verticalCenter: parent.verticalCenter
backendValue: checkBox.backendValue backendValue: checkBox.backendValue
visible: checkBox.enabled
} }
actionIndicator.icon.color: extFuncLogic.color
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
labelColor: colorLogic.textColor
ColorLogic { ColorLogic {
id: colorLogic id: colorLogic
backendValue: checkBox.backendValue backendValue: checkBox.backendValue
@@ -58,8 +57,4 @@ Controls.CheckBox {
backendValue.value = checkBox.checked; backendValue.value = checkBox.checked;
} }
style: CustomCheckBoxStyle {
}
} }

View File

@@ -24,7 +24,7 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.1 as Controls import StudioControls 1.0 as Controls
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
Controls.ComboBox { Controls.ComboBox {
@@ -32,7 +32,7 @@ Controls.ComboBox {
property variant backendValue property variant backendValue
property color textColor: colorLogic.textColor labelColor: colorLogic.textColor
property string scope: "Qt" property string scope: "Qt"
property bool useInteger: false property bool useInteger: false
@@ -45,6 +45,15 @@ Controls.ComboBox {
property bool block: false property bool block: false
ExtendedFunctionLogic {
id: extFuncLogic
backendValue: comboBox.backendValue
}
actionIndicator.icon.color: extFuncLogic.color
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
ColorLogic { ColorLogic {
id: colorLogic id: colorLogic
backendValue: comboBox.backendValue backendValue: comboBox.backendValue
@@ -84,7 +93,7 @@ Controls.ComboBox {
} }
} }
onCurrentTextChanged: { onActivated: {
if (!__isCompleted) if (!__isCompleted)
return; return;
@@ -106,14 +115,4 @@ Controls.ComboBox {
__isCompleted = true; __isCompleted = true;
} }
style: CustomComboBoxStyle {
textColor: comboBox.textColor
}
ExtendedFunctionButton {
x: 2
anchors.verticalCenter: parent.verticalCenter
backendValue: comboBox.backendValue
visible: comboBox.enabled
}
} }

View File

@@ -26,7 +26,7 @@
import QtQuick 2.1 import QtQuick 2.1
import StudioControls 1.0 as StudioControls import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
import QtQuickDesignerTheme 1.0
Item { Item {
id: extendedFunctionButton id: extendedFunctionButton

View File

@@ -28,6 +28,7 @@ import QtQuick.Controls 1.1 as Controls
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Private 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import StudioTheme 1.0 as StudioTheme
Controls.Label { Controls.Label {
id: label id: label
@@ -40,6 +41,8 @@ Controls.Label {
color: Theme.color(Theme.PanelTextColorLight) color: Theme.color(Theme.PanelTextColorLight)
elide: Text.ElideRight elide: Text.ElideRight
font.pixelSize: StudioTheme.Values.myFontSize
Layout.preferredWidth: width Layout.preferredWidth: width
Layout.minimumWidth: width Layout.minimumWidth: width
Layout.maximumWidth: width Layout.maximumWidth: width

View File

@@ -24,24 +24,20 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 as Controls import StudioControls 1.0 as Controls
import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Styles 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
Controls.TextField { Controls.TextField {
Controls.Action {
//Workaround to avoid that "Delete" deletes the item.
shortcut: "Delete"
}
id: lineEdit id: lineEdit
property variant backendValue property variant backendValue
property color borderColor: "#222" property color borderColor: "#222"
property color highlightColor: "orange" property color highlightColor: "orange"
property color textColor: colorLogic.textColor color: colorLogic.textColor
property bool showTranslateCheckBox: true property bool showTranslateCheckBox: true
translationIndicatorVisible: showTranslateCheckBox
property bool writeValueManually: false property bool writeValueManually: false
@@ -58,19 +54,21 @@ Controls.TextField {
if (translateFunction() === "qsTranslate") { if (translateFunction() === "qsTranslate") {
backendValue.expression = translateFunction() backendValue.expression = translateFunction()
+ "(\"" + backendValue.getTranslationContext() + "(\"" + backendValue.getTranslationContext()
+ "\", " + "\"" + trCheckbox.escapeString(text) + "\")" + "\", " + "\"" + escapeString(text) + "\")"
} else { } else {
backendValue.expression = translateFunction() + "(\"" + trCheckbox.escapeString(text) + "\")" backendValue.expression = translateFunction() + "(\"" + escapeString(text) + "\")"
} }
} }
ExtendedFunctionButton { ExtendedFunctionLogic {
x: 4 id: extFuncLogic
anchors.verticalCenter: parent.verticalCenter
backendValue: lineEdit.backendValue backendValue: lineEdit.backendValue
visible: lineEdit.enabled && showExtendedFunctionButton
} }
actionIndicator.icon.color: extFuncLogic.color
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
ColorLogic { ColorLogic {
id: colorLogic id: colorLogic
backendValue: lineEdit.backendValue backendValue: lineEdit.backendValue
@@ -102,7 +100,6 @@ Controls.TextField {
} }
onEditingFinished: { onEditingFinished: {
if (writeValueManually) if (writeValueManually)
return return
@@ -118,87 +115,35 @@ Controls.TextField {
__dirty = false __dirty = false
} }
style: TextFieldStyle { property bool isTranslated: colorLogic.backendValue.isTranslated
selectionColor: Theme.color(Theme.PanelTextColorLight) translationIndicator.onClicked: {
selectedTextColor: Theme.color(Theme.PanelTextColorMid) if (translationIndicator.checked) {
textColor: lineEdit.textColor setTranslateExpression()
placeholderTextColor: Theme.color(Theme.PanelTextColorMid) } else {
var textValue = lineEdit.text
padding.top: 2 lineEdit.backendValue.value = textValue
padding.bottom: 2
padding.left: 18
padding.right: lineEdit.showTranslateCheckBox ? 16 : 1
background: Rectangle {
implicitWidth: 100
implicitHeight: 24
color: Theme.qmlDesignerBackgroundColorDarker()
border.color: Theme.qmlDesignerBorderColor()
} }
colorLogic.evaluate();
} }
Controls.CheckBox { property variant backendValueValueInternal: backendValue.value
anchors.right: parent.right onBackendValueValueInternalChanged: {
anchors.verticalCenter: parent.verticalCenter lineEdit.translationIndicator.checked = lineEdit.backendValue.isTranslated
id: trCheckbox
property bool isTranslated: colorLogic.backendValue.isTranslated
property bool backendValueValue: colorLogic.backendValue.value
onIsTranslatedChanged: {
checked = lineEdit.backendValue.isTranslated
}
onBackendValueValueChanged: {
checked = lineEdit.backendValue.isTranslated
}
onClicked: {
if (trCheckbox.checked) {
setTranslateExpression()
} else {
var textValue = lineEdit.text
lineEdit.backendValue.value = textValue
}
colorLogic.evaluate();
}
function escapeString(string) {
var str = string;
str = str.replace(/\\/g, "\\\\");
str.replace(/\"/g, "\\\"");
str = str.replace(/\t/g, "\\t");
str = str.replace(/\r/g, "\\r");
str = str.replace(/\n/g, '\\n');
return str;
}
visible: showTranslateCheckBox
style: CheckBoxStyle {
spacing: 8
indicator: Item {
implicitWidth: 15
implicitHeight: 15
x: 7
y: 1
Rectangle {
anchors.fill: parent
border.color: Theme.qmlDesignerBorderColor()
color: Theme.qmlDesignerBackgroundColorDarker()
opacity: control.hovered || control.pressed ? 1 : 0.75
}
Image {
x: 1
y: 1
width: 13
height: 13
source: "image://icons/tr"
opacity: control.checked ? 1 : 0.3;
}
}
}
} }
onIsTranslatedChanged: {
lineEdit.translationIndicator.checked = lineEdit.backendValue.isTranslated
}
function escapeString(string) {
var str = string;
str = str.replace(/\\/g, "\\\\");
str.replace(/\"/g, "\\\"");
str = str.replace(/\t/g, "\\t");
str = str.replace(/\r/g, "\\r");
str = str.replace(/\n/g, '\\n');
return str;
}
} }

View File

@@ -27,6 +27,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.1 as Controls import QtQuick.Controls 1.1 as Controls
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import StudioTheme 1.0 as StudioTheme
Item { Item {
id: section id: section
@@ -54,6 +55,7 @@ Item {
color: Theme.color(Theme.PanelTextColorLight) color: Theme.color(Theme.PanelTextColorLight)
x: 22 x: 22
font.bold: true font.bold: true
font.pixelSize: StudioTheme.Values.myFontSize
} }
Image { Image {

View File

@@ -39,7 +39,7 @@ Item {
property alias backendValue: spinBox.backendValue property alias backendValue: spinBox.backendValue
width: 100 width: 120
implicitHeight: spinBox.height implicitHeight: spinBox.height
property bool __initialized: false property bool __initialized: false
@@ -60,7 +60,7 @@ Item {
if (!wrapper.__initialized) if (!wrapper.__initialized)
return return
spinBox[target] = Math.round(value * spinBox.factor) spinBox[target] = Math.round(value * spinBox.factor)
} }
StudioControls.SpinBox { StudioControls.SpinBox {
id: spinBox id: spinBox

View File

@@ -27,6 +27,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0 as Controls import QtQuick.Controls 1.0 as Controls
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import StudioTheme 1.0 as StudioTheme
Controls.TabView { Controls.TabView {
id: root id: root
@@ -42,6 +43,7 @@ Controls.TabView {
Text { Text {
id: text id: text
font.bold: true font.bold: true
font.pixelSize: StudioTheme.Values.myFontSize
anchors.centerIn: parent anchors.centerIn: parent
anchors.verticalCenterOffset: -1 anchors.verticalCenterOffset: -1
text: styleData.title text: styleData.title

View File

@@ -30,7 +30,7 @@ import StudioTheme 1.0 as StudioTheme
T.CheckBox { T.CheckBox {
id: myCheckBox id: myCheckBox
property alias actionIcon: actionIndicator.icon property alias actionIndicator: actionIndicator
property bool hover: myCheckBox.hovered // TODO two underscores property bool hover: myCheckBox.hovered // TODO two underscores
@@ -39,6 +39,7 @@ T.CheckBox {
property real __actionIndicatorHeight: StudioTheme.Values.height property real __actionIndicatorHeight: StudioTheme.Values.height
property alias labelVisible: checkBoxLabel.visible property alias labelVisible: checkBoxLabel.visible
property alias labelColor: checkBoxLabel.color
font.pixelSize: StudioTheme.Values.myFontSize font.pixelSize: StudioTheme.Values.myFontSize

View File

@@ -31,7 +31,9 @@ import StudioTheme 1.0 as StudioTheme
T.ComboBox { T.ComboBox {
id: myComboBox id: myComboBox
property alias actionIcon: actionIndicator.icon property alias actionIndicator: actionIndicator
property alias labelColor: comboBoxInput.color
property bool hover: false // This property is used to indicate the global hover state property bool hover: false // This property is used to indicate the global hover state

View File

@@ -30,7 +30,9 @@ import StudioTheme 1.0 as StudioTheme
T.TextField { T.TextField {
id: myTextField id: myTextField
property alias actionIcon: actionIndicator.icon property alias actionIndicator: actionIndicator
property alias translationIndicator: translationIndicator
property bool edit: false property bool edit: false
property bool hover: false // This property is used to indicate the global hover state property bool hover: false // This property is used to indicate the global hover state

View File

@@ -34,6 +34,9 @@ Item {
property bool hover: false property bool hover: false
property bool pressed: false property bool pressed: false
property bool checked: false
signal clicked
state: "default" state: "default"
@@ -67,6 +70,10 @@ Item {
hoverEnabled: true hoverEnabled: true
onContainsMouseChanged: translationIndicator.hover = containsMouse onContainsMouseChanged: translationIndicator.hover = containsMouse
onPressed: mouse.accepted = true // TODO onPressed: mouse.accepted = true // TODO
onClicked: {
translationIndicator.checked = !translationIndicator.checked
translationIndicator.clicked()
}
} }
} }
@@ -88,12 +95,23 @@ Item {
when: myControl.enabled && !translationIndicator.hover when: myControl.enabled && !translationIndicator.hover
&& !translationIndicator.pressed && !myControl.hover && !translationIndicator.pressed && !myControl.hover
&& !myControl.edit && !myControl.drag && !myControl.edit && !myControl.drag
&& !translationIndicator.checked
PropertyChanges { PropertyChanges {
target: translationIndicatorBackground target: translationIndicatorBackground
color: StudioTheme.Values.themeColumnBackground color: StudioTheme.Values.themeColumnBackground
border.color: StudioTheme.Values.themeTranslationIndicatorBorder border.color: StudioTheme.Values.themeTranslationIndicatorBorder
} }
}, },
State {
name: "checked"
when: translationIndicator.checked
PropertyChanges {
target: translationIndicatorBackground
//color: StudioTheme.Values.themeFocusDrag // TODO
color: "red"
}
},
State { State {
name: "hovered" name: "hovered"
when: translationIndicator.hover && !translationIndicator.pressed when: translationIndicator.hover && !translationIndicator.pressed