From 5b95c328d511f01a39cebb33d03d0a6927019727 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Sat, 30 Oct 2021 09:55:57 +0200 Subject: [PATCH] open files after the window has been opened this way we can update the window title --- main.py | 15 ++++++++------- ravenui.py | 6 +++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 167efa5..691d397 100644 --- a/main.py +++ b/main.py @@ -32,10 +32,6 @@ class MainWindow(QMainWindow): self.setAcceptDrops(True) self.tabs = Tabs(self.settings) - self.tabs.create_tab("/home/andi/ws/performanceDb/data/production/logs_2018-09-06_2018-09-06.csv") - self.tabs.create_tab("/home/andi/ws/performanceDb/data/production/vapbdcom.csv") - self.tabs.create_tab("/home/andi/ws/ravenlog/example.log") - self.tabs.create_tab("/var/log/syslog") self._menu_recent_files = QMenu(self.tr("Open &Recent"), self) @@ -47,6 +43,7 @@ class MainWindow(QMainWindow): menu_bar = QMenuBar() menu_bar.addMenu(self.file_menu()) + menu_bar.addMenu(self.highlight_menu()) menu_bar.addMenu(self.help_menu()) return menu_bar @@ -81,7 +78,7 @@ class MainWindow(QMainWindow): files = self._get_recent_files() for file in files: action = QAction(os.path.basename(file), self) - action.triggered.connect(lambda x, f=file: self._open_file(f)) + action.triggered.connect(lambda x, f=file: self.open_file(f)) self._menu_recent_files.addAction(action) def _open_file_dialog(self) -> None: @@ -97,7 +94,7 @@ class MainWindow(QMainWindow): self.tabs.create_tab(selected_file) self._remember_recent_file(selected_file) - def _open_file(self, file: str) -> None: + def open_file(self, file: str) -> None: self.tabs.create_tab(file) self._remember_recent_file(file) @@ -125,7 +122,7 @@ class MainWindow(QMainWindow): def dropEvent(self, e): file = urlutils.url_to_path(e.mimeData().text()) - self._open_file(file) + self.open_file(file) def closeEvent(self, event): self.destruct() @@ -167,6 +164,10 @@ if __name__ == "__main__": window = MainWindow() RavenUI.window = window window.show() + window.open_file("/home/andi/ws/performanceDb/data/production/logs_2018-09-06_2018-09-06.csv") + window.open_file("/home/andi/ws/performanceDb/data/production/vapbdcom.csv") + window.open_file("/var/log/syslog") + window.open_file("/home/andi/ws/ravenlog/example.log") signal.signal(signal.SIGINT, stop_signal) signal.signal(signal.SIGTERM, stop_signal) diff --git a/ravenui.py b/ravenui.py index 4e48cb7..b32a979 100644 --- a/ravenui.py +++ b/ravenui.py @@ -8,5 +8,9 @@ class RavenUI(): @staticmethod def update_window_title(title: str): - if RavenUI.window: + if not RavenUI.window: + return + if len(title) > 0: RavenUI.window.setWindowTitle("%s - RavenLog" % title) + else: + RavenUI.window.setWindowTitle("RavenLog")