21from PySide6
import QtCore
33 settings = QtCore.QSettings(self.
settingsPath +
"/extensions.ini", QtCore.QSettings.IniFormat)
44 if r
and webView.selectedText():
45 cond = Action.TypeCondition.Text
46 text = webView.selectedText()
47 elif r
and not r.linkUrl().isEmpty():
48 cond = Action.TypeCondition.Link
50 elif r
and not r.imageUrl().isEmpty():
51 cond = Action.TypeCondition.Image
53 elif r
and not r.mediaUrl().isEmpty():
54 cond = Action.TypeCondition.Media
57 cond = Action.TypeCondition.Page
59 if action.testAction(cond, url):
60 act = Falkon.Action(action.icon, action.title, self)
61 act.triggered.connect(
lambda a=action, w=webView, u=url, t=text: self.
execAction(a, w, u, t))
63 if action.submenu
not in menus:
64 menu = Falkon.Menu(action.menuTitle, webView)
65 menus[action.submenu] = menu
67 menus[action.submenu].addAction(act)
77 @disabledActions.setter
79 settings = QtCore.QSettings(self.
settingsPath +
"/extensions.ini", QtCore.QSettings.IniFormat)
80 settings.setValue(
"RunAction/disabledActions", value)
88 command = action.execAction(url, text)
89 if action.actionType == Action.Type.Command:
90 subprocess.Popen(command, shell=
True)
91 elif action.actionType == Action.Type.Url:
92 webView.openUrlInNewTab(QtCore.QUrl(command), Falkon.Qz.NT_SelectedTab)
98 os.path.join(os.path.dirname(__file__),
"actions"),
103 if not os.path.exists(path):
105 for file
in os.listdir(path):
106 if not file.endswith(
".desktop"):
108 fileName = os.path.join(path, file)
111 except Exception
as e:
112 print(
"Failed to parse {}: {}".format(fileName, e))
def execAction(self, action, webView, url, text="")
def showSettings(self, parent=None)
def getActions(self, webView, r=None)
def __init__(self, settingsPath, parent=None)
def disabledActions(self)
def disabledActions(self, value)