Short background Color animation on scroll
When the tree selection changes, trigger a short animation of the background color of the name-label of the selected module/parameter Change-Id: Ia56619a7e73458a5ac63ef821b5ac7ab5f7451df Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30651 Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
parent
bd06abc060
commit
644bfa85f7
@ -80,6 +80,11 @@ class MainWindow(QMainWindow):
|
|||||||
self.toolBar.hide()
|
self.toolBar.hide()
|
||||||
self.buildRecentNodeMenu()
|
self.buildRecentNodeMenu()
|
||||||
self.recentNodesChanged.connect(self.buildRecentNodeMenu)
|
self.recentNodesChanged.connect(self.buildRecentNodeMenu)
|
||||||
|
settings = QSettings()
|
||||||
|
self.actionHighlightAnimation.blockSignals(True)
|
||||||
|
self.actionHighlightAnimation.setChecked(
|
||||||
|
settings.value('highlightanimation', True, bool))
|
||||||
|
self.actionHighlightAnimation.blockSignals(False)
|
||||||
|
|
||||||
# what is which?
|
# what is which?
|
||||||
self.tab = TearOffTabWidget(self, self, self, self)
|
self.tab = TearOffTabWidget(self, self, self, self)
|
||||||
@ -146,6 +151,10 @@ class MainWindow(QMainWindow):
|
|||||||
def on_actionShow_Logs_toggled(self, active):
|
def on_actionShow_Logs_toggled(self, active):
|
||||||
self.logwin.setHidden(not active)
|
self.logwin.setHidden(not active)
|
||||||
|
|
||||||
|
def on_actionHighlightAnimation_toggled(self, toggled):
|
||||||
|
settings = QSettings()
|
||||||
|
settings.setValue('highlightanimation', toggled)
|
||||||
|
|
||||||
# def on_validateCheckBox_toggled(self, state):
|
# def on_validateCheckBox_toggled(self, state):
|
||||||
# print('validateCheckBox_toggled', state)
|
# print('validateCheckBox_toggled', state)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from frappy.gui.qt import QDialog, QHBoxLayout, QIcon, QLabel, QLineEdit, \
|
from frappy.gui.qt import QColor, QDialog, QHBoxLayout, QIcon, QLabel, \
|
||||||
QMessageBox, QPushButton, Qt, QToolButton, QWidget, pyqtSignal, pyqtSlot
|
QLineEdit, QMessageBox, QPropertyAnimation, QPushButton, Qt, QToolButton, \
|
||||||
|
QWidget, pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
|
|
||||||
from frappy.gui.util import Colors, loadUi
|
from frappy.gui.util import Colors, loadUi
|
||||||
from frappy.gui.valuewidgets import get_widget
|
from frappy.gui.valuewidgets import get_widget
|
||||||
@ -80,11 +81,50 @@ class CommandButton(QPushButton):
|
|||||||
#self.setEnabled(True)
|
#self.setEnabled(True)
|
||||||
|
|
||||||
|
|
||||||
|
class AnimatedLabel(QLabel):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setAutoFillBackground(True)
|
||||||
|
self.backgroundColor = self.palette().color(self.backgroundRole())
|
||||||
|
self.animation = QPropertyAnimation(self, b"bgColor", self)
|
||||||
|
self.animation.setDuration(350)
|
||||||
|
self.animation.setStartValue(Colors.colors['yellow'])
|
||||||
|
self.animation.setEndValue(self.backgroundColor)
|
||||||
|
|
||||||
|
@pyqtProperty(QColor)
|
||||||
|
def bgColor(self):
|
||||||
|
return self.palette().color(self.backgroundRole())
|
||||||
|
|
||||||
|
@bgColor.setter
|
||||||
|
def bgColor(self, color):
|
||||||
|
p = self.palette()
|
||||||
|
p.setColor(self.backgroundRole(), color)
|
||||||
|
self.setPalette(p)
|
||||||
|
|
||||||
|
def triggerAnimation(self):
|
||||||
|
self.animation.start()
|
||||||
|
|
||||||
|
|
||||||
|
class AnimatedLabelHandthrough(QWidget):
|
||||||
|
"""This class is a crutch for the failings of the current grouping
|
||||||
|
implementation. TODO: It has to be removed in the grouping rework """
|
||||||
|
def __init__(self, label, btn, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.label = label
|
||||||
|
box = QHBoxLayout()
|
||||||
|
box.addWidget(label)
|
||||||
|
box.addWidget(btn)
|
||||||
|
self.setLayout(box)
|
||||||
|
|
||||||
|
def triggerAnimation(self):
|
||||||
|
self.label.triggerAnimation()
|
||||||
|
|
||||||
|
|
||||||
class ModuleWidget(QWidget):
|
class ModuleWidget(QWidget):
|
||||||
plot = pyqtSignal(str)
|
plot = pyqtSignal(str)
|
||||||
plotAdd = pyqtSignal(str)
|
plotAdd = pyqtSignal(str)
|
||||||
def __init__(self, node, name, parent=None):
|
def __init__(self, node, name, parent=None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
loadUi(self, 'modulewidget.ui')
|
loadUi(self, 'modulewidget.ui')
|
||||||
self._node = node
|
self._node = node
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -129,17 +169,13 @@ class ModuleWidget(QWidget):
|
|||||||
if key in self._groups[key]:
|
if key in self._groups[key]:
|
||||||
# Param with same name as group
|
# Param with same name as group
|
||||||
self._addParam(key, row)
|
self._addParam(key, row)
|
||||||
name = QLabel(key)
|
name = AnimatedLabel(key)
|
||||||
button = QToolButton()
|
button = QToolButton()
|
||||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
||||||
button.setText('+')
|
button.setText('+')
|
||||||
button.pressed.connect(
|
button.pressed.connect(
|
||||||
lambda group=key: self._toggleGroupCollapse(group))
|
lambda group=key: self._toggleGroupCollapse(group))
|
||||||
box = QHBoxLayout()
|
groupLabel = AnimatedLabelHandthrough(name, button)
|
||||||
box.addWidget(name)
|
|
||||||
box.addWidget(button)
|
|
||||||
groupLabel = QWidget()
|
|
||||||
groupLabel.setLayout(box)
|
|
||||||
|
|
||||||
l = self.moduleDisplay.layout()
|
l = self.moduleDisplay.layout()
|
||||||
label = l.itemAtPosition(row, 0).widget()
|
label = l.itemAtPosition(row, 0).widget()
|
||||||
@ -147,10 +183,10 @@ class ModuleWidget(QWidget):
|
|||||||
row += 1
|
row += 1
|
||||||
old = self._paramWidgets[key].pop(0)
|
old = self._paramWidgets[key].pop(0)
|
||||||
old.setParent(None)
|
old.setParent(None)
|
||||||
self._paramWidgets[key].append(groupLabel)
|
self._paramWidgets[key].insert(0, groupLabel)
|
||||||
self._setParamHidden(key, True)
|
self._setParamHidden(key, True)
|
||||||
else:
|
else:
|
||||||
name = QLabel(key)
|
name = AnimatedLabel(key)
|
||||||
button = QToolButton()
|
button = QToolButton()
|
||||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
||||||
button.setText('+')
|
button.setText('+')
|
||||||
@ -243,7 +279,7 @@ class ModuleWidget(QWidget):
|
|||||||
def _addRParam(self, param, row):
|
def _addRParam(self, param, row):
|
||||||
props = self._node.getProperties(self._name, param)
|
props = self._node.getProperties(self._name, param)
|
||||||
|
|
||||||
nameLabel = QLabel(param)
|
nameLabel = AnimatedLabel(param)
|
||||||
unitLabel = QLabel(props.get('unit', ''))
|
unitLabel = QLabel(props.get('unit', ''))
|
||||||
display = QLineEdit()
|
display = QLineEdit()
|
||||||
|
|
||||||
@ -262,7 +298,7 @@ class ModuleWidget(QWidget):
|
|||||||
def _addRWParam(self, param, row):
|
def _addRWParam(self, param, row):
|
||||||
props = self._node.getProperties(self._name, param)
|
props = self._node.getProperties(self._name, param)
|
||||||
|
|
||||||
nameLabel = QLabel(param)
|
nameLabel = AnimatedLabel(param)
|
||||||
unitLabel = QLabel(props.get('unit', ''))
|
unitLabel = QLabel(props.get('unit', ''))
|
||||||
unitLabel2 = QLabel(props.get('unit', ''))
|
unitLabel2 = QLabel(props.get('unit', ''))
|
||||||
display = QLineEdit()
|
display = QLineEdit()
|
||||||
|
@ -25,8 +25,8 @@ import json
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from frappy.gui.qt import QCursor, QFont, QFontMetrics, QIcon, QInputDialog, \
|
from frappy.gui.qt import QCursor, QFont, QFontMetrics, QIcon, QInputDialog, \
|
||||||
QMenu, QTextCursor, QVBoxLayout, QWidget, pyqtSignal, pyqtSlot, \
|
QMenu, QSettings, QTextCursor, QVBoxLayout, QWidget, pyqtSignal, \
|
||||||
toHtmlEscaped
|
pyqtSlot, toHtmlEscaped
|
||||||
|
|
||||||
from frappy.errors import SECoPError
|
from frappy.errors import SECoPError
|
||||||
from frappy.gui.moduleoverview import ModuleOverview
|
from frappy.gui.moduleoverview import ModuleOverview
|
||||||
@ -200,10 +200,13 @@ class NodeWidget(QWidget):
|
|||||||
if module == '' and param == '':
|
if module == '' and param == '':
|
||||||
return # for now, don't do anything when resetting selection
|
return # for now, don't do anything when resetting selection
|
||||||
if param == '':
|
if param == '':
|
||||||
self.view.ensureWidgetVisible(self._modules[module])
|
widget = self._modules[module].moduleName
|
||||||
else:
|
else:
|
||||||
pw = self._modules[module]._paramWidgets[param][0]
|
widget = self._modules[module]._paramWidgets[param][0]
|
||||||
self.view.ensureWidgetVisible(pw)
|
self.view.ensureWidgetVisible(widget)
|
||||||
|
settings = QSettings()
|
||||||
|
if settings.value('highlightanimation', True, bool):
|
||||||
|
widget.triggerAnimation()
|
||||||
|
|
||||||
def _treeContextMenu(self, pos):
|
def _treeContextMenu(self, pos):
|
||||||
index = self.tree.indexAt(pos)
|
index = self.tree.indexAt(pos)
|
||||||
|
@ -33,7 +33,8 @@ from xml.sax.saxutils import escape as toHtmlEscaped
|
|||||||
try:
|
try:
|
||||||
from PyQt6 import uic
|
from PyQt6 import uic
|
||||||
from PyQt6.QtCore import QByteArray, QEvent, QMimeData, QObject, QPoint, \
|
from PyQt6.QtCore import QByteArray, QEvent, QMimeData, QObject, QPoint, \
|
||||||
QPointF, QRectF, QSettings, QSize, Qt, pyqtSignal, pyqtSlot
|
QPointF, QPropertyAnimation, QRectF, QSettings, QSize, Qt, \
|
||||||
|
pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
from PyQt6.QtGui import QAction, QBrush, QColor, QCursor, QDrag, QFont, \
|
from PyQt6.QtGui import QAction, QBrush, QColor, QCursor, QDrag, QFont, \
|
||||||
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
||||||
QPen, QPixmap, QPolygonF, QShortcut, QStandardItem, \
|
QPen, QPixmap, QPolygonF, QShortcut, QStandardItem, \
|
||||||
@ -52,7 +53,8 @@ try:
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
from PyQt5.QtCore import QByteArray, QEvent, QMimeData, QObject, QPoint, \
|
from PyQt5.QtCore import QByteArray, QEvent, QMimeData, QObject, QPoint, \
|
||||||
QPointF, QRectF, QSettings, QSize, Qt, pyqtSignal, pyqtSlot
|
QPointF, QPropertyAnimation, QRectF, QSettings, QSize, Qt, \
|
||||||
|
pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import QBrush, QColor, QCursor, QDrag, QFont, \
|
from PyQt5.QtGui import QBrush, QColor, QCursor, QDrag, QFont, \
|
||||||
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
||||||
QPen, QPixmap, QPolygonF, QStandardItem, QStandardItemModel, \
|
QPen, QPixmap, QPolygonF, QStandardItem, QStandardItemModel, \
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1228</width>
|
<width>1228</width>
|
||||||
<height>31</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -57,6 +57,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="actionShow_Logs"/>
|
<addaction name="actionShow_Logs"/>
|
||||||
<addaction name="actionDetailed_View"/>
|
<addaction name="actionDetailed_View"/>
|
||||||
|
<addaction name="actionHighlightAnimation"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuOptions"/>
|
<addaction name="menuOptions"/>
|
||||||
@ -109,6 +110,9 @@
|
|||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show Log Window</string>
|
<string>Show Log Window</string>
|
||||||
</property>
|
</property>
|
||||||
@ -151,6 +155,17 @@
|
|||||||
<string>Ctrl+R</string>
|
<string>Ctrl+R</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionHighlightAnimation">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Highlight name upon selection</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../resources/frappy-gui.qrc"/>
|
<include location="../../../resources/frappy-gui.qrc"/>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,10,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,10,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="moduleName">
|
<widget class="AnimatedLabel" name="moduleName">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>18</pointsize>
|
<pointsize>18</pointsize>
|
||||||
@ -218,6 +218,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>AnimatedLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header>frappy.gui.modulewidget.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../resources/frappy-gui.qrc"/>
|
<include location="../../../resources/frappy-gui.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -63,6 +63,7 @@ class Colors:
|
|||||||
if background > foreground: # light
|
if background > foreground: # light
|
||||||
cls.colors = {
|
cls.colors = {
|
||||||
'orange': QColor('#FA6800'),
|
'orange': QColor('#FA6800'),
|
||||||
|
'yellow': QColor('#FCFFa4'),
|
||||||
'plot-fg': QColor('black'),
|
'plot-fg': QColor('black'),
|
||||||
'plot-bg': QColor('white'),
|
'plot-bg': QColor('white'),
|
||||||
0: QColor('black'),
|
0: QColor('black'),
|
||||||
@ -75,6 +76,7 @@ class Colors:
|
|||||||
else:
|
else:
|
||||||
cls.colors = {
|
cls.colors = {
|
||||||
'orange': QColor('#FA6800'),
|
'orange': QColor('#FA6800'),
|
||||||
|
'yellow': QColor('#FEFE22'),
|
||||||
'plot-fg': QColor('white'),
|
'plot-fg': QColor('white'),
|
||||||
'plot-bg': QColor('black'),
|
'plot-bg': QColor('black'),
|
||||||
0: QColor('white'),
|
0: QColor('white'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user