add notes plugin
This commit is contained in:
0
raven/plugins/notes/__init__.py
Normal file
0
raven/plugins/notes/__init__.py
Normal file
14
raven/plugins/notes/noteswidget.py
Normal file
14
raven/plugins/notes/noteswidget.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from raven.plugins.ravenlog.Tab import Tab
|
||||
from PyQt6.QtWidgets import *
|
||||
|
||||
|
||||
class NotesWidget(Tab):
|
||||
|
||||
def __init__(self, unique_id: str, title: str):
|
||||
super(NotesWidget, self).__init__(unique_id, title)
|
||||
|
||||
self.text_area = QTextEdit(self)
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout.addWidget(self.text_area)
|
||||
38
raven/plugins/notesplugin.py
Normal file
38
raven/plugins/notesplugin.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from typing import Callable
|
||||
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
from raven.pluginbase import PluginBase
|
||||
from raven.pluginregistry import PluginRegistry
|
||||
from raven.plugins.domain.menucontribution import MenuContribution
|
||||
from raven.plugins.domain.raction import RAction
|
||||
from raven.plugins.notes.noteswidget import NotesWidget
|
||||
|
||||
|
||||
class NotesPlugin(PluginBase):
|
||||
|
||||
def __init__(self):
|
||||
super(NotesPlugin, self).__init__()
|
||||
self.settings = None
|
||||
self.tr = None
|
||||
self.tab_counter = 0
|
||||
|
||||
def set_translator(self, tr: Callable[[str], str]):
|
||||
self.tr = tr
|
||||
|
||||
def get_menu_contributions(self) -> [MenuContribution]:
|
||||
return [
|
||||
MenuContribution("window", action=self._add_notes_tab_action(), action_id="add notes tab", after="<last>"),
|
||||
]
|
||||
|
||||
def _add_notes_tab_action(self) -> RAction:
|
||||
open_file = RAction("&Add Notes", self._add_notes_tab, shortcut='Ctrl+Shift+N',
|
||||
icon_from_theme="filenew")
|
||||
return open_file
|
||||
|
||||
def _add_notes_tab(self):
|
||||
self.tab_counter = self.tab_counter + 1
|
||||
notes = NotesWidget(
|
||||
"notes_tab_%d" % self.tab_counter,
|
||||
self.tr("Notes %d") % self.tab_counter)
|
||||
PluginRegistry.execute_single("add_dock", Qt.DockWidgetArea.RightDockWidgetArea, notes)
|
||||
@@ -1,11 +1,13 @@
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtWidgets import QDockWidget, QLabel
|
||||
|
||||
import constants
|
||||
from aboutdialog import AboutDialog
|
||||
from raven.mainwindow import MainWindow
|
||||
from raven.pluginbase import PluginBase
|
||||
from raven.pluginregistry import PluginRegistry
|
||||
from raven.plugins.domain.menucontribution import MenuContribution
|
||||
from raven.plugins.domain.raction import RAction
|
||||
from raven.plugins.ravenlog.Tab import Tab
|
||||
@@ -33,6 +35,11 @@ class RavenLogPlugin(PluginBase):
|
||||
def add_tab(self, tab: Tab):
|
||||
self.main_window.tabs.add_tab(tab)
|
||||
|
||||
def add_dock(self, area: Qt.DockWidgetArea, widget: Tab):
|
||||
dock_widget = QDockWidget(widget.title, self.main_window)
|
||||
dock_widget.setWidget(widget)
|
||||
self.main_window.addDockWidget(area, dock_widget)
|
||||
|
||||
def _action_about(self) -> RAction:
|
||||
about_action = RAction(
|
||||
"&About",
|
||||
|
||||
Reference in New Issue
Block a user