File indexing completed on 2024-05-12 04:58:40
0001 # ============================================================ 0002 # RunAction plugin for Falkon 0003 # Copyright (C) 2018 David Rosca <nowrep@gmail.com> 0004 # 0005 # This program is free software: you can redistribute it and/or modify 0006 # it under the terms of the GNU General Public License as published by 0007 # the Free Software Foundation, either version 3 of the License, or 0008 # (at your option) any later version. 0009 # 0010 # This program is distributed in the hope that it will be useful, 0011 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 # GNU General Public License for more details. 0014 # 0015 # You should have received a copy of the GNU General Public License 0016 # along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 # ============================================================ 0018 import Falkon 0019 import os 0020 from PySide6 import QtGui, QtWidgets 0021 from runaction.i18n import i18n 0022 0023 0024 class RunActionButton(Falkon.AbstractButtonInterface): 0025 def __init__(self, manager): 0026 super().__init__() 0027 self.manager = manager 0028 0029 self.setIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icon.svg"))) 0030 self.setTitle(i18n("Run Action")) 0031 self.setToolTip(i18n("Run action on current page")) 0032 0033 self.clicked.connect(self.onClicked) 0034 0035 def id(self): 0036 return "runaction-button" 0037 0038 def name(self): 0039 return i18n("RunAction button") 0040 0041 def onClicked(self, controller): 0042 self.menu = QtWidgets.QMenu() 0043 0044 for action in self.manager.getActions(self.webView()): 0045 self.menu.addAction(action) 0046 0047 self.menu.addSeparator() 0048 self.menu.addAction(QtGui.QIcon.fromTheme("configure"), i18n("Configure..."), self.manager.showSettings) 0049 0050 self.menu.popup(controller.callPopupPosition(self.menu.sizeHint())) 0051 self.menu.aboutToHide.connect(controller.callPopupClosed)