cleanup
This commit is contained in:
2
main.py
2
main.py
@@ -52,8 +52,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# init plugins
|
# init plugins
|
||||||
PluginRegistry.load_plugin("RavenLogPlugin")
|
PluginRegistry.load_plugin("RavenLogPlugin")
|
||||||
PluginRegistry.load_plugin("FilterPlugin")
|
|
||||||
PluginRegistry.load_plugin("LogFileViewerPlugin")
|
|
||||||
PluginRegistry.load_plugin("OpenFilePlugin")
|
PluginRegistry.load_plugin("OpenFilePlugin")
|
||||||
|
|
||||||
window = PluginRegistry.executeSingle("create_main_window")
|
window = PluginRegistry.executeSingle("create_main_window")
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
from raven.pluginbase import PluginBase
|
|
||||||
|
|
||||||
|
|
||||||
class FilterPlugin(PluginBase):
|
|
||||||
def __init__(self):
|
|
||||||
super(FilterPlugin, self).__init__()
|
|
||||||
print("init FilterPlugin")
|
|
||||||
|
|
||||||
def say_hello(self, arg: str):
|
|
||||||
print("FilterPlugin says hello %s" % arg)
|
|
||||||
|
|
||||||
|
|
||||||
def init():
|
|
||||||
print("initializing filter plugin")
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
from raven.pluginbase import PluginBase
|
|
||||||
|
|
||||||
|
|
||||||
class LogFileViewerPlugin(PluginBase):
|
|
||||||
def __init__(self):
|
|
||||||
super(LogFileViewerPlugin, self).__init__()
|
|
||||||
print("init LogFileViewerPlugin")
|
|
||||||
|
|
||||||
def say_hello(self, *args):
|
|
||||||
print("LogFileViewerPlugin says hello")
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
import ctypes
|
|
||||||
import logging
|
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
from inspect import isclass
|
|
||||||
from importlib import import_module
|
|
||||||
from pathlib import Path
|
|
||||||
from pkgutil import iter_modules
|
|
||||||
|
|
||||||
from plugins import *
|
|
||||||
|
|
||||||
from PyQt6 import QtCore
|
|
||||||
from PyQt6.QtCore import QTimer
|
|
||||||
from PyQt6.QtGui import QIcon
|
|
||||||
from PyQt6.QtWidgets import QApplication
|
|
||||||
|
|
||||||
import constants
|
|
||||||
from raven.ravenwindow import RavenWindow
|
|
||||||
from ravenui import RavenUI
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
log = logging.getLogger("main")
|
|
||||||
|
|
||||||
|
|
||||||
def stop_signal(signum, _stackframe):
|
|
||||||
""" Handle terminate signal """
|
|
||||||
try:
|
|
||||||
log.info("Terminate signal received. %s", signum)
|
|
||||||
QtCore.QCoreApplication.quit()
|
|
||||||
except Exception:
|
|
||||||
log.exception("Exception occurred while terminating")
|
|
||||||
sys.exit(1)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def init_signal_handler():
|
|
||||||
# workaround to make signals work in QT apps.
|
|
||||||
# They do not work out of the box, because the main thread
|
|
||||||
# is running in C++ code once app.exec() is executed
|
|
||||||
# Forcing an empty lambda to be executed periodically gives
|
|
||||||
# control back to python and allows python to react to signals
|
|
||||||
timer = QTimer()
|
|
||||||
timer.timeout.connect(lambda: None)
|
|
||||||
timer.start(100)
|
|
||||||
signal.signal(signal.SIGINT, stop_signal)
|
|
||||||
signal.signal(signal.SIGTERM, stop_signal)
|
|
||||||
|
|
||||||
|
|
||||||
def init_translator(app: QApplication):
|
|
||||||
# translator = QTranslator()
|
|
||||||
# if translator.load(QLocale("de"), "messages_de.ts"):
|
|
||||||
# app.installTranslator(translator)
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def set_window_icon(app: QApplication):
|
|
||||||
app.setWindowIcon(QIcon("../" + constants.raven_icon))
|
|
||||||
|
|
||||||
# see https://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7/1552105#1552105
|
|
||||||
if sys.platform == 'win32' or sys.platform == 'cygwin':
|
|
||||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('opentext.ravenlog')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
PluginRegistry.load_plugin("FilterPlugin")
|
|
||||||
PluginRegistry.load_plugin("LogFileViewerPlugin")
|
|
||||||
|
|
||||||
PluginRegistry.execute("say_hello", "World")
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
|
||||||
set_window_icon(app)
|
|
||||||
init_translator(app)
|
|
||||||
init_signal_handler()
|
|
||||||
|
|
||||||
window = RavenWindow()
|
|
||||||
RavenUI.window = window
|
|
||||||
window.show()
|
|
||||||
|
|
||||||
app.exec()
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
from PyQt6.QtWidgets import QMainWindow, QMenu, QStatusBar
|
|
||||||
|
|
||||||
from cutesettings import CuteSettings
|
|
||||||
from settingsstore import SettingsStore
|
|
||||||
|
|
||||||
|
|
||||||
class RavenWindow(QMainWindow):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(RavenWindow, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
self.settings = SettingsStore.load()
|
|
||||||
self.setWindowTitle(self.tr("RavenLog"))
|
|
||||||
self._restore_window()
|
|
||||||
|
|
||||||
self.setDockNestingEnabled(True)
|
|
||||||
self.setAcceptDrops(True)
|
|
||||||
|
|
||||||
# self.tabs = Tabs(self.settings)
|
|
||||||
|
|
||||||
# self._menu_recent_files = QMenu(self.tr("Open &Recent"), self)
|
|
||||||
|
|
||||||
# self.setCentralWidget(self.tabs)
|
|
||||||
# self.status_bar = QStatusBar(self)
|
|
||||||
# self.setStatusBar(self.status_bar)
|
|
||||||
# self.setMenuBar(self.create_menu_bar())
|
|
||||||
|
|
||||||
def _restore_window(self):
|
|
||||||
qsettings = CuteSettings()
|
|
||||||
geometry_restored = False
|
|
||||||
geometry = qsettings.value("mainWindow/geometry")
|
|
||||||
if geometry:
|
|
||||||
geometry_restored = self.restoreGeometry(geometry)
|
|
||||||
if not geometry_restored:
|
|
||||||
self.setGeometry(0, 0, 800, 600)
|
|
||||||
Reference in New Issue
Block a user