Shows warning to restart if color mode changed while onionshare is running

This commit is contained in:
Saptak S 2021-01-30 22:13:22 +05:30
parent 6a226adc23
commit 3f40c4a140
3 changed files with 15 additions and 4 deletions

View File

@ -58,10 +58,6 @@ class Application(QtWidgets.QApplication):
and event.modifiers() == QtCore.Qt.ControlModifier
):
self.quit()
# Check if color switched while the app was open
if event.type() == QtCore.QEvent.Type.ApplicationPaletteChange:
self.color_mode = self.get_color_mode()
return False
def is_dark_mode(self):

View File

@ -289,6 +289,20 @@ class MainWindow(QtWidgets.QMainWindow):
self.system_tray.hide()
e.accept()
def event(self, event):
# Check if color mode switched while onionshare was open, if so, ask user to restart
if event.type() == QtCore.QEvent.Type.ApplicationPaletteChange:
QtCore.QTimer.singleShot(1, self.color_mode_warning)
return True
return QtWidgets.QMainWindow.event(self, event)
def color_mode_warning(self):
"""
Open the color mode warning alert.
"""
notice = strings._("gui_color_mode_changed_notice")
Alert(self.common, notice, QtWidgets.QMessageBox.Information)
def cleanup(self):
self.common.log("MainWindow", "cleanup")
self.tabs.cleanup()

View File

@ -111,6 +111,7 @@
"gui_open_folder_error": "Failed to open folder with xdg-open. The file is here: {}",
"gui_settings_language_label": "Preferred language",
"gui_settings_language_changed_notice": "Restart OnionShare for the new language to be applied.",
"gui_color_mode_changed_notice": "Restart OnionShare for the new color mode to be applied.",
"systray_menu_exit": "Quit",
"systray_page_loaded_title": "Page Loaded",
"systray_page_loaded_message": "OnionShare address loaded",