Feat: Add 'Close File' option to menu to unload current file
This commit is contained in:
@@ -111,6 +111,12 @@ class MainWindow(QMainWindow):
|
||||
save_action.triggered.connect(self.save_file)
|
||||
file_menu.addAction(save_action)
|
||||
|
||||
close_action = QAction("Close File", self)
|
||||
close_action.triggered.connect(self.close_file)
|
||||
file_menu.addAction(close_action)
|
||||
|
||||
file_menu.addSeparator()
|
||||
|
||||
exit_action = QAction("Exit", self)
|
||||
exit_action.triggered.connect(self.close)
|
||||
file_menu.addAction(exit_action)
|
||||
@@ -133,6 +139,19 @@ class MainWindow(QMainWindow):
|
||||
self.canvas.redraw()
|
||||
self.canvas.update()
|
||||
|
||||
def close_file(self):
|
||||
# Reset everything
|
||||
self.service = TeletextService()
|
||||
self.current_page = None
|
||||
self.populate_list()
|
||||
self.subpage_combo.clear()
|
||||
self.page_groups = {}
|
||||
# Clear canvas
|
||||
self.canvas.set_page(None)
|
||||
# Maybe reset text of hex input
|
||||
self.hex_input.clear()
|
||||
QMessageBox.information(self, "Closed", "File closed.")
|
||||
|
||||
def open_file(self):
|
||||
fname, _ = QFileDialog.getOpenFileName(self, "Open T42", "", "Teletext Files (*.t42);;All Files (*)")
|
||||
if fname:
|
||||
@@ -248,8 +267,8 @@ class MainWindow(QMainWindow):
|
||||
self.canvas.move_cursor(0, 1)
|
||||
else:
|
||||
# Typing
|
||||
# Filter non-printable
|
||||
if text and len(text) == 1 and 32 <= ord(text) <= 126:
|
||||
# Allow wider range of chars for national support
|
||||
if text and len(text) == 1 and ord(text) >= 32:
|
||||
self.canvas.handle_input(text)
|
||||
elif key == Qt.Key.Key_Backspace:
|
||||
# Move back and delete
|
||||
|
||||
Reference in New Issue
Block a user