remove ravenui.py by using plugin registry instead

This commit is contained in:
2022-02-06 15:49:12 +01:00
parent 6573580f3c
commit 111c11d5d4
6 changed files with 24 additions and 39 deletions

View File

@@ -21,7 +21,6 @@ from line import Line
from logFileModel import LogFileModel from logFileModel import LogFileModel
from raven.pluginregistry import PluginRegistry from raven.pluginregistry import PluginRegistry
from ravenui import RavenUI
from settings import Settings from settings import Settings
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
@@ -159,7 +158,7 @@ class InnerBigText(QWidget):
old_font_size = self.model.settings.getint_session('general', 'font_size') old_font_size = self.model.settings.getint_session('general', 'font_size')
new_font_size = max(4, min(50, old_font_size - direction)) new_font_size = max(4, min(50, old_font_size - direction))
self.model.settings.set_session('general', 'font_size', str(new_font_size)) self.model.settings.set_session('general', 'font_size', str(new_font_size))
RavenUI.update_ui() PluginRegistry.execute("update_ui")
self.update() self.update()
else: else:
# print("wheel event fired :) %s" % (direction)) # print("wheel event fired :) %s" % (direction))

View File

@@ -9,9 +9,10 @@ from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QChe
from bigtext import BigText from bigtext import BigText
from logFileModel import LogFileModel from logFileModel import LogFileModel
from ravenui import RavenUI
from raven.i18n import _ from raven.i18n import _
from raven.pluginregistry import PluginRegistry
class FilterTask(QRunnable): class FilterTask(QRunnable):
aborted = False aborted = False
@@ -149,7 +150,7 @@ class FilterWidget(QWidget):
self.filter_model.truncate() self.filter_model.truncate()
self.source_model.clear_query_highlight() self.source_model.clear_query_highlight()
self.filter_model.clear_query_highlight() self.filter_model.clear_query_highlight()
RavenUI.update_ui() PluginRegistry.execute("update_ui")
def filter_changed(self): def filter_changed(self):
query = self.query_field.text() query = self.query_field.text()

View File

@@ -10,7 +10,6 @@ import sys
import constants import constants
from raven.pluginregistry import PluginRegistry from raven.pluginregistry import PluginRegistry
from ravenui import RavenUI
import gettext import gettext
gettext.install('ravenlog', 'locale') gettext.install('ravenlog', 'locale')
@@ -56,8 +55,8 @@ if __name__ == "__main__":
PluginRegistry.load_plugin("NotesPlugin") PluginRegistry.load_plugin("NotesPlugin")
window = PluginRegistry.execute_single("create_main_window") window = PluginRegistry.execute_single("create_main_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/logs_2018-09-06_2018-09-06.csv")
# window.open_file("/home/andi/ws/performanceDb/data/production/vapbdcom.csv") # window.open_file("/home/andi/ws/performanceDb/data/production/vapbdcom.csv")
# window.open_file("/var/log/syslog") # window.open_file("/var/log/syslog")

View File

@@ -75,6 +75,20 @@ class RavenLogPlugin(PluginBase):
def current_file(self) -> Optional[str]: def current_file(self) -> Optional[str]:
return self.main_window.tabs.current_file() 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): def add_tab(self, tab: Tab):
self.main_window.tabs.add_tab(tab) self.main_window.tabs.add_tab(tab)

View File

@@ -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)

13
tabs.py
View File

@@ -2,11 +2,8 @@ from typing import Optional
from PySide6.QtWidgets import QWidget, QTabWidget, QVBoxLayout from PySide6.QtWidgets import QWidget, QTabWidget, QVBoxLayout
from bigtext import BigText from raven.pluginregistry import PluginRegistry
from fulltabwidget import FullTabWidget
from logFileModel import LogFileModel
from raven.plugins.ravenlog.Tab import Tab from raven.plugins.ravenlog.Tab import Tab
from ravenui import RavenUI
from settings import Settings from settings import Settings
@@ -41,11 +38,11 @@ class Tabs(QWidget):
def _current_tab_changed(self, tab_index: int): def _current_tab_changed(self, tab_index: int):
tab: Tab = self.tabs.widget(tab_index) tab: Tab = self.tabs.widget(tab_index)
if tab: if tab:
RavenUI.update_window_title(tab.title) PluginRegistry.execute("update_window_title", tab.title)
RavenUI.update_status_bar(tab.get_status_text()) PluginRegistry.execute("update_status_bar", tab.get_status_text())
else: else:
RavenUI.update_window_title("") PluginRegistry.execute("update_window_title", "")
RavenUI.update_status_bar("") PluginRegistry.execute("update_status_bar", "")
def _close_tab(self, tab_index: int): def _close_tab(self, tab_index: int):
full_tab: Tab = self.tabs.widget(tab_index) full_tab: Tab = self.tabs.widget(tab_index)