diff --git a/src/QtLearning.py b/src/QtLearning.py index 9d44804..9a54f4c 100644 --- a/src/QtLearning.py +++ b/src/QtLearning.py @@ -3,12 +3,12 @@ import sys from pathlib import Path from PySide6.QtCore import QStandardPaths -from PySide6.QtGui import QStandardItemModel, QStandardItem -from PySide6.QtWidgets import QMainWindow, QApplication, QTreeView, QTextEdit, QSplitter, QSizePolicy +from PySide6.QtGui import QStandardItemModel, QStandardItem, QIcon +from PySide6.QtWidgets import QMainWindow, QApplication, QTreeView, QTextEdit, QSplitter, QSizePolicy, QMenuBar, QMenu # TODO: Split this out into its own module for handling the FS operations in an abstract manner. We need to relocate # all of this code up to the class. -NYTEWORKS_DIR = QStandardPaths.locate(QStandardPaths.AppDataLocation, "NyteWoks", QStandardPaths.LocateDirectory) +NYTEWORKS_DIR = QStandardPaths.locate(QStandardPaths.AppDataLocation, 'NyteWoks', QStandardPaths.LocateDirectory) if not NYTEWORKS_DIR: # We don't already have a directory in the roaming area NYTEWORKS_DIR = QStandardPaths.standardLocations(QStandardPaths.AppDataLocation) @@ -16,7 +16,7 @@ if not NYTEWORKS_DIR: # There are no suitable areas on the system to write our data to. Throw an error and let the user decide where # to store the data if possible. # TODO: Implement some sort of handling for this unfortunate situation... - print("Unable to find a suitable location for data on your system.", file=sys.stderr) + print('Unable to find a suitable location for data on your system.', file=sys.stderr) sys.exit(1) else: NYTEWORKS_DIR = Path(NYTEWORKS_DIR[0] + '/Nyteworks') @@ -39,10 +39,11 @@ Path(INBOX_DIR).mkdir(parents=True, exist_ok=True) class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) - self.setWindowTitle("LifeFlow - Notes for the Real World") + self.setWindowTitle('LifeFlow - Notes for the Real World') self._create_ui() def _create_ui(self): + self._setup_menu_bar() self._create_note_tree_view() self.text_area = QTextEdit() self.setCentralWidget(self.note_tree_view) @@ -61,6 +62,23 @@ class MainWindow(QMainWindow): self.setCentralWidget(self.splitter) + def _setup_menu_bar(self): + menuBar = self.menuBar() + + fileMenu = menuBar.addMenu('&File') + fileMenu.addAction('Open') + fileMenu.addAction('New') + fileMenu.addAction('Save') + fileMenu.addAction('Save As...') + + editMenu = menuBar.addMenu('&Edit') + editMenu.addAction('Undo') + editMenu.addAction('Redo') + editMenu.addSeparator() + editMenu.addAction('Cut') + editMenu.addAction('Copy') + editMenu.addAction('Paste') + def _create_note_tree_view(self): self.note_tree_view = QTreeView() self.note_tree_view.setHeaderHidden(True) @@ -101,9 +119,9 @@ class MainWindow(QMainWindow): notebook = item.parent().text() binder = item.parent().parent().text() note = BINDERS_DIR / binder / notebook / item.text() - print("I should get:", note) + print('I should get:', note) note_text = None - with open(note, "r") as note_file: + with open(note, 'r') as note_file: note_text = note_file.readlines() self.text_area.setText(''.join(note_text))