Skip to content

Commit d8e5cde

Browse files
authored
Merge pull request #297 from Nitrokey/layout-fixes
Layout fixes
2 parents 2f5aabd + c26bf55 commit d8e5cde

File tree

9 files changed

+641
-219
lines changed

9 files changed

+641
-219
lines changed

nitrokeyapp/gui.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,9 @@ def show_navigation(self) -> None:
227227
self.ui.vertical_navigation.setMaximumWidth(80)
228228
self.ui.btn_dial_help.hide()
229229

230-
self.ui.main_logo.setMaximumWidth(48)
231-
self.ui.main_logo.setMaximumHeight(48)
232-
self.ui.main_logo.setMinimumWidth(48)
233-
self.ui.main_logo.setMinimumHeight(48)
230+
self.ui.main_logo.setFixedWidth(64)
231+
self.ui.main_logo.setFixedHeight(64)
232+
self.ui.main_logo.setContentsMargins(0, 0, 0, 0)
234233

235234
def hide_navigation(self) -> None:
236235
for btn in self.device_buttons:
@@ -240,10 +239,9 @@ def hide_navigation(self) -> None:
240239
self.ui.vertical_navigation.setMaximumWidth(200)
241240
self.ui.btn_dial_help.show()
242241

243-
self.ui.main_logo.setMaximumWidth(120)
244-
self.ui.main_logo.setMaximumHeight(120)
245-
self.ui.main_logo.setMinimumWidth(64)
246-
self.ui.main_logo.setMinimumHeight(64)
242+
self.ui.main_logo.setFixedWidth(190)
243+
self.ui.main_logo.setFixedHeight(200)
244+
self.ui.main_logo.setContentsMargins(30, 40, 40, 40)
247245

248246
def show_device(self, data: DeviceData) -> None:
249247
self.selected_device = data
@@ -271,6 +269,9 @@ def show_device(self, data: DeviceData) -> None:
271269
view = self.views[self.tabs.currentIndex()]
272270
view.refresh(data, force=True)
273271

272+
for btn in self.device_buttons:
273+
btn.set_stylesheet_small()
274+
274275
def hide_device(self) -> None:
275276
self.selected_device = None
276277

@@ -279,6 +280,9 @@ def hide_device(self) -> None:
279280
self.hide_navigation()
280281
self.welcome_widget.show()
281282

283+
for btn in self.device_buttons:
284+
btn.set_stylesheet_big()
285+
282286
@Slot(int)
283287
def tab_changed(self, idx: int) -> None:
284288
view = self.views[self.tabs.currentIndex()]

nitrokeyapp/nk3_button.py

+30-12
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,8 @@ def __init__(
2222
self.setCheckable(True)
2323
self.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
2424

25-
self.setStyleSheet(
26-
"""
27-
QToolButton { background-color: none; border: none; margin: 0;
28-
margin-top: 8px; padding: 0.25em; border-radius: 6px;
29-
font: bold; font-size: 10px; border: 1px solid palette(button);
30-
}
31-
QToolButton:checked { background-color: palette(button);
32-
border: 1px outset palette(shadow);
33-
font: bold; font-size: 10px;
34-
}
35-
"""
36-
)
25+
self.set_stylesheet_small()
26+
3727
self.effect = QtWidgets.QGraphicsColorizeEffect(self)
3828
self.effect.setColor(QtGui.QColor(115, 215, 125))
3929
self.effect.setStrength(0)
@@ -63,6 +53,34 @@ def __init__(
6353

6454
self.animation = anims
6555

56+
def set_stylesheet_big(self) -> None:
57+
self.setStyleSheet(
58+
"""
59+
QToolButton { background-color: none; border: none; margin: 0;
60+
margin-top: 8px; padding: 0.25em; border-radius: 6px;
61+
font: bold; font-size: 12px; border: 1px solid palette(button);
62+
}
63+
QToolButton:checked { background-color: palette(button);
64+
border: 1px outset palette(shadow);
65+
font: bold; font-size: 10px;
66+
}
67+
"""
68+
)
69+
70+
def set_stylesheet_small(self) -> None:
71+
self.setStyleSheet(
72+
"""
73+
QToolButton { background-color: none; border: none; margin: 0;
74+
margin-top: 8px; padding: 0.25em; border-radius: 6px;
75+
font: bold; font-size: 10px; border: 1px solid palette(button);
76+
}
77+
QToolButton:checked { background-color: palette(button);
78+
border: 1px outset palette(shadow);
79+
font: bold; font-size: 10px;
80+
}
81+
"""
82+
)
83+
6684
def start_touch(self) -> None:
6785
self.animation.start()
6886
self.setToolTip("touch your Nitrokey 3")

nitrokeyapp/secrets_tab/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def check_credential(self) -> None:
652652
if self.ui.select_algorithm.isEnabled():
653653
if algo == "None":
654654
self.ui.otp.setReadOnly(True)
655-
self.ui.otp.setPlaceholderText("<Select Algorithm>")
655+
self.ui.otp.setPlaceholderText("<select algorithm>")
656656
else:
657657
self.ui.otp.setReadOnly(False)
658658
self.ui.otp.setPlaceholderText("<empty>")

nitrokeyapp/settings_tab/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def update_status_form(self, data: Optional[List[Tuple[str, str]]] = None) -> No
271271
d_obj = getattr(self.ui, f"value_{idx}")
272272

273273
if data is not None and len(data) > idx:
274-
l_obj.setText(f"**{data[idx][0]}:**")
274+
l_obj.setText(f"{data[idx][0]}: ")
275275
d_obj.setText(data[idx][1])
276276
l_obj.show()
277277
d_obj.show()

nitrokeyapp/ui/mainwindow.ui

+41-36
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</size>
2424
</property>
2525
<property name="contextMenuPolicy">
26-
<enum>Qt::DefaultContextMenu</enum>
26+
<enum>Qt::ContextMenuPolicy::DefaultContextMenu</enum>
2727
</property>
2828
<property name="windowTitle">
2929
<string>Nitrokey App</string>
@@ -35,10 +35,10 @@
3535
<string notr="true"/>
3636
</property>
3737
<property name="toolButtonStyle">
38-
<enum>Qt::ToolButtonIconOnly</enum>
38+
<enum>Qt::ToolButtonStyle::ToolButtonIconOnly</enum>
3939
</property>
4040
<property name="tabShape">
41-
<enum>QTabWidget::Rounded</enum>
41+
<enum>QTabWidget::TabShape::Rounded</enum>
4242
</property>
4343
<property name="dockNestingEnabled">
4444
<bool>false</bool>
@@ -63,17 +63,17 @@
6363
</sizepolicy>
6464
</property>
6565
<property name="frameShape">
66-
<enum>QFrame::NoFrame</enum>
66+
<enum>QFrame::Shape::NoFrame</enum>
6767
</property>
6868
<property name="frameShadow">
69-
<enum>QFrame::Plain</enum>
69+
<enum>QFrame::Shadow::Plain</enum>
7070
</property>
7171
<property name="lineWidth">
7272
<number>0</number>
7373
</property>
7474
<layout class="QHBoxLayout" name="horizontalLayout_9">
7575
<property name="sizeConstraint">
76-
<enum>QLayout::SetMaximumSize</enum>
76+
<enum>QLayout::SizeConstraint::SetMaximumSize</enum>
7777
</property>
7878
<property name="leftMargin">
7979
<number>9</number>
@@ -124,7 +124,7 @@
124124
</property>
125125
<property name="font">
126126
<font>
127-
<pointsize>8</pointsize>
127+
<pointsize>11</pointsize>
128128
</font>
129129
</property>
130130
<property name="text">
@@ -135,10 +135,10 @@
135135
<item>
136136
<spacer name="__spacer">
137137
<property name="orientation">
138-
<enum>Qt::Horizontal</enum>
138+
<enum>Qt::Orientation::Horizontal</enum>
139139
</property>
140140
<property name="sizeType">
141-
<enum>QSizePolicy::Expanding</enum>
141+
<enum>QSizePolicy::Policy::Expanding</enum>
142142
</property>
143143
<property name="sizeHint" stdset="0">
144144
<size>
@@ -152,7 +152,7 @@
152152
<widget class="QLabel" name="device_info">
153153
<property name="font">
154154
<font>
155-
<pointsize>8</pointsize>
155+
<pointsize>11</pointsize>
156156
<bold>true</bold>
157157
</font>
158158
</property>
@@ -169,6 +169,11 @@
169169
<verstretch>0</verstretch>
170170
</sizepolicy>
171171
</property>
172+
<property name="font">
173+
<font>
174+
<pointsize>8</pointsize>
175+
</font>
176+
</property>
172177
<property name="text">
173178
<string/>
174179
</property>
@@ -179,7 +184,7 @@
179184
</layout>
180185
</widget>
181186
</item>
182-
<item row="0" column="0" rowspan="3" alignment="Qt::AlignHCenter">
187+
<item row="0" column="0" rowspan="3">
183188
<widget class="QFrame" name="vertical_navigation">
184189
<property name="sizePolicy">
185190
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@@ -197,10 +202,10 @@
197202
<string notr="true"/>
198203
</property>
199204
<property name="frameShape">
200-
<enum>QFrame::StyledPanel</enum>
205+
<enum>QFrame::Shape::StyledPanel</enum>
201206
</property>
202207
<property name="frameShadow">
203-
<enum>QFrame::Raised</enum>
208+
<enum>QFrame::Shadow::Raised</enum>
204209
</property>
205210
<layout class="QVBoxLayout" name="verticalLayout_2">
206211
<property name="leftMargin">
@@ -209,20 +214,14 @@
209214
<property name="rightMargin">
210215
<number>9</number>
211216
</property>
212-
<item alignment="Qt::AlignHCenter">
217+
<item>
213218
<widget class="QLabel" name="main_logo">
214219
<property name="sizePolicy">
215-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
220+
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
216221
<horstretch>0</horstretch>
217222
<verstretch>0</verstretch>
218223
</sizepolicy>
219224
</property>
220-
<property name="layoutDirection">
221-
<enum>Qt::LeftToRight</enum>
222-
</property>
223-
<property name="lineWidth">
224-
<number>1</number>
225-
</property>
226225
<property name="text">
227226
<string/>
228227
</property>
@@ -233,14 +232,14 @@
233232
<bool>true</bool>
234233
</property>
235234
<property name="alignment">
236-
<set>Qt::AlignCenter</set>
235+
<set>Qt::AlignmentFlag::AlignCenter</set>
237236
</property>
238237
</widget>
239238
</item>
240-
<item alignment="Qt::AlignHCenter">
239+
<item>
241240
<widget class="QLabel" name="label_insert_Nitrokey">
242241
<property name="sizePolicy">
243-
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
242+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
244243
<horstretch>0</horstretch>
245244
<verstretch>0</verstretch>
246245
</sizepolicy>
@@ -260,7 +259,7 @@
260259
your Nitrokey</string>
261260
</property>
262261
<property name="alignment">
263-
<set>Qt::AlignCenter</set>
262+
<set>Qt::AlignmentFlag::AlignCenter</set>
264263
</property>
265264
</widget>
266265
</item>
@@ -291,7 +290,7 @@
291290
<item>
292291
<spacer name="vertical_spacer">
293292
<property name="orientation">
294-
<enum>Qt::Vertical</enum>
293+
<enum>Qt::Orientation::Vertical</enum>
295294
</property>
296295
<property name="sizeHint" stdset="0">
297296
<size>
@@ -339,7 +338,7 @@
339338
</font>
340339
</property>
341340
<property name="focusPolicy">
342-
<enum>Qt::NoFocus</enum>
341+
<enum>Qt::FocusPolicy::NoFocus</enum>
343342
</property>
344343
<property name="toolTip">
345344
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;home&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -367,7 +366,7 @@
367366
</property>
368367
</widget>
369368
</item>
370-
<item alignment="Qt::AlignHCenter">
369+
<item>
371370
<widget class="QPushButton" name="btn_dial_help">
372371
<property name="sizePolicy">
373372
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -394,13 +393,13 @@
394393
<bool>false</bool>
395394
</property>
396395
<property name="focusPolicy">
397-
<enum>Qt::NoFocus</enum>
396+
<enum>Qt::FocusPolicy::NoFocus</enum>
398397
</property>
399398
<property name="toolTip">
400399
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;help&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
401400
</property>
402401
<property name="layoutDirection">
403-
<enum>Qt::RightToLeft</enum>
402+
<enum>Qt::LayoutDirection::RightToLeft</enum>
404403
</property>
405404
<property name="styleSheet">
406405
<string notr="true">QPushButton {
@@ -480,11 +479,12 @@
480479
</property>
481480
<property name="font">
482481
<font>
483-
<pointsize>14</pointsize>
482+
<pointsize>11</pointsize>
483+
<bold>false</bold>
484484
</font>
485485
</property>
486486
<property name="layoutDirection">
487-
<enum>Qt::LeftToRight</enum>
487+
<enum>Qt::LayoutDirection::LeftToRight</enum>
488488
</property>
489489
<property name="autoFillBackground">
490490
<bool>false</bool>
@@ -493,19 +493,19 @@
493493
<string notr="true"/>
494494
</property>
495495
<property name="inputMethodHints">
496-
<set>Qt::ImhNone</set>
496+
<set>Qt::InputMethodHint::ImhNone</set>
497497
</property>
498498
<property name="tabPosition">
499-
<enum>QTabWidget::North</enum>
499+
<enum>QTabWidget::TabPosition::North</enum>
500500
</property>
501501
<property name="tabShape">
502-
<enum>QTabWidget::Rounded</enum>
502+
<enum>QTabWidget::TabShape::Rounded</enum>
503503
</property>
504504
<property name="currentIndex">
505505
<number>-1</number>
506506
</property>
507507
<property name="elideMode">
508-
<enum>Qt::ElideNone</enum>
508+
<enum>Qt::TextElideMode::ElideNone</enum>
509509
</property>
510510
<property name="usesScrollButtons">
511511
<bool>true</bool>
@@ -529,6 +529,11 @@
529529
</item>
530530
<item row="1" column="1">
531531
<widget class="QProgressBar" name="progress_bar">
532+
<property name="font">
533+
<font>
534+
<pointsize>11</pointsize>
535+
</font>
536+
</property>
532537
<property name="value">
533538
<number>0</number>
534539
</property>

0 commit comments

Comments
 (0)