Skip to content

Commit

Permalink
Improve tab notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Nov 12, 2024
1 parent 7fda129 commit c64a7a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions MDANSE_GUI/Src/MDANSE_GUI/TabbedWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(
self._tabs["Instruments"]._visualiser.instrument_details_changed.connect(
self._tabs["Actions"].update_action_after_instrument_change
)
self.tabs.currentChanged.connect(self.tabs.reset_current_color)

def createCommonModels(self):
self._trajectory_model = GeneralModel()
Expand Down
8 changes: 6 additions & 2 deletions MDANSE_GUI/Src/MDANSE_GUI/Widgets/NotificationTabWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from qtpy.QtCore import Slot, Signal, QObject, QTimer
from qtpy.QtWidgets import QTabWidget
from qtpy.QtGui import QColor
from qtpy.QtGui import QColor, QIcon


class NotificationTabWidget(QTabWidget):
Expand All @@ -25,7 +25,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._normal_colours = {}
self._special_color = QColor(250, 10, 50)
self.tabBarClicked.connect(self.reset_current_color)

def addTab(self, widget: "QObject", name: str) -> int:
object_id = super().addTab(widget, name)
Expand All @@ -37,12 +36,17 @@ def addTab(self, widget: "QObject", name: str) -> int:
@Slot(int)
def set_special_color(self, tab_index: int):
self.tabBar().setTabTextColor(tab_index, self._special_color)
self.tabBar().setTabIcon(
tab_index, QIcon.fromTheme(QIcon.ThemeIcon.DialogInformation)
)

@Slot(int)
def reset_current_color(self):
tab_index = self.tabBar().currentIndex()
self.tabBar().setTabTextColor(tab_index, self._normal_colours[tab_index])
self.tabBar().setTabIcon(tab_index, QIcon())

@Slot(int)
def reset_color(self, tab_index: int):
self.tabBar().setTabTextColor(tab_index, self._normal_colours[tab_index])
self.tabBar().setTabIcon(tab_index, QIcon())

0 comments on commit c64a7a3

Please sign in to comment.