diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/add_entry_form.py | 61 | ||||
-rw-r--r-- | src/add_entry_form.ui | 185 | ||||
-rw-r--r-- | src/add_group_form.py | 42 | ||||
-rw-r--r-- | src/add_group_form.ui | 131 | ||||
-rw-r--r-- | src/edit_entry_form.py | 88 | ||||
-rw-r--r-- | src/edit_group_form.py | 53 | ||||
-rw-r--r-- | src/main.py | 77 | ||||
-rw-r--r-- | src/main.ui | 207 | ||||
-rw-r--r-- | src/preferences_dialog.py | 51 | ||||
-rw-r--r-- | src/preferences_dialog.ui | 128 |
10 files changed, 727 insertions, 296 deletions
diff --git a/src/add_entry_form.py b/src/add_entry_form.py index 9550108..ff66a19 100644 --- a/src/add_entry_form.py +++ b/src/add_entry_form.py @@ -1,7 +1,8 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QCheckBox, QDateTimeEdit, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import QDate, Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox +from PyQt5.QtCore import QDate from src.entry import Entry import src.globals as Globals import src.db_sqlite as DB @@ -9,63 +10,17 @@ import src.db_sqlite as DB class addEntryForm(QDialog): def __init__(self, parent): super().__init__() + uic.loadUi(os.path.join("src", "add_entry_form.ui"), self) self.initializeUI(parent) def initializeUI(self, parent): - self.resize(400, 1) - self.setWindowTitle("Add Entry") self.displayWidgets(parent) self.exec() def displayWidgets(self, parent): - entry_form_layout = QFormLayout() - - title = QLabel("Add Entry") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - entry_form_layout.addRow(title) - - self.new_entry_desc = QLineEdit() - entry_form_layout.addRow("Description:", self.new_entry_desc) - - self.due_hbox = QHBoxLayout() - self.new_entry_due = QDateTimeEdit(QDate.currentDate()) - self.new_entry_due.setDisplayFormat("MM/dd/yyyy") - self.due_hbox.addWidget(self.new_entry_due) - self.new_entry_due_checkbox = QCheckBox() - self.new_entry_due_checkbox.setChecked(True) - self.due_hbox.addWidget(self.new_entry_due_checkbox) - entry_form_layout.addRow("Due Date:", self.due_hbox) - - self.new_entry_due_alt = QLineEdit() - entry_form_layout.addRow("Due Date (Alt):", self.new_entry_due_alt) - - self.new_entry_link = QLineEdit() # TODO see if there is a widget specifically for URLs - entry_form_layout.addRow("Link:", self.new_entry_link) - - # TODO: - # depends - - self.new_entry_color = QLineEdit() - entry_form_layout.addRow("Color:", self.new_entry_color) - - self.new_entry_highlight = QLineEdit() - entry_form_layout.addRow("Highlight:", self.new_entry_highlight) - - # Submit and cancel buttons - buttons_h_box = QHBoxLayout() - buttons_h_box.addStretch() - close_button = QPushButton("Cancel") - close_button.clicked.connect(self.close) - buttons_h_box.addWidget(close_button) - submit_button = QPushButton("Submit") - submit_button.clicked.connect(lambda: self.handleSubmit(parent)) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - entry_form_layout.addRow(buttons_h_box) - - self.setLayout(entry_form_layout) + self.new_entry_due.setDate(QDate.currentDate()) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(lambda: self.handleSubmit(parent)) def handleSubmit(self, parent): # Check that the new entry is not blank diff --git a/src/add_entry_form.ui b/src/add_entry_form.ui new file mode 100644 index 0000000..3f8f9e7 --- /dev/null +++ b/src/add_entry_form.ui @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Dialog</class> + <widget class="QDialog" name="Dialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>266</height> + </rect> + </property> + <property name="windowTitle"> + <string>Add Entry</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="1" column="0"> + <widget class="QLabel" name="descriptionLabel"> + <property name="text"> + <string>Description: </string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="new_entry_desc"/> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="title"> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>18</pointsize> + </font> + </property> + <property name="text"> + <string>Add Entry</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="dueDateLabel"> + <property name="text"> + <string>Due Date: </string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QWidget" name="due_hbox" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QDateTimeEdit" name="new_entry_due"> + <property name="displayFormat"> + <string>MM/dd/yyyy</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="new_entry_due_checkbox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="dueDateAltLabel"> + <property name="text"> + <string>Due Date (Alt):</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="new_entry_due_alt"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="linkLabel"> + <property name="text"> + <string>Link:</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="new_entry_link"/> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="colorLabel"> + <property name="text"> + <string>Color:</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="new_entry_color"/> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="highlightLabel"> + <property name="text"> + <string>Highlight:</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLineEdit" name="new_entry_highlight"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>Dialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>Dialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/add_group_form.py b/src/add_group_form.py index b7144d0..0d35777 100644 --- a/src/add_group_form.py +++ b/src/add_group_form.py @@ -1,7 +1,7 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QComboBox, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox import src.globals as Globals from src.group import Group @@ -13,46 +13,16 @@ class addGroupForm(QDialog): """ def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "add_group_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) - self.setWindowTitle("Add Group") self.displayWidgets() self.exec() def displayWidgets(self): - group_form_layout = QFormLayout() - - title = QLabel("Add Group") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - group_form_layout.addRow(title) - - self.new_group_name = QLineEdit() - group_form_layout.addRow("Name:", self.new_group_name) - - self.new_group_column = QComboBox() - self.new_group_column.addItems(["Left", "Right"]) - group_form_layout.addRow("Column:", self.new_group_column) - - self.new_group_link = QLineEdit() # TODO see if there is a widget specifically for URLs - group_form_layout.addRow("Link:", self.new_group_link) - - # Submit and cancel buttons - buttons_h_box = QHBoxLayout() - buttons_h_box.addStretch() - close_button = QPushButton("Cancel") - close_button.clicked.connect(self.close) - buttons_h_box.addWidget(close_button) - submit_button = QPushButton("Submit") - submit_button.clicked.connect(self.handleSubmit) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - group_form_layout.addRow(buttons_h_box) - - self.setLayout(group_form_layout) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): name_text = self.new_group_name.text() diff --git a/src/add_group_form.ui b/src/add_group_form.ui new file mode 100644 index 0000000..c3c5c80 --- /dev/null +++ b/src/add_group_form.ui @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Dialog</class> + <widget class="QDialog" name="Dialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>172</height> + </rect> + </property> + <property name="windowTitle"> + <string>Add Entry</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="title"> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>18</pointsize> + </font> + </property> + <property name="text"> + <string>Add Group</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="descriptionLabel"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="new_group_name"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="dueDateLabel"> + <property name="text"> + <string>Column:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="new_group_column"> + <item> + <property name="text"> + <string>Left</string> + </property> + </item> + <item> + <property name="text"> + <string>Right</string> + </property> + </item> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="linkLabel"> + <property name="text"> + <string>Link:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="new_group_link"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + <property name="centerButtons"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>Dialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>Dialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/edit_entry_form.py b/src/edit_entry_form.py index 55c388c..c1d3664 100644 --- a/src/edit_entry_form.py +++ b/src/edit_entry_form.py @@ -1,12 +1,14 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QCheckBox, QDateTimeEdit, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import QDate, Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox +from PyQt5.QtCore import QDate import src.globals as Globals from src.entry import Entry import src.db_sqlite as DB +# Reuses the add_entry_form UI file class editEntryForm(QDialog): """ Form to edit/update an entry @@ -14,82 +16,42 @@ class editEntryForm(QDialog): def __init__(self, id): self.id = id super().__init__() + uic.loadUi(os.path.join("src", "add_entry_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) self.setWindowTitle("Edit Entry") self.displayWidgets() self.exec() def displayWidgets(self): - entry_form_layout = QFormLayout() entry = list(filter(lambda e: e.id == self.id, Globals.entries))[0] - title = QLabel("Edit Entry") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - entry_form_layout.addRow(title) - - self.entry_desc = QLineEdit() - self.entry_desc.setText(entry.desc) - entry_form_layout.addRow("Description:", self.entry_desc) - - self.due_hbox = QHBoxLayout() - self.entry_due = QDateTimeEdit(QDate.currentDate()) - self.entry_due.setDisplayFormat("MM/dd/yyyy") - if entry.due: - self.entry_due.setDate(entry.due) - self.due_hbox.addWidget(self.entry_due) - self.entry_due_checkbox = QCheckBox() + self.title.setText("Edit Entry") + self.new_entry_desc.setText(entry.desc) + self.new_entry_due.setDate(QDate.currentDate()) if entry.due: - self.entry_due_checkbox.setChecked(True) + self.new_entry_due.setDate(entry.due) + self.new_entry_due_checkbox.setChecked(True) else: - self.entry_due_checkbox.setChecked(False) - self.due_hbox.addWidget(self.entry_due_checkbox) - entry_form_layout.addRow("Due Date:", self.due_hbox) - - self.entry_due_alt = QLineEdit() - self.entry_due_alt.setText(entry.due_alt) - entry_form_layout.addRow("Due Date (Alt):", self.entry_due_alt) - - self.entry_link = QLineEdit() # TODO see if there is a widget specifically for URLs - self.entry_link.setText(entry.link) - entry_form_layout.addRow("Link:", self.entry_link) - - self.entry_color = QLineEdit() - self.entry_color.setText(entry.color) - entry_form_layout.addRow("Color:", self.entry_color) - - self.entry_highlight = QLineEdit() - self.entry_highlight.setText(entry.highlight) - entry_form_layout.addRow("Highlight:", self.entry_highlight) - - # Submit and cancel buttons - buttons_h_box = QHBoxLayout() - buttons_h_box.addStretch() - close_button = QPushButton("Cancel") - close_button.clicked.connect(self.close) - buttons_h_box.addWidget(close_button) - submit_button = QPushButton("Submit") - submit_button.clicked.connect(self.handleSubmit) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - entry_form_layout.addRow(buttons_h_box) - - self.setLayout(entry_form_layout) + self.new_entry_due_checkbox.setChecked(False) + self.new_entry_due_alt.setText(entry.due_alt) + self.new_entry_link.setText(entry.link) + self.new_entry_color.setText(entry.color) + self.new_entry_highlight.setText(entry.highlight) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): - desc_text = self.entry_desc.text() - if self.entry_due_checkbox.isChecked(): - due_text = self.entry_due.date() # due_text is a QDate + desc_text = self.new_entry_desc.text() + if self.new_entry_due_checkbox.isChecked(): + due_text = self.new_entry_due.date() # due_text is a QDate else: due_text = "" # due is unchecked - due_alt_text = self.entry_due_alt.text() - link_text = self.entry_link.text() - color_text = self.entry_color.text() - highlight_text = self.entry_highlight.text() + due_alt_text = self.new_entry_due_alt.text() + link_text = self.new_entry_link.text() + color_text = self.new_entry_color.text() + highlight_text = self.new_entry_highlight.text() if not desc_text: QMessageBox.warning(self, "Error Message", diff --git a/src/edit_group_form.py b/src/edit_group_form.py index c4a8622..e29a0fb 100644 --- a/src/edit_group_form.py +++ b/src/edit_group_form.py @@ -1,7 +1,7 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QComboBox, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox import src.globals as Globals from src.group import Group @@ -14,55 +14,28 @@ class editGroupForm(QDialog): def __init__(self, id): self.id = id super().__init__() + uic.loadUi(os.path.join("src", "add_group_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) self.setWindowTitle("Edit Group") self.displayWidgets() self.exec() def displayWidgets(self): - group_form_layout = QFormLayout() group = list(filter(lambda g: g.id == self.id, Globals.groups))[0] - title = QLabel("Edit Group") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - group_form_layout.addRow(title) - - self.group_name = QLineEdit() - self.group_name.setText(group.name) - group_form_layout.addRow("Name:", self.group_name) - - self.group_column = QComboBox() - self.group_column.addItems(["Left", "Right"]) - self.group_column.setCurrentIndex(0 if group.column.lower() == "left" else 1) - group_form_layout.addRow("Column:", self.group_column) - - self.group_link = QLineEdit() # TODO see if there is a widget specifically for URLs - self.group_link.setText(group.link) - group_form_layout.addRow("Link:", self.group_link) - - # Submit and cancel buttons - buttons_h_box = QHBoxLayout() - buttons_h_box.addStretch() - close_button = QPushButton("Cancel") - close_button.clicked.connect(self.close) - buttons_h_box.addWidget(close_button) - submit_button = QPushButton("Submit") - submit_button.clicked.connect(self.handleSubmit) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - group_form_layout.addRow(buttons_h_box) - - self.setLayout(group_form_layout) + self.title.setText("Edit Group") + self.new_group_name.setText(group.name) + self.new_group_column.setCurrentIndex(0 if group.column.lower() == "left" else 1) + self.new_group_link.setText(group.link) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): - name_text = self.group_name.text() - column_text = self.group_column.currentText() - link_text = self.group_link.text() + name_text = self.new_group_name.text() + column_text = self.new_group_column.currentText() + link_text = self.new_group_link.text() if not name_text: QMessageBox.warning(self, "Error Message", diff --git a/src/main.py b/src/main.py index fed6830..91ddeca 100644 --- a/src/main.py +++ b/src/main.py @@ -1,8 +1,10 @@ #!/usr/bin/python3 +import os import sys import time -from PyQt5.QtWidgets import QAction, QApplication, QGridLayout, QHBoxLayout, QLabel, QMainWindow, QMenu, QMessageBox, QScrollArea, QToolBar, QVBoxLayout, QWidget -from PyQt5.QtGui import QCursor, QFont +from PyQt5 import uic +from PyQt5.QtWidgets import QAction, QApplication, QMainWindow, QMenu, QMessageBox, QVBoxLayout +from PyQt5.QtGui import QCursor from PyQt5.QtCore import QDate, Qt from src.config import Config from src.preferences_dialog import PreferencesDialog @@ -17,12 +19,11 @@ from src.rules_dialog import RulesDialog class AssignmentList(QMainWindow): def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "main.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(640, 480) - self.setWindowTitle("Assignment List") self.createMenu() self.createToolbar() Config() @@ -31,73 +32,25 @@ class AssignmentList(QMainWindow): self.show() def createMenu(self): - menu_bar = self.menuBar() - file_menu = menu_bar.addMenu("File") - edit_menu = menu_bar.addMenu("Edit") - help_menu = menu_bar.addMenu("Help") - - self.preferences_act = QAction("Preferences", self) - self.preferences_act.setShortcut("Alt+Return") - self.preferences_act.triggered.connect(self.preferences) - file_menu.addAction(self.preferences_act) - self.reload_act = QAction("Reload", self) - self.reload_act.setShortcut("F5") - self.reload_act.triggered.connect(self.reload) - file_menu.addAction(self.reload_act) - file_menu.addSeparator() - exit_act = QAction("Exit", self) - exit_act.setShortcut("Ctrl+Q") - exit_act.triggered.connect(self.close) - file_menu.addAction(exit_act) - - self.add_group_act = QAction("Add Group", self) - self.add_group_act.triggered.connect(self.addGroup) - edit_menu.addAction(self.add_group_act) - edit_menu.addSeparator() - self.clean_hidden_act = QAction("Permanently Delete Removed Groups and Entries", self) - self.clean_hidden_act.triggered.connect(self.cleanHidden) - edit_menu.addAction(self.clean_hidden_act) - - about_act = QAction("About", self) - about_act.triggered.connect(self.aboutDialog) - help_menu.addAction(about_act) + self.actionPreferences.triggered.connect(self.preferences) + self.actionReload.triggered.connect(self.reload) + self.actionExit.triggered.connect(self.close) - def createToolbar(self): - tool_bar = QToolBar("Toolbar") - self.addToolBar(tool_bar) + self.actionAdd_Group.triggered.connect(self.addGroup) + self.actionClean_Hidden.triggered.connect(self.cleanHidden) + + self.actionAbout.triggered.connect(self.aboutDialog) - tool_bar.addAction(self.add_group_act) + def createToolbar(self): + self.toolBar.addAction(self.actionAdd_Group) def setupDB(self): DB.initDB() def displayWidgets(self): - main_widget_scroll_area = QScrollArea(self) - main_widget_scroll_area.setWidgetResizable(True) - main_widget = QWidget() - self.setCentralWidget(main_widget_scroll_area) - - title = QLabel(time.strftime("%A, %b %d %Y")) - title.setFont(QFont("Arial", 17)) - title.setTextInteractionFlags(Qt.TextSelectableByMouse) - - title_h_box = QHBoxLayout() - title_h_box.addStretch() - title_h_box.addWidget(title) - title_h_box.addStretch() - - self.groups_layout = QGridLayout() - self.groups_layout.setContentsMargins(20, 5, 20, 5) + self.title.setText(time.strftime("%A, %b %d %Y")) self.drawGroups() - v_box = QVBoxLayout() - v_box.addLayout(title_h_box) - v_box.addLayout(self.groups_layout) - v_box.addStretch() - - main_widget.setLayout(v_box) - main_widget_scroll_area.setWidget(main_widget) - def addGroup(self): """ Open the 'addGroup' form diff --git a/src/main.ui b/src/main.ui new file mode 100644 index 0000000..bc3c0fb --- /dev/null +++ b/src/main.ui @@ -0,0 +1,207 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Assignment List</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents_3"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>620</width> + <height>421</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QVBoxLayout" name="v_box"> + <item> + <layout class="QHBoxLayout" name="title_h_box"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="title"> + <property name="font"> + <font> + <family>Arial</family> + <pointsize>17</pointsize> + </font> + </property> + <property name="text"> + <string>[DATE]</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QGridLayout" name="groups_layout"> + <property name="leftMargin"> + <number>20</number> + </property> + <property name="topMargin"> + <number>5</number> + </property> + <property name="rightMargin"> + <number>20</number> + </property> + <property name="bottomMargin"> + <number>5</number> + </property> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionPreferences"/> + <addaction name="actionReload"/> + <addaction name="separator"/> + <addaction name="actionExit"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + <addaction name="actionAdd_Group"/> + <addaction name="separator"/> + <addaction name="actionClean_Hidden"/> + </widget> + <widget class="QMenu" name="menuHelp"> + <property name="title"> + <string>Help</string> + </property> + <addaction name="actionAbout"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuEdit"/> + <addaction name="menuHelp"/> + </widget> + <widget class="QToolBar" name="toolBar"> + <property name="windowTitle"> + <string>toolBar</string> + </property> + <attribute name="toolBarArea"> + <enum>TopToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + </widget> + <action name="actionPreferences"> + <property name="text"> + <string>Preferences</string> + </property> + <property name="shortcut"> + <string>Alt+Return</string> + </property> + </action> + <action name="actionReload"> + <property name="text"> + <string>Reload</string> + </property> + <property name="shortcut"> + <string>F5</string> + </property> + </action> + <action name="actionExit"> + <property name="text"> + <string>Exit</string> + </property> + <property name="shortcut"> + <string>Ctrl+Q</string> + </property> + </action> + <action name="actionAdd_Group"> + <property name="text"> + <string>Add Group</string> + </property> + </action> + <action name="actionClean_Hidden"> + <property name="text"> + <string>Permanently Delete Removed Groups and Entries</string> + </property> + </action> + <action name="actionAbout"> + <property name="text"> + <string>About</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/preferences_dialog.py b/src/preferences_dialog.py index 7f39fb7..e6d4187 100644 --- a/src/preferences_dialog.py +++ b/src/preferences_dialog.py @@ -1,5 +1,7 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout, QLineEdit, QPushButton, QTabWidget, QVBoxLayout, QWidget +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog from src.config import Config class PreferencesDialog(QDialog): @@ -8,6 +10,7 @@ class PreferencesDialog(QDialog): """ def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "preferences_dialog.ui"), self) # class globals self.config = Config() @@ -15,58 +18,22 @@ class PreferencesDialog(QDialog): 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() + 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) - - 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) + self.close_button.clicked.connect(self.close) + self.apply_button.clicked.connect(self.apply) + self.reload_button.clicked.connect(self.reload) 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 + self.db_path_button.clicked.connect(self.dbPathDialog) def dbPathDialog(self): file_dialog = QFileDialog(self) diff --git a/src/preferences_dialog.ui b/src/preferences_dialog.ui new file mode 100644 index 0000000..244eb26 --- /dev/null +++ b/src/preferences_dialog.ui @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Dialog</class> + <widget class="QDialog" name="Dialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>500</width> + <height>320</height> + </rect> + </property> + <property name="windowTitle"> + <string>Preferences</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="main_layout"> + <item> + <widget class="QTabWidget" name="tab_bar"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Paths</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QWidget" name="widget" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QFormLayout" name="paths_tab_layout"> + <item row="0" column="0"> + <widget class="QLabel" name="databaseFileLabel"> + <property name="text"> + <string>Database File:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QWidget" name="db_path_hbox" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLineEdit" name="db_path_edit"/> + </item> + <item> + <widget class="QPushButton" name="db_path_button"> + <property name="maximumSize"> + <size> + <width>25</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="buttons_hbox"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="close_button"> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="apply_button"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="reload_button"> + <property name="text"> + <string>Reload</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |