|
@@ -2,9 +2,13 @@
|
2
|
2
|
Provides a helper tool to (de-)activate multiple people at once.
|
3
|
3
|
"""
|
4
|
4
|
|
|
5
|
+import math
|
5
|
6
|
import sys
|
6
|
7
|
|
7
|
8
|
# pylint: disable=E0611
|
|
9
|
+import qdarkstyle
|
|
10
|
+from PySide2.QtCore import QObject, QSize, Qt, Signal, Slot
|
|
11
|
+from PySide2.QtGui import QIcon
|
8
|
12
|
from PySide2.QtWidgets import (
|
9
|
13
|
QAction,
|
10
|
14
|
QActionGroup,
|
|
@@ -19,14 +23,10 @@ from PySide2.QtWidgets import (
|
19
|
23
|
QToolBar,
|
20
|
24
|
QWidget,
|
21
|
25
|
)
|
22
|
|
-from PySide2.QtGui import QIcon
|
23
|
|
-from PySide2.QtCore import QObject, QSize, Qt, Signal, Slot
|
24
|
26
|
|
25
|
|
-# pylint: enable=E0611
|
|
27
|
+from piket_client.model import NetworkError, Person, ServerStatus
|
26
|
28
|
|
27
|
|
-import qdarkstyle
|
28
|
|
-
|
29
|
|
-from piket_client.model import Person, ServerStatus
|
|
29
|
+# pylint: enable=E0611
|
30
|
30
|
|
31
|
31
|
|
32
|
32
|
class ActivationButton(QPushButton):
|
|
@@ -55,7 +55,8 @@ class ActivationButtons(QWidget):
|
55
|
55
|
|
56
|
56
|
def init_ui(self) -> None:
|
57
|
57
|
ps = Person.get_all()
|
58
|
|
- num_columns = round(len(ps) / 10) + 1
|
|
58
|
+ assert not isinstance(ps, NetworkError)
|
|
59
|
+ num_columns = math.ceil(math.sqrt(len(ps)))
|
59
|
60
|
|
60
|
61
|
for index, person in enumerate(ps):
|
61
|
62
|
button = ActivationButton(person, self)
|
|
@@ -66,7 +67,7 @@ class ActiveStateMainWindow(QMainWindow):
|
66
|
67
|
def __init__(self) -> None:
|
67
|
68
|
super().__init__()
|
68
|
69
|
|
69
|
|
- self.toolbar = None
|
|
70
|
+ self.toolbar = QToolBar()
|
70
|
71
|
|
71
|
72
|
self.init_ui()
|
72
|
73
|
|
|
@@ -79,7 +80,6 @@ class ActiveStateMainWindow(QMainWindow):
|
79
|
80
|
icon_size = font_metrics.height() * 1.45
|
80
|
81
|
|
81
|
82
|
# Toolbar
|
82
|
|
- self.toolbar = QToolBar()
|
83
|
83
|
self.toolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
|
84
|
84
|
self.toolbar.setIconSize(QSize(icon_size, icon_size))
|
85
|
85
|
|
|
@@ -112,17 +112,16 @@ def main() -> None:
|
112
|
112
|
app.setFont(font)
|
113
|
113
|
|
114
|
114
|
# Test connectivity
|
115
|
|
- server_running, info = ServerStatus.is_server_running()
|
|
115
|
+ server_running = ServerStatus.is_server_running()
|
116
|
116
|
|
117
|
|
- if not server_running:
|
118
|
|
- LOG.critical("Could not connect to server", extra={"info": info})
|
|
117
|
+ if not isinstance(server_running, bool):
|
119
|
118
|
QMessageBox.critical(
|
120
|
119
|
None,
|
121
|
120
|
"Help er is iets kapot",
|
122
|
121
|
"Kan niet starten omdat de server niet reageert, stuur een foto van "
|
123
|
|
- "dit naar Maarten: " + repr(info),
|
|
122
|
+ "dit naar Maarten: " + repr(server_running.value),
|
124
|
123
|
)
|
125
|
|
- return 1
|
|
124
|
+ return
|
126
|
125
|
|
127
|
126
|
# Load main window
|
128
|
127
|
main_window = ActiveStateMainWindow()
|