-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.py
More file actions
executable file
·88 lines (69 loc) · 3.19 KB
/
Copy pathsettings.py
File metadata and controls
executable file
·88 lines (69 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from PyQt6.QtWidgets import QDialog, QFormLayout, QLineEdit, QPushButton, QSizePolicy, QCheckBox, QFrame
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QSystemTrayIcon, QMenu
from config import write_timer_config, read_timer_config
from utils import load_styles, toggle_theme, resource_path
class SettingsDialog(QDialog):
def __init__(self, work_duration, break_duration, long_break_duration, support, cycle_count, score):
super().__init__()
self.setWindowTitle("Settings")
self.setWindowTitle("Entracte")
self.setWindowIcon(QIcon(resource_path("assets/app.png")))
self.setFixedSize(200, 330)
self.layout = QFormLayout()
self.work_input = QLineEdit(self)
self.work_input.setText(str(work_duration))
self.layout.addRow("Work:", self.work_input)
self.break_input = QLineEdit(self)
self.break_input.setText(str(break_duration))
self.layout.addRow("Break:", self.break_input)
self.long_break_input = QLineEdit(self)
self.long_break_input.setText(str(long_break_duration))
self.layout.addRow("Rest:", self.long_break_input)
separator = QFrame()
separator.setFrameShape(QFrame.Shape.HLine)
separator.setFrameShadow(QFrame.Shadow.Sunken)
self.layout.addRow(separator)
self.cycle_count_input = QLineEdit(self)
self.cycle_count_input.setText(str(cycle_count))
self.layout.addRow("Cycle:", self.cycle_count_input)
self.score_input = QLineEdit(self)
self.score_input.setText(str(score))
self.layout.addRow("Score:", self.score_input)
separator2 = QFrame()
separator2.setFrameShape(QFrame.Shape.HLine)
separator2.setFrameShadow(QFrame.Shadow.Sunken)
self.layout.addRow(separator2)
self.support_checkbox = QCheckBox("Support future", self)
self.support_checkbox.setChecked(support)
self.layout.addRow(self.support_checkbox)
self.save_button = QPushButton("Save", self)
self.save_button.setObjectName("save_button")
self.save_button.clicked.connect(self.save_settings)
self.save_button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
self.layout.addRow(self.save_button)
self.theme_button = QPushButton("Toggle Theme", self)
self.theme_button.clicked.connect(self.toggle_theme)
self.layout.addRow(self.theme_button)
self.setLayout(self.layout)
load_styles(self)
def save_settings(self):
work_duration = int(self.work_input.text())
break_duration = int(self.break_input.text())
long_break_duration = int(self.long_break_input.text())
support = self.support_checkbox.isChecked()
config = read_timer_config()
config.update({
"work_duration": work_duration,
"break_duration": break_duration,
"long_break_duration": long_break_duration,
"support": support
})
write_timer_config(config)
load_styles(self)
self.accept()
def toggle_theme(self):
theme = toggle_theme()
self.update_styles()
def update_styles(self):
load_styles(self)