aboutsummaryrefslogtreecommitdiff
path: root/desktop/src/onionshare/__init__.py
diff options
context:
space:
mode:
authorSaptak S <saptak013@gmail.com>2021-01-24 03:18:56 +0530
committerSaptak S <saptak013@gmail.com>2021-01-24 03:18:56 +0530
commit123bea94e9ee984f3e23b1cd58a602a0b2c98d12 (patch)
treee5f8635cca7404035ef0099f32ed195e8426f87e /desktop/src/onionshare/__init__.py
parent6eee7f9c5c42752bb17a1ae2da14a96a55ba7297 (diff)
downloadonionshare-123bea94e9ee984f3e23b1cd58a602a0b2c98d12.tar.gz
onionshare-123bea94e9ee984f3e23b1cd58a602a0b2c98d12.zip
Sets text color and images based on the mac system color mode
Diffstat (limited to 'desktop/src/onionshare/__init__.py')
-rw-r--r--desktop/src/onionshare/__init__.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/desktop/src/onionshare/__init__.py b/desktop/src/onionshare/__init__.py
index f66c5a28..a8cdd60b 100644
--- a/desktop/src/onionshare/__init__.py
+++ b/desktop/src/onionshare/__init__.py
@@ -27,7 +27,7 @@ import signal
import json
import psutil
import getpass
-from PySide2 import QtCore, QtWidgets
+from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.common import Common
@@ -46,6 +46,9 @@ class Application(QtWidgets.QApplication):
if common.platform == "Linux" or common.platform == "BSD":
self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
QtWidgets.QApplication.__init__(self, sys.argv)
+
+ # Check color mode on starting the app
+ self.color_mode = self.get_color_mode()
self.installEventFilter(self)
def eventFilter(self, obj, event):
@@ -55,8 +58,21 @@ 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):
+ baseColor = QtGui.QPalette().color(QtGui.QPalette.Base)
+ if baseColor.name().lower() == "#ffffff":
+ return False
+ return True
+
+ def get_color_mode(self):
+ return "dark" if self.is_dark_mode() else "light"
+
def main():
"""