mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 06:14:16 +02:00
[improvement][ui] disabled button tooltip
This commit is contained in:
@@ -241,11 +241,15 @@ class InputFilter(QLineEdit):
|
||||
|
||||
class IconButton(QWidget):
|
||||
|
||||
def __init__(self, icon: QIcon, action, background: str = None, align: int = Qt.AlignCenter, tooltip: str = None):
|
||||
def __init__(self, icon: QIcon, action, i18n: I18n, background: str = None, align: int = Qt.AlignCenter, tooltip: str = None):
|
||||
super(IconButton, self).__init__()
|
||||
self.bt = QToolButton()
|
||||
self.bt.setIcon(icon)
|
||||
self.bt.clicked.connect(action)
|
||||
self.i18n = i18n
|
||||
self.default_tootip = tooltip
|
||||
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
self.bt.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
|
||||
if background:
|
||||
style = 'QToolButton { color: white; background: ' + background + '} '
|
||||
@@ -261,6 +265,14 @@ class IconButton(QWidget):
|
||||
layout.addWidget(self.bt)
|
||||
self.setLayout(layout)
|
||||
|
||||
def setEnabled(self, enabled):
|
||||
super(IconButton, self).setEnabled(enabled)
|
||||
|
||||
if not enabled:
|
||||
self.bt.setToolTip(self.i18n['icon_button.tooltip.disabled'])
|
||||
else:
|
||||
self.bt.setToolTip(self.default_tootip)
|
||||
|
||||
|
||||
class FormQt(QGroupBox):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user