summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/add_entry_form.py61
-rw-r--r--src/add_entry_form.ui185
-rw-r--r--src/main.py51
3 files changed, 195 insertions, 102 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/main.py b/src/main.py
index 9e6f4c0..91ddeca 100644
--- a/src/main.py
+++ b/src/main.py
@@ -3,8 +3,8 @@ import os
import sys
import time
from PyQt5 import uic
-from PyQt5.QtWidgets import QAction, QApplication, QGridLayout, QHBoxLayout, QLabel, QMainWindow, QMenu, QMessageBox, QScrollArea, QVBoxLayout, QWidget
-from PyQt5.QtGui import QCursor, QFont
+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
@@ -24,8 +24,6 @@ class AssignmentList(QMainWindow):
self.initializeUI()
def initializeUI(self):
- #self.resize(640, 480)
- #self.setWindowTitle("Assignment List")
self.createMenu()
self.createToolbar()
Config()
@@ -34,36 +32,14 @@ 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.actionPreferences.triggered.connect(self.preferences)
- #file_menu.addAction(self.preferences_act)
- #self.reload_act = QAction("Reload", self)
- #self.reload_act.setShortcut("F5")
self.actionReload.triggered.connect(self.reload)
- #file_menu.addAction(self.reload_act)
- #file_menu.addSeparator()
- #exit_act = QAction("Exit", self)
- #exit_act.setShortcut("Ctrl+Q")
self.actionExit.triggered.connect(self.close)
- #file_menu.addAction(exit_act)
- #self.add_group_act = QAction("Add Group", self)
self.actionAdd_Group.triggered.connect(self.addGroup)
- #self.actionAdd_Group.addAction(self.add_group_act)
- #edit_menu.addSeparator()
- #self.clean_hidden_act = QAction("Permanently Delete Removed Groups and Entries", self)
self.actionClean_Hidden.triggered.connect(self.cleanHidden)
- #edit_menu.addAction(self.clean_hidden_act)
- #about_act = QAction("About", self)
self.actionAbout.triggered.connect(self.aboutDialog)
- #help_menu.addAction(about_act)
def createToolbar(self):
self.toolBar.addAction(self.actionAdd_Group)
@@ -72,32 +48,9 @@ class AssignmentList(QMainWindow):
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)
-
self.title.setText(time.strftime("%A, %b %d %Y"))
- #self.title.setFont(QFont("Arial", 17))
- #self.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.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