diff --git a/bigtext.py b/bigtext.py index 4081fa5..da477bf 100644 --- a/bigtext.py +++ b/bigtext.py @@ -21,7 +21,6 @@ from line import Line from logFileModel import LogFileModel from raven.pluginregistry import PluginRegistry -from ravenui import RavenUI from settings import Settings from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler @@ -159,7 +158,7 @@ class InnerBigText(QWidget): old_font_size = self.model.settings.getint_session('general', 'font_size') new_font_size = max(4, min(50, old_font_size - direction)) self.model.settings.set_session('general', 'font_size', str(new_font_size)) - RavenUI.update_ui() + PluginRegistry.execute("update_ui") self.update() else: # print("wheel event fired :) %s" % (direction)) diff --git a/filterwidget.py b/filterwidget.py index 6a496c2..a487998 100644 --- a/filterwidget.py +++ b/filterwidget.py @@ -9,9 +9,10 @@ from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QChe from bigtext import BigText from logFileModel import LogFileModel -from ravenui import RavenUI from raven.i18n import _ +from raven.pluginregistry import PluginRegistry + class FilterTask(QRunnable): aborted = False @@ -149,7 +150,7 @@ class FilterWidget(QWidget): self.filter_model.truncate() self.source_model.clear_query_highlight() self.filter_model.clear_query_highlight() - RavenUI.update_ui() + PluginRegistry.execute("update_ui") def filter_changed(self): query = self.query_field.text() diff --git a/main.py b/main.py index daca9b8..2c7b4e4 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,6 @@ import sys import constants from raven.pluginregistry import PluginRegistry -from ravenui import RavenUI import gettext gettext.install('ravenlog', 'locale') @@ -56,8 +55,8 @@ if __name__ == "__main__": PluginRegistry.load_plugin("NotesPlugin") window = PluginRegistry.execute_single("create_main_window") - 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") diff --git a/raven/plugins/ravenlogplugin.py b/raven/plugins/ravenlogplugin.py index caaf285..270d218 100644 --- a/raven/plugins/ravenlogplugin.py +++ b/raven/plugins/ravenlogplugin.py @@ -75,6 +75,20 @@ class RavenLogPlugin(PluginBase): def current_file(self) -> Optional[str]: return self.main_window.tabs.current_file() + def update_window_title(self, title: str): + if len(title) > 0: + self.main_window.setWindowTitle(_("{0} - RavenLog").format(title)) + else: + self.main_window.setWindowTitle(_("RavenLog")) + + def update_status_bar(self, text: str): + if not self.main_window: + return + self.main_window.status_bar.showMessage(text) + + def update_ui(self): + self.main_window.update() + def add_tab(self, tab: Tab): self.main_window.tabs.add_tab(tab) diff --git a/ravenui.py b/ravenui.py deleted file mode 100644 index 92f5e41..0000000 --- a/ravenui.py +++ /dev/null @@ -1,25 +0,0 @@ -from raven.i18n import _ - - -class RavenUI(): - # no type hint because of circular dependencies - window = None - - @staticmethod - def update_ui(): - RavenUI.window.update() - - @staticmethod - def update_window_title(title: str): - if not RavenUI.window: - return - if len(title) > 0: - RavenUI.window.setWindowTitle(_("{0} - RavenLog").format(title)) - else: - RavenUI.window.setWindowTitle(_("RavenLog")) - - @staticmethod - def update_status_bar(text: str): - if not RavenUI.window: - return - RavenUI.window.status_bar.showMessage(text) diff --git a/tabs.py b/tabs.py index 18beeea..e2bb6f7 100644 --- a/tabs.py +++ b/tabs.py @@ -2,11 +2,8 @@ from typing import Optional from PySide6.QtWidgets import QWidget, QTabWidget, QVBoxLayout -from bigtext import BigText -from fulltabwidget import FullTabWidget -from logFileModel import LogFileModel +from raven.pluginregistry import PluginRegistry from raven.plugins.ravenlog.Tab import Tab -from ravenui import RavenUI from settings import Settings @@ -41,11 +38,11 @@ class Tabs(QWidget): def _current_tab_changed(self, tab_index: int): tab: Tab = self.tabs.widget(tab_index) if tab: - RavenUI.update_window_title(tab.title) - RavenUI.update_status_bar(tab.get_status_text()) + PluginRegistry.execute("update_window_title", tab.title) + PluginRegistry.execute("update_status_bar", tab.get_status_text()) else: - RavenUI.update_window_title("") - RavenUI.update_status_bar("") + PluginRegistry.execute("update_window_title", "") + PluginRegistry.execute("update_status_bar", "") def _close_tab(self, tab_index: int): full_tab: Tab = self.tabs.widget(tab_index)