diff --git a/cellacdc/__main__.py b/cellacdc/__main__.py
index 2146831a..70408aa1 100755
--- a/cellacdc/__main__.py
+++ b/cellacdc/__main__.py
@@ -136,6 +136,7 @@ def eventFilter(self, object, event):
from cellacdc import is_win, is_linux, temp_path, issues_url
from cellacdc import settings_csv_path
from cellacdc import printl
+ from cellacdc import _warnings
except ModuleNotFoundError as e:
src_path = os.path.dirname(os.path.abspath(__file__))
main_path = os.path.dirname(src_path)
@@ -369,25 +370,9 @@ def onDarkModeToggled(self, checked):
df_settings = pd.read_csv(settings_csv_path, index_col='setting')
df_settings.at['colorScheme', 'value'] = scheme
df_settings.to_csv(settings_csv_path)
- msg = widgets.myMessageBox(wrapText=False)
- txt = (
- 'In order for the change to take effect, '
- 'please restart Cell-ACDC'
+ _warnings.warnRestartCellACDCcolorModeToggled(
+ scheme, app_name='Cell-ACDC', parent=self
)
- if scheme == 'dark':
- issues_href = f'GitHub page'
- note_txt = (
- 'NOTE: dark mode is still in beta phase and '
- 'it is not perfect, but we believe it is usable.
'
- 'Many icons are not very visible on a dark background, but '
- 'if you see anything clearly wrong
'
- '(besides icons) please report it by opening an issue '
- f'on our {issues_href}.
'
- 'Thanks!'
- )
- txt = f'{txt}
{note_txt}'
- txt = html_utils.paragraph(txt)
- msg.information(self, 'Restart Cell-ACDC', txt)
self.statusBarLayout.addWidget(QLabel(html_utils.paragraph(
'Restart Cell-ACDC for the change to take effect',
font_color='red'
diff --git a/cellacdc/_warnings.py b/cellacdc/_warnings.py
index 55254638..04e66469 100644
--- a/cellacdc/_warnings.py
+++ b/cellacdc/_warnings.py
@@ -1,4 +1,5 @@
from . import widgets, html_utils
+from . import issues_url
def warnTooManyItems(mainWin, numItems, qparent):
mainWin.logger.info(
@@ -21,4 +22,23 @@ def warnTooManyItems(mainWin, numItems, qparent):
widgets.reloadPushButton(' Switch to low resolution ')
)
)
- return msg.cancel, msg.clickedButton==switchToLowResButton
\ No newline at end of file
+ return msg.cancel, msg.clickedButton==switchToLowResButton
+
+def warnRestartCellACDCcolorModeToggled(scheme, app_name='Cell-ACDC', parent=None):
+ msg = widgets.myMessageBox(wrapText=False)
+ txt = (
+ 'In order for the change to take effect, '
+ f'please restart {app_name}'
+ )
+ if scheme == 'dark':
+ issues_href = f'GitHub page'
+ note_txt = (
+ 'NOTE: dark mode is a recent feature so if you see '
+ 'if you see anything odd,
'
+ 'please, report it by opening an issue '
+ f'on our {issues_href}.
'
+ 'Thanks!'
+ )
+ txt = f'{txt}
{note_txt}'
+ txt = html_utils.paragraph(txt)
+ msg.information(parent, f'Restart {app_name}', txt)
\ No newline at end of file
diff --git a/cellacdc/gui.py b/cellacdc/gui.py
index d7dafe1e..771a9c5c 100755
--- a/cellacdc/gui.py
+++ b/cellacdc/gui.py
@@ -835,6 +835,7 @@ def __init__(
self.closeGUI = False
self.setAcceptDrops(True)
+ self._appName = 'Cell-ACDC'
def _printl(
self, *objects, is_decorator=False, **kwargs
@@ -1063,6 +1064,12 @@ def loadLastSessionSettings(self):
if 'manual_separate_draw_mode' not in self.df_settings.index:
col = 'manual_separate_draw_mode'
self.df_settings.at[col, 'value'] = 'threepoints_arc'
+
+ if 'colorScheme' in self.df_settings.index:
+ col = 'colorScheme'
+ self._colorScheme = self.df_settings.at[col, 'value']
+ else:
+ self._colorScheme = 'light'
def dragEnterEvent(self, event):
file_path = event.mimeData().urls()[0].toLocalFile()
@@ -1289,6 +1296,7 @@ def gui_createMenuBar(self):
# Settings menu
self.settingsMenu = QMenu("Settings", self)
menuBar.addMenu(self.settingsMenu)
+ self.settingsMenu.addAction(self.toggleColorSchemeAction)
self.settingsMenu.addAction(self.editShortcutsAction)
self.settingsMenu.addSeparator()
@@ -2618,6 +2626,11 @@ def gui_createActions(self):
'(from the current session not the saved information)'
)
+ self.toggleColorSchemeAction = QAction(
+ 'Switch to light mode'
+ )
+ self.gui_updateSwitchColorSchemeActionText()
+
self.editShortcutsAction = QAction(
'Customize keyboard shortcuts...', self
)
@@ -2809,6 +2822,13 @@ def gui_createActions(self):
# self.imgGradLabelsAlphaUpAction = QAction(self)
# self.imgGradLabelsAlphaUpAction.setVisible(False)
# self.imgGradLabelsAlphaUpAction.setShortcut('Ctrl+Up')
+
+ def gui_updateSwitchColorSchemeActionText(self):
+ if self._colorScheme == 'dark':
+ txt = 'Switch to light mode'
+ else:
+ txt = 'Switch to dark mode'
+ self.toggleColorSchemeAction.setText(txt)
def gui_connectActions(self):
# Connect File actions
@@ -2828,6 +2848,7 @@ def gui_connectActions(self):
self.nextAction.triggered.connect(self.nextActionTriggered)
self.prevAction.triggered.connect(self.prevActionTriggered)
+ self.toggleColorSchemeAction.triggered.connect(self.onToggleColorScheme)
self.editShortcutsAction.triggered.connect(self.editShortcuts_cb)
# Connect Help actions
@@ -2857,7 +2878,26 @@ def gui_connectActions(self):
)
self.addCustomModelFrameAction.callback = self.segmFrameCallback
self.addCustomModelVideoAction.callback = self.segmVideoCallback
-
+
+ def onToggleColorScheme(self):
+ if self.toggleColorSchemeAction.text().find('light') != -1:
+ self._colorScheme = 'light'
+ setDarkModeToggleChecked = False
+ else:
+ self._colorScheme = 'dark'
+ setDarkModeToggleChecked = True
+ self.gui_updateSwitchColorSchemeActionText()
+ _warnings.warnRestartCellACDCcolorModeToggled(
+ self._colorScheme, app_name=self._appName, parent=self
+ )
+ load.rename_qrc_resources_file(self._colorScheme)
+ self.statusBarLabel.setText(html_utils.paragraph(
+ f'Restart {self._appName} for the change to take effect',
+ font_color='red'
+ ))
+ self.df_settings.at['colorScheme', 'value'] = self._colorScheme
+ self.df_settings.to_csv(settings_csv_path)
+
def gui_connectEditActions(self):
self.showInExplorerAction.setEnabled(True)
self.setEnabledFileToolbar(True)
@@ -3161,7 +3201,7 @@ def gui_createQuickSettingsWidgets(self):
# the new default is True. This requires larger font size.
self.fontSize = 2*self.fontSize
self.df_settings.at['pxMode', 'value'] = 1
- self.df_settings.to_csv(self.settings_csv_path)
+ self.df_settings.to_csv(settings_csv_path)
self.fontSizeSpinBox.setValue(self.fontSize)
self.fontSizeSpinBox.editingFinished.connect(self.changeFontSize)
self.fontSizeSpinBox.sigUpClicked.connect(self.changeFontSize)