aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-04-09 17:32:42 +0200
committerlonkaars <loek@pipeframe.xyz>2023-04-09 17:32:42 +0200
commit6d5c0901baf7a96e36e5e075b52970e0df2ccf19 (patch)
tree0b010c60afe88159fb9dfa7cb724abd38d0fa85f
parent8ce3898e775cdd4ac91960d415a36ffdc61d0fc7 (diff)
add layout and tab shims
-rw-r--r--gui.todo32
-rw-r--r--gui/gui.todo32
-rw-r--r--gui/login_dialog.py9
-rwxr-xr-xgui/main.py12
-rw-r--r--gui/main_window.py65
-rw-r--r--gui/split_view_layout.py24
-rw-r--r--gui/tab_calendar.py13
-rw-r--r--gui/tab_circuits.py13
-rw-r--r--gui/tab_drivers.py18
-rw-r--r--gui/tab_races.py13
-rw-r--r--gui/tab_teams.py13
11 files changed, 199 insertions, 45 deletions
diff --git a/gui.todo b/gui.todo
deleted file mode 100644
index 4ce3748..0000000
--- a/gui.todo
+++ /dev/null
@@ -1,32 +0,0 @@
-[ ] login dialog box (like mac system settings with padlock) (username + password)
-[ ] drivers
- - {show} {set} full name
- - {show} {set} nationality (both as text and as flag)
- - {show} portrait
- - {show} {set} team
- - {show} {set} role/function
-[ ] teams
- - {show} team name
- - {show} driver names (-> link to driver browser?)
-[ ] calendar
- - {pick/create} year
- - {add} race to calendar year
- - {show} GP name
- - {show} circuit (-> link)
- - {show} race (-> link)
-[ ] cirucits
- - {show} circuit name
- - {show} circuit length
- - {show} circuit lap count
- - {show} location
- - {show} photo / map
-[ ] races
- - {create} new race
- - {show} race number
- - {show} race date
- - {set} race outcome
- - {set} points (per driver)
- - {set} driver that got the fastest round
- - {set/order} drivers by finish number
- - {set/radio} driver disqualified/DNF
-
diff --git a/gui/gui.todo b/gui/gui.todo
new file mode 100644
index 0000000..720da30
--- /dev/null
+++ b/gui/gui.todo
@@ -0,0 +1,32 @@
+[x] login dialog box (like mac system settings with padlock) (username + password)
+[ ] drivers
+ - [ ] {show} {set} full name
+ - [ ] {show} {set} nationality (both as text and as flag)
+ - [ ] {show} portrait
+ - [ ] {show} {set} team
+ - [ ] {show} {set} role/function
+[ ] teams
+ - [ ] {show} team name
+ - [ ] {show} driver names (-> link to driver browser?)
+[ ] calendar
+ - [ ] {pick/create} year
+ - [ ] {add} race to calendar year
+ - [ ] {show} GP name
+ - [ ] {show} circuit (-> link)
+ - [ ] {show} race (-> link)
+[ ] cirucits
+ - [ ] {show} circuit name
+ - [ ] {show} circuit length
+ - [ ] {show} circuit lap count
+ - [ ] {show} location
+ - [ ] {show} photo / map
+[ ] races
+ - [ ] {create} new race
+ - [ ] {show} race number
+ - [ ] {show} race date
+ - [ ] {set} race outcome
+ - [ ] {set} points (per driver)
+ - [ ] {set} driver that got the fastest round
+ - [ ] {set/order} drivers by finish number
+ - [ ] {set/radio} driver disqualified/DNF
+
diff --git a/gui/login_dialog.py b/gui/login_dialog.py
index 5d24c13..3be923e 100644
--- a/gui/login_dialog.py
+++ b/gui/login_dialog.py
@@ -7,10 +7,10 @@ class LoginDialog(QDialog):
username = os.getlogin()
database = "formula1"
password = ""
- field_database = None
- field_hostname = None
- field_username = None
- field_password = None
+ field_database: QLineEdit
+ field_hostname: QLineEdit
+ field_username: QLineEdit
+ field_password: QLineEdit
def submit(self):
self.database = self.field_database.text()
@@ -43,3 +43,4 @@ class LoginDialog(QDialog):
layout.addRow(self.login_button)
self.setLayout(layout)
+
diff --git a/gui/main.py b/gui/main.py
index a190eab..335d7ed 100755
--- a/gui/main.py
+++ b/gui/main.py
@@ -7,14 +7,7 @@ from PyQt6.QtWidgets import *
from PyQt6 import *
from login_dialog import *
-
-global db
-global cursor
-
-class MainWindow(QMainWindow):
- def __init__(self, parent=None):
- super(MainWindow, self).__init__(parent)
- self.setWindowTitle("[floating] dab2 eindopdracht main window")
+from main_window import *
if __name__ == '__main__':
app = QApplication(sys.argv)
@@ -28,6 +21,7 @@ if __name__ == '__main__':
break
except:
print("Login failed, please try again")
- cursor = db.cursor(buffered=True)
+ win.set_cursor(db.cursor(buffered=True))
win.show()
app.exec()
+
diff --git a/gui/main_window.py b/gui/main_window.py
new file mode 100644
index 0000000..957bd27
--- /dev/null
+++ b/gui/main_window.py
@@ -0,0 +1,65 @@
+import mariadb
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+from tab_drivers import *
+from tab_teams import *
+from tab_calendar import *
+from tab_circuits import *
+from tab_races import *
+
+class MainWindow(QMainWindow):
+ cursor: mariadb.Cursor = None
+ menu_bar: QMenuBar
+
+ _tab_drivers: TabDrivers
+ _tab_teams: TabTeams
+ _tab_calendar: TabCalendar
+ _tab_circuits: TabCircuits
+ _tab_races: TabRaces
+
+ def set_cursor(self, cursor):
+ self.cursor = cursor
+
+ def call_update_flags(self):
+ folder = QFileDialog().getExistingDirectory(self, "Open directory", "/var/dab2/")
+ self.cursor.execute("call spUpdateFlags(?)", (folder,))
+
+ def call_update_persons(self):
+ folder = QFileDialog().getExistingDirectory(self, "Open directory", "/var/dab2/")
+ self.cursor.execute("call spUpdatePersons(?)", (folder,))
+
+ def call_delete_flags(self):
+ self.cursor.execute("call spDeleteFlags()")
+
+ def __init__(self, parent=None):
+ super(MainWindow, self).__init__(parent)
+ self.setWindowTitle("[floating] dab2 eindopdracht main window")
+ self.setMinimumHeight(500)
+
+ self._tab_drivers = TabDrivers(self)
+ self._tab_teams = TabTeams(self)
+ self._tab_calendar = TabCalendar(self)
+ self._tab_circuits = TabCircuits(self)
+ self._tab_races = TabRaces(self)
+
+ main_layout = QTabWidget(self);
+ main_layout.addTab(self._tab_drivers, "drivers")
+ main_layout.addTab(self._tab_teams, "teams")
+ main_layout.addTab(self._tab_calendar, "calendar")
+ main_layout.addTab(self._tab_circuits, "cirucits")
+ main_layout.addTab(self._tab_races, "races")
+
+ self.menu_bar = QMenuBar(self)
+ menu_procedures = self.menu_bar.addMenu("procedures")
+ sp_update_flags = menu_procedures.addAction("Import/update flags")
+ sp_update_flags.triggered.connect(self.call_update_flags)
+ sp_update_persons = menu_procedures.addAction("Import/update driver portraits")
+ sp_update_persons.triggered.connect(self.call_update_persons)
+ sp_delete_flags = menu_procedures.addAction("Delete flags")
+ sp_delete_flags.triggered.connect(self.call_delete_flags)
+
+ self.setMenuBar(self.menu_bar)
+ self.setCentralWidget(main_layout)
+
+
diff --git a/gui/split_view_layout.py b/gui/split_view_layout.py
new file mode 100644
index 0000000..ef0a14c
--- /dev/null
+++ b/gui/split_view_layout.py
@@ -0,0 +1,24 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+from PyQt6.QtCore import Qt
+
+class SplitViewLayout(QGridLayout):
+ def _setWidget(self, column: int, w: QWidget):
+ self.addWidget(w, 0, column, Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
+
+ return
+
+ def leftWidget(self, w: QWidget):
+ self._setWidget(0, w)
+
+ def rightWidget(self, w: QWidget):
+ self._setWidget(1, w)
+
+ def __init__(self, parent=None):
+ super(SplitViewLayout, self).__init__(parent)
+ self.setColumnStretch(0, 1)
+ self.setColumnMinimumWidth(0, 300)
+ self.setColumnStretch(1, 0)
+ self.setColumnMinimumWidth(1, 400)
+
diff --git a/gui/tab_calendar.py b/gui/tab_calendar.py
new file mode 100644
index 0000000..98aec52
--- /dev/null
+++ b/gui/tab_calendar.py
@@ -0,0 +1,13 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+class TabCalendar(QWidget):
+ def __init__(self, parent=None):
+ super(TabCalendar, self).__init__(parent)
+
+ layout = QFormLayout()
+ layout.addWidget(QLabel("hoi"))
+
+ self.setLayout(layout)
+
diff --git a/gui/tab_circuits.py b/gui/tab_circuits.py
new file mode 100644
index 0000000..332a9a4
--- /dev/null
+++ b/gui/tab_circuits.py
@@ -0,0 +1,13 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+class TabCircuits(QWidget):
+ def __init__(self, parent=None):
+ super(TabCircuits, self).__init__(parent)
+
+ layout = QFormLayout()
+ layout.addWidget(QLabel("hoi"))
+
+ self.setLayout(layout)
+
diff --git a/gui/tab_drivers.py b/gui/tab_drivers.py
new file mode 100644
index 0000000..d9a6098
--- /dev/null
+++ b/gui/tab_drivers.py
@@ -0,0 +1,18 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+from split_view_layout import *
+
+class TabDrivers(QWidget):
+ layout: SplitViewLayout
+
+ def __init__(self, parent=None):
+ super(TabDrivers, self).__init__(parent)
+
+ layout = SplitViewLayout(self)
+ layout.leftWidget(QLabel("hoi"))
+ layout.rightWidget(QLabel("doei"))
+
+ self.setLayout(layout)
+
diff --git a/gui/tab_races.py b/gui/tab_races.py
new file mode 100644
index 0000000..316e0af
--- /dev/null
+++ b/gui/tab_races.py
@@ -0,0 +1,13 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+class TabRaces(QWidget):
+ def __init__(self, parent=None):
+ super(TabRaces, self).__init__(parent)
+
+ layout = QFormLayout()
+ layout.addWidget(QLabel("hoi"))
+
+ self.setLayout(layout)
+
diff --git a/gui/tab_teams.py b/gui/tab_teams.py
new file mode 100644
index 0000000..2b25900
--- /dev/null
+++ b/gui/tab_teams.py
@@ -0,0 +1,13 @@
+import os
+from PyQt6.QtGui import *
+from PyQt6.QtWidgets import *
+
+class TabTeams(QWidget):
+ def __init__(self, parent=None):
+ super(TabTeams, self).__init__(parent)
+
+ layout = QFormLayout()
+ layout.addWidget(QLabel("hoi"))
+
+ self.setLayout(layout)
+