move the log file viewer to its own plugin
We plan to have multiple different types of tabs.
This commit is contained in:
38
raven/plugins/logfileplugin.py
Normal file
38
raven/plugins/logfileplugin.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import os.path
|
||||
from typing import Callable, Optional
|
||||
|
||||
from PyQt6.QtWidgets import QMessageBox
|
||||
|
||||
from fulltabwidget import FullTabWidget
|
||||
from logFileModel import LogFileModel
|
||||
from raven.pluginbase import PluginBase
|
||||
from raven.plugins.ravenlog.Tab import Tab
|
||||
from settings import Settings
|
||||
|
||||
|
||||
class LogFilePlugin(PluginBase):
|
||||
def __init__(self):
|
||||
super(LogFilePlugin, self).__init__()
|
||||
self.settings = None
|
||||
self.tr = None
|
||||
|
||||
def set_settings(self, settings: Settings):
|
||||
self.settings = settings
|
||||
|
||||
def set_translator(self, tr: Callable[[str], str]):
|
||||
self.tr = tr
|
||||
|
||||
def create_tab(self, file: str) -> Optional[Tab]:
|
||||
if not os.path.isfile(file):
|
||||
message = QMessageBox(QMessageBox.Icon.Warning, "File not found",
|
||||
"'%s' is not a file or cannot be opened" % file)
|
||||
message.exec()
|
||||
return None
|
||||
|
||||
realpath = os.path.realpath(file)
|
||||
filename = os.path.basename(realpath)
|
||||
|
||||
model = LogFileModel(file, self.settings)
|
||||
tab = FullTabWidget(model, unique_id=realpath, title=filename)
|
||||
|
||||
return tab
|
||||
Reference in New Issue
Block a user