Skip to content

Commit 6470b9a

Browse files
committed
use dark mode in user config
1 parent 60bea80 commit 6470b9a

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# These are supported funding model platforms
22

3-
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"
4-
github: [Cedric PAILLE]
3+
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"]
4+
github: [Cedric PAILLE, Furtif]

main.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ def __init__(self):
13031303

13041304
darkstylelayout = widgets.QHBoxLayout()
13051305
self.darklayoutcheck = widgets.QCheckBox()
1306-
self.darklayoutcheck.setChecked(False)
1306+
self.darklayoutcheck.setChecked(options.dark_mode)
13071307
self.darklayoutcheck.stateChanged.connect(set_dark_style)
13081308
darkstylelabel = widgets.QLabel(_("Dark style"))
13091309
darkstylelayout.addWidget(self.darklayoutcheck)
@@ -1351,8 +1351,9 @@ def setIcon(self):
13511351

13521352
def save_config(self):
13531353
options.configuration["lang"] = options.lang_list[self.langcombo.currentText()]
1354+
options.configuration["dark"] = options.dark_mode
13541355
options.save_config()
1355-
exit(0)
1356+
app.exit(0)
13561357

13571358
def check_elm(self):
13581359
currentitem = self.listview.currentItem()
@@ -1566,11 +1567,17 @@ def demoMode(self):
15661567
options.simultation_mode = True
15671568
app = widgets.QApplication(sys.argv)
15681569

1569-
stylefile = core.QFile("dtt4all_data/qstyle.qss")
1570-
stylefile.open(core.QFile.ReadOnly)
1571-
options.dark_mode = False
1572-
StyleSheet = bytes(stylefile.readAll()).decode()
1573-
app.setStyleSheet(StyleSheet)
1570+
try:
1571+
f = open("dtt4all_data/config.json", "r", encoding="UTF-8")
1572+
configuration = json.loads(f.read())
1573+
f.close()
1574+
if configuration["dark"]:
1575+
set_dark_style(2)
1576+
else:
1577+
set_dark_style(0)
1578+
except:
1579+
set_dark_style(0)
1580+
pass
15741581

15751582
fsize = 9
15761583
fname = "Segoe UI"

options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
mode_edit = False
3434
safe_commands = ["3E", "14", "21", "22", "17", "19", "10"]
3535
configuration = {
36-
"lang": None
36+
"lang": None,
37+
"dark": False
3738
}
3839
lang_list = {
3940
"English": "en_US",
@@ -69,6 +70,7 @@ def create_new_config():
6970
# print(i + " code: " + lang_list[i])
7071
# codes += lang_list[i] + " "
7172
configuration["lang"] = get_translator_lang()
73+
configuration["dark"] = False
7274
# print("\nEdit it only if it not ok for you country language.")
7375
# print(f'Edit the `dtt4all_data/config.json`\nConfiguration however you want this to be translated.\nThe self-assigned code is: {lang}')
7476
# print(f'Close and edit the configuration for list: \n\t{codes.strip()} \nAnd reopen the application.')

0 commit comments

Comments
 (0)