Skip to content

Commit

Permalink
use dark mode in user config
Browse files Browse the repository at this point in the history
  • Loading branch information
Furtif committed Mar 5, 2024
1 parent 60bea80 commit 6470b9a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

custom: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=cedricpaille%40gmail%2ecom&lc=CY&item_name=codetronic&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"
github: [Cedric PAILLE]
custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=cedricpaille%40gmail%2ecom&lc=CY&item_name=codetronic&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted", "https://github.com/sponsors/Furtif"]
github: [Cedric PAILLE, Furtif]
21 changes: 14 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ def __init__(self):

darkstylelayout = widgets.QHBoxLayout()
self.darklayoutcheck = widgets.QCheckBox()
self.darklayoutcheck.setChecked(False)
self.darklayoutcheck.setChecked(options.dark_mode)
self.darklayoutcheck.stateChanged.connect(set_dark_style)
darkstylelabel = widgets.QLabel(_("Dark style"))
darkstylelayout.addWidget(self.darklayoutcheck)
Expand Down Expand Up @@ -1351,8 +1351,9 @@ def setIcon(self):

def save_config(self):
options.configuration["lang"] = options.lang_list[self.langcombo.currentText()]
options.configuration["dark"] = options.dark_mode
options.save_config()
exit(0)
app.exit(0)

def check_elm(self):
currentitem = self.listview.currentItem()
Expand Down Expand Up @@ -1566,11 +1567,17 @@ def demoMode(self):
options.simultation_mode = True
app = widgets.QApplication(sys.argv)

stylefile = core.QFile("dtt4all_data/qstyle.qss")
stylefile.open(core.QFile.ReadOnly)
options.dark_mode = False
StyleSheet = bytes(stylefile.readAll()).decode()
app.setStyleSheet(StyleSheet)
try:
f = open("dtt4all_data/config.json", "r", encoding="UTF-8")
configuration = json.loads(f.read())
f.close()
if configuration["dark"]:
set_dark_style(2)
else:
set_dark_style(0)
except:
set_dark_style(0)
pass

fsize = 9
fname = "Segoe UI"
Expand Down
4 changes: 3 additions & 1 deletion options.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
mode_edit = False
safe_commands = ["3E", "14", "21", "22", "17", "19", "10"]
configuration = {
"lang": None
"lang": None,
"dark": False
}
lang_list = {
"English": "en_US",
Expand Down Expand Up @@ -69,6 +70,7 @@ def create_new_config():
# print(i + " code: " + lang_list[i])
# codes += lang_list[i] + " "
configuration["lang"] = get_translator_lang()
configuration["dark"] = False
# print("\nEdit it only if it not ok for you country language.")
# print(f'Edit the `dtt4all_data/config.json`\nConfiguration however you want this to be translated.\nThe self-assigned code is: {lang}')
# print(f'Close and edit the configuration for list: \n\t{codes.strip()} \nAnd reopen the application.')
Expand Down

0 comments on commit 6470b9a

Please sign in to comment.