Skip to content

Commit 716670a

Browse files
committed
extract styles into own file
1 parent fccebc0 commit 716670a

7 files changed

+31
-18
lines changed

app/gui/access_key_dialog.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from PyQt6.QtWidgets import QDialog, QLabel, QLineEdit, QApplication, QHBoxLayout, QVBoxLayout, \
55
QPushButton, QListWidget
66

7+
from app.gui import styles
8+
79
if TYPE_CHECKING:
810
from gui.gui import Gui
911

@@ -28,8 +30,7 @@ def __init__(self, parent=None):
2830
self.help_text_label = QLabel(
2931
'\n'.join(self.help_text),
3032
self)
31-
# TODO extract styles in own file
32-
self.help_text_label.setStyleSheet('color: lightgrey; font-style: italic; padding: 5px;')
33+
self.help_text_label.setStyleSheet(styles.help_text_style)
3334

3435
self.access_key_selection_text = QLabel("Select existing access-key:", self)
3536
self.access_key_selection = QListWidget()
@@ -40,17 +41,17 @@ def __init__(self, parent=None):
4041

4142
self.key_name_text = QLabel("Key name:", self)
4243
self.key_name_input = QLineEdit(self)
43-
self.key_name_input.setStyleSheet("color: black; background-color: white;")
44+
self.key_name_input.setStyleSheet(styles.input_field_style)
4445
self.key_name_input.textChanged.connect(self.check_access_key_name)
4546
self.key_name_input.setPlaceholderText('access-key-<name>')
4647

4748
self.key_id_text = QLabel("Key ID:", self)
4849
self.key_id_input = QLineEdit(self)
49-
self.key_id_input.setStyleSheet("color: black; background-color: white;")
50+
self.key_id_input.setStyleSheet(styles.input_field_style)
5051

5152
self.key_secret_text = QLabel("Key secret:", self)
5253
self.key_secret_input = QLineEdit(self)
53-
self.key_secret_input.setStyleSheet("color: black; background-color: white;")
54+
self.key_secret_input.setStyleSheet(styles.input_field_style)
5455
self.key_secret_input.setEchoMode(QLineEdit.EchoMode.Password)
5556

5657
self.ok_button = QPushButton("OK")
@@ -59,7 +60,7 @@ def __init__(self, parent=None):
5960
self.cancel_button.clicked.connect(self.cancel)
6061

6162
self.error_text = QLabel('access key will be overwritten!', self)
62-
self.error_text.setStyleSheet('color: rgb(255, 0, 0);')
63+
self.error_text.setStyleSheet(styles.error_text_style)
6364

6465
hbox = QHBoxLayout()
6566
hbox.addWidget(self.ok_button)

app/gui/config_dialog.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from app import __version__
1010
from app.core import files
1111
from app.core.config import Config
12+
from app.gui import styles
1213
from app.yubico import mfa
1314

1415
if TYPE_CHECKING:
@@ -29,16 +30,16 @@ def __init__(self, parent=None):
2930
font = QtGui.QFont("Courier New")
3031
font.setPointSize(14)
3132
self.text_box.setFont(font)
32-
self.text_box.setStyleSheet("color: black; background-color: white;")
33+
self.text_box.setStyleSheet(styles.input_field_style)
3334
self.text_box.setTabStopDistance(16)
3435

3536
self.mfa_command_label = QLabel("Shell command to fetch mfa token:", self)
3637
self.mfa_command_input = QLineEdit(self)
37-
self.mfa_command_input.setStyleSheet("color: black; background-color: white;")
38+
self.mfa_command_input.setStyleSheet(styles.input_field_style)
3839

3940
self.default_access_key_label = QLabel("Default access key name:", self)
4041
self.default_access_key_input = QLineEdit(self)
41-
self.default_access_key_input.setStyleSheet("color: black; background-color: white;")
42+
self.default_access_key_input.setStyleSheet(styles.input_field_style)
4243

4344
self.ok_button = QPushButton("OK")
4445
self.ok_button.clicked.connect(self.ok)
@@ -125,12 +126,12 @@ def update_error_text(self, config: Config):
125126

126127
def set_error_text(self, message):
127128
self.info_text.setText(message)
128-
self.info_text.setStyleSheet('color: rgb(255, 0, 0);')
129+
self.info_text.setStyleSheet(styles.error_text_style)
129130
self.info_text.repaint()
130131

131132
def set_success_text(self, message):
132133
self.info_text.setText(message)
133-
self.info_text.setStyleSheet('color: rgb(0, 255, 0);')
134+
self.info_text.setStyleSheet(styles.success_text_style)
134135
self.info_text.repaint()
135136

136137
def show_dialog(self, config: Config):

app/gui/key_rotation_dialog.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from PyQt6.QtWidgets import QDialog, QLabel, QApplication, QHBoxLayout, QVBoxLayout, \
55
QPushButton, QListWidget
66

7+
from app.gui import styles
8+
79
if TYPE_CHECKING:
810
from gui.gui import Gui
911

@@ -29,8 +31,7 @@ def __init__(self, parent=None):
2931
self.help_text_label = QLabel(
3032
'\n'.join(self.help_text),
3133
self)
32-
# TODO extract styles in own file
33-
self.help_text_label.setStyleSheet('color: lightgrey; font-style: italic; padding: 5px;')
34+
self.help_text_label.setStyleSheet(styles.help_text_style)
3435

3536
self.access_key_selection_text = QLabel("Select existing access-key:", self)
3637
self.access_key_selection = QListWidget()

app/gui/log_dialog.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from PyQt6.QtWidgets import QApplication, QLabel, QSizePolicy, QScrollArea, QVBoxLayout, \
55
QDialog
66

7+
from app.gui import styles
8+
79
if TYPE_CHECKING:
810
from gui.gui import Gui
911

@@ -20,7 +22,7 @@ def __init__(self, parent=None):
2022

2123
self.text_box = QLabel('no logs', self)
2224
self.text_box.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
23-
self.text_box.setStyleSheet("color: black; background-color: white;")
25+
self.text_box.setStyleSheet(styles.input_field_style)
2426
self.text_box.setAlignment(Qt.AlignmentFlag.AlignTop)
2527

2628
self.scroll_area = QScrollArea(self)

app/gui/mfa_dialog.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from PyQt6.QtWidgets import QDialog, QLabel, QLineEdit, QApplication, QHBoxLayout, QVBoxLayout, \
55
QPushButton
66

7+
from app.gui import styles
8+
79
if TYPE_CHECKING:
810
from gui.gui import Gui
911

@@ -18,7 +20,7 @@ def __init__(self, parent=None):
1820
self.text = QLabel("Mfa Token:", self)
1921

2022
self.input_field = QLineEdit(self)
21-
self.input_field.setStyleSheet("color: black; background-color: white;")
23+
self.input_field.setStyleSheet(styles.input_field_style)
2224

2325
self.ok_button = QPushButton("OK")
2426
self.ok_button.clicked.connect(self.ok)

app/gui/service_profile_dialog.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from app.aws import iam
88
from app.core.config import Config
99
from app.core.core import Core
10+
from app.gui import styles
1011
from app.gui.background_task import BackgroundTask
1112

1213
if TYPE_CHECKING:
@@ -48,8 +49,7 @@ def __init__(self, parent=None):
4849
self.help_text_label = QLabel(
4950
'\n'.join(self.help_text),
5051
self)
51-
# TODO extract styles in own file
52-
self.help_text_label.setStyleSheet('color: lightgrey; font-style: italic; padding: 5px;')
52+
self.help_text_label.setStyleSheet(styles.help_text_style)
5353

5454
self.group_headline = QLabel("Active group:", self)
5555
self.active_group_text = QLabel(self.active_group, self)
@@ -83,7 +83,7 @@ def __init__(self, parent=None):
8383
self.cancel_button.clicked.connect(self.cancel)
8484

8585
self.error_text = QLabel('', self)
86-
self.error_text.setStyleSheet('color: rgb(255, 0, 0);')
86+
self.error_text.setStyleSheet(styles.error_text_style)
8787

8888
hbox = QHBoxLayout()
8989
hbox.addWidget(self.ok_button)

app/gui/styles.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
help_text_style = 'color: lightgrey; font-style: italic; padding: 5px;'
2+
3+
input_field_style = 'color: black; background-color: white;'
4+
5+
error_text_style = 'color: rgb(255, 0, 0);'
6+
success_text_style = 'color: rgb(0, 255, 0);'

0 commit comments

Comments
 (0)