open files after the window has been opened
this way we can update the window title
This commit is contained in:
15
main.py
15
main.py
@@ -32,10 +32,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.setAcceptDrops(True)
|
self.setAcceptDrops(True)
|
||||||
|
|
||||||
self.tabs = Tabs(self.settings)
|
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)
|
self._menu_recent_files = QMenu(self.tr("Open &Recent"), self)
|
||||||
|
|
||||||
@@ -47,6 +43,7 @@ class MainWindow(QMainWindow):
|
|||||||
menu_bar = QMenuBar()
|
menu_bar = QMenuBar()
|
||||||
|
|
||||||
menu_bar.addMenu(self.file_menu())
|
menu_bar.addMenu(self.file_menu())
|
||||||
|
menu_bar.addMenu(self.highlight_menu())
|
||||||
menu_bar.addMenu(self.help_menu())
|
menu_bar.addMenu(self.help_menu())
|
||||||
|
|
||||||
return menu_bar
|
return menu_bar
|
||||||
@@ -81,7 +78,7 @@ class MainWindow(QMainWindow):
|
|||||||
files = self._get_recent_files()
|
files = self._get_recent_files()
|
||||||
for file in files:
|
for file in files:
|
||||||
action = QAction(os.path.basename(file), self)
|
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)
|
self._menu_recent_files.addAction(action)
|
||||||
|
|
||||||
def _open_file_dialog(self) -> None:
|
def _open_file_dialog(self) -> None:
|
||||||
@@ -97,7 +94,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.tabs.create_tab(selected_file)
|
self.tabs.create_tab(selected_file)
|
||||||
self._remember_recent_file(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.tabs.create_tab(file)
|
||||||
self._remember_recent_file(file)
|
self._remember_recent_file(file)
|
||||||
|
|
||||||
@@ -125,7 +122,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def dropEvent(self, e):
|
def dropEvent(self, e):
|
||||||
file = urlutils.url_to_path(e.mimeData().text())
|
file = urlutils.url_to_path(e.mimeData().text())
|
||||||
self._open_file(file)
|
self.open_file(file)
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
self.destruct()
|
self.destruct()
|
||||||
@@ -167,6 +164,10 @@ if __name__ == "__main__":
|
|||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
RavenUI.window = window
|
RavenUI.window = window
|
||||||
window.show()
|
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.SIGINT, stop_signal)
|
||||||
signal.signal(signal.SIGTERM, stop_signal)
|
signal.signal(signal.SIGTERM, stop_signal)
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ class RavenUI():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_window_title(title: str):
|
def update_window_title(title: str):
|
||||||
if RavenUI.window:
|
if not RavenUI.window:
|
||||||
|
return
|
||||||
|
if len(title) > 0:
|
||||||
RavenUI.window.setWindowTitle("%s - RavenLog" % title)
|
RavenUI.window.setWindowTitle("%s - RavenLog" % title)
|
||||||
|
else:
|
||||||
|
RavenUI.window.setWindowTitle("RavenLog")
|
||||||
|
|||||||
Reference in New Issue
Block a user