Falkon Develop
Cross-platform Qt-based web browser
runaction.py
Go to the documentation of this file.
1# ============================================================
2# RunAction plugin for Falkon
3# Copyright (C) 2018 David Rosca <nowrep@gmail.com>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# ============================================================
18import Falkon
19from PySide6 import QtCore
20from runaction import actionmanager, button
21
22
23class RunActionPlugin(Falkon.PluginInterface, QtCore.QObject):
24 buttons = {}
25 manager = None
26
27 def init(self, state, settingsPath):
28 plugins = Falkon.MainApplication.instance().plugins()
29 plugins.mainWindowCreated.connect(self.mainWindowCreated)
30 plugins.mainWindowDeleted.connect(self.mainWindowDeleted)
31
32 self.manager = actionmanager.ActionManager(settingsPath)
33
34 if state == Falkon.PluginInterface.LateInitState:
35 for window in Falkon.MainApplication.instance().windows():
36 self.mainWindowCreated(window)
37
38 def unload(self):
39 for window in Falkon.MainApplication.instance().windows():
40 self.mainWindowDeleted(window)
41
42 self.manager = None
43
44 def testPlugin(self):
45 return True
46
47 def populateWebViewMenu(self, menu, view, r):
48 for action in self.manager.getActions(view, r):
49 if action.inherits("QMenu"):
50 menu.addMenu(action).setParent(menu)
51 else:
52 action.setParent(menu)
53 menu.addAction(action)
54
55 def showSettings(self, parent):
56 self.manager.showSettings(parent)
57
58 def mainWindowCreated(self, window):
60 window.statusBar().addButton(b)
61 window.navigationBar().addToolButton(b)
62 self.buttons[window] = b
63
64 def mainWindowDeleted(self, window):
65 if window not in self.buttons:
66 return
67 b = self.buttons[window]
68 window.statusBar().removeButton(b)
69 window.navigationBar().removeToolButton(b)
70 del self.buttons[window]
71
72
73Falkon.registerPlugin(RunActionPlugin())
def init(self, state, settingsPath)
Definition: runaction.py:27
def showSettings(self, parent)
Definition: runaction.py:55
def populateWebViewMenu(self, menu, view, r)
Definition: runaction.py:47
def mainWindowDeleted(self, window)
Definition: runaction.py:64
def mainWindowCreated(self, window)
Definition: runaction.py:58