Skip to content

Commit ef14402

Browse files
committed
[ui] Messaging : test code, simplify code
1 parent e2b8a99 commit ef14402

File tree

4 files changed

+30
-48
lines changed

4 files changed

+30
-48
lines changed

meshroom/ui/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from meshroom.ui.components.scene3D import Scene3DHelper, Transformations3DHelper
2727
from meshroom.ui.components.scriptEditor import ScriptEditorManager
2828
from meshroom.ui.components.thumbnail import ThumbnailCache
29-
from meshroom.ui.components.statusBar import MessageController
29+
from meshroom.ui.components.messaging import MessageController
3030
from meshroom.ui.palette import PaletteManager
3131
from meshroom.ui.reconstruction import Reconstruction
3232
from meshroom.ui.utils import QmlInstantEngine

meshroom/ui/components/statusBar.py renamed to meshroom/ui/components/messaging.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ def getMessages(self):
5656

5757
@Slot(result=str)
5858
def getMessagesAsString(self):
59-
return json.dumps(self._getMessagesDict(fullDate=True), indent=4)
59+
""" Return messages for clipboard copy
60+
.. note::
61+
Could also do `json.dumps(self._getMessagesDict(fullDate=True), indent=4)`
62+
"""
63+
messages = []
64+
for msg in self._messages:
65+
messages.append(f"{msg.dateStr(True)} [{msg.status.upper():<7}] {msg.msg}")
66+
return "\n".join(messages)
6067

6168
@Slot()
6269
def clearMessages(self):

meshroom/ui/qml/Controls/StatusBar.qml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,12 @@ RowLayout {
9898
}
9999
}
100100

101-
function _showMessage(msg, status=undefined, duration=root.interval) {
101+
function showMessage(msg, status=undefined, duration=root.interval) {
102102
statusBar.showMessage(msg, status, duration)
103103
// Add message to the message list
104104
_messageController.storeMessage(msg, status)
105105
}
106106

107-
function showMessage(msg, status=undefined, duration=root.interval) {
108-
// Info
109-
statusBar.showMessage("test info", "info", duration)
110-
_messageController.storeMessage("test info", "info")
111-
// Warning
112-
statusBar.showMessage("test warning", "warning", duration)
113-
_messageController.storeMessage("test warning", "warning")
114-
// Error
115-
statusBar.showMessage("test error", "error", duration)
116-
_messageController.storeMessage("test error", "error")
117-
// Ok
118-
statusBar.showMessage("test ok", "ok", duration)
119-
_messageController.storeMessage("test ok", "ok")
120-
}
121-
122107
Connections {
123108
target: _messageController
124109
function onMessage(message, color, duration) {

meshroom/ui/qml/Controls/StatusMessages.qml

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,25 @@ ApplicationWindow {
1515

1616
SystemPalette { id: systemPalette }
1717

18-
function getColor(status, mode="unknown") {
19-
var color = systemPalette.text
20-
var alphaValue = 1.0
18+
function getColor(status) {
2119
switch (status) {
22-
case "ok": {
23-
color = Colors.green
24-
break
25-
}
26-
case "warning": {
27-
color = Colors.orange
28-
break
29-
}
30-
case "error": {
31-
color = Colors.red
32-
break
33-
}
34-
}
35-
switch (mode) {
36-
case "background": {
37-
if (status == "info") alphaValue = 0.05
38-
else alphaValue = 0.1
39-
break
40-
}
41-
case "border": {
42-
if (status == "info") alphaValue = 0.2
43-
else alphaValue = 0.3
44-
break
45-
}
20+
case "ok": return Colors.green
21+
case "warning": return Colors.orange
22+
case "error": return Colors.red
23+
default: return systemPalette.text
4624
}
25+
}
26+
27+
function getBackgroundColor(status) {
28+
// var color = Qt.darker(getColor(status), 1.2)
29+
var color = getColor(status)
30+
var alphaValue = status == "info" ? 0.05 : 0.1
31+
return Qt.rgba(color.r, color.g, color.b, alphaValue)
32+
}
33+
34+
function getBorderColor(status) {
35+
var color = getColor(status)
36+
var alphaValue = status == "info" ? 0.2 : 0.3
4737
return Qt.rgba(color.r, color.g, color.b, alphaValue)
4838
}
4939

@@ -61,7 +51,7 @@ ApplicationWindow {
6151
background: Rectangle {
6252
implicitWidth: root.width
6353
implicitHeight: 50
64-
color: Qt.darker(systemPalette.base, 1.1)
54+
color: Qt.darker(systemPalette.base, 1.2)
6555
}
6656

6757
RowLayout {
@@ -122,8 +112,8 @@ ApplicationWindow {
122112
delegate: Rectangle {
123113
width: messageListView.width
124114
height: messageLayout.implicitHeight + 16
125-
color: root.getColor(modelData.status, "background")
126-
border.color: root.getColor(modelData.status, "border")
115+
color: root.getBackgroundColor(modelData.status)
116+
border.color: root.getBorderColor(modelData.status)
127117
border.width: 1
128118
radius: 4
129119

0 commit comments

Comments
 (0)