QmlDesigner: Controls 1 cleanup

* Replace ScrollView Controls 1 with ScrollView Controls 2
* Replace TabView with TabBar and StackLayout
* Remove unused styles
* Replace Controls 1 imports
* Remove print statement in FontSection
* Fix layout width by correcting CheckBox width
* Remove TabView from QtObjectPane

Task-number: QDS-2454
Task-number: QDS-2455
Task-number: QDS-2456
Change-Id: I913d326afb012375dd5b804171cb8cd67681514c
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2020-07-03 16:17:54 +02:00
committed by Henning Gründl
parent 245c9c760f
commit 58ea14aea7
29 changed files with 839 additions and 809 deletions

View File

@@ -23,9 +23,8 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.1 import QtQuick.Controls 2.15
import QtQuick.Controls.Styles 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0 import HelperWidgets 2.0
@@ -76,8 +75,6 @@ Item {
id: mouseRegion id: mouseRegion
anchors.fill: parent anchors.fill: parent
tooltip: itemName tooltip: itemName
onPressed: { onPressed: {
rootView.startDragAndDrop(mouseRegion, itemLibraryEntry) rootView.startDragAndDrop(mouseRegion, itemLibraryEntry)
} }

View File

@@ -23,15 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.1 import QtQuick.Layouts 1.15
import QtQuick.Controls.Styles 1.0
import "../common"
import QtQuick.Layouts 1.0
import HelperWidgets 2.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioTheme 1.0 as StudioTheme
/* The view displaying the item grid. /* The view displaying the item grid.
@@ -65,9 +61,6 @@ ScrollView {
Item { Item {
id: styleConstants id: styleConstants
readonly property color backgroundColor: Theme.qmlDesignerBackgroundColorDarkAlternate()
readonly property color lighterBackgroundColor: Theme.color(Theme.FancyToolBarSeparatorColor)
property int textWidth: 58 property int textWidth: 58
property int textHeight: Theme.smallFontPixelSize() * 2 property int textHeight: Theme.smallFontPixelSize() * 2
@@ -81,48 +74,37 @@ ScrollView {
2 * cellVerticalMargin + cellVerticalSpacing 2 * cellVerticalMargin + cellVerticalSpacing
} }
Rectangle { Column {
id: background id: column
anchors.fill: parent Repeater {
color: styleConstants.backgroundColor model: itemLibraryModel // to be set in Qml context
} delegate: Section {
width: itemsView.width -
(itemsView.verticalScrollBarVisible ? StudioTheme.Values.scrollBarThickness : 0)
caption: sectionName // to be set by model
visible: sectionVisible
topPadding: 2
leftPadding: 2
rightPadding: 1
expanded: sectionExpanded
onExpandedChanged: itemLibraryModel.setExpanded(expanded, sectionName);
Grid {
id: itemGrid
style: DesignerScrollViewStyle { columns: parent.width / styleConstants.cellWidth
property int flexibleWidth: (parent.width - styleConstants.cellWidth * columns) / columns
} Repeater {
model: sectionEntries
Flickable { delegate: ItemDelegate {
contentHeight: column.height visible: itemVisible
Column { width: styleConstants.cellWidth + itemGrid.flexibleWidth
id: column height: styleConstants.cellHeight
Repeater {
model: itemLibraryModel // to be set in Qml context
delegate: Section {
width: itemsView.viewport.width
caption: sectionName // to be set by model
visible: sectionVisible
topPadding: 2
leftPadding: 2
rightPadding: 1
expanded: sectionExpanded
onExpandedChanged: itemLibraryModel.setExpanded(expanded, sectionName);
Grid {
id: itemGrid
columns: parent.width / styleConstants.cellWidth
property int flexibleWidth: (parent.width - styleConstants.cellWidth * columns) / columns
Repeater {
model: sectionEntries
delegate: ItemDelegate {
visible: itemVisible
width: styleConstants.cellWidth + itemGrid.flexibleWidth
height: styleConstants.cellHeight
}
} }
} }
} }
} }
} }
} }
} }

View File

@@ -33,7 +33,7 @@ Section {
caption: qsTr("Advanced") caption: qsTr("Advanced")
SectionLayout { SectionLayout {
rows: 4 columns: 2
Label { Label {
text: qsTr("Origin") text: qsTr("Origin")
@@ -171,7 +171,6 @@ Section {
backendValue: backendValues.focus backendValue: backendValues.focus
text: backendValues.focus.valueToString text: backendValues.focus.valueToString
enabled: backendValues.focus.isAvailable enabled: backendValues.focus.isAvailable
implicitWidth: 180
} }
ExpandingSpacer { ExpandingSpacer {
} }
@@ -187,7 +186,6 @@ Section {
backendValue: backendValues.activeFocusOnTab backendValue: backendValues.activeFocusOnTab
text: backendValues.activeFocusOnTab.valueToString text: backendValues.activeFocusOnTab.valueToString
enabled: backendValues.activeFocusOnTab.isAvailable enabled: backendValues.activeFocusOnTab.isAvailable
implicitWidth: 180
} }
ExpandingSpacer { ExpandingSpacer {
} }

View File

@@ -32,10 +32,10 @@ import StudioTheme 1.0 as StudioTheme
Section { Section {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
caption: qsTr("Align") caption: qsTr("Align")
ColumnLayout { SectionLayout {
width: parent.width
enabled: alignDistribute.multiSelection && enabled: alignDistribute.multiSelection &&
!alignDistribute.selectionHasAnchors && !alignDistribute.selectionHasAnchors &&
alignDistribute.selectionExclusivlyItems && alignDistribute.selectionExclusivlyItems &&
@@ -49,8 +49,11 @@ Section {
Label { Label {
text: qsTr("Align objects") text: qsTr("Align objects")
width: 120 width: 120
Layout.columnSpan: 2
} }
RowLayout { RowLayout {
Layout.columnSpan: 2
Row { Row {
spacing: -StudioTheme.Values.border spacing: -StudioTheme.Values.border
AbstractButton { AbstractButton {
@@ -105,8 +108,11 @@ Section {
Label { Label {
text: qsTr("Distribute objects") text: qsTr("Distribute objects")
width: 120 width: 120
Layout.columnSpan: 2
} }
RowLayout { RowLayout {
Layout.columnSpan: 2
Row { Row {
spacing: -StudioTheme.Values.border spacing: -StudioTheme.Values.border
AbstractButton { AbstractButton {
@@ -161,8 +167,11 @@ Section {
Label { Label {
text: qsTr("Distribute spacing") text: qsTr("Distribute spacing")
width: 120 width: 120
Layout.columnSpan: 2
} }
RowLayout { RowLayout {
Layout.columnSpan: 2
Row { Row {
spacing: -StudioTheme.Values.border spacing: -StudioTheme.Values.border
AbstractButton { AbstractButton {
@@ -242,18 +251,16 @@ Section {
} }
} }
SectionLayout { ItemFilterModel {
columns: 2 id: itemFilterModel
modelNodeBackendProperty: modelNodeBackend
selectionOnly: true
}
ItemFilterModel { Label {
id: itemFilterModel text: qsTr("Align to")
modelNodeBackendProperty: modelNodeBackend }
selectionOnly: true SecondColumnLayout {
}
Label {
text: qsTr("Align to")
}
ComboBox { ComboBox {
id: alignToComboBox id: alignToComboBox
Layout.fillWidth: true Layout.fillWidth: true
@@ -267,9 +274,14 @@ Section {
} }
} }
Label { ExpandingSpacer {
text: qsTr("Key object")
} }
}
Label {
text: qsTr("Key object")
}
SecondColumnLayout {
ComboBox { ComboBox {
id: keyObjectComboBox id: keyObjectComboBox
enabled: alignToComboBox.currentIndex === 2 enabled: alignToComboBox.currentIndex === 2
@@ -285,11 +297,15 @@ Section {
lastSelectedItem = "" // TODO lastSelectedItem = "" // TODO
} }
} }
ExpandingSpacer {
}
} }
SectionLayout { SectionLayout {
columns: 1 columns: 1
Layout.topMargin: 30 Layout.topMargin: 30
Layout.columnSpan: 2
visible: alignDistribute.multiSelection && visible: alignDistribute.multiSelection &&
(alignDistribute.selectionHasAnchors || (alignDistribute.selectionHasAnchors ||
!alignDistribute.selectionExclusivlyItems || !alignDistribute.selectionExclusivlyItems ||

View File

@@ -23,9 +23,9 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.0 import QtQuick 2.15
import HelperWidgets 2.0 import HelperWidgets 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.15
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import StudioControls 1.0 as StudioControls import StudioControls 1.0 as StudioControls
@@ -34,11 +34,9 @@ import StudioTheme 1.0 as StudioTheme
RowLayout { RowLayout {
id: anchorRow id: anchorRow
anchors.left: parent.left
anchors.right: parent.right
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
property alias iconSource: icon.source property alias iconSource: iconLabel.icon
property variant anchorMargin property variant anchorMargin
@@ -64,8 +62,10 @@ RowLayout {
readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor
IconLabel { IconLabel {
id: icon id: iconLabel
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Layout.topMargin: 4
Layout.leftMargin: 4
} }
GridLayout { GridLayout {

View File

@@ -23,10 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.0 import QtQuick 2.15
import HelperWidgets 2.0 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.15
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioControls 1.0 as StudioControls import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
@@ -35,14 +36,15 @@ Rectangle {
width: 320 width: 320
height: 400 height: 400
color: Theme.qmlDesignerBackgroundColorDarkAlternate() color: Theme.qmlDesignerBackgroundColorDarkAlternate()
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: forceActiveFocus() onClicked: forceActiveFocus()
} }
ScrollView { ScrollView {
clip: true
anchors.fill: parent anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
Column { Column {
y: -1 y: -1
@@ -57,7 +59,6 @@ Rectangle {
SectionLayout { SectionLayout {
Label { Label {
text: qsTr("Type") text: qsTr("Type")
} }
SecondColumnLayout { SecondColumnLayout {
@@ -280,7 +281,6 @@ Rectangle {
Item { Item {
width: 10 width: 10
height: 10 height: 10
} }
CheckBox { CheckBox {
@@ -319,88 +319,92 @@ Rectangle {
width: 4 width: 4
} }
TabView { StudioControls.TabBar {
id: tabBar
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
frameVisible: false
id: tabView StudioControls.TabButton {
text: backendValues.className.value
}
StudioControls.TabButton {
text: qsTr("Layout")
}
StudioControls.TabButton {
text: qsTr("Advanced")
}
}
StackLayout {
anchors.left: parent.left
anchors.right: parent.right
currentIndex: tabBar.currentIndex
property int currentHeight: children[currentIndex].implicitHeight
property int extraHeight: 40
height: currentHeight + extraHeight height: currentHeight + extraHeight
property int currentHeight: getTab(currentIndex).item.implicitHeight Column {
property int extraHeight: 40 anchors.left: parent.left
anchors.right: parent.right
Tab { Loader {
title: backendValues.className.value anchors.left: parent.left
anchors.right: parent.right
visible: theSource !== ""
component: Column { id: specificsTwo;
sourceComponent: specificQmlComponent
property string theSource: specificQmlData
onTheSourceChanged: {
active = false
active = true
}
}
Loader {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
Loader { id: specificsOne;
anchors.left: parent.left source: specificsUrl;
anchors.right: parent.right
visible: theSource !== ""
id: specificsTwo; property int loaderHeight: specificsOne.item.height + tabView.extraHeight
sourceComponent: specificQmlComponent
property string theSource: specificQmlData
onTheSourceChanged: {
active = false
active = true
}
}
Loader {
anchors.left: parent.left
anchors.right: parent.right
id: specificsOne;
source: specificsUrl;
property int loaderHeight: specificsOne.item.height + tabView.extraHeight
}
} }
} }
Tab { Column {
title: qsTr("Layout") anchors.left: parent.left
component: Column { anchors.right: parent.right
anchors.left: parent.left
anchors.right: parent.right
LayoutSection { LayoutSection {
} }
MarginSection { MarginSection {
visible: anchorBackend.isInLayout visible: anchorBackend.isInLayout
backendValueTopMargin: backendValues.Layout_topMargin backendValueTopMargin: backendValues.Layout_topMargin
backendValueBottomMargin: backendValues.Layout_bottomMargin backendValueBottomMargin: backendValues.Layout_bottomMargin
backendValueLeftMargin: backendValues.Layout_leftMargin backendValueLeftMargin: backendValues.Layout_leftMargin
backendValueRightMargin: backendValues.Layout_rightMargin backendValueRightMargin: backendValues.Layout_rightMargin
backendValueMargins: backendValues.Layout_margins backendValueMargins: backendValues.Layout_margins
} }
AlignDistributeSection { AlignDistributeSection {
visible: !anchorBackend.isInLayout visible: !anchorBackend.isInLayout
}
} }
} }
Tab { Column {
anchors.fill: parent anchors.left: parent.left
title: qsTr("Advanced") anchors.right: parent.right
component: Column {
anchors.left: parent.left
anchors.right: parent.right
AdvancedSection { AdvancedSection {
} }
LayerSection { LayerSection {
}
} }
} }
} }

View File

@@ -50,8 +50,8 @@ Section {
} }
AnchorRow { AnchorRow {
visible: anchorBackend.topAnchored; visible: anchorBackend.topAnchored
iconSource: "image://icons/anchor-top" iconSource: StudioTheme.Constants.anchorTop
anchorMargin: backendValues.anchors_topMargin anchorMargin: backendValues.anchors_topMargin
targetName: anchorBackend.topTarget targetName: anchorBackend.topTarget
onTargetChanged: { onTargetChanged: {
@@ -73,8 +73,8 @@ Section {
} }
AnchorRow { AnchorRow {
visible: anchorBackend.bottomAnchored; visible: anchorBackend.bottomAnchored
iconSource: "image://icons/anchor-bottom" iconSource: StudioTheme.Constants.anchorBottom
anchorMargin: backendValues.anchors_bottomMargin anchorMargin: backendValues.anchors_bottomMargin
targetName: anchorBackend.bottomTarget targetName: anchorBackend.bottomTarget
onTargetChanged: { onTargetChanged: {
@@ -97,8 +97,8 @@ Section {
} }
AnchorRow { AnchorRow {
visible: anchorBackend.leftAnchored; visible: anchorBackend.leftAnchored
iconSource: "image://icons/anchor-left" iconSource: StudioTheme.Constants.anchorLeft
anchorMargin: backendValues.anchors_leftMargin anchorMargin: backendValues.anchors_leftMargin
targetName: anchorBackend.leftTarget targetName: anchorBackend.leftTarget
onTargetChanged: { onTargetChanged: {
@@ -120,8 +120,8 @@ Section {
} }
AnchorRow { AnchorRow {
visible: anchorBackend.rightAnchored; visible: anchorBackend.rightAnchored
iconSource: "image://icons/anchor-right" iconSource: StudioTheme.Constants.anchorRight
anchorMargin: backendValues.anchors_rightMargin anchorMargin: backendValues.anchors_rightMargin
targetName: anchorBackend.rightTarget targetName: anchorBackend.rightTarget
onTargetChanged: { onTargetChanged: {
@@ -145,8 +145,8 @@ Section {
AnchorRow { AnchorRow {
showAlternativeTargets: false showAlternativeTargets: false
visible: anchorBackend.horizontalCentered; visible: anchorBackend.horizontalCentered
iconSource: "image://icons/anchor-horizontal" iconSource: StudioTheme.Constants.centerHorizontal
anchorMargin: backendValues.anchors_horizontalCenterOffset anchorMargin: backendValues.anchors_horizontalCenterOffset
targetName: anchorBackend.horizontalTarget targetName: anchorBackend.horizontalTarget
onTargetChanged: { onTargetChanged: {
@@ -158,8 +158,8 @@ Section {
AnchorRow { AnchorRow {
showAlternativeTargets: false showAlternativeTargets: false
visible: anchorBackend.verticalCentered; visible: anchorBackend.verticalCentered
iconSource: "image://icons/anchor-vertical" iconSource: StudioTheme.Constants.centerVertical
anchorMargin: backendValues.anchors_verticalCenterOffset anchorMargin: backendValues.anchors_verticalCenterOffset
targetName: anchorBackend.verticalTarget targetName: anchorBackend.verticalTarget
onTargetChanged: { onTargetChanged: {

View File

@@ -23,10 +23,10 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.0 import QtQuick 2.15
import HelperWidgets 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
Rectangle { Rectangle {
id: itemPane id: itemPane
@@ -43,6 +43,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
Column { Column {
id: rootColumn
y: -1 y: -1
width: itemPane.width width: itemPane.width
Section { Section {
@@ -54,7 +55,6 @@ Rectangle {
SectionLayout { SectionLayout {
Label { Label {
text: qsTr("Type") text: qsTr("Type")
} }
SecondColumnLayout { SecondColumnLayout {
@@ -148,69 +148,30 @@ Rectangle {
width: 4 width: 4
} }
TabView { Column {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
frameVisible: false Loader {
id: specificsTwo
anchors.left: parent.left
anchors.right: parent.right
visible: theSource !== ""
sourceComponent: specificQmlComponent
id: tabView property string theSource: specificQmlData
height: Math.max(layoutSectionHeight, specficsHeight)
property int layoutSectionHeight: 400 onTheSourceChanged: {
property int specficsOneHeight: 0 active = false
property int specficsTwoHeight: 0 active = true
property int specficsHeight: Math.max(specficsOneHeight, specficsTwoHeight)
property int extraHeight: 40
Tab {
id: tab
title: backendValues.className.value
component: Column {
anchors.left: parent.left
anchors.right: parent.right
Loader {
anchors.left: parent.left
anchors.right: parent.right
visible: theSource !== ""
id: specificsTwo;
sourceComponent: specificQmlComponent
property string theSource: specificQmlData
onTheSourceChanged: {
active = false
active = true
}
property int loaderHeight: specificsTwo.item.height + tabView.extraHeight
onLoaderHeightChanged: tabView.specficsTwoHeight = loaderHeight
onLoaded: {
tabView.specficsTwoHeight = loaderHeight
}
}
Loader {
anchors.left: parent.left
anchors.right: parent.right
id: specificsOne;
source: specificsUrl;
property int loaderHeight: specificsOne.item.height + tabView.extraHeight
onLoaderHeightChanged: tabView.specficsHeight = loaderHeight
onLoaded: {
tabView.specficsOneHeight = loaderHeight
}
}
} }
} }
Loader {
id: specificsOne
anchors.left: parent.left
anchors.right: parent.right
source: specificsUrl
}
} }
} }
} }

View File

@@ -156,7 +156,7 @@ StudioControls.ButtonRow {
buttonIcon: StudioTheme.Constants.centerVertical buttonIcon: StudioTheme.Constants.centerVertical
tooltip: qsTr("Anchor item vertically.") tooltip: qsTr("Anchor item vertically.")
property bool verticalCentered: anchorBackend.verticalCentered; property bool verticalCentered: anchorBackend.verticalCentered
onVerticalCenteredChanged: { onVerticalCenteredChanged: {
checked = verticalCentered checked = verticalCentered
} }
@@ -179,7 +179,7 @@ StudioControls.ButtonRow {
buttonIcon: StudioTheme.Constants.centerHorizontal buttonIcon: StudioTheme.Constants.centerHorizontal
tooltip: qsTr("Anchor item horizontally.") tooltip: qsTr("Anchor item horizontally.")
property bool horizontalCentered: anchorBackend.horizontalCentered; property bool horizontalCentered: anchorBackend.horizontalCentered
onHorizontalCenteredChanged: { onHorizontalCenteredChanged: {
checked = horizontalCentered checked = horizontalCentered
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -23,48 +23,79 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.1 as Controls import QtQuick.Templates 2.15 as T
import QtQuick.Controls.Styles 1.1 import StudioTheme 1.0 as StudioTheme
import "Constants.js" as Constants
Controls.Button { T.AbstractButton {
property color borderColor: "#222" id: myButton
property color highlightColor: "orange"
property color textColor: "#eee" implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
style: ButtonStyle { implicitContentWidth + leftPadding + rightPadding)
label: Text { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
color: Constants.colorsDefaultText implicitContentHeight + topPadding + bottomPadding)
anchors.fill: parent
renderType: Text.NativeRendering background: Rectangle {
verticalAlignment: Text.AlignVCenter id: buttonBackground
horizontalAlignment: Text.AlignHCenter implicitWidth: 100
text: control.text implicitHeight: 23
opacity: enabled ? 1 : 0.7 radius: 3
} color: StudioTheme.Values.themeControlBackground
background: Rectangle { border.color: StudioTheme.Values.themeControlOutline
implicitWidth: 100 border.width: StudioTheme.Values.border
implicitHeight: 23
radius: 3
gradient: control.pressed ? pressedGradient : gradient
Gradient{
id: pressedGradient
GradientStop{color: "#333" ; position: 0}
}
Gradient {
id: gradient
GradientStop {color: "#606060" ; position: 0}
GradientStop {color: "#404040" ; position: 0.07}
GradientStop {color: "#303030" ; position: 1}
}
Rectangle {
anchors.fill: parent
anchors.margins: -1
color: "transparent"
radius: 4
opacity: 0.3
visible: control.activeFocus
}
}
} }
contentItem: Text {
id: buttonText
color: StudioTheme.Values.themeTextColor
font.family: StudioTheme.Constants.font.family
font.pixelSize: StudioTheme.Values.myFontSize
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.fill: parent
renderType: Text.QtRendering
text: myButton.text
}
states: [
State {
name: "default"
when: myButton.enabled && !myButton.hovered && !myButton.pressed
&& !myButton.checked
PropertyChanges {
target: buttonBackground
color: StudioTheme.Values.themeControlBackground
}
},
State {
name: "hovered"
when: myButton.hovered && !myButton.pressed
PropertyChanges {
target: buttonBackground
color: StudioTheme.Values.themeHoverHighlight
}
},
State {
name: "pressed"
when: myButton.hovered && myButton.pressed
PropertyChanges {
target: buttonBackground
color: StudioTheme.Values.themeControlBackgroundPressed
border.color: StudioTheme.Values.themeInteraction
}
},
State {
name: "disabled"
when: !myButton.enabled
PropertyChanges {
target: buttonBackground
color: StudioTheme.Values.themeControlBackgroundDisabled
border.color: StudioTheme.Values.themeControlOutlineDisabled
}
PropertyChanges {
target: buttonText
color: StudioTheme.Values.themeTextColorDisabled
}
}
]
} }

View File

@@ -23,10 +23,8 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.0 as Controls import QtQuick.Layouts 1.15
import QtQuick.Layouts 1.0
import QtQuick.Controls.Private 1.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
Item { Item {

View File

@@ -38,7 +38,7 @@ Column {
property bool supportGradient: false property bool supportGradient: false
property string caption: "Color" property string caption: qsTr("Color")
property variant backendValue property variant backendValue
@@ -47,7 +47,6 @@ Column {
return Qt.rgba(backendValue.value.x, backendValue.value.y, backendValue.value.z, 1); return Qt.rgba(backendValue.value.x, backendValue.value.y, backendValue.value.z, 1);
else else
return backendValue.value; return backendValue.value;
} }
property alias gradientPropertyName: gradientLine.gradientPropertyName property alias gradientPropertyName: gradientLine.gradientPropertyName

View File

@@ -73,7 +73,6 @@ Section {
Layout.fillWidth: true Layout.fillWidth: true
width: 160 width: 160
property string familyName: backendValue.value property string familyName: backendValue.value
onFamilyNameChanged: print(styleNamesForFamily(familyName))
} }
Label { Label {

View File

@@ -23,12 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.11 import QtQuick 2.15
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.15
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import HelperWidgets 2.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioControls 1.0 as StudioControls import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
@@ -76,49 +75,52 @@ Dialog {
anchors.margins: 13 anchors.margins: 13
anchors.bottomMargin: 71 anchors.bottomMargin: 71
TabView { StudioControls.TabBar {
id: presetTabView id: presetTabBar
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillHeight: true
Layout.fillWidth: true
Tab { anchors.left: parent.left
title: qsTr("System Presets") anchors.right: parent.right
anchors.fill: parent
GradientPresetTabContent { StudioControls.TabButton {
id: defaultTabContent text: qsTr("System Presets")
viewModel: defaultPresetListModel }
editableName: false StudioControls.TabButton {
} text: qsTr("User Presets")
}
}
StackLayout {
anchors.left: parent.left
anchors.right: parent.right
currentIndex: presetTabBar.currentIndex
GradientPresetTabContent {
id: defaultTabContent
viewModel: defaultPresetListModel
editableName: false
} }
Tab { GradientPresetTabContent {
title: qsTr("User Presets") id: customTabContent
anchors.fill: parent viewModel: customPresetListModel
editableName: true
onPresetNameChanged: customPresetListModel.changePresetName(id, name)
GradientPresetTabContent { property int deleteId
id: customTabContent
viewModel: customPresetListModel
editableName: true
onPresetNameChanged: customPresetListModel.changePresetName(id, name)
property int deleteId onDeleteButtonClicked: {
deleteId = id
deleteDialog.open()
}
onDeleteButtonClicked: { MessageDialog {
deleteId = id id: deleteDialog
deleteDialog.open() visible: false
} modality: Qt.WindowModal
standardButtons: Dialog.No | Dialog.Yes
MessageDialog { title: qsTr("Delete preset?")
id: deleteDialog text: qsTr("Are you sure you want to delete this preset?")
visible: false onAccepted: customPresetListModel.deletePreset(customTabContent.deleteId)
modality: Qt.WindowModal
standardButtons: Dialog.No | Dialog.Yes
title: qsTr("Delete preset?")
text: qsTr("Are you sure you want to delete this preset?")
onAccepted: customPresetListModel.deletePreset(customTabContent.deleteId)
}
} }
} }
} }

View File

@@ -23,12 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.11 import QtQuick 2.15
import QtQuick.Layouts 1.12 import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.15
import HelperWidgets 2.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioControls 1.0 as StudioControls import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
@@ -48,271 +47,277 @@ Rectangle {
property real delegateHeight: 178 property real delegateHeight: 178
property real gridCellWidth: 160 property real gridCellWidth: 160
ScrollView { GridView {
id: gradientTable
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: 10
clip: true
delegate: gradientDelegate
GridView { property int gridColumns: width / tabBackground.gridCellWidth;
id: gradientTable cellWidth: width / gridColumns
Layout.fillWidth: true cellHeight: 185
Layout.fillHeight: true
anchors.fill: parent
anchors.leftMargin: 10
clip: true
delegate: gradientDelegate
property int gridColumns: width / tabBackground.gridCellWidth; property bool bothVisible: horizontal.scrollBarVisible && vertical.scrollBarVisible
cellWidth: width / gridColumns
cellHeight: 185
Component { ScrollBar.horizontal: HorizontalScrollBar {
id: gradientDelegate id: horizontal
parent: gradientTable
}
Rectangle { ScrollBar.vertical: VerticalScrollBar {
id: backgroundCard id: vertical
color: StudioTheme.Values.themeControlOutline parent: gradientTable
clip: true }
property real flexibleWidth: (gradientTable.width - gradientTable.cellWidth * gradientTable.gridColumns) / gradientTable.gridColumns Component {
property bool isSelected: false id: gradientDelegate
width: gradientTable.cellWidth + flexibleWidth - 8 Rectangle {
height: tabBackground.delegateHeight id: backgroundCard
radius: 16 color: StudioTheme.Values.themeControlOutline
clip: true
function selectPreset(index) { property real flexibleWidth: (gradientTable.width - gradientTable.cellWidth * gradientTable.gridColumns) / gradientTable.gridColumns
gradientTable.currentIndex = index property bool isSelected: false
gradientData.stops = stopsPosList
gradientData.colors = stopsColorList
gradientData.stopsCount = stopListSize
gradientData.presetID = presetID
gradientData.presetType = presetTabView.currentIndex
if (gradientData.selectedItem != null) width: gradientTable.cellWidth + flexibleWidth - 8
gradientData.selectedItem.isSelected = false height: tabBackground.delegateHeight
radius: 16
backgroundCard.isSelected = true function selectPreset(index) {
gradientData.selectedItem = backgroundCard gradientTable.currentIndex = index
gradientData.stops = stopsPosList
gradientData.colors = stopsColorList
gradientData.stopsCount = stopListSize
gradientData.presetID = presetID
gradientData.presetType = presetTabBar.currentIndex
if (gradientData.selectedItem != null)
gradientData.selectedItem.isSelected = false
backgroundCard.isSelected = true
gradientData.selectedItem = backgroundCard
}
MouseArea {
id: rectMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
presetNameBox.edit = false
nameInput.focus = false
backgroundCard.selectPreset(index)
} }
}
MouseArea { states: [
id: rectMouseArea State {
anchors.fill: parent name: "default"
hoverEnabled: true when: !(rectMouseArea.containsMouse || removeButton.hovered ||
onClicked: { (nameMouseArea.containsMouse && !tabBackground.editableName)) &&
presetNameBox.edit = false !backgroundCard.isSelected
nameInput.focus = false PropertyChanges {
backgroundCard.selectPreset(index) target: backgroundCard
color: StudioTheme.Values.themeControlOutline
border.width: 0
}
},
State {
name: "hovered"
when: (rectMouseArea.containsMouse || removeButton.hovered ||
(nameMouseArea.containsMouse && !tabBackground.editableName)) &&
!backgroundCard.isSelected
PropertyChanges {
target: backgroundCard
color: StudioTheme.Values.themeControlBackgroundPressed
border.width: 1
border.color: StudioTheme.Values.themeInteraction
}
},
State {
name: "selected"
when: backgroundCard.isSelected
PropertyChanges {
target: backgroundCard
color:StudioTheme.Values.themeInteraction
border.width: 1
border.color: StudioTheme.Values.themeControlBackgroundPressed
}
}
]
ColumnLayout {
spacing: 2
anchors.fill: parent
Rectangle {
id: gradientRect
width: 150
height: 150
radius: 16
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.topMargin: 2
gradient: Gradient {
id: showGr
}
Component {
id: stopComponent
GradientStop {}
}
Component.onCompleted: {
var stopsAmount = stopListSize;
var newStops = [];
for (var i = 0; i < stopsAmount; i++) {
newStops.push( stopComponent.createObject(showGr, { "position": stopsPosList[i], "color": stopsColorList[i] }) );
}
showGr.stops = newStops;
}
AbstractButton {
id: removeButton
visible: editableName && (rectMouseArea.containsMouse || removeButton.hovered)
backgroundRadius: StudioTheme.Values.smallRectWidth
anchors.right: parent.right
anchors.rightMargin: 5
anchors.top: parent.top
anchors.topMargin: 5
width: Math.round(StudioTheme.Values.smallRectWidth)
height: Math.round(StudioTheme.Values.smallRectWidth)
buttonIcon: StudioTheme.Constants.closeCross
onClicked: tabBackground.deleteButtonClicked(index)
} }
} }
states: [ Item {
State { id: presetNameBox
name: "default" Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
when: !(rectMouseArea.containsMouse || removeButton.hovered || Layout.preferredWidth: backgroundCard.width - 2
(nameMouseArea.containsMouse && !tabBackground.editableName)) && Layout.preferredHeight: backgroundCard.height - gradientRect.height - 4
!backgroundCard.isSelected Layout.bottomMargin: 4
PropertyChanges {
target: backgroundCard
color: StudioTheme.Values.themeControlOutline
border.width: 0
}
},
State {
name: "hovered"
when: (rectMouseArea.containsMouse || removeButton.hovered ||
(nameMouseArea.containsMouse && !tabBackground.editableName)) &&
!backgroundCard.isSelected
PropertyChanges {
target: backgroundCard
color: StudioTheme.Values.themeControlBackgroundPressed
border.width: 1
border.color: StudioTheme.Values.themeInteraction
}
},
State {
name: "selected"
when: backgroundCard.isSelected
PropertyChanges {
target: backgroundCard
color:StudioTheme.Values.themeInteraction
border.width: 1
border.color: StudioTheme.Values.themeControlBackgroundPressed
}
}
]
ColumnLayout { property bool edit: false
spacing: 2
anchors.fill: parent
Rectangle { Rectangle {
id: gradientRect id: nameBackgroundColor
width: 150 enabled: tabBackground.editableName
height: 150 color: "transparent"
radius: 16 radius: 16
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter visible: true
Layout.topMargin: 2 anchors.fill: parent
}
gradient: Gradient { ToolTipArea {
id: showGr id: nameMouseArea
} anchors.fill: parent
tooltip: nameText.text
propagateComposedEvents: true
Component { onClicked: {
id: stopComponent if (!tabBackground.editableName) {
GradientStop {} backgroundCard.selectPreset(index)
} return
Component.onCompleted: {
var stopsAmount = stopListSize;
var newStops = [];
for (var i = 0; i < stopsAmount; i++) {
newStops.push( stopComponent.createObject(showGr, { "position": stopsPosList[i], "color": stopsColorList[i] }) );
} }
showGr.stops = newStops;
}
AbstractButton { presetNameBox.edit = true
id: removeButton nameInput.forceActiveFocus()
visible: editableName && (rectMouseArea.containsMouse || removeButton.hovered) // have to select text like this, otherwise there is an issue with long names
backgroundRadius: StudioTheme.Values.smallRectWidth nameInput.cursorPosition = 0
anchors.right: parent.right nameInput.cursorPosition = nameInput.length
anchors.rightMargin: 5 nameInput.selectAll()
anchors.top: parent.top
anchors.topMargin: 5
width: Math.round(StudioTheme.Values.smallRectWidth)
height: Math.round(StudioTheme.Values.smallRectWidth)
buttonIcon: StudioTheme.Constants.closeCross
onClicked: tabBackground.deleteButtonClicked(index)
} }
} }
Item { Text {
id: presetNameBox id: nameText
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter text: presetName
Layout.preferredWidth: backgroundCard.width - 2 anchors.fill: parent
Layout.preferredHeight: backgroundCard.height - gradientRect.height - 4 horizontalAlignment: Text.AlignHCenter
Layout.bottomMargin: 4 verticalAlignment: Text.AlignVCenter
color: StudioTheme.Values.themeTextColor
property bool edit: false elide: Text.ElideMiddle
maximumLineCount: 1
Rectangle {
id: nameBackgroundColor
enabled: tabBackground.editableName
color: "transparent"
radius: 16
visible: true
anchors.fill: parent
}
ToolTipArea {
id: nameMouseArea
anchors.fill: parent
tooltip: nameText.text
propagateComposedEvents: true
onClicked: {
if (!tabBackground.editableName) {
backgroundCard.selectPreset(index)
return
}
presetNameBox.edit = true
nameInput.forceActiveFocus()
// have to select text like this, otherwise there is an issue with long names
nameInput.cursorPosition = 0
nameInput.cursorPosition = nameInput.length
nameInput.selectAll()
}
}
Text {
id: nameText
text: presetName
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: StudioTheme.Values.themeTextColor
elide: Text.ElideMiddle
maximumLineCount: 1
}
TextInput {
id: nameInput
enabled: tabBackground.editableName
visible: false
text: presetName
anchors.fill: parent
anchors.leftMargin: 5
anchors.rightMargin: 5
horizontalAlignment: TextInput.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
color: StudioTheme.Values.themeTextColor
selectionColor: StudioTheme.Values.themeInteraction
selectByMouse: true
activeFocusOnPress: true
wrapMode: TextInput.NoWrap
clip: true
onEditingFinished: {
nameText.text = text
tabBackground.presetNameChanged(index, text)
presetNameBox.edit = false
}
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
event.accepted = true
nameInput.editingFinished()
nameInput.focus = false
}
if (event.key === Qt.Key_Escape) {
event.accepted = true
nameInput.text = nameText.text
nameInput.focus = false
}
}
}
states: [
State {
name: "default"
when: tabBackground.editableName && !nameMouseArea.containsMouse && !presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: "transparent"
border.width: 0
}
PropertyChanges { target: nameText; visible: true }
PropertyChanges { target: nameInput; visible: false }
},
State {
name: "hovered"
when: tabBackground.editableName && nameMouseArea.containsMouse && !presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: StudioTheme.Values.themeControlBackgroundPressed
border.width: 0
}
PropertyChanges { target: nameText; visible: true }
PropertyChanges { target: nameInput; visible: false }
},
State {
name: "edit"
when: tabBackground.editableName && presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: StudioTheme.Values.themeControlBackgroundPressed
border.color: StudioTheme.Values.themeInteraction
border.width: 1
}
PropertyChanges { target: nameText; visible: false }
PropertyChanges { target: nameInput; visible: true }
}
]
} }
TextInput {
id: nameInput
enabled: tabBackground.editableName
visible: false
text: presetName
anchors.fill: parent
anchors.leftMargin: 5
anchors.rightMargin: 5
horizontalAlignment: TextInput.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
color: StudioTheme.Values.themeTextColor
selectionColor: StudioTheme.Values.themeInteraction
selectByMouse: true
activeFocusOnPress: true
wrapMode: TextInput.NoWrap
clip: true
onEditingFinished: {
nameText.text = text
tabBackground.presetNameChanged(index, text)
presetNameBox.edit = false
}
Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
event.accepted = true
nameInput.editingFinished()
nameInput.focus = false
}
if (event.key === Qt.Key_Escape) {
event.accepted = true
nameInput.text = nameText.text
nameInput.focus = false
}
}
}
states: [
State {
name: "default"
when: tabBackground.editableName && !nameMouseArea.containsMouse && !presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: "transparent"
border.width: 0
}
PropertyChanges { target: nameText; visible: true }
PropertyChanges { target: nameInput; visible: false }
},
State {
name: "hovered"
when: tabBackground.editableName && nameMouseArea.containsMouse && !presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: StudioTheme.Values.themeControlBackgroundPressed
border.width: 0
}
PropertyChanges { target: nameText; visible: true }
PropertyChanges { target: nameInput; visible: false }
},
State {
name: "edit"
when: tabBackground.editableName && presetNameBox.edit
PropertyChanges {
target: nameBackgroundColor
color: StudioTheme.Values.themeControlBackgroundPressed
border.color: StudioTheme.Values.themeInteraction
border.width: 1
}
PropertyChanges { target: nameText; visible: false }
PropertyChanges { target: nameInput; visible: true }
}
]
} }
} }
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -23,25 +23,29 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 1.1 import QtQuick.Controls 2.15
import QtQuick.Controls.Styles 1.1 import StudioTheme 1.0 as StudioTheme
import QtQuickDesignerTheme 1.0
TextFieldStyle { ScrollBar {
selectionColor: Theme.color(Theme.PanelTextColorLight) id: scrollBar
selectedTextColor: Theme.color(Theme.PanelTextColorDark)
textColor: Theme.color(Theme.PanelTextColorLight)
placeholderTextColor: Theme.color(Theme.PanelTextColorMid)
padding.top: 4 property bool scrollBarVisible: parent.childrenRect.width > parent.width
padding.bottom: 4
orientation: Qt.Horizontal
policy: scrollBar.scrollBarVisible ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
x: 0
y: parent.height - height
width: parent.availableWidth
- (parent.bothVisible ? parent.verticalThickness : 0)
padding: 0
background: Rectangle { background: Rectangle {
implicitWidth: 100 color: StudioTheme.Values.themeSectionHeadBackground
implicitHeight: font.pixelSize + padding.top + padding.bottom }
color: Theme.color(Theme.FancyToolButtonSelectedColor)
border.color: Theme.qmlDesignerBackgroundColorDarker() contentItem: Rectangle {
implicitHeight: StudioTheme.Values.scrollBarThickness
color: StudioTheme.Values.themeScrollBarHandle
} }
renderType: Text.NativeRendering
} }

View File

@@ -23,31 +23,16 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 2.0 as Controls import HelperWidgets 2.0
import QtQuick.Layouts 1.0 import StudioTheme 1.0 as StudioTheme
Item { Label {
id: label id: myLabel
width: parent.width < 300 ? 80 : Math.min(140, parent.width - 220)
height: 16
property alias source: image.source
Item { property alias icon: myLabel.text
width: 16
height: 16
Image {
id: image
anchors.fill: parent
}
} text: StudioTheme.Constants.actionIcon
font.family: StudioTheme.Constants.iconFont.family
Layout.preferredWidth: width font.pixelSize: StudioTheme.Values.myIconFontSize
Layout.minimumWidth: width
Layout.maximumWidth: width
// Component.onCompleted: {
// label.Layout.preferredWidth = width
// }
} }

View File

@@ -23,13 +23,37 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.0 as Controls import QtQuick.Controls 2.15
import "../../../common/" import StudioTheme 1.0 as StudioTheme
Controls.ScrollView { Flickable {
style: DesignerScrollViewStyle { id: flickable
property alias horizontalThickness: horizontalScrollBar.height
property alias verticalThickness: verticalScrollBar.width
property bool bothVisible: verticalScrollBar.scrollBarVisible
&& horizontalScrollBar.scrollBarVisible
contentWidth: areaItem.childrenRect.width
contentHeight: areaItem.childrenRect.height
boundsBehavior: Flickable.StopAtBounds
default property alias content: areaItem.children
Item {
id: areaItem
}
ScrollBar.horizontal: HorizontalScrollBar {
id: horizontalScrollBar
parent: flickable
scrollBarVisible: areaItem.childrenRect.width > flickable.width
}
ScrollBar.vertical: VerticalScrollBar {
id: verticalScrollBar
parent: flickable
scrollBarVisible: areaItem.childrenRect.height > flickable.height
} }
frameVisible: false
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -23,9 +23,29 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.0 as Controls import QtQuick.Controls 2.15
import StudioTheme 1.0 as StudioTheme
Controls.Tab { ScrollBar {
id: scrollBar
property bool scrollBarVisible: parent.childrenRect.height > parent.height
orientation: Qt.Vertical
policy: scrollBar.scrollBarVisible ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
x: parent.width - width
y: 0
height: parent.availableHeight
- (parent.bothVisible ? parent.horizontalThickness : 0)
padding: 0
background: Rectangle {
color: StudioTheme.Values.themeSectionHeadBackground
}
contentItem: Rectangle {
implicitWidth: StudioTheme.Values.scrollBarThickness
color: StudioTheme.Values.themeScrollBarHandle
}
} }

View File

@@ -39,11 +39,11 @@ SimpleColorPalette 2.0 SimpleColorPalette.qml
DoubleSpinBox 2.0 DoubleSpinBox.qml DoubleSpinBox 2.0 DoubleSpinBox.qml
SpinBox 2.0 SpinBox.qml SpinBox 2.0 SpinBox.qml
StandardTextSection 2.0 StandardTextSection.qml StandardTextSection 2.0 StandardTextSection.qml
Tab 2.0 Tab.qml
TabView 2.0 TabView.qml
ToolTipArea 2.0 ToolTipArea.qml ToolTipArea 2.0 ToolTipArea.qml
UrlChooser 2.0 UrlChooser.qml UrlChooser 2.0 UrlChooser.qml
PaddingSection 2.0 PaddingSection.qml PaddingSection 2.0 PaddingSection.qml
RoundedPanel 2.0 RoundedPanel.qml RoundedPanel 2.0 RoundedPanel.qml
ExpressionTextField 2.0 ExpressionTextField.qml ExpressionTextField 2.0 ExpressionTextField.qml
MarginSection 2.0 MarginSection.qml MarginSection 2.0 MarginSection.qml
HorizontalScrollBar 2.0 HorizontalScrollBar.qml
VerticalScrollBar 2.0 VerticalScrollBar.qml

View File

@@ -116,7 +116,6 @@ Rectangle {
color: StudioTheme.Values.themeHoverHighlight color: StudioTheme.Values.themeHoverHighlight
border.color: StudioTheme.Values.themeControlOutline border.color: StudioTheme.Values.themeControlOutline
} }
}, },
State { State {
name: "edit" name: "edit"

View File

@@ -46,8 +46,7 @@ T.CheckBox {
implicitWidth: Math.max( implicitWidth: Math.max(
implicitBackgroundWidth + leftInset + rightInset, implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding implicitContentWidth + leftPadding + rightPadding)
+ implicitIndicatorWidth + spacing + actionIndicator.width)
implicitHeight: Math.max( implicitHeight: Math.max(
implicitBackgroundHeight + topInset + bottomInset, implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding, implicitContentHeight + topPadding + bottomPadding,

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -23,38 +23,33 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 1.1 import QtQuick.Templates 2.15 as T
import QtQuick.Controls.Styles 1.1 import StudioTheme 1.0 as StudioTheme
import QtQuickDesignerTheme 1.0
ScrollViewStyle { T.TabBar {
readonly property color scrollbarColor: Theme.color(Theme.BackgroundColorDark) id: myButton
readonly property color scrollBarHandleColor: Theme.color(Theme.QmlDesigner_ScrollBarHandleColor)
padding {left: 0; top: 0; right: 0; bottom: 0} implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
scrollBarBackground: Rectangle { spacing: 0
height: 10 bottomPadding: 4
width: 10
color: scrollbarColor contentItem: ListView {
} model: myButton.contentModel
handle: Item { currentIndex: myButton.currentIndex
implicitWidth: 10
implicitHeight: 10 spacing: myButton.spacing
Rectangle { orientation: ListView.Horizontal
anchors.fill: parent boundsBehavior: Flickable.StopAtBounds
color: scrollBarHandleColor flickableDirection: Flickable.AutoFlickIfNeeded
} snapMode: ListView.SnapToItem
} }
decrementControl: Item {} background: Rectangle {
incrementControl: Item {} color: StudioTheme.Values.themeTabLight
corner: Item {}
//Even if the platform style reports touch support a scrollview should not be flickable.
Component.onCompleted: {
control.flickableItem.interactive = false
} }
transientScrollBars: false
} }

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
@@ -23,40 +23,38 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.15
import QtQuick.Controls 1.0 as Controls import QtQuick.Templates 2.15 as T
import QtQuick.Controls.Styles 1.1
import QtQuickDesignerTheme 1.0
import StudioTheme 1.0 as StudioTheme import StudioTheme 1.0 as StudioTheme
Controls.TabView { T.TabButton {
id: root id: myButton
frameVisible: false implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
style: TabViewStyle { implicitContentWidth + leftPadding + rightPadding)
frameOverlap: 0 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
frame: Item { } implicitContentHeight + topPadding + bottomPadding)
tab: Rectangle {
color: styleData.selected ? Theme.qmlDesignerTabLight() : Theme.qmlDesignerTabDark()
implicitWidth: root.width/root.count + 2
implicitHeight: 28
Text {
id: text
font.bold: true
font.pixelSize: StudioTheme.Values.myFontSize
anchors.centerIn: parent
anchors.verticalCenterOffset: -1
text: styleData.title
renderType: Text.NativeRendering
color: styleData.selected ? Theme.qmlDesignerTabDark() : Theme.qmlDesignerTabLight()
}
Rectangle { padding: 1
color:Theme.qmlDesignerTabLight()
width: parent.width background: Rectangle {
height: 4 id: buttonBackground
anchors.bottom: parent.bottom color: myButton.checked ? StudioTheme.Values.themeTabLight : StudioTheme.Values.themeTabDark
} border.color: StudioTheme.Values.themeControlOutline
} border.width: 0
}
contentItem: T.Label {
id: buttonIcon
color: myButton.checked ? StudioTheme.Values.themeTabDark : StudioTheme.Values.themeTabLight
font.weight: Font.Bold
//font.family: StudioTheme.Constants.font.family
font.pixelSize: StudioTheme.Values.myFontSize
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.fill: parent
renderType: Text.QtRendering
text: myButton.text
} }
} }

View File

@@ -28,6 +28,8 @@ SliderPopup 1.0 SliderPopup.qml
SpinBox 1.0 SpinBox.qml SpinBox 1.0 SpinBox.qml
SpinBoxIndicator 1.0 SpinBoxIndicator.qml SpinBoxIndicator 1.0 SpinBoxIndicator.qml
SpinBoxInput 1.0 SpinBoxInput.qml SpinBoxInput 1.0 SpinBoxInput.qml
TabBar 1.0 TabBar.qml
TabButton 1.0 TabButton.qml
TextArea 1.0 TextArea.qml TextArea 1.0 TextArea.qml
TextField 1.0 TextField.qml TextField 1.0 TextField.qml
TranslationIndicator 1.0 TranslationIndicator.qml TranslationIndicator 1.0 TranslationIndicator.qml

View File

@@ -79,6 +79,8 @@ QtObject {
property real inputHorizontalPadding: Math.round(4 * values.scaleFactor) property real inputHorizontalPadding: Math.round(4 * values.scaleFactor)
property real scrollBarThickness: 10
// Theme Colors // Theme Colors
// COLORS NOW COME FROM THE THEME FILES // COLORS NOW COME FROM THE THEME FILES
@@ -117,6 +119,9 @@ QtObject {
property string themeTranslationIndicatorBorder: Theme.color(Theme.DStranlsationIndicatorBorder) property string themeTranslationIndicatorBorder: Theme.color(Theme.DStranlsationIndicatorBorder)
property string themeSectionHeadBackground: Theme.color(Theme.DSsectionHeadBackground) property string themeSectionHeadBackground: Theme.color(Theme.DSsectionHeadBackground)
property string themeTabDark: Theme.color(Theme.QmlDesigner_TabDark)
property string themeTabLight: Theme.color(Theme.QmlDesigner_TabLight)
// Taken out of Constants.js // Taken out of Constants.js
property string themeChangedStateText: Theme.color(Theme.DSchangedStateText) property string themeChangedStateText: Theme.color(Theme.DSchangedStateText)
} }

View File

@@ -23,13 +23,15 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import HelperWidgets 2.0
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme
Rectangle { Rectangle {
id: myRoot
border.width: 1 border.width: 1
property bool isBaseState property bool isBaseState
property bool isCurrentState property bool isCurrentState
@@ -41,6 +43,8 @@ Rectangle {
property string delegateWhenConditionString property string delegateWhenConditionString
readonly property bool isDefaultState: isDefault readonly property bool isDefaultState: isDefault
signal delegateInteraction
color: baseColor color: baseColor
border.color: Theme.qmlDesignerBorderColor() border.color: Theme.qmlDesignerBorderColor()
@@ -50,38 +54,28 @@ Rectangle {
} }
MouseArea { MouseArea {
id: mouseArea
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onClicked: { onClicked: {
focus = true focus = true
root.currentStateInternalId = internalNodeId root.currentStateInternalId = internalNodeId
contextMenu.dismiss() // close potentially open context menu
myRoot.delegateInteraction()
} }
} }
ToolButton { StudioControls.AbstractButton {
id: removeStateButton id: removeStateButton
buttonIcon: StudioTheme.Constants.closeCross
style: ButtonStyle {
background: Rectangle {
color: control.hovered ? Qt.lighter(baseColor, 1.2) : "transparent"
Image {
source: "image://icons/close"
height: 16
width: 16
}
}
}
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 2 anchors.rightMargin: 4
anchors.verticalCenter: stateNameField.verticalCenter anchors.verticalCenter: stateNameField.verticalCenter
height: 16
width: 16
visible: !isBaseState visible: !isBaseState
onClicked: { onClicked: {
myRoot.delegateInteraction()
if (isDefaultState) if (isDefaultState)
statesEditorModel.resetDefaultState() statesEditorModel.resetDefaultState()
@@ -89,86 +83,78 @@ Rectangle {
} }
} }
Image { StudioControls.Menu {
id: whenButton id: contextMenu
visible: !isBaseState || (isBaseState && modelHasDefaultState)
width: 14
height: 14
x: 4
y: 6
source: {
if (whenMouseArea.containsMouse)
return "image://icons/submenu"
return delegateHasWhenCondition ? "image://icons/expression" : "image://icons/placeholder"
StudioControls.MenuItem {
enabled: !isBaseState
text: qsTr("Set when Condition")
onTriggered: {
bindingEditor.showWidget()
bindingEditor.text = delegateWhenConditionString
bindingEditor.prepareBindings()
}
} }
MouseArea { StudioControls.MenuItem {
id: whenMouseArea enabled: !isBaseState && delegateHasWhenCondition
hoverEnabled: true text: qsTr("Reset when Condition")
anchors.fill: parent onTriggered: {
onClicked: contextMenu.popup() statesEditorModel.resetWhenCondition(internalNodeId)
}
} }
Menu {
id: contextMenu
MenuItem { StudioControls.MenuItem {
visible: !isBaseState enabled: !isBaseState && !isDefaultState
text: qsTr("Set when Condition") text: qsTr("Set as Default")
onTriggered: { onTriggered: {
bindingEditor.showWidget() statesEditorModel.setStateAsDefault(internalNodeId)
bindingEditor.text = delegateWhenConditionString
bindingEditor.prepareBindings()
}
} }
}
MenuItem { StudioControls.MenuItem {
visible: !isBaseState && delegateHasWhenCondition enabled: (!isBaseState && isDefaultState) || (isBaseState && modelHasDefaultState)
text: qsTr("Reset when Condition") text: qsTr("Reset Default")
onTriggered: { onTriggered: {
statesEditorModel.resetWhenCondition(internalNodeId) statesEditorModel.resetDefaultState()
}
} }
}
MenuItem { onClosed: {
visible: !isBaseState && !isDefaultState stateNameField.actionIndicator.forceVisible = false
text: qsTr("Set as Default") }
onTriggered: {
statesEditorModel.setStateAsDefault(internalNodeId)
}
}
MenuItem { onOpened: {
visible: (!isBaseState && isDefaultState) || (isBaseState && modelHasDefaultState) myRoot.delegateInteraction()
text: qsTr("Reset Default")
onTriggered: {
statesEditorModel.resetDefaultState()
}
}
} }
} }
TextField {
StudioControls.TextField {
id: stateNameField id: stateNameField
y: 4 actionIndicatorVisible: !isBaseState || (isBaseState && modelHasDefaultState)
font.pixelSize: Theme.smallFontPixelSize()
anchors.left: whenButton.right actionIndicator.onClicked: {
// use the spacing which the image to the delegate rectangle has stateNameField.actionIndicator.forceVisible = true
anchors.leftMargin: 4 contextMenu.popup()
anchors.right: removeStateButton.left
anchors.rightMargin: 4
style: DesignerTextFieldStyle {
background: Rectangle {
implicitWidth: 100
implicitHeight: font.pixelSize + padding.top + padding.bottom
color: ((isBaseState && modelHasDefaultState) ? "transparent"
: Theme.color(Theme.FancyToolButtonSelectedColor))
border.color: ((isBaseState && !modelHasDefaultState) || isDefaultState) ? "#ffd700"
: (isBaseState && modelHasDefaultState) ? "transparent"
: Theme.qmlDesignerBackgroundColorDarker()
}
} }
onEditChanged: {
if (contextMenu.open && stateNameField.edit)
contextMenu.dismiss()
}
actionIndicator.icon.text: delegateHasWhenCondition
? StudioTheme.Constants.actionIconBinding : StudioTheme.Constants.actionIcon
translationIndicatorVisible: false
y: 4
anchors.left: parent.left
// use the spacing which the image to the delegate rectangle has
anchors.leftMargin: (isBaseState ? StudioTheme.Values.height : 0) + 4
anchors.right: removeStateButton.left
anchors.rightMargin: 2
readOnly: isBaseState readOnly: isBaseState
onActiveFocusChanged: { onActiveFocusChanged: {
@@ -188,7 +174,7 @@ Rectangle {
stateNameField.oldValue = stateNameField.text stateNameField.oldValue = stateNameField.text
if (stateNameField.text != delegateStateName) if (stateNameField.text !== delegateStateName)
statesEditorModel.renameState(internalNodeId, stateNameField.text) statesEditorModel.renameState(internalNodeId, stateNameField.text)
} }
} }
@@ -220,8 +206,8 @@ Rectangle {
Text { Text {
id: stateDefaultIndicator id: stateDefaultIndicator
anchors.left: whenButton.left anchors.left: parent.left
anchors.leftMargin: 0 anchors.leftMargin: StudioTheme.Values.height
anchors.right: removeStateButton.left anchors.right: removeStateButton.left
anchors.rightMargin: 4 anchors.rightMargin: 4
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

View File

@@ -23,32 +23,33 @@
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.2 import QtQuick 2.15
import QtQuick.Controls 1.1 import QtQuick.Controls 2.15
import QtQuick.Controls.Styles 1.1
import "../common"
import QtQuickDesignerTheme 1.0 import QtQuickDesignerTheme 1.0
import HelperWidgets 2.0
import StudioControls 1.0 as StudioControls
import StudioTheme 1.0 as StudioTheme
FocusScope { FocusScope {
id: root id: root
height: expanded ? 192 : 40 height: (root.expanded ? 192 : 40) + StudioTheme.Values.scrollBarThickness
signal createNewState signal createNewState
signal deleteState(int internalNodeId) signal deleteState(int internalNodeId)
signal duplicateCurrentState signal duplicateCurrentState
property int stateImageSize: 180 property int stateImageSize: 180
property int delegateWidth: stateImageSize + 44
property int padding: 2 property int padding: 2
property int delegateHeight: root.height - padding * 2 + 1 property int delegateWidth: root.stateImageSize + 44
property int delegateHeight: root.height - StudioTheme.Values.scrollBarThickness - root.padding * 2 + 1
property int innerSpacing: 0 property int innerSpacing: 0
property int currentStateInternalId : 0 property int currentStateInternalId: 0
property bool expanded: true property bool expanded: true
Connections { Connections {
target: statesEditorModel target: statesEditorModel
onChangedToState: root.currentStateInternalId = n function onChangedToState(n) { root.currentStateInternalId = n }
} }
SystemPalette { SystemPalette {
@@ -66,35 +67,41 @@ FocusScope {
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: { onClicked: {
if (mouse.button === Qt.LeftButton) if (mouse.button === Qt.LeftButton) {
contextMenu.dismiss()
focus = true focus = true
else if (mouse.button === Qt.RightButton) } else if (mouse.button === Qt.RightButton) {
contextMenu.popup() contextMenu.popup()
}
} }
Menu { StudioControls.Menu {
id: contextMenu id: contextMenu
MenuItem { StudioControls.MenuItem {
text: root.expanded ? qsTr("Collapse") : qsTr("Expand") text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
onTriggered: { onTriggered: {
root.expanded = !root.expanded root.expanded = !root.expanded
} }
} }
} }
} }
function closeContextMenu() {
if (contextMenu.open)
contextMenu.dismiss()
}
Item { Item {
id: addStateItem id: addStateItem
property int buttonLeftSpacing: 8 * (expanded ? 1 : 2) property int buttonLeftSpacing: 8 * (root.expanded ? 1 : 2)
anchors.right: parent.right anchors.right: parent.right
width: delegateHeight / 2 + buttonLeftSpacing width: root.delegateHeight / 2 + buttonLeftSpacing
height: delegateHeight height: root.delegateHeight
Button { AbstractButton {
id: addStateButton id: addStateButton
visible: canAddNewStates visible: canAddNewStates
@@ -106,56 +113,69 @@ FocusScope {
width: Math.max(parent.height / 2 - 8, 18) width: Math.max(parent.height / 2 - 8, 18)
height: width height: width
onClicked: root.createNewState() onClicked: {
root.closeContextMenu()
root.createNewState()
}
style: ButtonStyle { background: Rectangle {
background: Rectangle { property color buttonBaseColor: Qt.darker(Theme.qmlDesignerBackgroundColorDarkAlternate(), 1.1)
property color buttonBaseColor: Qt.darker(Theme.qmlDesignerBackgroundColorDarkAlternate(), 1.1) color: addStateButton.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor
color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor border.color: Theme.qmlDesignerBorderColor()
border.color: Theme.qmlDesignerBorderColor() border.width: 1
border.width: 1 Image {
Image { source: "image://icons/plus"
source: "image://icons/plus" width: 16
width: 16 height: 16
height: 16 anchors.centerIn: parent
anchors.centerIn: parent smooth: false
smooth: false
}
} }
} }
} }
} }
ScrollView { ListView {
id: flickable
boundsBehavior: Flickable.StopAtBounds
clip: true
anchors.left: parent.left anchors.left: parent.left
anchors.right: addStateItem.left anchors.right: addStateItem.left
height: delegateHeight height: root.delegateHeight + StudioTheme.Values.scrollBarThickness
y: padding y: root.padding
anchors.leftMargin: padding anchors.leftMargin: root.padding
anchors.rightMargin: padding anchors.rightMargin: root.padding
style: DesignerScrollViewStyle { model: statesEditorModel
orientation: ListView.Horizontal
spacing: root.innerSpacing
delegate: StatesDelegate {
id: statesDelegate
width: root.delegateWidth
height: root.delegateHeight
isBaseState: 0 == internalNodeId
isCurrentState: root.currentStateInternalId == internalNodeId
baseColor: isCurrentState ? Theme.color(Theme.QmlDesigner_HighlightColor) : background.color
delegateStateName: stateName
delegateStateImageSource: stateImageSource
delegateStateImageSize: stateImageSize
delegateHasWhenCondition: hasWhenCondition
delegateWhenConditionString: whenConditionString
onDelegateInteraction: root.closeContextMenu()
} }
ListView { property bool bothVisible: horizontal.scrollBarVisible && vertical.scrollBarVisible
anchors.fill: parent
model: statesEditorModel
orientation: ListView.Horizontal
spacing: innerSpacing
delegate: StatesDelegate { ScrollBar.horizontal: HorizontalScrollBar {
id: statesDelegate id: horizontal
width: delegateWidth parent: flickable
height: delegateHeight }
isBaseState: 0 == internalNodeId
isCurrentState: root.currentStateInternalId == internalNodeId ScrollBar.vertical: VerticalScrollBar {
baseColor: isCurrentState ? Theme.color(Theme.QmlDesigner_HighlightColor) : background.color id: vertical
delegateStateName: stateName parent: flickable
delegateStateImageSource: stateImageSource
delegateStateImageSize: stateImageSize
delegateHasWhenCondition: hasWhenCondition
delegateWhenConditionString: whenConditionString
}
} }
} }
} }

View File

@@ -110,6 +110,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
{{"highlightColor"}, Utils::StyleHelper::notTooBrightHighlightColor()} {{"highlightColor"}, Utils::StyleHelper::notTooBrightHighlightColor()}
} }
); );
m_itemViewQuickWidget->setClearColor(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
/* create Resources view and its model */ /* create Resources view and its model */
m_resourcesFileSystemModel = new CustomFileSystemModel(this); m_resourcesFileSystemModel = new CustomFileSystemModel(this);