forked from qt-creator/qt-creator
QmlDesigner: Fix ColorEditor opening position
Fix ColorEditor being cut off at the top, when there isn't enough space to fit. Task-number: QDS-5076 Change-Id: If9dc832b89d64c60e11a3458e1d90e5d7e2f0450 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
4e1eb3727f
commit
2e1bdabd1f
@@ -303,38 +303,59 @@ SecondColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This connection is meant to update the popups y-position and the main scrollviews
|
||||||
|
// height as soon as the height of the color picker changes. Initially the height of the
|
||||||
|
// color picker is 0 until its completion is done.
|
||||||
|
Connections {
|
||||||
|
target: colorPicker
|
||||||
|
function onHeightChanged() {
|
||||||
|
cePopup.setPopupY()
|
||||||
|
cePopup.setMainScrollViewHeight()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
|
cePopup.setPopupY()
|
||||||
|
cePopup.setMainScrollViewHeight()
|
||||||
|
}
|
||||||
|
onYChanged: cePopup.setMainScrollViewHeight()
|
||||||
|
onHeightChanged: cePopup.setMainScrollViewHeight()
|
||||||
|
|
||||||
|
function setMainScrollViewHeight() {
|
||||||
if (Controller.mainScrollView === null)
|
if (Controller.mainScrollView === null)
|
||||||
return
|
return
|
||||||
|
|
||||||
var mapped = preview.mapToItem(Controller.mainScrollView.contentItem, cePopup.x, cePopup.y)
|
var mapped = preview.mapToItem(Controller.mainScrollView.contentItem, cePopup.x, cePopup.y)
|
||||||
Controller.mainScrollView.temporaryHeight = mapped.y + cePopup.height + 20
|
Controller.mainScrollView.temporaryHeight = mapped.y + cePopup.height
|
||||||
|
+ StudioTheme.Values.colorEditorPopupMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
onHeightChanged: {
|
function setPopupY() {
|
||||||
if (Controller.mainScrollView === null)
|
if (Controller.mainScrollView === null)
|
||||||
return
|
return
|
||||||
|
|
||||||
var mapped = preview.mapToItem(Controller.mainScrollView.contentItem, cePopup.x, cePopup.y)
|
var tmp = preview.mapToItem(Controller.mainScrollView.contentItem, preview.x, preview.y)
|
||||||
Controller.mainScrollView.temporaryHeight = mapped.y + cePopup.height + 20
|
cePopup.y = Math.max(-tmp.y + StudioTheme.Values.colorEditorPopupMargin,
|
||||||
|
cePopup.__defaultY)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosed: {
|
onClosed: Controller.mainScrollView.temporaryHeight = 0
|
||||||
Controller.mainScrollView.temporaryHeight = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
x: - StudioTheme.Values.colorEditorPopupWidth * 0.5
|
property real __defaultX: - StudioTheme.Values.colorEditorPopupWidth * 0.5
|
||||||
+ preview.width * 0.5
|
+ preview.width * 0.5
|
||||||
y: - StudioTheme.Values.colorEditorPopupMargin
|
property real __defaultY: - StudioTheme.Values.colorEditorPopupPadding
|
||||||
- (StudioTheme.Values.colorEditorPopupSpacing * 2)
|
- (StudioTheme.Values.colorEditorPopupSpacing * 2)
|
||||||
- StudioTheme.Values.defaultControlHeight
|
- StudioTheme.Values.defaultControlHeight
|
||||||
- StudioTheme.Values.colorEditorPopupLineHeight
|
- StudioTheme.Values.colorEditorPopupLineHeight
|
||||||
- colorPicker.height * 0.5
|
- colorPicker.height * 0.5
|
||||||
+ preview.height * 0.5
|
+ preview.height * 0.5
|
||||||
|
|
||||||
|
x: cePopup.__defaultX
|
||||||
|
y: cePopup.__defaultY
|
||||||
|
|
||||||
width: StudioTheme.Values.colorEditorPopupWidth
|
width: StudioTheme.Values.colorEditorPopupWidth
|
||||||
height: colorColumn.height + sectionColumn.height
|
height: colorColumn.height + sectionColumn.height
|
||||||
+ StudioTheme.Values.colorEditorPopupMargin + 2 // TODO magic number
|
+ StudioTheme.Values.colorEditorPopupPadding + 2 // TODO magic number
|
||||||
|
|
||||||
padding: StudioTheme.Values.border
|
padding: StudioTheme.Values.border
|
||||||
margins: -1 // If not defined margin will be -1
|
margins: -1 // If not defined margin will be -1
|
||||||
@@ -353,7 +374,7 @@ SecondColumnLayout {
|
|||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: StudioTheme.Values.colorEditorPopupMargin
|
anchors.margins: StudioTheme.Values.colorEditorPopupPadding
|
||||||
spacing: StudioTheme.Values.colorEditorPopupSpacing
|
spacing: StudioTheme.Values.colorEditorPopupSpacing
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -714,7 +735,7 @@ SecondColumnLayout {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: sectionColumn
|
id: sectionColumn
|
||||||
anchors.topMargin: StudioTheme.Values.colorEditorPopupMargin
|
anchors.topMargin: StudioTheme.Values.colorEditorPopupPadding
|
||||||
anchors.top: colorColumn.bottom
|
anchors.top: colorColumn.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
@@ -179,9 +179,10 @@ QtObject {
|
|||||||
// Color Editor Popup
|
// Color Editor Popup
|
||||||
property real colorEditorPopupWidth: 4 * values.colorEditorPopupSpinBoxWidth
|
property real colorEditorPopupWidth: 4 * values.colorEditorPopupSpinBoxWidth
|
||||||
+ 3 * values.controlGap
|
+ 3 * values.controlGap
|
||||||
+ 2 * values.colorEditorPopupMargin
|
+ 2 * values.colorEditorPopupPadding
|
||||||
property real colorEditorPopupHeight: 800
|
property real colorEditorPopupHeight: 800
|
||||||
property real colorEditorPopupMargin: 10
|
property real colorEditorPopupPadding: 10
|
||||||
|
property real colorEditorPopupMargin: 20
|
||||||
|
|
||||||
property real colorEditorPopupSpacing: 10
|
property real colorEditorPopupSpacing: 10
|
||||||
property real colorEditorPopupLineHeight: 60
|
property real colorEditorPopupLineHeight: 60
|
||||||
|
Reference in New Issue
Block a user