Skip to content

Commit 7cf7035

Browse files
committed
[ui] file dialog : fix light palette issues
1 parent e34de0a commit 7cf7035

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

meshroom/ui/palette.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def togglePalette(self):
5656
if self.qmlEngine.rootObjects():
5757
self.qmlEngine.reload()
5858
self.paletteChanged.emit()
59+
60+
@Slot(result=bool)
61+
def isDarkPalette(self):
62+
return QApplication.instance().palette() == self.darkPalette
5963

6064
paletteChanged = Signal()
6165
palette = Property(QPalette, lambda self: QApplication.instance().palette(), notify=paletteChanged)

meshroom/ui/qml/Dialogs/MrFileDialog.qml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,10 @@ Window {
529529

530530
highlighted: fileListView.currentIndex == -1 ? isCurrentItemSelected() : ListView.isCurrentItem
531531

532+
532533
// Enable drag for folders
533-
Drag.active: model.fileIsDir && dragArea.drag.active
534+
property bool isDragging: false
535+
Drag.active: isDragging
534536
Drag.dragType: Drag.Automatic
535537
Drag.supportedActions: Qt.CopyAction
536538
Drag.mimeData: { "text/uri-list": model.fileURL.toString() }
@@ -574,10 +576,19 @@ Window {
574576
}
575577

576578
MouseArea {
577-
id: dragArea
578579
anchors.fill: parent
579580
drag.target: model.fileIsDir ? parent : null
580-
581+
582+
onPressed: {
583+
if (model.fileIsDir) {
584+
parent.isDragging = true
585+
}
586+
}
587+
588+
onReleased: {
589+
parent.isDragging = false
590+
}
591+
581592
onClicked: {
582593
fileListView.currentIndex = model.index
583594
if (model.fileIsDir) {
@@ -619,7 +630,9 @@ Window {
619630

620631
function selectedPathExists() {
621632
return Filepath.exists(getSelectedPath())
622-
}
633+
}
634+
635+
property color fileExistsColor: _PaletteManager.isDarkPalette() ? Qt.darker(Colors.red, 2) : Qt.lighter(Colors.red, 1.5)
623636

624637
RowLayout {
625638
anchors.fill: parent
@@ -629,7 +642,7 @@ Window {
629642
Rectangle {
630643
Layout.fillWidth: true
631644
height: filenameField.implicitHeight
632-
color: selectionBar.selectedPathExists() ? Qt.darker(Colors.red, 2): root.activePalette.base
645+
color: selectionBar.selectedPathExists() ? selectionBar.fileExistsColor : root.activePalette.base
633646
border.color: filenameField.activeFocus ? root.activePalette.accent : Qt.darker(root.activePalette.base, 1.4)
634647
border.width: 1
635648
radius: 5

0 commit comments

Comments
 (0)