forked from qt-creator/qt-creator
New Project Dialog: Use hover states for interactive items
Also, changed the "Save Preset" dialog so that, when the user presses Enter, the dialog will be accept-ed. Task-number: QDS-5741 Change-Id: I7056d1184a3d9d400ac718c8d434cf2ad36ed35e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -204,11 +204,22 @@ Item {
|
|||||||
font.weight: Font.DemiBold
|
font.weight: Font.DemiBold
|
||||||
font.pixelSize: DialogValues.viewHeaderPixelSize
|
font.pixelSize: DialogValues.viewHeaderPixelSize
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: tabBarRow.currIndex === index ? DialogValues.textColorInteraction
|
|
||||||
: DialogValues.textColor
|
color: {
|
||||||
|
var color = tabBarRow.currIndex === index
|
||||||
|
? DialogValues.textColorInteraction
|
||||||
|
: DialogValues.textColor
|
||||||
|
|
||||||
|
return tabItemMouseArea.containsMouse
|
||||||
|
? Qt.darker(color, 1.5)
|
||||||
|
: color
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on color { ColorAnimation { duration: tabBar.animDur } }
|
Behavior on color { ColorAnimation { duration: tabBar.animDur } }
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: tabItemMouseArea
|
||||||
|
hoverEnabled: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
tabBar.selectTab(index)
|
tabBar.selectTab(index)
|
||||||
|
@@ -286,12 +286,8 @@ Item {
|
|||||||
realStepSize: 10
|
realStepSize: 10
|
||||||
font.pixelSize: DialogValues.defaultPixelSize
|
font.pixelSize: DialogValues.defaultPixelSize
|
||||||
|
|
||||||
onRealValueChanged: {
|
onRealValueChanged: orientationButton.isHorizontal =
|
||||||
if (widthField.realValue >= heightField.realValue)
|
widthField.realValue >= heightField.realValue
|
||||||
orientationButton.setHorizontal()
|
|
||||||
else
|
|
||||||
orientationButton.setVertical()
|
|
||||||
}
|
|
||||||
} // Width Text Field
|
} // Width Text Field
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
@@ -311,12 +307,8 @@ Item {
|
|||||||
realStepSize: 10
|
realStepSize: 10
|
||||||
font.pixelSize: DialogValues.defaultPixelSize
|
font.pixelSize: DialogValues.defaultPixelSize
|
||||||
|
|
||||||
onRealValueChanged: {
|
onRealValueChanged: orientationButton.isHorizontal =
|
||||||
if (widthField.realValue >= heightField.realValue)
|
widthField.realValue >= heightField.realValue
|
||||||
orientationButton.setHorizontal()
|
|
||||||
else
|
|
||||||
orientationButton.setVertical()
|
|
||||||
}
|
|
||||||
} // Height Text Field
|
} // Height Text Field
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
@@ -327,69 +319,69 @@ Item {
|
|||||||
|
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
|
|
||||||
Button {
|
Item {
|
||||||
id: orientationButton
|
id: orientationButton
|
||||||
implicitWidth: 100
|
implicitWidth: 100
|
||||||
implicitHeight: 50
|
implicitHeight: 50
|
||||||
checked: false
|
property bool isHorizontal: false
|
||||||
hoverEnabled: false
|
|
||||||
background: Rectangle {
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
Item {
|
spacing: orientationButton.width / 4
|
||||||
width: orientationButton.width / 2
|
|
||||||
height: orientationButton.height
|
function computeColor(barId) {
|
||||||
Rectangle {
|
var color = DialogValues.textColor
|
||||||
id: horizontalBar
|
|
||||||
color: "white"
|
if (barId === horizontalBar) {
|
||||||
width: parent.width
|
color = orientationButton.isHorizontal
|
||||||
height: orientationButton.height / 2
|
? DialogValues.textColorInteraction
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
: DialogValues.textColor
|
||||||
radius: 3
|
} else {
|
||||||
}
|
color = orientationButton.isHorizontal
|
||||||
|
? DialogValues.textColor
|
||||||
|
: DialogValues.textColorInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
if (orientationButtonMouseArea.containsMouse)
|
||||||
width: orientationButton.width / 4
|
color = Qt.darker(color, 1.5)
|
||||||
height: orientationButton.height
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
return color
|
||||||
id: verticalBar
|
}
|
||||||
width: orientationButton.width / 4
|
|
||||||
height: orientationButton.height
|
Rectangle {
|
||||||
color: "white"
|
id: horizontalBar
|
||||||
radius: 3
|
color: parent.computeColor(horizontalBar)
|
||||||
}
|
width: orientationButton.width / 2
|
||||||
|
height: orientationButton.height / 2
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
radius: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: verticalBar
|
||||||
|
color: parent.computeColor(verticalBar)
|
||||||
|
width: orientationButton.width / 4
|
||||||
|
height: orientationButton.height
|
||||||
|
radius: 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
MouseArea {
|
||||||
if (widthField.realValue && heightField.realValue) {
|
id: orientationButtonMouseArea
|
||||||
[widthField.realValue, heightField.realValue] = [heightField.realValue, widthField.realValue]
|
anchors.fill: parent
|
||||||
orientationButton.checked = !orientationButton.checked
|
hoverEnabled: true
|
||||||
|
|
||||||
if (widthField.realValue === heightField.realValue)
|
onClicked: {
|
||||||
orientationButton.checked ? setVertical() : setHorizontal()
|
if (widthField.realValue && heightField.realValue) {
|
||||||
|
[widthField.realValue, heightField.realValue] = [heightField.realValue, widthField.realValue]
|
||||||
|
|
||||||
|
if (widthField.realValue === heightField.realValue)
|
||||||
|
orientationButton.isHorizontal = !orientationButton.isHorizontal
|
||||||
|
else
|
||||||
|
orientationButton.isHorizontal = widthField.realValue > heightField.realValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setHorizontal() {
|
|
||||||
orientationButton.checked = false
|
|
||||||
horizontalBar.color = DialogValues.textColorInteraction
|
|
||||||
verticalBar.color = "white"
|
|
||||||
}
|
|
||||||
|
|
||||||
function setVertical() {
|
|
||||||
orientationButton.checked = true
|
|
||||||
horizontalBar.color = "white"
|
|
||||||
verticalBar.color = DialogValues.textColorInteraction
|
|
||||||
}
|
|
||||||
} // Orientation button
|
} // Orientation button
|
||||||
|
|
||||||
} // GridLayout: orientation + width + height
|
} // GridLayout: orientation + width + height
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -507,6 +499,8 @@ Item {
|
|||||||
presetNameTextField.text = text.trim()
|
presetNameTextField.text = text.trim()
|
||||||
presetNameTextField.text = text.replace(/\s+/g, " ")
|
presetNameTextField.text = text.replace(/\s+/g, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAccepted: savePresetDialog.accept()
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
|
@@ -160,8 +160,17 @@ Item {
|
|||||||
+ 2 * DialogValues.styleImageBorderWidth
|
+ 2 * DialogValues.styleImageBorderWidth
|
||||||
height: DialogValues.styleImageHeight
|
height: DialogValues.styleImageHeight
|
||||||
+ 2 * DialogValues.styleImageBorderWidth
|
+ 2 * DialogValues.styleImageBorderWidth
|
||||||
border.color: index === stylesList.currentIndex ? DialogValues.textColorInteraction : "transparent"
|
|
||||||
border.width: index === stylesList.currentIndex ? DialogValues.styleImageBorderWidth : 0
|
border.color: itemRectMouseArea.containsMouse
|
||||||
|
? DialogValues.textColor
|
||||||
|
: (index === stylesList.currentIndex
|
||||||
|
? DialogValues.textColorInteraction
|
||||||
|
: "transparent")
|
||||||
|
|
||||||
|
border.width: index === stylesList.currentIndex || itemRectMouseArea.containsMouse
|
||||||
|
? DialogValues.styleImageBorderWidth
|
||||||
|
: 0
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
@@ -173,6 +182,12 @@ Item {
|
|||||||
asynchronous: false
|
asynchronous: false
|
||||||
source: "image://newprojectdialog_library/" + BackendApi.styleModel.iconId(model.index)
|
source: "image://newprojectdialog_library/" + BackendApi.styleModel.iconId(model.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: itemRectMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
}
|
||||||
} // Rectangle
|
} // Rectangle
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
Reference in New Issue
Block a user