34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from PySide6.QtCore import Qt
|
|
|
|
from src.pluginbase import PluginBase
|
|
from src.pluginregistry import PluginRegistry
|
|
from src.plugins.domain.menucontribution import MenuContribution
|
|
from src.plugins.domain.raction import RAction
|
|
from src.plugins.notes.noteswidget import NotesWidget
|
|
from src.i18n import _
|
|
|
|
|
|
class NotesPlugin(PluginBase):
|
|
|
|
def __init__(self):
|
|
super(NotesPlugin, self).__init__()
|
|
self.settings = None
|
|
self.tab_counter = 0
|
|
|
|
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,
|
|
_("Notes {0}").format(self.tab_counter))
|
|
PluginRegistry.execute_single("add_dock", Qt.DockWidgetArea.RightDockWidgetArea, notes)
|