Skip to content

Commit 0fb1153

Browse files
committed
Add configuration for (some) mcgui colors in mccode_config
(improves visibility e.g. in macOS dark mode) In case of a long path/filename, add (..long dirname..) as directory and show directory as mouse-over tooltip
1 parent 0322ddc commit 0fb1153

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

tools/Python/mccodelib/mccode_config.json.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"BROWSER": "@BROWSER@",
1616
"GUICOLS": "3",
1717
"GUIFONTSIZE": "12",
18+
"GUILOGCOLOR": "blue",
19+
"GUIINFOCOLOR": "green",
20+
"GUIERRCOLOR": "red",
1821
"NDBUFFERSIZE": "10000000",
1922
"EDITOR": "@EDITOR@",
2023
"FORMAT": "McCode",

tools/Python/mcgui/viewclasses.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ def closeCodeEditorWindow(self):
7171
'''
7272
def updateInstrument(self, labels, instr):
7373
''' labels: <instrument path>, <work dir> '''
74-
self.mw.ui.lblInstrument.setText(labels[0])
74+
if len(labels[0])>70:
75+
label=str(pathlib.Path("(..long dirname..)",pathlib.Path(labels[0]).name))
76+
tooltip="Located in: "+str(pathlib.Path(labels[0]).parent)
77+
else:
78+
label=labels[0]
79+
tooltip=labels[0]
80+
self.mw.ui.lblInstrument.setText(label)
81+
self.mw.ui.lblInstrument.setToolTip(tooltip)
7582
if str(labels[0]) == '':
7683
self.__ssd = None
7784
if Qsci:
@@ -85,11 +92,11 @@ def updateLog(self, text='', error=False, gui=False, clear=False):
8592
if clear:
8693
self.mw.ui.txtbrwMcgui.setText('Cleared messages.')
8794
if error:
88-
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('red'))
95+
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUIERRCOLOR"]))
8996
elif gui:
90-
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('blue'))
97+
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUILOGCOLOR"]))
9198
else:
92-
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('green'))
99+
self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUIINFOCOLOR"]))
93100
self.mw.ui.txtbrwMcgui.append(text)
94101

95102
def disableRunBtn(self):
@@ -116,9 +123,9 @@ def updateSimState(self, state=[]):
116123
ui.btnEdit.setEnabled(enableRun)
117124
ui.btnPlot.setEnabled(enablePlot)
118125
if enableRun:
119-
ui.lblInstrument.setStyleSheet('color: green')
126+
ui.lblInstrument.setStyleSheet('color: ' + mccode_config.configuration["GUILOGCOLOR"])
120127
else:
121-
ui.lblInstrument.setStyleSheet('color: red')
128+
ui.lblInstrument.setStyleSheet('color: ' + mccode_config.configuration["GUIERRCOLOR"])
122129
ui.actionClose_Instrument.setEnabled(enableRun)
123130
ui.actionPlot.setEnabled(enablePlot)
124131
ui.actionDisplay.setEnabled(enableRun)

0 commit comments

Comments
 (0)