diff --git a/frappy/gui/mainwindow.py b/frappy/gui/mainwindow.py
index 88a1839..7ac57b7 100644
--- a/frappy/gui/mainwindow.py
+++ b/frappy/gui/mainwindow.py
@@ -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)
diff --git a/frappy/gui/modulewidget.py b/frappy/gui/modulewidget.py
index e6670ab..2f66644 100644
--- a/frappy/gui/modulewidget.py
+++ b/frappy/gui/modulewidget.py
@@ -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()
diff --git a/frappy/gui/nodewidget.py b/frappy/gui/nodewidget.py
index 8eca248..a20e5a7 100644
--- a/frappy/gui/nodewidget.py
+++ b/frappy/gui/nodewidget.py
@@ -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)
diff --git a/frappy/gui/qt.py b/frappy/gui/qt.py
index a74b830..c4c110e 100644
--- a/frappy/gui/qt.py
+++ b/frappy/gui/qt.py
@@ -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, \
diff --git a/frappy/gui/ui/mainwin.ui b/frappy/gui/ui/mainwin.ui
index d3cad1e..23afe77 100644
--- a/frappy/gui/ui/mainwin.ui
+++ b/frappy/gui/ui/mainwin.ui
@@ -22,7 +22,7 @@
0
0
1228
- 31
+ 30
@@ -109,6 +110,9 @@
true
+
+ false
+
Show Log Window
@@ -151,6 +155,17 @@
Ctrl+R
+
+
+ true
+
+
+ true
+
+
+ Highlight name upon selection
+
+
diff --git a/frappy/gui/ui/modulewidget.ui b/frappy/gui/ui/modulewidget.ui
index adba7ed..f8a13b2 100644
--- a/frappy/gui/ui/modulewidget.ui
+++ b/frappy/gui/ui/modulewidget.ui
@@ -23,7 +23,7 @@
-
-
-
+
18
@@ -218,6 +218,13 @@
+
+
+ AnimatedLabel
+ QLabel
+ frappy.gui.modulewidget.h
+
+
diff --git a/frappy/gui/util.py b/frappy/gui/util.py
index 664b551..ec935ee 100644
--- a/frappy/gui/util.py
+++ b/frappy/gui/util.py
@@ -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'),