summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2023-09-16 09:36:14 -0400
committerLouie S <louie@example.com>2023-09-16 09:36:14 -0400
commitfe34cdaa6bd0efdc605ae89c96d7075645eaa5fd (patch)
tree9650abd173a803d32f9305812925f8dfa01b8043
parent6e52afa26d8c50d07988376e43a641c70370b9c5 (diff)
Add bolding to entries that are due today or earlier
-rwxr-xr-xassignment-list.py2
-rw-r--r--entry.py16
-rw-r--r--preferences_dialog.py93
3 files changed, 107 insertions, 4 deletions
diff --git a/assignment-list.py b/assignment-list.py
index 71e0ae7..1219661 100755
--- a/assignment-list.py
+++ b/assignment-list.py
@@ -40,7 +40,7 @@ class AssignmentList(QMainWindow):
self.preferences_act.triggered.connect(PreferencesDialog)
file_menu.addAction(self.preferences_act)
# TODO implement reload of DB that works
- self.reload_act = QAction("Reload", self)
+ self.reload_act = QAction("Reload [WIP]", self)
self.reload_act.setShortcut("F5")
#self.reload_act.triggered.connect(self.reload)
file_menu.addAction(self.reload_act)
diff --git a/entry.py b/entry.py
index 0a0b3b1..addc96a 100644
--- a/entry.py
+++ b/entry.py
@@ -1,3 +1,4 @@
+from datetime import date, datetime
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QHBoxLayout, QLabel
@@ -39,10 +40,17 @@ class Entry:
output.addWidget(bullet)
if self.due:
- body.setText("{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year()))
+ body.setText("{0}/{1}/{2}: ".format(
+ self.due.month(),
+ self.due.day(),
+ self.due.year()
+ ))
if self.link:
body.setOpenExternalLinks(True)
- body.setText(body.text() + "<a href=\"{0}\" style=\"color: {1}; text-decoration: none;\">".format(self.link, self.color if self.color else "default"))
+ body.setText(body.text() + "<a href=\"{0}\" style=\"color: {1};\">".format(
+ self.link,
+ self.color if self.color else "default"
+ ))
body.setText(body.text() + self.desc)
if self.link:
body.setText(body.text() + "</a>")
@@ -66,9 +74,11 @@ class Entry:
QLabel{{
color: {0};
background-color: {1};
+ font-weight: {2};
}}""".format(
self.color if self.color else "default",
- self.highlight if self.highlight else "none"
+ self.highlight if self.highlight else "none",
+ "bold" if self.due and self.due <= date.today() else "normal"
))
return output
diff --git a/preferences_dialog.py b/preferences_dialog.py
new file mode 100644
index 0000000..df192ba
--- /dev/null
+++ b/preferences_dialog.py
@@ -0,0 +1,93 @@
+import sys
+from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout, QLineEdit, QPushButton, QTabWidget, QVBoxLayout, QWidget
+from config import Config
+
+class PreferencesDialog(QDialog):
+ """
+ Implemented to set configuration options in the program
+ """
+ def __init__(self):
+ super().__init__()
+
+ # class globals
+ self.config = Config()
+
+ self.initializeUI()
+
+ def initializeUI(self):
+ self.resize(500, 320)
+ self.setWindowTitle("Preferences")
+ self.displayWidgets()
+ self.exec()
+
+ def displayWidgets(self):
+ # TODO make this a scrollable window
+ # FIXME could use some work on sizing
+ main_layout = QVBoxLayout()
+ tab_bar = QTabWidget(self)
+ paths_tab = self.pathsTabLayout()
+
+ tab_bar.addTab(paths_tab, "Paths")
+ main_layout.addWidget(tab_bar)
+ main_layout.addStretch()
+
+ buttons_hbox = QHBoxLayout()
+ buttons_hbox.addStretch()
+
+ close_button = QPushButton("Close", self)
+ close_button.clicked.connect(self.close)
+ buttons_hbox.addWidget(close_button)
+
+ apply_button = QPushButton("Apply", self)
+ apply_button.clicked.connect(self.apply)
+ buttons_hbox.addWidget(apply_button)
+
+ main_layout.addLayout(buttons_hbox)
+ self.setLayout(main_layout)
+
+ def pathsTabLayout(self):
+ output = QWidget()
+ output_layout = QFormLayout()
+
+ # Dialog for setting the database file path
+ db_path_hbox = QHBoxLayout()
+ self.db_path_edit = QLineEdit()
+ if "paths" in self.config.config:
+ self.db_path_edit.setText(self.config.config["paths"]["db_path"])
+ db_path_hbox.addWidget(self.db_path_edit)
+ db_path_button = QPushButton("...")
+ db_path_button.setMaximumWidth(25)
+ db_path_button.clicked.connect(self.dbPathDialog)
+ db_path_hbox.addWidget(db_path_button)
+ output_layout.addRow("Database File:", db_path_hbox)
+
+ output.setLayout(output_layout)
+ return output
+
+ def dbPathDialog(self):
+ file_dialog = QFileDialog(self)
+ # TODO create filter to only allow selecting .db files
+ new_path = file_dialog.getOpenFileName(self, "Open File")
+
+ if new_path[0]:
+ self.db_path_edit.setText(new_path[0])
+
+ def apply(self):
+ """
+ Update the configuration in the config file
+ """
+ # Save paths
+ if "paths" in self.config.config:
+ try:
+ with open(self.db_path_edit.text(), 'a'):
+ self.config.config["paths"]["db_path"] = self.db_path_edit.text()
+ except:
+ print("Warning: db_path '{}' does not exist; skipping".format(self.db_path_edit.text()))
+
+ self.config.updateConfig()
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ window = PreferencesDialog()
+ sys.exit(app.exec_())