mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-03 19:31:58 +02:00
[ui] fix Palette propagation
* bugfix: in latest PySide2 versions, application palette is not properly applied to all QtQuick Controls 2 components. Force this by exposing QApplication palette and bind it to the root ApplicationWindow. * rename all "palette" ids to "activePalette" to avoid clashes with "palette" property on QtQuick Controls 2 * use parent component palette when it makes sense to propagate active/disabled style (instead of always using Active SystemPalette)
This commit is contained in:
parent
571560a43a
commit
2f2390e465
16 changed files with 46 additions and 43 deletions
|
@ -2,7 +2,7 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide2.QtCore import Qt, QObject, Slot
|
from PySide2.QtCore import Qt, QObject, Slot, Signal, Property
|
||||||
from PySide2.QtGui import QPalette, QColor, QIcon
|
from PySide2.QtGui import QPalette, QColor, QIcon
|
||||||
from PySide2.QtWidgets import QApplication
|
from PySide2.QtWidgets import QApplication
|
||||||
|
|
||||||
|
@ -60,6 +60,10 @@ class PaletteManager(QObject):
|
||||||
app.setPalette(self.darkPalette)
|
app.setPalette(self.darkPalette)
|
||||||
if self.qmlEngine.rootObjects():
|
if self.qmlEngine.rootObjects():
|
||||||
self.qmlEngine.reload()
|
self.qmlEngine.reload()
|
||||||
|
self.paletteChanged.emit()
|
||||||
|
|
||||||
|
paletteChanged = Signal()
|
||||||
|
palette = Property(QPalette, lambda self: QApplication.instance().palette(), notify=paletteChanged)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -9,12 +9,10 @@ import QtQuick.Layouts 1.3
|
||||||
Pane {
|
Pane {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
|
||||||
|
|
||||||
property bool opaque: false
|
property bool opaque: false
|
||||||
property int radius: 1
|
property int radius: 1
|
||||||
|
|
||||||
padding: 6
|
padding: 6
|
||||||
anchors.margins: 2
|
anchors.margins: 2
|
||||||
background: Rectangle { color: palette.base; opacity: opaque ? 1.0 : 0.7; radius: root.radius }
|
background: Rectangle { color: root.palette.base; opacity: opaque ? 1.0 : 0.7; radius: root.radius }
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,9 @@ ColumnLayout {
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
background: Rectangle { color: Qt.darker(palette.window, 1.15) }
|
background: Rectangle { color: Qt.darker(parent.palette.window, 1.15) }
|
||||||
padding: 2
|
padding: 2
|
||||||
RowLayout {
|
RowLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -43,7 +43,7 @@ RowLayout {
|
||||||
// make label italic if attribute is a link
|
// make label italic if attribute is a link
|
||||||
font.italic: object.isLink
|
font.italic: object.isLink
|
||||||
|
|
||||||
background: Rectangle { color: Qt.darker(palette.window, 1.2) }
|
background: Rectangle { color: Qt.darker(parent.palette.window, 1.2) }
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: parameterMA
|
id: parameterMA
|
||||||
|
|
|
@ -134,7 +134,7 @@ RowLayout {
|
||||||
rightPadding: root.layoutDirection == Qt.LeftToRight ? 1 : 0
|
rightPadding: root.layoutDirection == Qt.LeftToRight ? 1 : 0
|
||||||
text: attribute.name
|
text: attribute.name
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: palette.window
|
color: parent.palette.window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ Item {
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
@ -195,7 +195,7 @@ Item {
|
||||||
property var dstAnchor: dst.nodeItem.mapFromItem(dst, dst.edgeAnchorPos.x, dst.edgeAnchorPos.y)
|
property var dstAnchor: dst.nodeItem.mapFromItem(dst, dst.edgeAnchorPos.x, dst.edgeAnchorPos.y)
|
||||||
|
|
||||||
edge: object
|
edge: object
|
||||||
color: containsMouse && !readOnly ? palette.highlight : palette.text
|
color: containsMouse && !readOnly ? activePalette.highlight : activePalette.text
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
point1x: src.nodeItem.x + srcAnchor.x
|
point1x: src.nodeItem.x + srcAnchor.x
|
||||||
point1y: src.nodeItem.y + srcAnchor.y
|
point1y: src.nodeItem.y + srcAnchor.y
|
||||||
|
|
|
@ -23,6 +23,8 @@ Item {
|
||||||
implicitHeight: body.height
|
implicitHeight: body.height
|
||||||
objectName: node.name
|
objectName: node.name
|
||||||
|
|
||||||
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: parent
|
drag.target: parent
|
||||||
|
@ -91,7 +93,7 @@ Item {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: background
|
id: background
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: palette.base
|
color: activePalette.base
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.effect: DropShadow { radius: 2; color: shadowColor }
|
layer.effect: DropShadow { radius: 2; color: shadowColor }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ ListView {
|
||||||
id: root
|
id: root
|
||||||
interactive: false
|
interactive: false
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
property color defaultColor: Qt.darker(palette.window, 1.1)
|
property color defaultColor: Qt.darker(activePalette.window, 1.1)
|
||||||
property real chunkHeight: height
|
property real chunkHeight: height
|
||||||
property real chunkWidth: model ? width / model.count : 0
|
property real chunkWidth: model ? width / model.count : 0
|
||||||
|
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
implicitWidth: 100
|
implicitWidth: 100
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
|
@ -16,7 +16,7 @@ import "common.js" as Common
|
||||||
FocusScope {
|
FocusScope {
|
||||||
property variant node
|
property variant node
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
Controls1.SplitView {
|
Controls1.SplitView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -42,13 +42,13 @@ FocusScope {
|
||||||
text: "Chunks"
|
text: "Chunks"
|
||||||
padding: 4
|
padding: 4
|
||||||
z: 10
|
z: 10
|
||||||
background: Rectangle { color: palette.window }
|
background: Rectangle { color: parent.palette.window }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
highlight: Component {
|
highlight: Component {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: palette.highlight
|
color: activePalette.highlight
|
||||||
opacity: 0.3
|
opacity: 0.3
|
||||||
z: 2
|
z: 2
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ FocusScope {
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
padding: 0
|
padding: 0
|
||||||
background: Rectangle { color: Qt.darker(palette.window, 1.2) }
|
background: Rectangle { color: Qt.darker(activePalette.window, 1.2) }
|
||||||
Column {
|
Column {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
ToolButton {
|
ToolButton {
|
||||||
|
|
|
@ -18,8 +18,6 @@ Item {
|
||||||
signal pressed(var mouse)
|
signal pressed(var mouse)
|
||||||
signal removeRequest()
|
signal removeRequest()
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
|
||||||
|
|
||||||
// retrieve viewpoints inner data
|
// retrieve viewpoints inner data
|
||||||
QtObject {
|
QtObject {
|
||||||
id: _viewpoint
|
id: _viewpoint
|
||||||
|
@ -62,10 +60,10 @@ Item {
|
||||||
// Image thumbnail and background
|
// Image thumbnail and background
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: imageBackground
|
id: imageBackground
|
||||||
color: Qt.darker(palette.base, 1.15)
|
color: Qt.darker(imageLabel.palette.base, 1.15)
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
border.color: isCurrentItem ? palette.highlight : Qt.darker(palette.highlight)
|
border.color: isCurrentItem ? imageLabel.palette.highlight : Qt.darker(imageLabel.palette.highlight)
|
||||||
border.width: imageMA.containsMouse || imageDelegate.isCurrentItem ? 2 : 0
|
border.width: imageMA.containsMouse || imageDelegate.isCurrentItem ? 2 : 0
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -79,6 +77,7 @@ Item {
|
||||||
}
|
}
|
||||||
// Image basename
|
// Image basename
|
||||||
Label {
|
Label {
|
||||||
|
id: imageLabel
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
padding: 2
|
padding: 2
|
||||||
font.pointSize: 8
|
font.pointSize: 8
|
||||||
|
@ -86,7 +85,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: Filepath.basename(imageDelegate.source)
|
text: Filepath.basename(imageDelegate.source)
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: imageDelegate.isCurrentItem ? palette.highlight : "transparent"
|
color: imageDelegate.isCurrentItem ? parent.palette.highlight : "transparent"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ Panel {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: dropArea.containsDrag
|
visible: dropArea.containsDrag
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: palette.window
|
color: root.palette.window
|
||||||
opacity: 0.8
|
opacity: 0.8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +175,9 @@ Panel {
|
||||||
text: "Add Images"
|
text: "Add Images"
|
||||||
font.bold: true
|
font.bold: true
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: parent.hovered ? palette.highlight : palette.window
|
color: parent.hovered ? parent.palette.highlight : parent.palette.window
|
||||||
opacity: 0.8
|
opacity: 0.8
|
||||||
border.color: palette.highlight
|
border.color: parent.palette.highlight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ Panel {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: parent.hovered ? palette.highlight : palette.window
|
color: parent.hovered ? palette.highlight : palette.window
|
||||||
opacity: 0.8
|
opacity: 0.8
|
||||||
border.color: palette.highlight
|
border.color: parent.palette.highlight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,11 @@ Page {
|
||||||
property int footerHeight: 22
|
property int footerHeight: 22
|
||||||
property int hPadding: 6
|
property int hPadding: 6
|
||||||
property int vPadding: 2
|
property int vPadding: 2
|
||||||
readonly property color paneBackgroundColor: Qt.darker(palette.window, 1.15)
|
readonly property color paneBackgroundColor: Qt.darker(root.palette.window, 1.15)
|
||||||
}
|
}
|
||||||
|
|
||||||
padding: 2
|
padding: 2
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
|
||||||
|
|
||||||
header: Pane {
|
header: Pane {
|
||||||
id: headerPane
|
id: headerPane
|
||||||
|
|
|
@ -20,8 +20,6 @@ FloatingPane {
|
||||||
clip: true
|
clip: true
|
||||||
padding: 4
|
padding: 4
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert GPS metadata to degree coordinates.
|
* Convert GPS metadata to degree coordinates.
|
||||||
*
|
*
|
||||||
|
@ -173,7 +171,7 @@ FloatingPane {
|
||||||
id: sizeHandle
|
id: sizeHandle
|
||||||
height: parent.contentHeight
|
height: parent.contentHeight
|
||||||
width: 1
|
width: 1
|
||||||
color: palette.mid
|
color: root.palette.mid
|
||||||
x: parent.width * 0.4
|
x: parent.width * 0.4
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -198,7 +196,7 @@ FloatingPane {
|
||||||
Label {
|
Label {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
padding: 2
|
padding: 2
|
||||||
background: Rectangle { color: palette.mid }
|
background: Rectangle { color: parent.palette.mid }
|
||||||
text: section
|
text: section
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +238,7 @@ FloatingPane {
|
||||||
anchorPoint.y: circle.paintedHeight
|
anchorPoint.y: circle.paintedHeight
|
||||||
sourceItem: Text {
|
sourceItem: Text {
|
||||||
id: circle
|
id: circle
|
||||||
color: palette.highlight
|
color: root.palette.highlight
|
||||||
font.pointSize: 18
|
font.pointSize: 18
|
||||||
font.family: MaterialIcons.fontFamily
|
font.family: MaterialIcons.fontFamily
|
||||||
text: MaterialIcons.location_on
|
text: MaterialIcons.location_on
|
||||||
|
|
|
@ -142,6 +142,8 @@ FocusScope {
|
||||||
depthMapSource = ''
|
depthMapSource = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
Scene3D {
|
Scene3D {
|
||||||
id: scene3D
|
id: scene3D
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -358,7 +360,7 @@ FocusScope {
|
||||||
CuboidMesh { xExtent: 0.2; yExtent: 0.2; zExtent: 0.2},
|
CuboidMesh { xExtent: 0.2; yExtent: 0.2; zExtent: 0.2},
|
||||||
PhongMaterial{
|
PhongMaterial{
|
||||||
id: mat
|
id: mat
|
||||||
ambient: viewId == _reconstruction.selectedViewId ? palette.highlight : "#CCC"
|
ambient: viewId == _reconstruction.selectedViewId ? activePalette.highlight : "#CCC"
|
||||||
diffuse: ambient
|
diffuse: ambient
|
||||||
},
|
},
|
||||||
ObjectPicker {
|
ObjectPicker {
|
||||||
|
|
|
@ -53,7 +53,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
SystemPalette { id: activePalette }
|
||||||
|
|
||||||
Controls1.SplitView {
|
Controls1.SplitView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -109,7 +109,7 @@ Item {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
z: -1
|
z: -1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Qt.darker(palette.base, 1.1)
|
color: Qt.darker(activePalette.base, 1.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ Item {
|
||||||
text: "Loading..."
|
text: "Loading..."
|
||||||
visible: viewer3D.loading
|
visible: viewer3D.loading
|
||||||
padding: 6
|
padding: 6
|
||||||
background: Rectangle { color: palette.base; opacity: 0.5 }
|
background: Rectangle { color: parent.palette.base; opacity: 0.5 }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load reconstructed model
|
// Load reconstructed model
|
||||||
|
|
|
@ -30,10 +30,12 @@ ApplicationWindow {
|
||||||
ensureSaved(function(){ Qt.quit() })
|
ensureSaved(function(){ Qt.quit() })
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemPalette { id: palette }
|
// force Application palette assignation
|
||||||
SystemPalette { id: disabledPalette; colorGroup: SystemPalette.Disabled}
|
// note: should be implicit (PySide bug)
|
||||||
|
palette: _PaletteManager.palette
|
||||||
|
|
||||||
palette.window: palette.window
|
SystemPalette { id: activePalette }
|
||||||
|
SystemPalette { id: disabledPalette; colorGroup: SystemPalette.Disabled }
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: settings_UILayout
|
id: settings_UILayout
|
||||||
|
@ -222,7 +224,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
header: MenuBar {
|
header: MenuBar {
|
||||||
palette.window: Qt.darker(palette.window, 1.15)
|
palette.window: Qt.darker(activePalette.window, 1.15)
|
||||||
Menu {
|
Menu {
|
||||||
title: "File"
|
title: "File"
|
||||||
Action {
|
Action {
|
||||||
|
@ -321,7 +323,7 @@ ApplicationWindow {
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
|
|
||||||
// Setup global tooltip style
|
// Setup global tooltip style
|
||||||
ToolTip.toolTip.background: Rectangle { color: palette.base; border.color: palette.mid }
|
ToolTip.toolTip.background: Rectangle { color: activePalette.base; border.color: activePalette.mid }
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue