summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-x[-rw-r--r--]assignment-list0
-rw-r--r--src/db_sqlite.py2
-rw-r--r--src/main.py18
-rw-r--r--src/preferences_dialog.py10
5 files changed, 29 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 46aa7b9..16e2109 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
__pycache__
test.db
dummy*
+build
+dist
diff --git a/assignment-list b/assignment-list
index cb0af8a..cb0af8a 100644..100755
--- a/assignment-list
+++ b/assignment-list
diff --git a/src/db_sqlite.py b/src/db_sqlite.py
index 88a64c2..fd06b5a 100644
--- a/src/db_sqlite.py
+++ b/src/db_sqlite.py
@@ -82,6 +82,7 @@ def loadFromTables():
query = QSqlQuery()
# Load groups
+ Globals.groups = [] # Reset local groups array
query.exec_("SELECT * FROM groups")
while query.next():
record = query.record()
@@ -94,6 +95,7 @@ def loadFromTables():
record.field("hidden").value()))
# Load entries
+ Globals.entries = [] # Reset local entries array
query.exec_("SELECT * FROM entries")
while query.next():
record = query.record()
diff --git a/src/main.py b/src/main.py
index dfdf8a7..1b82204 100644
--- a/src/main.py
+++ b/src/main.py
@@ -37,12 +37,12 @@ class AssignmentList(QMainWindow):
self.preferences_act = QAction("Preferences", self)
self.preferences_act.setShortcut("Alt+Return")
- self.preferences_act.triggered.connect(PreferencesDialog)
+ self.preferences_act.triggered.connect(self.preferences)
file_menu.addAction(self.preferences_act)
# TODO implement reload of DB that works
- self.reload_act = QAction("Reload [WIP]", self)
+ self.reload_act = QAction("Reload", self)
self.reload_act.setShortcut("F5")
- #self.reload_act.triggered.connect(self.reload)
+ self.reload_act.triggered.connect(self.reload)
file_menu.addAction(self.reload_act)
file_menu.addSeparator()
exit_act = QAction("Exit", self)
@@ -203,6 +203,13 @@ class AssignmentList(QMainWindow):
menu.exec_(QCursor.pos())
+ def preferences(self):
+ # TODO not sure if this is working exactly how I think it does, but it works
+ need_reload = PreferencesDialog()
+ print(need_reload)
+ if need_reload:
+ self.reload()
+
def cleanHidden(self):
"""
Permanently delete removed groups and entries from db
@@ -284,6 +291,11 @@ class AssignmentList(QMainWindow):
return entries_vbox
+ def reload(self):
+ Config()
+ self.setupDB()
+ self.drawGroups()
+
def aboutDialog(self):
QMessageBox.about(self, "About Assignment List",
"Created by Louie S. - 2023")
diff --git a/src/preferences_dialog.py b/src/preferences_dialog.py
index e8292d6..7f39fb7 100644
--- a/src/preferences_dialog.py
+++ b/src/preferences_dialog.py
@@ -41,6 +41,10 @@ class PreferencesDialog(QDialog):
apply_button = QPushButton("Apply", self)
apply_button.clicked.connect(self.apply)
buttons_hbox.addWidget(apply_button)
+
+ reload_button = QPushButton("Reload", self)
+ reload_button.clicked.connect(self.reload)
+ buttons_hbox.addWidget(reload_button)
main_layout.addLayout(buttons_hbox)
self.setLayout(main_layout)
@@ -86,6 +90,12 @@ class PreferencesDialog(QDialog):
self.config.updateConfig()
+ def reload(self):
+ """
+ Update, reload, and close the window
+ """
+ self.apply()
+ self.done(1)
if __name__ == "__main__":
app = QApplication(sys.argv)