add notes plugin
This commit is contained in:
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)
|
||||
Reference in New Issue
Block a user