From 4e7e2b4cc493f17c02221d87dc888933a5766e06 Mon Sep 17 00:00:00 2001 From: jupfi Date: Sun, 30 Jul 2023 18:05:27 +0200 Subject: [PATCH] Added tooltips for settings. --- .../base_spectrometer_view.py | 15 +++++++++++++++ .../resources/icons/QuestionMark_16x16.png | Bin 0 -> 240 bytes 2 files changed, 15 insertions(+) create mode 100644 src/nqrduck_spectrometer/resources/icons/QuestionMark_16x16.png diff --git a/src/nqrduck_spectrometer/base_spectrometer_view.py b/src/nqrduck_spectrometer/base_spectrometer_view.py index 460865b..74e3321 100644 --- a/src/nqrduck_spectrometer/base_spectrometer_view.py +++ b/src/nqrduck_spectrometer/base_spectrometer_view.py @@ -1,5 +1,7 @@ import logging +from pathlib import Path from PyQt6.QtWidgets import QWidget, QLabel, QLineEdit, QHBoxLayout, QSizePolicy, QSpacerItem, QVBoxLayout +from PyQt6.QtGui import QIcon from PyQt6.QtCore import Qt, pyqtSlot from nqrduck.module.module_view import ModuleView @@ -54,10 +56,23 @@ class BaseSpectrometerView(ModuleView): layout = QHBoxLayout() # Connect the editingFinished signal to the on_value_changed slot of the setting line_edit.editingFinished.connect(lambda x=line_edit, s=setting: s.on_value_changed(x.text())) + # Add a icon that can be used as a tooltip + if setting.description is not None: + logger.debug("Adding tooltip to setting: %s", setting.name) + self_path = Path(__file__).parent + tooltip_icon_path = self_path / "resources/icons" / "QuestionMark_16x16.png" + icon = QIcon(str(tooltip_icon_path)) + icon_label = QLabel() + icon_label.setPixmap(icon.pixmap(icon.availableSizes()[0])) + icon_label.setFixedSize(icon.availableSizes()[0]) + + icon_label.setToolTip(setting.description) + # Add the label and the line edit to the layout layout.addItem(spacer) layout.addWidget(setting_label) layout.addWidget(line_edit) + layout.addWidget(icon_label) layout.addStretch(1) # Add the layout to the vertical layout of the widget category_layout.addLayout(layout) diff --git a/src/nqrduck_spectrometer/resources/icons/QuestionMark_16x16.png b/src/nqrduck_spectrometer/resources/icons/QuestionMark_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..13158ae96bcee214a33513ff77b6183a2335d93c GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}t2|vCLn2y} z6C_?XOk~;me`SW4jKRdkowFJw!vCiyBqZ#J+snOP>1>#J(3zHIM_DEfyZQBhnBtm+ zba^EtBs};#56Uy8`o(HA#r{4O@Z-g&C2dC*@G(j_od5r#ilg<)13pGEr7I6UF^0{b z%*AHIazb}YRP6lDteYRSV>!67i2`vX%^Egv(p98=13Ca$v$&5Znwfd;eK lH1s&zYb*_3HC&8gV6chMHvXh$SO#=8gQu&X%Q~loCIC9rQvUz| literal 0 HcmV?d00001