diff options
author | Louie S <louie@example.com> | 2023-09-16 09:36:14 -0400 |
---|---|---|
committer | Louie S <louie@example.com> | 2023-09-16 09:36:14 -0400 |
commit | 0ce1224da8c2007de9bdf7898341142897e0c64f (patch) | |
tree | d1e37b838b99c17892dbc90f71a273d1673a1708 /src | |
parent | 8650e59af3ecc0d77615f1f4fd2a8b78db6232d0 (diff) |
Implement reloading
Diffstat (limited to 'src')
-rw-r--r-- | src/db_sqlite.py | 2 | ||||
-rw-r--r-- | src/main.py | 18 | ||||
-rw-r--r-- | src/preferences_dialog.py | 10 |
3 files changed, 27 insertions, 3 deletions
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) |