Color statusbar on prompts
This commit is contained in:
parent
61d4821065
commit
edacb23076
@ -818,6 +818,10 @@ DATA = OrderedDict([
|
|||||||
SettingValue(types.Color(), '${statusbar.fg}'),
|
SettingValue(types.Color(), '${statusbar.fg}'),
|
||||||
"Foreground color of the statusbar if there was an error."),
|
"Foreground color of the statusbar if there was an error."),
|
||||||
|
|
||||||
|
('statusbar.bg.prompt',
|
||||||
|
SettingValue(types.Color(), 'darkblue'),
|
||||||
|
"Background color of the statusbar if there is a prompt."),
|
||||||
|
|
||||||
('statusbar.progress.bg',
|
('statusbar.progress.bg',
|
||||||
SettingValue(types.Color(), 'white'),
|
SettingValue(types.Color(), 'white'),
|
||||||
"Background color of the progress bar."),
|
"Background color of the progress bar."),
|
||||||
|
@ -66,6 +66,12 @@ class StatusBar(QWidget):
|
|||||||
For some reason we need to have this as class attribute so
|
For some reason we need to have this as class attribute so
|
||||||
pyqtProperty works correctly.
|
pyqtProperty works correctly.
|
||||||
|
|
||||||
|
_prompt_active: If we're currently in prompt-mode, accessed through the
|
||||||
|
prompt_active property.
|
||||||
|
|
||||||
|
For some reason we need to have this as class attribute
|
||||||
|
so pyqtProperty works correctly.
|
||||||
|
|
||||||
Signals:
|
Signals:
|
||||||
resized: Emitted when the statusbar has resized, so the completion
|
resized: Emitted when the statusbar has resized, so the completion
|
||||||
widget can adjust its size to it.
|
widget can adjust its size to it.
|
||||||
@ -78,9 +84,10 @@ class StatusBar(QWidget):
|
|||||||
resized = pyqtSignal('QRect')
|
resized = pyqtSignal('QRect')
|
||||||
moved = pyqtSignal('QPoint')
|
moved = pyqtSignal('QPoint')
|
||||||
_error = False
|
_error = False
|
||||||
|
_prompt_active = False
|
||||||
|
|
||||||
STYLESHEET = """
|
STYLESHEET = """
|
||||||
QWidget#StatusBar[error="false"] {{
|
QWidget#StatusBar {{
|
||||||
{color[statusbar.bg]}
|
{color[statusbar.bg]}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@ -88,6 +95,10 @@ class StatusBar(QWidget):
|
|||||||
{color[statusbar.bg.error]}
|
{color[statusbar.bg.error]}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
QWidget#StatusBar[prompt_active="true"] {{
|
||||||
|
{color[statusbar.bg.prompt]}
|
||||||
|
}}
|
||||||
|
|
||||||
QWidget {{
|
QWidget {{
|
||||||
{color[statusbar.fg]}
|
{color[statusbar.fg]}
|
||||||
{font[statusbar]}
|
{font[statusbar]}
|
||||||
@ -163,6 +174,22 @@ class StatusBar(QWidget):
|
|||||||
self._error = val
|
self._error = val
|
||||||
self.setStyleSheet(get_stylesheet(self.STYLESHEET))
|
self.setStyleSheet(get_stylesheet(self.STYLESHEET))
|
||||||
|
|
||||||
|
@pyqtProperty(bool)
|
||||||
|
def prompt_active(self):
|
||||||
|
"""Getter for self.prompt, so it can be used as Qt property."""
|
||||||
|
# pylint: disable=method-hidden
|
||||||
|
return self._prompt_active
|
||||||
|
|
||||||
|
@prompt_active.setter
|
||||||
|
def prompt_active(self, val):
|
||||||
|
"""Setter for self.prompt, so it can be used as Qt property.
|
||||||
|
|
||||||
|
Re-set the stylesheet after setting the value, so everything gets
|
||||||
|
updated by Qt properly.
|
||||||
|
"""
|
||||||
|
self._prompt_active = val
|
||||||
|
self.setStyleSheet(get_stylesheet(self.STYLESHEET))
|
||||||
|
|
||||||
def _pop_text(self):
|
def _pop_text(self):
|
||||||
"""Display a text in the statusbar and pop it from _text_queue."""
|
"""Display a text in the statusbar and pop it from _text_queue."""
|
||||||
try:
|
try:
|
||||||
@ -199,6 +226,7 @@ class StatusBar(QWidget):
|
|||||||
def _show_prompt_widget(self):
|
def _show_prompt_widget(self):
|
||||||
"""Show prompt widget instead of temporary text."""
|
"""Show prompt widget instead of temporary text."""
|
||||||
self.error = False
|
self.error = False
|
||||||
|
self.prompt_active = True
|
||||||
if self._text_pop_timer.isActive():
|
if self._text_pop_timer.isActive():
|
||||||
self._timer_was_active = True
|
self._timer_was_active = True
|
||||||
self._text_pop_timer.stop()
|
self._text_pop_timer.stop()
|
||||||
@ -206,6 +234,7 @@ class StatusBar(QWidget):
|
|||||||
|
|
||||||
def _hide_prompt_widget(self):
|
def _hide_prompt_widget(self):
|
||||||
"""Show temporary text instead of prompt widget."""
|
"""Show temporary text instead of prompt widget."""
|
||||||
|
self.prompt_active = False
|
||||||
logger.debug("Hiding prompt widget, queue: {}".format(
|
logger.debug("Hiding prompt widget, queue: {}".format(
|
||||||
self._text_queue))
|
self._text_queue))
|
||||||
if self._timer_was_active:
|
if self._timer_was_active:
|
||||||
|
Loading…
Reference in New Issue
Block a user