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.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?
|
||||
self.tab = TearOffTabWidget(self, self, self, self)
|
||||
@ -146,6 +151,10 @@ class MainWindow(QMainWindow):
|
||||
def on_actionShow_Logs_toggled(self, active):
|
||||
self.logwin.setHidden(not active)
|
||||
|
||||
def on_actionHighlightAnimation_toggled(self, toggled):
|
||||
settings = QSettings()
|
||||
settings.setValue('highlightanimation', toggled)
|
||||
|
||||
# def on_validateCheckBox_toggled(self, state):
|
||||
# print('validateCheckBox_toggled', state)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from frappy.gui.qt import QDialog, QHBoxLayout, QIcon, QLabel, QLineEdit, \
|
||||
QMessageBox, QPushButton, Qt, QToolButton, QWidget, pyqtSignal, pyqtSlot
|
||||
from frappy.gui.qt import QColor, QDialog, QHBoxLayout, QIcon, QLabel, \
|
||||
QLineEdit, QMessageBox, QPropertyAnimation, QPushButton, Qt, QToolButton, \
|
||||
QWidget, pyqtProperty, pyqtSignal, pyqtSlot
|
||||
|
||||
from frappy.gui.util import Colors, loadUi
|
||||
from frappy.gui.valuewidgets import get_widget
|
||||
@ -80,11 +81,50 @@ class CommandButton(QPushButton):
|
||||
#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):
|
||||
plot = pyqtSignal(str)
|
||||
plotAdd = pyqtSignal(str)
|
||||
def __init__(self, node, name, parent=None):
|
||||
super().__init__()
|
||||
super().__init__(parent)
|
||||
loadUi(self, 'modulewidget.ui')
|
||||
self._node = node
|
||||
self._name = name
|
||||
@ -129,17 +169,13 @@ class ModuleWidget(QWidget):
|
||||
if key in self._groups[key]:
|
||||
# Param with same name as group
|
||||
self._addParam(key, row)
|
||||
name = QLabel(key)
|
||||
name = AnimatedLabel(key)
|
||||
button = QToolButton()
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
||||
button.setText('+')
|
||||
button.pressed.connect(
|
||||
lambda group=key: self._toggleGroupCollapse(group))
|
||||
box = QHBoxLayout()
|
||||
box.addWidget(name)
|
||||
box.addWidget(button)
|
||||
groupLabel = QWidget()
|
||||
groupLabel.setLayout(box)
|
||||
groupLabel = AnimatedLabelHandthrough(name, button)
|
||||
|
||||
l = self.moduleDisplay.layout()
|
||||
label = l.itemAtPosition(row, 0).widget()
|
||||
@ -147,10 +183,10 @@ class ModuleWidget(QWidget):
|
||||
row += 1
|
||||
old = self._paramWidgets[key].pop(0)
|
||||
old.setParent(None)
|
||||
self._paramWidgets[key].append(groupLabel)
|
||||
self._paramWidgets[key].insert(0, groupLabel)
|
||||
self._setParamHidden(key, True)
|
||||
else:
|
||||
name = QLabel(key)
|
||||
name = AnimatedLabel(key)
|
||||
button = QToolButton()
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextOnly)
|
||||
button.setText('+')
|
||||
@ -243,7 +279,7 @@ class ModuleWidget(QWidget):
|
||||
def _addRParam(self, param, row):
|
||||
props = self._node.getProperties(self._name, param)
|
||||
|
||||
nameLabel = QLabel(param)
|
||||
nameLabel = AnimatedLabel(param)
|
||||
unitLabel = QLabel(props.get('unit', ''))
|
||||
display = QLineEdit()
|
||||
|
||||
@ -262,7 +298,7 @@ class ModuleWidget(QWidget):
|
||||
def _addRWParam(self, param, row):
|
||||
props = self._node.getProperties(self._name, param)
|
||||
|
||||
nameLabel = QLabel(param)
|
||||
nameLabel = AnimatedLabel(param)
|
||||
unitLabel = QLabel(props.get('unit', ''))
|
||||
unitLabel2 = QLabel(props.get('unit', ''))
|
||||
display = QLineEdit()
|
||||
|
@ -25,8 +25,8 @@ import json
|
||||
from collections import OrderedDict
|
||||
|
||||
from frappy.gui.qt import QCursor, QFont, QFontMetrics, QIcon, QInputDialog, \
|
||||
QMenu, QTextCursor, QVBoxLayout, QWidget, pyqtSignal, pyqtSlot, \
|
||||
toHtmlEscaped
|
||||
QMenu, QSettings, QTextCursor, QVBoxLayout, QWidget, pyqtSignal, \
|
||||
pyqtSlot, toHtmlEscaped
|
||||
|
||||
from frappy.errors import SECoPError
|
||||
from frappy.gui.moduleoverview import ModuleOverview
|
||||
@ -200,10 +200,13 @@ class NodeWidget(QWidget):
|
||||
if module == '' and param == '':
|
||||
return # for now, don't do anything when resetting selection
|
||||
if param == '':
|
||||
self.view.ensureWidgetVisible(self._modules[module])
|
||||
widget = self._modules[module].moduleName
|
||||
else:
|
||||
pw = self._modules[module]._paramWidgets[param][0]
|
||||
self.view.ensureWidgetVisible(pw)
|
||||
widget = self._modules[module]._paramWidgets[param][0]
|
||||
self.view.ensureWidgetVisible(widget)
|
||||
settings = QSettings()
|
||||
if settings.value('highlightanimation', True, bool):
|
||||
widget.triggerAnimation()
|
||||
|
||||
def _treeContextMenu(self, pos):
|
||||
index = self.tree.indexAt(pos)
|
||||
|
@ -33,7 +33,8 @@ from xml.sax.saxutils import escape as toHtmlEscaped
|
||||
try:
|
||||
from PyQt6 import uic
|
||||
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, \
|
||||
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
||||
QPen, QPixmap, QPolygonF, QShortcut, QStandardItem, \
|
||||
@ -52,7 +53,8 @@ try:
|
||||
except ImportError as e:
|
||||
from PyQt5 import uic
|
||||
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, \
|
||||
QFontMetrics, QIcon, QKeySequence, QMouseEvent, QPainter, QPalette, \
|
||||
QPen, QPixmap, QPolygonF, QStandardItem, QStandardItemModel, \
|
||||
|
@ -22,7 +22,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1228</width>
|
||||
<height>31</height>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@ -57,6 +57,7 @@
|
||||
</property>
|
||||
<addaction name="actionShow_Logs"/>
|
||||
<addaction name="actionDetailed_View"/>
|
||||
<addaction name="actionHighlightAnimation"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuOptions"/>
|
||||
@ -109,6 +110,9 @@
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Log Window</string>
|
||||
</property>
|
||||
@ -151,6 +155,17 @@
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources>
|
||||
<include location="../../../resources/frappy-gui.qrc"/>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,10,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="moduleName">
|
||||
<widget class="AnimatedLabel" name="moduleName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
@ -218,6 +218,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AnimatedLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>frappy.gui.modulewidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../resources/frappy-gui.qrc"/>
|
||||
</resources>
|
||||
|
@ -63,6 +63,7 @@ class Colors:
|
||||
if background > foreground: # light
|
||||
cls.colors = {
|
||||
'orange': QColor('#FA6800'),
|
||||
'yellow': QColor('#FCFFa4'),
|
||||
'plot-fg': QColor('black'),
|
||||
'plot-bg': QColor('white'),
|
||||
0: QColor('black'),
|
||||
@ -75,6 +76,7 @@ class Colors:
|
||||
else:
|
||||
cls.colors = {
|
||||
'orange': QColor('#FA6800'),
|
||||
'yellow': QColor('#FEFE22'),
|
||||
'plot-fg': QColor('white'),
|
||||
'plot-bg': QColor('black'),
|
||||
0: QColor('white'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user