Guest User

srccoreActionsManagercpp

a guest
Jun 4th, 2020
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 118.19 KB | None | 0 0
  1. diff --git a/src/core/ActionsManager.cpp b/src/core/ActionsManager.cpp
  2. index 4b5ec74a0..403bb894c 100644
  3. --- a/src/core/ActionsManager.cpp
  4. +++ b/src/core/ActionsManager.cpp
  5. @@ -1,23 +1,23 @@
  6. /**************************************************************************
  7. -* Otter Browser: Web browser controlled by the user, not vice-versa.
  8. -* Copyright (C) 2013 - 2020 Michal Dutkiewicz aka Emdek <michal@emdek.pl>
  9. -* Copyright (C) 2014 - 2015 Piotr Wójcik <chocimier@tlen.pl>
  10. -* Copyright (C) 2015 Jan Bajer aka bajasoft <jbajer@gmail.com>
  11. -*
  12. -* This program is free software: you can redistribute it and/or modify
  13. -* it under the terms of the GNU General Public License as published by
  14. -* the Free Software Foundation, either version 3 of the License, or
  15. -* (at your option) any later version.
  16. -*
  17. -* This program is distributed in the hope that it will be useful,
  18. -* but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. -* GNU General Public License for more details.
  21. -*
  22. -* You should have received a copy of the GNU General Public License
  23. -* along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. -*
  25. -**************************************************************************/
  26. + * Otter Browser: Web browser controlled by the user, not vice-versa.
  27. + * Copyright (C) 2013 - 2020 Michal Dutkiewicz aka Emdek <michal@emdek.pl>
  28. + * Copyright (C) 2014 - 2015 Piotr Wójcik <chocimier@tlen.pl>
  29. + * Copyright (C) 2015 Jan Bajer aka bajasoft <jbajer@gmail.com>
  30. + *
  31. + * This program is free software: you can redistribute it and/or modify
  32. + * it under the terms of the GNU General Public License as published by
  33. + * the Free Software Foundation, either version 3 of the License, or
  34. + * (at your option) any later version.
  35. + *
  36. + * This program is distributed in the hope that it will be useful,
  37. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. + * GNU General Public License for more details.
  40. + *
  41. + * You should have received a copy of the GNU General Public License
  42. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  43. + *
  44. + **************************************************************************/
  45.  
  46. #include "ActionsManager.h"
  47. #include "JsonSettings.h"
  48. @@ -30,780 +30,709 @@
  49. #include <QtCore/QTextStream>
  50. #include <QtGui/QKeySequence>
  51.  
  52. -namespace Otter
  53. -{
  54. -
  55. -bool KeyboardProfile::Action::operator ==(const KeyboardProfile::Action &other) const
  56. -{
  57. - return (shortcuts == other.shortcuts && parameters == other.parameters && action == other.action);
  58. -}
  59. -
  60. -KeyboardProfile::KeyboardProfile(const QString &identifier, LoadMode mode) :
  61. - m_identifier(identifier),
  62. - m_isModified(false)
  63. -{
  64. - if (identifier.isEmpty())
  65. - {
  66. - return;
  67. - }
  68. -
  69. - const JsonSettings settings(SessionsManager::getReadableDataPath(QLatin1String("keyboard/") + identifier + QLatin1String(".json")));
  70. - const QStringList comments(settings.getComment().split(QLatin1Char('\n')));
  71. -
  72. - for (int i = 0; i < comments.count(); ++i)
  73. - {
  74. - const QString key(comments.at(i).section(QLatin1Char(':'), 0, 0).trimmed());
  75. - const QString value(comments.at(i).section(QLatin1Char(':'), 1).trimmed());
  76. -
  77. - if (key == QLatin1String("Title"))
  78. - {
  79. - m_title = value;
  80. - }
  81. - else if (key == QLatin1String("Description"))
  82. - {
  83. - m_description = value;
  84. - }
  85. - else if (key == QLatin1String("Author"))
  86. - {
  87. - m_author = value;
  88. - }
  89. - else if (key == QLatin1String("Version"))
  90. - {
  91. - m_version = value;
  92. - }
  93. - }
  94. -
  95. - if (mode == MetaDataOnlyMode)
  96. - {
  97. - return;
  98. - }
  99. -
  100. - const QJsonArray contextsArray(settings.array());
  101. - const bool areSingleKeyShortcutsAllowed((mode == FullMode) ? true : SettingsManager::getOption(SettingsManager::Browser_EnableSingleKeyShortcutsOption).toBool());
  102. -
  103. - for (int i = 0; i < contextsArray.count(); ++i)
  104. - {
  105. - const QJsonArray actionsArray(contextsArray.at(i).toObject().value(QLatin1String("actions")).toArray());
  106. - QVector<Action> definitions;
  107. - definitions.reserve(actionsArray.count());
  108. -
  109. - for (int j = 0; j < actionsArray.count(); ++j)
  110. - {
  111. - const QJsonObject actionObject(actionsArray.at(j).toObject());
  112. - const int action(ActionsManager::getActionIdentifier(actionObject.value(QLatin1String("action")).toString()));
  113. -
  114. - if (action < 0)
  115. - {
  116. - continue;
  117. - }
  118. -
  119. - const QJsonArray shortcutsArray(actionObject.value(QLatin1String("shortcuts")).toArray());
  120. - QVector<QKeySequence> shortcuts;
  121. - shortcuts.reserve(shortcutsArray.count());
  122. -
  123. - for (int k = 0; k < shortcutsArray.count(); ++k)
  124. - {
  125. - const QKeySequence shortcut(shortcutsArray.at(k).toString());
  126. -
  127. - if (shortcut.isEmpty() || (!areSingleKeyShortcutsAllowed && !ActionsManager::isShortcutAllowed(shortcut, ActionsManager::DisallowSingleKeyShortcutCheck, false)))
  128. - {
  129. - continue;
  130. - }
  131. -
  132. - shortcuts.append(shortcut);
  133. - }
  134. -
  135. - if (shortcuts.isEmpty())
  136. - {
  137. - continue;
  138. - }
  139. -
  140. - KeyboardProfile::Action definition;
  141. - definition.shortcuts = shortcuts;
  142. - definition.parameters = actionObject.value(QLatin1String("parameters")).toVariant().toMap();
  143. - definition.action = action;
  144. -
  145. - definitions.append(definition);
  146. - }
  147. -
  148. - m_definitions[ActionsManager::GenericContext] = definitions;
  149. - }
  150. -}
  151. -
  152. -void KeyboardProfile::setTitle(const QString &title)
  153. -{
  154. - if (title != m_title)
  155. - {
  156. - m_title = title;
  157. - m_isModified = true;
  158. - }
  159. -}
  160. -
  161. -void KeyboardProfile::setDescription(const QString &description)
  162. -{
  163. - if (description != m_description)
  164. - {
  165. - m_description = description;
  166. - m_isModified = true;
  167. - }
  168. -}
  169. -
  170. -void KeyboardProfile::setAuthor(const QString &author)
  171. -{
  172. - if (author != m_author)
  173. - {
  174. - m_author = author;
  175. - m_isModified = true;
  176. - }
  177. -}
  178. -
  179. -void KeyboardProfile::setVersion(const QString &version)
  180. -{
  181. - if (version != m_version)
  182. - {
  183. - m_version = version;
  184. - m_isModified = true;
  185. - }
  186. -}
  187. -
  188. -void KeyboardProfile::setDefinitions(const QHash<int, QVector<KeyboardProfile::Action> > &definitions)
  189. -{
  190. - if (definitions != m_definitions)
  191. - {
  192. - m_definitions = definitions;
  193. - m_isModified = true;
  194. - }
  195. -}
  196. -
  197. -void KeyboardProfile::setModified(bool isModified)
  198. -{
  199. - m_isModified = isModified;
  200. -}
  201. -
  202. -QString KeyboardProfile::getName() const
  203. -{
  204. - return m_identifier;
  205. -}
  206. -
  207. -QString KeyboardProfile::getTitle() const
  208. -{
  209. - return (m_title.isEmpty() ? QCoreApplication::translate("Otter::KeyboardProfile", "(Untitled)") : m_title);
  210. -}
  211. -
  212. -QString KeyboardProfile::getDescription() const
  213. -{
  214. - return m_description;
  215. -}
  216. -
  217. -QString KeyboardProfile::getAuthor() const
  218. -{
  219. - return m_author;
  220. -}
  221. -
  222. -QString KeyboardProfile::getVersion() const
  223. -{
  224. - return m_version;
  225. -}
  226. -
  227. -QHash<int, QVector<KeyboardProfile::Action> > KeyboardProfile::getDefinitions() const
  228. -{
  229. - return m_definitions;
  230. -}
  231. -
  232. -bool KeyboardProfile::isModified() const
  233. -{
  234. - return m_isModified;
  235. -}
  236. -
  237. -bool KeyboardProfile::save()
  238. -{
  239. - JsonSettings settings(SessionsManager::getWritableDataPath(QLatin1String("keyboard/") + m_identifier + QLatin1String(".json")));
  240. - QString comment;
  241. - QTextStream stream(&comment);
  242. - stream.setCodec("UTF-8");
  243. - stream << QLatin1String("Title: ") << (m_title.isEmpty() ? QT_TR_NOOP("(Untitled)") : m_title) << QLatin1Char('\n');
  244. - stream << QLatin1String("Description: ") << m_description << QLatin1Char('\n');
  245. - stream << QLatin1String("Type: keyboard-profile\n");
  246. - stream << QLatin1String("Author: ") << m_author << QLatin1Char('\n');
  247. - stream << QLatin1String("Version: ") << m_version;
  248. -
  249. - settings.setComment(comment);
  250. -
  251. - QJsonArray contextsArray;
  252. - QHash<int, QVector<KeyboardProfile::Action> >::const_iterator contextsIterator;
  253. -
  254. - for (contextsIterator = m_definitions.constBegin(); contextsIterator != m_definitions.constEnd(); ++contextsIterator)
  255. - {
  256. - QJsonArray actionsArray;
  257. -
  258. - for (int i = 0; i < contextsIterator.value().count(); ++i)
  259. - {
  260. - const KeyboardProfile::Action &action(contextsIterator.value().at(i));
  261. - QJsonArray shortcutsArray;
  262. -
  263. - for (int j = 0; j < action.shortcuts.count(); ++j)
  264. - {
  265. - shortcutsArray.append(action.shortcuts.at(j).toString());
  266. - }
  267. -
  268. - QJsonObject actionObject{{QLatin1String("action"), ActionsManager::getActionName(action.action)}, {QLatin1String("shortcuts"), shortcutsArray}};
  269. -
  270. - if (!action.parameters.isEmpty())
  271. - {
  272. - actionObject.insert(QLatin1String("parameters"), QJsonObject::fromVariantMap(action.parameters));
  273. - }
  274. -
  275. - actionsArray.append(actionObject);
  276. - }
  277. -
  278. - contextsArray.append(QJsonObject({{QLatin1String("context"), QLatin1String("Generic")}, {QLatin1String("actions"), actionsArray}}));
  279. - }
  280. -
  281. - settings.setArray(contextsArray);
  282. -
  283. - const bool result(settings.save());
  284. -
  285. - if (result)
  286. - {
  287. - m_isModified = false;
  288. - }
  289. -
  290. - return result;
  291. -}
  292. -
  293. -ActionsManager* ActionsManager::m_instance(nullptr);
  294. -QMap<int, QVector<QKeySequence> > ActionsManager::m_shortcuts;
  295. -QMultiMap<int, QPair<QVariantMap, QVector<QKeySequence> > > ActionsManager::m_extraShortcuts;
  296. -QVector<QKeySequence> ActionsManager::m_disallowedShortcuts;
  297. -QVector<ActionsManager::ActionDefinition> ActionsManager::m_definitions;
  298. -int ActionsManager::m_actionIdentifierEnumerator(0);
  299. -
  300. -ActionsManager::ActionsManager(QObject *parent) : QObject(parent),
  301. - m_reloadTimer(0)
  302. -{
  303. - m_definitions.reserve(ActionsManager::OtherAction);
  304. -
  305. - registerAction(RunMacroAction, QT_TRANSLATE_NOOP("actions", "Run Macro"), QT_TRANSLATE_NOOP("actions", "Run Arbitrary List of Actions"), {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  306. - registerAction(SetOptionAction, QT_TRANSLATE_NOOP("actions", "Set Option"), QT_TRANSLATE_NOOP("actions", "Set, Reset or Toggle Option"), {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  307. - registerAction(NewTabAction, QT_TRANSLATE_NOOP("actions", "New Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-new")), ActionDefinition::MainWindowScope);
  308. - registerAction(NewTabPrivateAction, QT_TRANSLATE_NOOP("actions", "New Private Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-new-private")), ActionDefinition::MainWindowScope);
  309. - registerAction(NewWindowAction, QT_TRANSLATE_NOOP("actions", "New Window"), {}, ThemesManager::createIcon(QLatin1String("window-new")), ActionDefinition::ApplicationScope);
  310. - registerAction(NewWindowPrivateAction, QT_TRANSLATE_NOOP("actions", "New Private Window"), {}, ThemesManager::createIcon(QLatin1String("window-new-private")), ActionDefinition::ApplicationScope);
  311. - registerAction(OpenAction, QT_TRANSLATE_NOOP("actions", "Open…"), {}, ThemesManager::createIcon(QLatin1String("document-open")), ActionDefinition::MainWindowScope);
  312. - registerAction(SaveAction, QT_TRANSLATE_NOOP("actions", "Save…"), {}, ThemesManager::createIcon(QLatin1String("document-save")), ActionDefinition::WindowScope);
  313. - registerAction(CloneTabAction, QT_TRANSLATE_NOOP("actions", "Clone Tab"), {}, {}, ActionDefinition::WindowScope);
  314. - registerAction(PeekTabAction, QT_TRANSLATE_NOOP("actions", "Peek Tab"), {}, {}, ActionDefinition::MainWindowScope);
  315. - registerAction(PinTabAction, QT_TRANSLATE_NOOP("actions", "Pin Tab"), {}, {}, ActionDefinition::WindowScope);
  316. - registerAction(DetachTabAction, QT_TRANSLATE_NOOP("actions", "Detach Tab"), {}, {}, ActionDefinition::WindowScope);
  317. - registerAction(MaximizeTabAction, QT_TRANSLATE_NOOP("actions", "Maximize"), QT_TRANSLATE_NOOP("actions", "Maximize Tab"), {}, ActionDefinition::WindowScope);
  318. - registerAction(MinimizeTabAction, QT_TRANSLATE_NOOP("actions", "Minimize"), QT_TRANSLATE_NOOP("actions", "Minimize Tab"), {}, ActionDefinition::WindowScope);
  319. - registerAction(RestoreTabAction, QT_TRANSLATE_NOOP("actions", "Restore"), QT_TRANSLATE_NOOP("actions", "Restore Tab"), {}, ActionDefinition::WindowScope);
  320. - registerAction(AlwaysOnTopTabAction, QT_TRANSLATE_NOOP("actions", "Stay on Top"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  321. - registerAction(ClearTabHistoryAction, QT_TRANSLATE_NOOP("actions", "Clear Tab History"), QT_TRANSLATE_NOOP("actions", "Remove Local Tab History"), {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionsManager::ActionDefinition::NavigationCategory);
  322. - registerAction(PurgeTabHistoryAction, QT_TRANSLATE_NOOP("actions", "Purge Tab History"), QT_TRANSLATE_NOOP("actions", "Remove Local and Global Tab History"), {}, ActionDefinition::WindowScope, ActionDefinition::IsDeprecatedFlag, ActionsManager::ActionDefinition::NavigationCategory);
  323. - registerAction(MuteTabMediaAction, QT_TRANSLATE_NOOP("actions", "Mute Tab Media"), {}, ThemesManager::createIcon(QLatin1String("audio-volume-muted")), ActionDefinition::WindowScope);
  324. - registerAction(SuspendTabAction, QT_TRANSLATE_NOOP("actions", "Suspend Tab"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  325. - registerAction(CloseTabAction, QT_TRANSLATE_NOOP("actions", "Close Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-close")), ActionDefinition::WindowScope);
  326. - registerAction(CloseOtherTabsAction, QT_TRANSLATE_NOOP("actions", "Close Other Tabs"), {}, ThemesManager::createIcon(QLatin1String("tab-close-other")), ActionDefinition::MainWindowScope);
  327. - registerAction(ClosePrivateTabsAction, QT_TRANSLATE_NOOP("actions", "Close All Private Tabs"), QT_TRANSLATE_NOOP("actions", "Close All Private Tabs in Current Window"), {}, ActionDefinition::MainWindowScope, ActionDefinition::NoFlags);
  328. - registerAction(ClosePrivateTabsPanicAction, QT_TRANSLATE_NOOP("actions", "Close Private Tabs and Windows"), {}, {}, ActionDefinition::ApplicationScope);
  329. - registerAction(ReopenTabAction, QT_TRANSLATE_NOOP("actions", "Reopen Previously Closed Tab"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::NoFlags);
  330. - registerAction(MaximizeAllAction, QT_TRANSLATE_NOOP("actions", "Maximize All"), {}, {}, ActionDefinition::MainWindowScope);
  331. - registerAction(MinimizeAllAction, QT_TRANSLATE_NOOP("actions", "Minimize All"), {}, {}, ActionDefinition::MainWindowScope);
  332. - registerAction(RestoreAllAction, QT_TRANSLATE_NOOP("actions", "Restore All"), {}, {}, ActionDefinition::MainWindowScope);
  333. - registerAction(CascadeAllAction, QT_TRANSLATE_NOOP("actions", "Cascade"), {}, {}, ActionDefinition::MainWindowScope);
  334. - registerAction(TileAllAction, QT_TRANSLATE_NOOP("actions", "Tile"), {}, {}, ActionDefinition::MainWindowScope);
  335. - registerAction(CloseWindowAction, QT_TRANSLATE_NOOP("actions", "Close Window"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  336. - registerAction(ReopenWindowAction, QT_TRANSLATE_NOOP("actions", "Reopen Previously Closed Window"), {}, {}, ActionDefinition::ApplicationScope, ActionDefinition::NoFlags);
  337. - registerAction(SessionsAction, QT_TRANSLATE_NOOP("actions", "Manage Sessions…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  338. - registerAction(SaveSessionAction, QT_TRANSLATE_NOOP("actions", "Save Current Session…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  339. - registerAction(OpenUrlAction, QT_TRANSLATE_NOOP("actions", "Open URL"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  340. - registerAction(OpenLinkAction, QT_TRANSLATE_NOOP("actions", "Open"), {}, ThemesManager::createIcon(QLatin1String("document-open")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  341. - registerAction(OpenLinkInCurrentTabAction, QT_TRANSLATE_NOOP("actions", "Open in This Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  342. - registerAction(OpenLinkInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  343. - registerAction(OpenLinkInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  344. - registerAction(OpenLinkInNewWindowAction, QT_TRANSLATE_NOOP("actions", "Open in New Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  345. - registerAction(OpenLinkInNewWindowBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  346. - registerAction(OpenLinkInNewPrivateTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  347. - registerAction(OpenLinkInNewPrivateTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  348. - registerAction(OpenLinkInNewPrivateWindowAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  349. - registerAction(OpenLinkInNewPrivateWindowBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Background Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  350. - registerAction(CopyLinkToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  351. - registerAction(BookmarkLinkAction, QT_TRANSLATE_NOOP("actions", "Bookmark Link…"), {}, ThemesManager::createIcon(QLatin1String("bookmark-new")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  352. - registerAction(SaveLinkToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Link Target As…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  353. - registerAction(SaveLinkToDownloadsAction, QT_TRANSLATE_NOOP("actions", "Save to Downloads"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  354. - registerAction(OpenSelectionAsLinkAction, QT_TRANSLATE_NOOP("actions", "Go to This Address"), {}, {}, ActionDefinition::WindowScope);
  355. - registerAction(OpenFrameAction, QT_TRANSLATE_NOOP("actions", "Open"), QT_TRANSLATE_NOOP("actions", "Open Frame"), {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  356. - registerAction(OpenFrameInCurrentTabAction, QT_TRANSLATE_NOOP("actions", "Open"), QT_TRANSLATE_NOOP("actions", "Open Frame in This Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  357. - registerAction(OpenFrameInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Tab"), QT_TRANSLATE_NOOP("actions", "Open Frame in New Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  358. - registerAction(OpenFrameInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Tab"), QT_TRANSLATE_NOOP("actions", "Open Frame in New Background Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  359. - registerAction(CopyFrameLinkToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Frame Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  360. - registerAction(ReloadFrameAction, QT_TRANSLATE_NOOP("actions", "Reload"), QT_TRANSLATE_NOOP("actions", "Reload Frame"), {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  361. - registerAction(ViewFrameSourceAction, QT_TRANSLATE_NOOP("actions", "View Frame Source"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  362. - registerAction(OpenImageAction, QT_TRANSLATE_NOOP("actions", "Open Image"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  363. - registerAction(OpenImageInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open Image In New Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::ImageCategory);
  364. - registerAction(OpenImageInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open Image in New Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::ImageCategory);
  365. - registerAction(SaveImageToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Image…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  366. - registerAction(CopyImageToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Image to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  367. - registerAction(CopyImageUrlToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Image Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  368. - registerAction(ReloadImageAction, QT_TRANSLATE_NOOP("actions", "Reload Image"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  369. - registerAction(ImagePropertiesAction, QT_TRANSLATE_NOOP("actions", "Image Properties…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  370. - registerAction(SaveMediaToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Media…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  371. - registerAction(CopyMediaUrlToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Media Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  372. - registerAction(MediaControlsAction, QT_TRANSLATE_NOOP("actions", "Show Controls"), QT_TRANSLATE_NOOP("actions", "Show Media Controls"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::MediaCategory);
  373. - registerAction(MediaLoopAction, QT_TRANSLATE_NOOP("actions", "Looping"), QT_TRANSLATE_NOOP("actions", "Playback Looping"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::MediaCategory);
  374. - registerAction(MediaPlayPauseAction, QT_TRANSLATE_NOOP("actions", "Play"), QT_TRANSLATE_NOOP("actions", "Play Media"), ThemesManager::createIcon(QLatin1String("media-playback-start")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  375. - registerAction(MediaMuteAction, QT_TRANSLATE_NOOP("actions", "Mute"), QT_TRANSLATE_NOOP("actions", "Mute Media"), ThemesManager::createIcon(QLatin1String("audio-volume-muted")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  376. - registerAction(MediaPlaybackRateAction, QT_TRANSLATE_NOOP("actions", "Playback Rate"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsCheckableFlag, ActionDefinition::MediaCategory);
  377. - registerAction(FillPasswordAction, QT_TRANSLATE_NOOP("actions", "Log In"), {}, ThemesManager::createIcon(QLatin1String("fill-password")), ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionDefinition::PageCategory);
  378. - registerAction(GoAction, QT_TRANSLATE_NOOP("actions", "Go"), QT_TRANSLATE_NOOP("actions", "Go to URL"), ThemesManager::createIcon(QLatin1String("go-jump-locationbar")), ActionDefinition::MainWindowScope);
  379. - registerAction(GoBackAction, QT_TRANSLATE_NOOP("actions", "Back"), QT_TRANSLATE_NOOP("actions", "Go Back"), ThemesManager::createIcon(QLatin1String("go-previous")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  380. - registerAction(GoForwardAction, QT_TRANSLATE_NOOP("actions", "Forward"), QT_TRANSLATE_NOOP("actions", "Go Forward"), ThemesManager::createIcon(QLatin1String("go-next")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  381. - registerAction(GoToHistoryIndexAction, QT_TRANSLATE_NOOP("actions", "Go to History Entry"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::RequiresParameters, ActionDefinition::NavigationCategory);
  382. - registerAction(GoToPageAction, QT_TRANSLATE_NOOP("actions", "Go to Page or Search"), {}, {}, ActionDefinition::MainWindowScope);
  383. - registerAction(GoToHomePageAction, QT_TRANSLATE_NOOP("actions", "Go to Home Page"), {}, ThemesManager::createIcon(QLatin1String("go-home")), ActionDefinition::MainWindowScope);
  384. - registerAction(GoToParentDirectoryAction, QT_TRANSLATE_NOOP("actions", "Go to Parent Directory"), {}, {}, ActionDefinition::WindowScope);
  385. - registerAction(RewindAction, QT_TRANSLATE_NOOP("actions", "Rewind"), QT_TRANSLATE_NOOP("actions", "Rewind History"), ThemesManager::createIcon(QLatin1String("go-first")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  386. - registerAction(FastForwardAction, QT_TRANSLATE_NOOP("actions", "Fast Forward"), {}, ThemesManager::createIcon(QLatin1String("go-last")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  387. - registerAction(RemoveHistoryIndexAction, QT_TRANSLATE_NOOP("actions", "Remove History Entry"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::RequiresParameters, ActionDefinition::NavigationCategory);
  388. - registerAction(StopAction, QT_TRANSLATE_NOOP("actions", "Stop"), {}, ThemesManager::createIcon(QLatin1String("process-stop")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  389. - registerAction(StopScheduledReloadAction, QT_TRANSLATE_NOOP("actions", "Stop Scheduled Page Reload"), {}, {}, ActionDefinition::WindowScope);
  390. - registerAction(StopAllAction, QT_TRANSLATE_NOOP("actions", "Stop All Pages"), {}, ThemesManager::createIcon(QLatin1String("process-stop")), ActionDefinition::MainWindowScope);
  391. - registerAction(ReloadAction, QT_TRANSLATE_NOOP("actions", "Reload"), {}, ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  392. - registerAction(ReloadOrStopAction, QT_TRANSLATE_NOOP("actions", "Reload"), QT_TRANSLATE_NOOP("actions", "Reload or Stop"), ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  393. - registerAction(ReloadAndBypassCacheAction, QT_TRANSLATE_NOOP("actions", "Reload and Bypass Cache"), {}, {}, ActionDefinition::WindowScope);
  394. - registerAction(ReloadAllAction, QT_TRANSLATE_NOOP("actions", "Reload All Tabs"), {}, ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::MainWindowScope);
  395. - registerAction(ScheduleReloadAction, QT_TRANSLATE_NOOP("actions", "Schedule Page Reload"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  396. - registerAction(ContextMenuAction, QT_TRANSLATE_NOOP("actions", "Show Context Menu"), {}, {}, ActionDefinition::WindowScope);
  397. - registerAction(UndoAction, QT_TRANSLATE_NOOP("actions", "Undo"), {}, ThemesManager::createIcon(QLatin1String("edit-undo")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  398. - registerAction(RedoAction, QT_TRANSLATE_NOOP("actions", "Redo"), {}, ThemesManager::createIcon(QLatin1String("edit-redo")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  399. - registerAction(CutAction, QT_TRANSLATE_NOOP("actions", "Cut"), {}, ThemesManager::createIcon(QLatin1String("edit-cut")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  400. - registerAction(CopyAction, QT_TRANSLATE_NOOP("actions", "Copy"), {}, ThemesManager::createIcon(QLatin1String("edit-copy")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  401. - registerAction(CopyPlainTextAction, QT_TRANSLATE_NOOP("actions", "Copy as Plain Text"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsDeprecatedFlag, ActionDefinition::EditingCategory);
  402. - registerAction(CopyAddressAction, QT_TRANSLATE_NOOP("actions", "Copy Address"), {}, {}, ActionDefinition::WindowScope);
  403. - registerAction(CopyToNoteAction, QT_TRANSLATE_NOOP("actions", "Copy to Note"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  404. - registerAction(PasteAction, QT_TRANSLATE_NOOP("actions", "Paste"), {}, ThemesManager::createIcon(QLatin1String("edit-paste")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  405. - registerAction(PasteAndGoAction, QT_TRANSLATE_NOOP("actions", "Paste and Go"), {}, {}, ActionDefinition::WindowScope);
  406. - registerAction(DeleteAction, QT_TRANSLATE_NOOP("actions", "Delete"), {}, ThemesManager::createIcon(QLatin1String("edit-delete")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  407. - registerAction(SelectAllAction, QT_TRANSLATE_NOOP("actions", "Select All"), {}, ThemesManager::createIcon(QLatin1String("edit-select-all")), ActionDefinition::EditorScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  408. - registerAction(UnselectAction, QT_TRANSLATE_NOOP("actions", "Deselect"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  409. - registerAction(ClearAllAction, QT_TRANSLATE_NOOP("actions", "Clear All"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  410. - registerAction(CheckSpellingAction, QT_TRANSLATE_NOOP("actions", "Check Spelling"), {}, {}, ActionDefinition::EditorScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::EditingCategory);
  411. - registerAction(FindAction, QT_TRANSLATE_NOOP("actions", "Find…"), {}, ThemesManager::createIcon(QLatin1String("edit-find")), ActionDefinition::WindowScope);
  412. - registerAction(FindNextAction, QT_TRANSLATE_NOOP("actions", "Find Next"), {}, ThemesManager::createIcon(QLatin1String("go-down")), ActionDefinition::WindowScope);
  413. - registerAction(FindPreviousAction, QT_TRANSLATE_NOOP("actions", "Find Previous"), {}, ThemesManager::createIcon(QLatin1String("go-up")), ActionDefinition::WindowScope);
  414. - registerAction(QuickFindAction, QT_TRANSLATE_NOOP("actions", "Quick Find"), {}, {}, ActionDefinition::WindowScope);
  415. - registerAction(SearchAction, QT_TRANSLATE_NOOP("actions", "Search"), {}, ThemesManager::createIcon(QLatin1String("edit-find")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  416. - registerAction(CreateSearchAction, QT_TRANSLATE_NOOP("actions", "Create Search…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  417. - registerAction(ZoomInAction, QT_TRANSLATE_NOOP("actions", "Zoom In"), {}, ThemesManager::createIcon(QLatin1String("zoom-in")), ActionDefinition::WindowScope);
  418. - registerAction(ZoomOutAction, QT_TRANSLATE_NOOP("actions", "Zoom Out"), {}, ThemesManager::createIcon(QLatin1String("zoom-out")), ActionDefinition::WindowScope);
  419. - registerAction(ZoomOriginalAction, QT_TRANSLATE_NOOP("actions", "Zoom Original"), {}, ThemesManager::createIcon(QLatin1String("zoom-original")), ActionDefinition::WindowScope);
  420. - registerAction(ScrollToStartAction, QT_TRANSLATE_NOOP("actions", "Go to Start of the Page"), {}, {}, ActionDefinition::WindowScope);
  421. - registerAction(ScrollToEndAction, QT_TRANSLATE_NOOP("actions", "Go to the End of the Page"), {}, {}, ActionDefinition::WindowScope);
  422. - registerAction(ScrollPageUpAction, QT_TRANSLATE_NOOP("actions", "Page Up"), {}, {}, ActionDefinition::WindowScope);
  423. - registerAction(ScrollPageDownAction, QT_TRANSLATE_NOOP("actions", "Page Down"), {}, {}, ActionDefinition::WindowScope);
  424. - registerAction(ScrollPageLeftAction, QT_TRANSLATE_NOOP("actions", "Page Left"), {}, {}, ActionDefinition::WindowScope);
  425. - registerAction(ScrollPageRightAction, QT_TRANSLATE_NOOP("actions", "Page Right"), {}, {}, ActionDefinition::WindowScope);
  426. - registerAction(StartDragScrollAction, QT_TRANSLATE_NOOP("actions", "Enter Drag Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  427. - registerAction(StartMoveScrollAction, QT_TRANSLATE_NOOP("actions", "Enter Move Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  428. - registerAction(EndScrollAction, QT_TRANSLATE_NOOP("actions", "Exit Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  429. - registerAction(PrintAction, QT_TRANSLATE_NOOP("actions", "Print…"), {}, ThemesManager::createIcon(QLatin1String("document-print")), ActionDefinition::WindowScope);
  430. - registerAction(PrintPreviewAction, QT_TRANSLATE_NOOP("actions", "Print Preview"), {}, ThemesManager::createIcon(QLatin1String("document-print-preview")), ActionDefinition::WindowScope);
  431. - registerAction(TakeScreenshotAction, QT_TRANSLATE_NOOP("actions", "Take Screenshot"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  432. - registerAction(ActivateAddressFieldAction, QT_TRANSLATE_NOOP("actions", "Activate Address Field"), {}, {}, ActionDefinition::MainWindowScope);
  433. - registerAction(ActivateSearchFieldAction, QT_TRANSLATE_NOOP("actions", "Activate Search Field"), {}, {}, ActionDefinition::MainWindowScope);
  434. - registerAction(ActivateContentAction, QT_TRANSLATE_NOOP("actions", "Activate Content"), {}, {}, ActionDefinition::WindowScope);
  435. - registerAction(ActivatePreviouslyUsedTabAction, QT_TRANSLATE_NOOP("actions", "Go to Previously Used Tab"), {}, {}, ActionDefinition::MainWindowScope);
  436. - registerAction(ActivateLeastRecentlyUsedTabAction, QT_TRANSLATE_NOOP("actions", "Go to Least Recently Used Tab"), {}, {}, ActionDefinition::MainWindowScope);
  437. - registerAction(ActivateTabAction, QT_TRANSLATE_NOOP("actions", "Activate Tab"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  438. - registerAction(ActivateTabOnLeftAction, QT_TRANSLATE_NOOP("actions", "Go to Tab on Left"), {}, {}, ActionDefinition::MainWindowScope);
  439. - registerAction(ActivateTabOnRightAction, QT_TRANSLATE_NOOP("actions", "Go to Tab on Right"), {}, {}, ActionDefinition::MainWindowScope);
  440. - registerAction(ActivateWindowAction, QT_TRANSLATE_NOOP("actions", "Activate Window"), {}, {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  441. - registerAction(BookmarksAction, QT_TRANSLATE_NOOP("actions", "Manage Bookmarks"), {}, ThemesManager::createIcon(QLatin1String("bookmarks-organize")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  442. - registerAction(BookmarkPageAction, QT_TRANSLATE_NOOP("actions", "Bookmark Page…"), {}, ThemesManager::createIcon(QLatin1String("bookmark-new")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::PageCategory);
  443. - registerAction(BookmarkAllOpenPagesAction, QT_TRANSLATE_NOOP("actions", "Bookmark All Open Pages"), {}, {}, ActionDefinition::MainWindowScope);
  444. - registerAction(OpenBookmarkAction, QT_TRANSLATE_NOOP("actions", "Open Bookmark"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  445. - registerAction(QuickBookmarkAccessAction, QT_TRANSLATE_NOOP("actions", "Quick Bookmark Access"), {}, {}, ActionDefinition::MainWindowScope);
  446. - registerAction(OpenFeedAction, QT_TRANSLATE_NOOP("actions", "Open Feed"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  447. - registerAction(CookiesAction, QT_TRANSLATE_NOOP("actions", "Cookies"), {}, ThemesManager::createIcon(QLatin1String("cookies")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  448. - registerAction(LoadPluginsAction, QT_TRANSLATE_NOOP("actions", "Load All Plugins on the Page"), {}, ThemesManager::createIcon(QLatin1String("preferences-plugin")), ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  449. - registerAction(EnableJavaScriptAction, QT_TRANSLATE_NOOP("actions", "Enable JavaScript"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::PageCategory);
  450. - registerAction(EnableReferrerAction, QT_TRANSLATE_NOOP("actions", "Enable Referrer"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::PageCategory);
  451. - registerAction(ViewSourceAction, QT_TRANSLATE_NOOP("actions", "View Source"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionDefinition::NavigationCategory);
  452. - registerAction(InspectPageAction, QT_TRANSLATE_NOOP("actions", "Inspect Page"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsCheckableFlag);
  453. - registerAction(InspectElementAction, QT_TRANSLATE_NOOP("actions", "Inspect Element…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  454. - registerAction(WorkOfflineAction, QT_TRANSLATE_NOOP("actions", "Work Offline"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  455. - registerAction(FullScreenAction, QT_TRANSLATE_NOOP("actions", "Full Screen"), {}, ThemesManager::createIcon(QLatin1String("view-fullscreen")), ActionDefinition::MainWindowScope);
  456. - registerAction(ShowTabSwitcherAction, QT_TRANSLATE_NOOP("actions", "Show Tab Switcher"), {}, {}, ActionDefinition::MainWindowScope);
  457. - registerAction(ShowToolBarAction, QT_TRANSLATE_NOOP("actions", "Show Toolbar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsCheckableFlag | ActionDefinition::RequiresParameters));
  458. - registerAction(ShowMenuBarAction, QT_TRANSLATE_NOOP("actions", "Show Menubar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  459. - registerAction(ShowTabBarAction, QT_TRANSLATE_NOOP("actions", "Show Tabbar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  460. - registerAction(ShowSidebarAction, QT_TRANSLATE_NOOP("actions", "Show Sidebar"), {}, ThemesManager::createIcon(QLatin1String("sidebar-show")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  461. - registerAction(ShowErrorConsoleAction, QT_TRANSLATE_NOOP("actions", "Show Error Console"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  462. - registerAction(LockToolBarsAction, QT_TRANSLATE_NOOP("actions", "Lock Toolbars"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  463. - registerAction(ResetToolBarsAction, QT_TRANSLATE_NOOP("actions", "Reset to Defaults…"), QT_TRANSLATE_NOOP("actions", "Reset Toolbars to Defaults…"), {}, ActionDefinition::ApplicationScope);
  464. - registerAction(ShowPanelAction, QT_TRANSLATE_NOOP("actions", "Show Panel"), QT_TRANSLATE_NOOP("actions", "Show Specified Panel in Sidebar"), {}, ActionDefinition::MainWindowScope);
  465. - registerAction(OpenPanelAction, QT_TRANSLATE_NOOP("actions", "Open Panel as Tab"), QT_TRANSLATE_NOOP("actions", "Open Curent Sidebar Panel as Tab"), ThemesManager::createIcon(QLatin1String("arrow-right")), ActionDefinition::MainWindowScope);
  466. - registerAction(ContentBlockingAction, QT_TRANSLATE_NOOP("actions", "Content Blocking"), {}, ThemesManager::createIcon(QLatin1String("content-blocking")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  467. - registerAction(HistoryAction, QT_TRANSLATE_NOOP("actions", "View History"), {}, ThemesManager::createIcon(QLatin1String("view-history")), ActionDefinition::MainWindowScope);
  468. - registerAction(ClearHistoryAction, QT_TRANSLATE_NOOP("actions", "Clear History…"), {}, ThemesManager::createIcon(QLatin1String("edit-clear-history")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  469. - registerAction(AddonsAction, QT_TRANSLATE_NOOP("actions", "Addons"), {}, ThemesManager::createIcon(QLatin1String("preferences-plugin")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  470. - registerAction(NotesAction, QT_TRANSLATE_NOOP("actions", "Notes"), {}, ThemesManager::createIcon(QLatin1String("notes")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  471. - registerAction(PasswordsAction, QT_TRANSLATE_NOOP("actions", "Passwords"), {}, ThemesManager::createIcon(QLatin1String("dialog-password")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  472. - registerAction(TransfersAction, QT_TRANSLATE_NOOP("actions", "Downloads"), {}, ThemesManager::createIcon(QLatin1String("transfers")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  473. - registerAction(PreferencesAction, QT_TRANSLATE_NOOP("actions", "Preferences…"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  474. - registerAction(WebsitePreferencesAction, QT_TRANSLATE_NOOP("actions", "Website Preferences…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::PageCategory);
  475. - registerAction(QuickPreferencesAction, QT_TRANSLATE_NOOP("actions", "Quick Preferences"), {}, {}, ActionDefinition::WindowScope);
  476. - registerAction(ResetQuickPreferencesAction, QT_TRANSLATE_NOOP("actions", "Reset Options"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  477. - registerAction(WebsiteInformationAction, QT_TRANSLATE_NOOP("actions", "Website Information…"), {}, {}, ActionDefinition::WindowScope);
  478. - registerAction(WebsiteCertificateInformationAction, QT_TRANSLATE_NOOP("actions", "Website Certificate Information…"), {}, {}, ActionDefinition::WindowScope);
  479. - registerAction(SwitchApplicationLanguageAction, QT_TRANSLATE_NOOP("actions", "Switch Application Language…"), {}, ThemesManager::createIcon(QLatin1String("preferences-desktop-locale")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  480. - registerAction(CheckForUpdatesAction, QT_TRANSLATE_NOOP("actions", "Check for Updates…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  481. - registerAction(DiagnosticReportAction, QT_TRANSLATE_NOOP("actions", "Diagnostic Report…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  482. - registerAction(AboutApplicationAction, QT_TRANSLATE_NOOP("actions", "About Otter…"), {}, ThemesManager::createIcon(QLatin1String("otter-browser"), false), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  483. - registerAction(AboutQtAction, QT_TRANSLATE_NOOP("actions", "About Qt…"), {}, ThemesManager::createIcon(QLatin1String("qt")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  484. - registerAction(ExitAction, QT_TRANSLATE_NOOP("actions", "Exit"), {}, ThemesManager::createIcon(QLatin1String("application-exit")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  485. -
  486. - connect(SettingsManager::getInstance(), &SettingsManager::optionChanged, this, &ActionsManager::handleOptionChanged);
  487. -}
  488. -
  489. -void ActionsManager::createInstance()
  490. -{
  491. - if (!m_instance)
  492. - {
  493. - m_instance = new ActionsManager(QCoreApplication::instance());
  494. - m_actionIdentifierEnumerator = ActionsManager::staticMetaObject.indexOfEnumerator(QLatin1String("ActionIdentifier").data());
  495. -
  496. - loadProfiles();
  497. - }
  498. -}
  499. -
  500. -void ActionsManager::timerEvent(QTimerEvent *event)
  501. -{
  502. - if (event->timerId() == m_reloadTimer)
  503. - {
  504. - killTimer(m_reloadTimer);
  505. -
  506. - m_reloadTimer = 0;
  507. -
  508. - loadProfiles();
  509. - }
  510. -}
  511. -
  512. -void ActionsManager::loadProfiles()
  513. -{
  514. - m_shortcuts.clear();
  515. - m_extraShortcuts.clear();
  516. -
  517. - QVector<QKeySequence> allShortcuts;
  518. - const QStringList profiles(SettingsManager::getOption(SettingsManager::Browser_KeyboardShortcutsProfilesOrderOption).toStringList());
  519. -
  520. - for (int i = 0; i < profiles.count(); ++i)
  521. - {
  522. - const QHash<int, QVector<KeyboardProfile::Action> > definitions(KeyboardProfile(profiles.at(i)).getDefinitions());
  523. - QHash<int, QVector<KeyboardProfile::Action> >::const_iterator iterator;
  524. -
  525. - for (iterator = definitions.constBegin(); iterator != definitions.constEnd(); ++iterator)
  526. - {
  527. - for (int j = 0; j < iterator.value().count(); ++j)
  528. - {
  529. - const KeyboardProfile::Action definition(iterator.value().at(j));
  530. - QVector<QKeySequence> shortcuts;
  531. -
  532. - if (definition.parameters.isEmpty() && m_shortcuts.contains(definition.action))
  533. - {
  534. - shortcuts = m_shortcuts[definition.action];
  535. - }
  536. - else if (!definition.parameters.isEmpty() && m_extraShortcuts.contains(definition.action))
  537. - {
  538. - const QList<QPair<QVariantMap, QVector<QKeySequence> > > extraDefinitions(m_extraShortcuts.values(definition.action));
  539. -
  540. - for (int k = 0; k < extraDefinitions.count(); ++k)
  541. - {
  542. - if (extraDefinitions.at(k).first == definition.parameters)
  543. - {
  544. - shortcuts = extraDefinitions.at(k).second;
  545. -
  546. - break;
  547. - }
  548. - }
  549. - }
  550. -
  551. - shortcuts.reserve(shortcuts.count() + definition.shortcuts.count());
  552. -
  553. - for (int k = 0; k < definition.shortcuts.count(); ++k)
  554. - {
  555. - const QKeySequence shortcut(definition.shortcuts.at(k));
  556. -
  557. - if (!allShortcuts.contains(shortcut))
  558. - {
  559. - shortcuts.append(shortcut);
  560. - allShortcuts.append(shortcut);
  561. - }
  562. - }
  563. -
  564. - if (!shortcuts.isEmpty())
  565. - {
  566. - if (definition.parameters.isEmpty())
  567. - {
  568. - m_shortcuts[definition.action] = shortcuts;
  569. - }
  570. - else
  571. - {
  572. - m_extraShortcuts.insert(definition.action, {definition.parameters, shortcuts});
  573. - }
  574. - }
  575. - }
  576. - }
  577. - }
  578. -
  579. - emit m_instance->shortcutsChanged();
  580. -}
  581. -
  582. -void ActionsManager::registerAction(int identifier, const QString &text, const QString &description, const QIcon &icon, ActionDefinition::ActionScope scope, ActionDefinition::ActionFlags flags, ActionDefinition::ActionCategory category)
  583. -{
  584. - ActionsManager::ActionDefinition action;
  585. - action.description = description;
  586. - action.defaultState.text = text;
  587. - action.defaultState.icon = icon;
  588. - action.defaultState.isEnabled = flags.testFlag(ActionDefinition::IsEnabledFlag);
  589. - action.identifier = identifier;
  590. - action.flags = flags;
  591. - action.category = category;
  592. - action.scope = scope;
  593. -
  594. - m_definitions.append(action);
  595. -}
  596. -
  597. -void ActionsManager::handleOptionChanged(int identifier)
  598. -{
  599. - switch (identifier)
  600. - {
  601. - case SettingsManager::Browser_EnableSingleKeyShortcutsOption:
  602. - case SettingsManager::Browser_KeyboardShortcutsProfilesOrderOption:
  603. - if (m_reloadTimer == 0)
  604. - {
  605. - m_reloadTimer = startTimer(250);
  606. - }
  607. -
  608. - break;
  609. - default:
  610. - break;
  611. - }
  612. -}
  613. -
  614. -ActionsManager* ActionsManager::getInstance()
  615. -{
  616. - return m_instance;
  617. -}
  618. -
  619. -QString ActionsManager::createReport()
  620. -{
  621. - QString report;
  622. - QTextStream stream(&report);
  623. - stream.setFieldAlignment(QTextStream::AlignLeft);
  624. - stream << QLatin1String("Keyboard Shortcuts:\n");
  625. -
  626. - for (int i = 0; i < m_definitions.count(); ++i)
  627. - {
  628. - if (m_shortcuts.contains(i))
  629. - {
  630. - const QVector<QKeySequence> shortcuts(m_shortcuts[i]);
  631. -
  632. - stream << QLatin1Char('\t');
  633. - stream.setFieldWidth(30);
  634. - stream << getActionName(i);
  635. - stream.setFieldWidth(20);
  636. -
  637. - for (int j = 0; j < shortcuts.count(); ++j)
  638. - {
  639. - stream << shortcuts.at(j).toString(QKeySequence::PortableText);
  640. - }
  641. -
  642. - stream.setFieldWidth(0);
  643. - stream << QLatin1Char('\n');
  644. - }
  645. -
  646. - if (m_extraShortcuts.contains(i))
  647. - {
  648. - const QList<QPair<QVariantMap, QVector<QKeySequence> > > definitions(m_extraShortcuts.values(i));
  649. -
  650. - if (!m_shortcuts.contains(i))
  651. - {
  652. - stream << QLatin1Char('\t');
  653. - stream.setFieldWidth(30);
  654. - stream << getActionName(i);
  655. - stream.setFieldWidth(0);
  656. - stream << QLatin1Char('\n');
  657. - }
  658. -
  659. - for (int j = 0; j < definitions.count(); ++j)
  660. - {
  661. - const QVector<QKeySequence> shortcuts(definitions.at(j).second);
  662. -
  663. - stream << QLatin1Char('\t');
  664. - stream.setFieldWidth(30);
  665. - stream << QLatin1Char(' ') + QString::fromLatin1(QJsonDocument(QJsonObject::fromVariantMap(definitions.at(j).first)).toJson(QJsonDocument::Compact));
  666. - stream.setFieldWidth(20);
  667. -
  668. - for (int k = 0; k < shortcuts.count(); ++k)
  669. - {
  670. - stream << shortcuts.at(k).toString(QKeySequence::PortableText);
  671. - }
  672. -
  673. - stream.setFieldWidth(0);
  674. - stream << QLatin1Char('\n');
  675. - }
  676. - }
  677. - }
  678. -
  679. - stream << QLatin1Char('\n');
  680. -
  681. - return report;
  682. -}
  683. -
  684. -QString ActionsManager::getActionName(int identifier)
  685. -{
  686. - QString name(ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).valueToKey(identifier));
  687. -
  688. - if (!name.isEmpty())
  689. - {
  690. - name.chop(6);
  691. -
  692. - return name;
  693. - }
  694. -
  695. - return {};
  696. -}
  697. -
  698. -QKeySequence ActionsManager::getActionShortcut(int identifier, const QVariantMap &parameters)
  699. -{
  700. - if (parameters.isEmpty() && m_shortcuts.contains(identifier))
  701. - {
  702. - return m_shortcuts[identifier].value(0);
  703. - }
  704. -
  705. - if (!parameters.isEmpty() && m_extraShortcuts.contains(identifier))
  706. - {
  707. - const QList<QPair<QVariantMap, QVector<QKeySequence> > > definitions(m_extraShortcuts.values(identifier));
  708. -
  709. - for (int i = 0; i < definitions.count(); ++i)
  710. - {
  711. - if (definitions.at(i).first == parameters)
  712. - {
  713. - return definitions.at(i).second.value(0);
  714. - }
  715. - }
  716. - }
  717. -
  718. - return {};
  719. -}
  720. -
  721. -QVector<QKeySequence> ActionsManager::getActionShortcuts(int identifier, const QVariantMap &parameters)
  722. -{
  723. - if (parameters.isEmpty() && m_shortcuts.contains(identifier))
  724. - {
  725. - return m_shortcuts[identifier];
  726. - }
  727. -
  728. - if (!parameters.isEmpty() && m_extraShortcuts.contains(identifier))
  729. - {
  730. - const QList<QPair<QVariantMap, QVector<QKeySequence> > > definitions(m_extraShortcuts.values(identifier));
  731. -
  732. - for (int i = 0; i < definitions.count(); ++i)
  733. - {
  734. - if (definitions.at(i).first == parameters)
  735. - {
  736. - return definitions.at(i).second;
  737. - }
  738. - }
  739. - }
  740. -
  741. - return {};
  742. -}
  743. -
  744. -QVector<ActionsManager::ActionDefinition> ActionsManager::getActionDefinitions()
  745. -{
  746. - return m_definitions;
  747. -}
  748. -
  749. -QVector<KeyboardProfile::Action> ActionsManager::getShortcutDefinitions()
  750. -{
  751. - QVector<KeyboardProfile::Action> definitions;
  752. - definitions.reserve(m_shortcuts.count() + m_extraShortcuts.count());
  753. -
  754. - QMap<int, QVector<QKeySequence> >::iterator shortcutsIterator;
  755. -
  756. - for (shortcutsIterator = m_shortcuts.begin(); shortcutsIterator != m_shortcuts.end(); ++shortcutsIterator)
  757. - {
  758. - KeyboardProfile::Action definition;
  759. - definition.shortcuts = shortcutsIterator.value();
  760. - definition.action = shortcutsIterator.key();
  761. -
  762. - definitions.append(definition);
  763. - }
  764. -
  765. - QMultiMap<int, QPair<QVariantMap, QVector<QKeySequence> > >::iterator extraShortcutsIterator;
  766. -
  767. - for (extraShortcutsIterator = m_extraShortcuts.begin(); extraShortcutsIterator != m_extraShortcuts.end(); ++extraShortcutsIterator)
  768. - {
  769. - KeyboardProfile::Action definition;
  770. - definition.parameters = extraShortcutsIterator.value().first;
  771. - definition.shortcuts = extraShortcutsIterator.value().second;
  772. - definition.action = extraShortcutsIterator.key();
  773. -
  774. - definitions.append(definition);
  775. - }
  776. -
  777. - return definitions;
  778. -}
  779. -
  780. -ActionsManager::ActionDefinition ActionsManager::getActionDefinition(int identifier)
  781. -{
  782. - if (identifier < 0 || identifier >= m_definitions.count())
  783. - {
  784. - return ActionsManager::ActionDefinition();
  785. - }
  786. -
  787. - return m_definitions[identifier];
  788. -}
  789. -
  790. -int ActionsManager::getActionIdentifier(const QString &name)
  791. -{
  792. - if (!name.endsWith(QLatin1String("Action")))
  793. - {
  794. - return ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).keyToValue((name + QLatin1String("Action")).toLatin1());
  795. - }
  796. -
  797. - return ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).keyToValue(name.toLatin1());
  798. -}
  799. -
  800. -bool ActionsManager::isShortcutAllowed(const QKeySequence &shortcut, ShortcutCheck check, bool areSingleKeyShortcutsAllowed)
  801. -{
  802. - if (shortcut.isEmpty())
  803. - {
  804. - return false;
  805. - }
  806. -
  807. - if ((check == AllChecks || check == DisallowSingleKeyShortcutCheck) && (!areSingleKeyShortcutsAllowed && (shortcut[0] == Qt::Key_Plus || !shortcut.toString(QKeySequence::PortableText).contains(QLatin1Char('+'))) && shortcut[0] != Qt::Key_Delete && !(shortcut[0] >= Qt::Key_F1 && shortcut[0] <= Qt::Key_F35)))
  808. - {
  809. - return false;
  810. - }
  811. -
  812. - if (check == AllChecks || check == DisallowStandardShortcutCheck)
  813. - {
  814. - if (m_disallowedShortcuts.isEmpty())
  815. - {
  816. - m_disallowedShortcuts = {QKeySequence(QKeySequence::Copy), QKeySequence(QKeySequence::Cut), QKeySequence(QKeySequence::Delete), QKeySequence(QKeySequence::Paste), QKeySequence(QKeySequence::Redo), QKeySequence(QKeySequence::SelectAll), QKeySequence(QKeySequence::Undo)};
  817. - }
  818. -
  819. - if (m_disallowedShortcuts.contains(shortcut))
  820. - {
  821. - return false;
  822. - }
  823. - }
  824. -
  825. - return true;
  826. -}
  827. +namespace Otter {
  828. +
  829. + bool KeyboardProfile::Action::operator == (const KeyboardProfile::Action & other) const {
  830. + return (shortcuts == other.shortcuts && parameters == other.parameters && action == other.action);
  831. + }
  832. +
  833. + KeyboardProfile::KeyboardProfile(const QString & identifier, LoadMode mode):
  834. + m_identifier(identifier),
  835. + m_isModified(false) {
  836. + if (identifier.isEmpty()) {
  837. + return;
  838. + }
  839. +
  840. + const JsonSettings settings(SessionsManager::getReadableDataPath(QLatin1String("keyboard/") + identifier + QLatin1String(".json")));
  841. + const QStringList comments(settings.getComment().split(QLatin1Char('\n')));
  842. +
  843. + for (int i = 0; i < comments.count(); ++i) {
  844. + const QString key(comments.at(i).section(QLatin1Char(':'), 0, 0).trimmed());
  845. + const QString value(comments.at(i).section(QLatin1Char(':'), 1).trimmed());
  846. +
  847. + if (key == QLatin1String("Title")) {
  848. + m_title = value;
  849. + } else if (key == QLatin1String("Description")) {
  850. + m_description = value;
  851. + } else if (key == QLatin1String("Author")) {
  852. + m_author = value;
  853. + } else if (key == QLatin1String("Version")) {
  854. + m_version = value;
  855. + }
  856. + }
  857. +
  858. + if (mode == MetaDataOnlyMode) {
  859. + return;
  860. + }
  861. +
  862. + const QJsonArray contextsArray(settings.array());
  863. + const bool areSingleKeyShortcutsAllowed((mode == FullMode) ? true : SettingsManager::getOption(SettingsManager::Browser_EnableSingleKeyShortcutsOption).toBool());
  864. +
  865. + for (int i = 0; i < contextsArray.count(); ++i) {
  866. + const QJsonArray actionsArray(contextsArray.at(i).toObject().value(QLatin1String("actions")).toArray());
  867. + QVector < Action > definitions;
  868. + definitions.reserve(actionsArray.count());
  869. +
  870. + for (int j = 0; j < actionsArray.count(); ++j) {
  871. + const QJsonObject actionObject(actionsArray.at(j).toObject());
  872. + const int action(ActionsManager::getActionIdentifier(actionObject.value(QLatin1String("action")).toString()));
  873. +
  874. + if (action < 0) {
  875. + continue;
  876. + }
  877. +
  878. + const QJsonArray shortcutsArray(actionObject.value(QLatin1String("shortcuts")).toArray());
  879. + QVector < QKeySequence > shortcuts;
  880. + shortcuts.reserve(shortcutsArray.count());
  881. +
  882. + for (int k = 0; k < shortcutsArray.count(); ++k) {
  883. + const QKeySequence shortcut(shortcutsArray.at(k).toString());
  884. +
  885. + if (shortcut.isEmpty() || (!areSingleKeyShortcutsAllowed && !ActionsManager::isShortcutAllowed(shortcut, ActionsManager::DisallowSingleKeyShortcutCheck, false))) {
  886. + continue;
  887. + }
  888. +
  889. + shortcuts.append(shortcut);
  890. + }
  891. +
  892. + if (shortcuts.isEmpty()) {
  893. + continue;
  894. + }
  895. +
  896. + KeyboardProfile::Action definition;
  897. + definition.shortcuts = shortcuts;
  898. + definition.parameters = actionObject.value(QLatin1String("parameters")).toVariant().toMap();
  899. + definition.action = action;
  900. +
  901. + definitions.append(definition);
  902. + }
  903. +
  904. + m_definitions[ActionsManager::GenericContext] = definitions;
  905. + }
  906. + }
  907. +
  908. + void KeyboardProfile::setTitle(const QString & title) {
  909. + if (title != m_title) {
  910. + m_title = title;
  911. + m_isModified = true;
  912. + }
  913. + }
  914. +
  915. + void KeyboardProfile::setDescription(const QString & description) {
  916. + if (description != m_description) {
  917. + m_description = description;
  918. + m_isModified = true;
  919. + }
  920. + }
  921. +
  922. + void KeyboardProfile::setAuthor(const QString & author) {
  923. + if (author != m_author) {
  924. + m_author = author;
  925. + m_isModified = true;
  926. + }
  927. + }
  928. +
  929. + void KeyboardProfile::setVersion(const QString & version) {
  930. + if (version != m_version) {
  931. + m_version = version;
  932. + m_isModified = true;
  933. + }
  934. + }
  935. +
  936. + void KeyboardProfile::setDefinitions(const QHash < int, QVector < KeyboardProfile::Action > > & definitions) {
  937. + if (definitions != m_definitions) {
  938. + m_definitions = definitions;
  939. + m_isModified = true;
  940. + }
  941. + }
  942. +
  943. + void KeyboardProfile::setModified(bool isModified) {
  944. + m_isModified = isModified;
  945. + }
  946. +
  947. + QString KeyboardProfile::getName() const {
  948. + return m_identifier;
  949. + }
  950. +
  951. + QString KeyboardProfile::getTitle() const {
  952. + return (m_title.isEmpty() ? QCoreApplication::translate("Otter::KeyboardProfile", "(Untitled)") : m_title);
  953. + }
  954. +
  955. + QString KeyboardProfile::getDescription() const {
  956. + return m_description;
  957. + }
  958. +
  959. + QString KeyboardProfile::getAuthor() const {
  960. + return m_author;
  961. + }
  962. +
  963. + QString KeyboardProfile::getVersion() const {
  964. + return m_version;
  965. + }
  966. +
  967. + QHash < int, QVector < KeyboardProfile::Action > > KeyboardProfile::getDefinitions() const {
  968. + return m_definitions;
  969. + }
  970. +
  971. + bool KeyboardProfile::isModified() const {
  972. + return m_isModified;
  973. + }
  974. +
  975. + bool KeyboardProfile::save() {
  976. + JsonSettings settings(SessionsManager::getWritableDataPath(QLatin1String("keyboard/") + m_identifier + QLatin1String(".json")));
  977. + QString comment;
  978. + QTextStream stream( & comment);
  979. + stream.setCodec("UTF-8");
  980. + stream << QLatin1String("Title: ") << (m_title.isEmpty() ? QT_TR_NOOP("(Untitled)") : m_title) << QLatin1Char('\n');
  981. + stream << QLatin1String("Description: ") << m_description << QLatin1Char('\n');
  982. + stream << QLatin1String("Type: keyboard-profile\n");
  983. + stream << QLatin1String("Author: ") << m_author << QLatin1Char('\n');
  984. + stream << QLatin1String("Version: ") << m_version;
  985. +
  986. + settings.setComment(comment);
  987. +
  988. + QJsonArray contextsArray;
  989. + QHash < int, QVector < KeyboardProfile::Action > > ::const_iterator contextsIterator;
  990. +
  991. + for (contextsIterator = m_definitions.constBegin(); contextsIterator != m_definitions.constEnd(); ++contextsIterator) {
  992. + QJsonArray actionsArray;
  993. +
  994. + for (int i = 0; i < contextsIterator.value().count(); ++i) {
  995. + const KeyboardProfile::Action & action(contextsIterator.value().at(i));
  996. + QJsonArray shortcutsArray;
  997. +
  998. + for (int j = 0; j < action.shortcuts.count(); ++j) {
  999. + shortcutsArray.append(action.shortcuts.at(j).toString());
  1000. + }
  1001. +
  1002. + QJsonObject actionObject {
  1003. + {
  1004. + QLatin1String("action"), ActionsManager::getActionName(action.action)
  1005. + }, {
  1006. + QLatin1String("shortcuts"),
  1007. + shortcutsArray
  1008. + }
  1009. + };
  1010. +
  1011. + if (!action.parameters.isEmpty()) {
  1012. + actionObject.insert(QLatin1String("parameters"), QJsonObject::fromVariantMap(action.parameters));
  1013. + }
  1014. +
  1015. + actionsArray.append(actionObject);
  1016. + }
  1017. +
  1018. + contextsArray.append(QJsonObject({
  1019. + {
  1020. + QLatin1String("context"), QLatin1String("Generic")
  1021. + },
  1022. + {
  1023. + QLatin1String("actions"),
  1024. + actionsArray
  1025. + }
  1026. + }));
  1027. + }
  1028. +
  1029. + settings.setArray(contextsArray);
  1030. +
  1031. + const bool result(settings.save());
  1032. +
  1033. + if (result) {
  1034. + m_isModified = false;
  1035. + }
  1036. +
  1037. + return result;
  1038. + }
  1039. +
  1040. + ActionsManager * ActionsManager::m_instance(nullptr);
  1041. + QMap < int, QVector < QKeySequence > > ActionsManager::m_shortcuts;
  1042. + QMultiMap < int, QPair < QVariantMap, QVector < QKeySequence > > > ActionsManager::m_extraShortcuts;
  1043. + QVector < QKeySequence > ActionsManager::m_disallowedShortcuts;
  1044. + QVector < ActionsManager::ActionDefinition > ActionsManager::m_definitions;
  1045. + int ActionsManager::m_actionIdentifierEnumerator(0);
  1046. +
  1047. + ActionsManager::ActionsManager(QObject * parent): QObject(parent),
  1048. + m_reloadTimer(0) {
  1049. + m_definitions.reserve(ActionsManager::OtherAction);
  1050. +
  1051. + registerAction(RunMacroAction, QT_TRANSLATE_NOOP("actions", "Run Macro"), QT_TRANSLATE_NOOP("actions", "Run Arbitrary List of Actions"), {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  1052. + registerAction(SetOptionAction, QT_TRANSLATE_NOOP("actions", "Set Option"), QT_TRANSLATE_NOOP("actions", "Set, Reset or Toggle Option"), {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  1053. + registerAction(NewTabAction, QT_TRANSLATE_NOOP("actions", "New Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-new")), ActionDefinition::MainWindowScope);
  1054. + registerAction(NewTabPrivateAction, QT_TRANSLATE_NOOP("actions", "New Private Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-new-private")), ActionDefinition::MainWindowScope);
  1055. + registerAction(NewWindowAction, QT_TRANSLATE_NOOP("actions", "New Window"), {}, ThemesManager::createIcon(QLatin1String("window-new")), ActionDefinition::ApplicationScope);
  1056. + registerAction(NewWindowPrivateAction, QT_TRANSLATE_NOOP("actions", "New Private Window"), {}, ThemesManager::createIcon(QLatin1String("window-new-private")), ActionDefinition::ApplicationScope);
  1057. + registerAction(OpenAction, QT_TRANSLATE_NOOP("actions", "Open…"), {}, ThemesManager::createIcon(QLatin1String("document-open")), ActionDefinition::MainWindowScope);
  1058. + registerAction(SaveAction, QT_TRANSLATE_NOOP("actions", "Save…"), {}, ThemesManager::createIcon(QLatin1String("document-save")), ActionDefinition::WindowScope);
  1059. + registerAction(CloneTabAction, QT_TRANSLATE_NOOP("actions", "Clone Tab"), {}, {}, ActionDefinition::WindowScope);
  1060. + registerAction(PeekTabAction, QT_TRANSLATE_NOOP("actions", "Peek Tab"), {}, {}, ActionDefinition::MainWindowScope);
  1061. + registerAction(PinTabAction, QT_TRANSLATE_NOOP("actions", "Pin Tab"), {}, {}, ActionDefinition::WindowScope);
  1062. + registerAction(DetachTabAction, QT_TRANSLATE_NOOP("actions", "Detach Tab"), {}, {}, ActionDefinition::WindowScope);
  1063. + registerAction(MaximizeTabAction, QT_TRANSLATE_NOOP("actions", "Maximize"), QT_TRANSLATE_NOOP("actions", "Maximize Tab"), {}, ActionDefinition::WindowScope);
  1064. + registerAction(MinimizeTabAction, QT_TRANSLATE_NOOP("actions", "Minimize"), QT_TRANSLATE_NOOP("actions", "Minimize Tab"), {}, ActionDefinition::WindowScope);
  1065. + registerAction(RestoreTabAction, QT_TRANSLATE_NOOP("actions", "Restore"), QT_TRANSLATE_NOOP("actions", "Restore Tab"), {}, ActionDefinition::WindowScope);
  1066. + registerAction(AlwaysOnTopTabAction, QT_TRANSLATE_NOOP("actions", "Stay on Top"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  1067. + registerAction(ClearTabHistoryAction, QT_TRANSLATE_NOOP("actions", "Clear Tab History"), QT_TRANSLATE_NOOP("actions", "Remove Local Tab History"), {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionsManager::ActionDefinition::NavigationCategory);
  1068. + registerAction(PurgeTabHistoryAction, QT_TRANSLATE_NOOP("actions", "Purge Tab History"), QT_TRANSLATE_NOOP("actions", "Remove Local and Global Tab History"), {}, ActionDefinition::WindowScope, ActionDefinition::IsDeprecatedFlag, ActionsManager::ActionDefinition::NavigationCategory);
  1069. + registerAction(MuteTabMediaAction, QT_TRANSLATE_NOOP("actions", "Mute Tab Media"), {}, ThemesManager::createIcon(QLatin1String("audio-volume-muted")), ActionDefinition::WindowScope);
  1070. + registerAction(SuspendTabAction, QT_TRANSLATE_NOOP("actions", "Suspend Tab"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  1071. + registerAction(CloseTabAction, QT_TRANSLATE_NOOP("actions", "Close Tab"), {}, ThemesManager::createIcon(QLatin1String("tab-close")), ActionDefinition::WindowScope);
  1072. + registerAction(CloseOtherTabsAction, QT_TRANSLATE_NOOP("actions", "Close Other Tabs"), {}, ThemesManager::createIcon(QLatin1String("tab-close-other")), ActionDefinition::MainWindowScope);
  1073. + registerAction(ClosePrivateTabsAction, QT_TRANSLATE_NOOP("actions", "Close All Private Tabs"), QT_TRANSLATE_NOOP("actions", "Close All Private Tabs in Current Window"), {}, ActionDefinition::MainWindowScope, ActionDefinition::NoFlags);
  1074. + registerAction(ClosePrivateTabsPanicAction, QT_TRANSLATE_NOOP("actions", "Close Private Tabs and Windows"), {}, {}, ActionDefinition::ApplicationScope);
  1075. + registerAction(ReopenTabAction, QT_TRANSLATE_NOOP("actions", "Reopen Previously Closed Tab"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::NoFlags);
  1076. + registerAction(MaximizeAllAction, QT_TRANSLATE_NOOP("actions", "Maximize All"), {}, {}, ActionDefinition::MainWindowScope);
  1077. + registerAction(MinimizeAllAction, QT_TRANSLATE_NOOP("actions", "Minimize All"), {}, {}, ActionDefinition::MainWindowScope);
  1078. + registerAction(RestoreAllAction, QT_TRANSLATE_NOOP("actions", "Restore All"), {}, {}, ActionDefinition::MainWindowScope);
  1079. + registerAction(CascadeAllAction, QT_TRANSLATE_NOOP("actions", "Cascade"), {}, {}, ActionDefinition::MainWindowScope);
  1080. + registerAction(TileAllAction, QT_TRANSLATE_NOOP("actions", "Tile"), {}, {}, ActionDefinition::MainWindowScope);
  1081. + registerAction(CloseWindowAction, QT_TRANSLATE_NOOP("actions", "Close Window"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1082. + registerAction(ReopenWindowAction, QT_TRANSLATE_NOOP("actions", "Reopen Previously Closed Window"), {}, {}, ActionDefinition::ApplicationScope, ActionDefinition::NoFlags);
  1083. + registerAction(SessionsAction, QT_TRANSLATE_NOOP("actions", "Manage Sessions…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1084. + registerAction(SaveSessionAction, QT_TRANSLATE_NOOP("actions", "Save Current Session…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1085. + registerAction(OpenUrlAction, QT_TRANSLATE_NOOP("actions", "Open URL"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  1086. + registerAction(OpenLinkAction, QT_TRANSLATE_NOOP("actions", "Open"), {}, ThemesManager::createIcon(QLatin1String("document-open")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  1087. + registerAction(OpenLinkInCurrentTabAction, QT_TRANSLATE_NOOP("actions", "Open in This Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1088. + registerAction(OpenLinkInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1089. + registerAction(OpenLinkInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1090. + registerAction(OpenLinkInNewWindowAction, QT_TRANSLATE_NOOP("actions", "Open in New Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1091. + registerAction(OpenLinkInNewWindowBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1092. + registerAction(OpenLinkInNewPrivateTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1093. + registerAction(OpenLinkInNewPrivateTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1094. + registerAction(OpenLinkInNewPrivateWindowAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1095. + registerAction(OpenLinkInNewPrivateWindowBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Private Background Window"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::LinkCategory);
  1096. + registerAction(CopyLinkToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  1097. + registerAction(BookmarkLinkAction, QT_TRANSLATE_NOOP("actions", "Bookmark Link…"), {}, ThemesManager::createIcon(QLatin1String("bookmark-new")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  1098. + registerAction(SaveLinkToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Link Target As…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  1099. + registerAction(SaveLinkToDownloadsAction, QT_TRANSLATE_NOOP("actions", "Save to Downloads"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::LinkCategory);
  1100. + registerAction(OpenSelectionAsLinkAction, QT_TRANSLATE_NOOP("actions", "Go to This Address"), {}, {}, ActionDefinition::WindowScope);
  1101. + registerAction(OpenFrameAction, QT_TRANSLATE_NOOP("actions", "Open"), QT_TRANSLATE_NOOP("actions", "Open Frame"), {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  1102. + registerAction(OpenFrameInCurrentTabAction, QT_TRANSLATE_NOOP("actions", "Open"), QT_TRANSLATE_NOOP("actions", "Open Frame in This Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  1103. + registerAction(OpenFrameInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open in New Tab"), QT_TRANSLATE_NOOP("actions", "Open Frame in New Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  1104. + registerAction(OpenFrameInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open in New Background Tab"), QT_TRANSLATE_NOOP("actions", "Open Frame in New Background Tab"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::FrameCategory);
  1105. + registerAction(CopyFrameLinkToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Frame Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  1106. + registerAction(ReloadFrameAction, QT_TRANSLATE_NOOP("actions", "Reload"), QT_TRANSLATE_NOOP("actions", "Reload Frame"), {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  1107. + registerAction(ViewFrameSourceAction, QT_TRANSLATE_NOOP("actions", "View Frame Source"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::FrameCategory);
  1108. + registerAction(OpenImageAction, QT_TRANSLATE_NOOP("actions", "Open Image"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1109. + registerAction(OpenImageInNewTabAction, QT_TRANSLATE_NOOP("actions", "Open Image In New Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::ImageCategory);
  1110. + registerAction(OpenImageInNewTabBackgroundAction, QT_TRANSLATE_NOOP("actions", "Open Image in New Background Tab"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag), ActionDefinition::ImageCategory);
  1111. + registerAction(SaveImageToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Image…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1112. + registerAction(CopyImageToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Image to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1113. + registerAction(CopyImageUrlToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Image Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1114. + registerAction(ReloadImageAction, QT_TRANSLATE_NOOP("actions", "Reload Image"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1115. + registerAction(ImagePropertiesAction, QT_TRANSLATE_NOOP("actions", "Image Properties…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::ImageCategory);
  1116. + registerAction(SaveMediaToDiskAction, QT_TRANSLATE_NOOP("actions", "Save Media…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  1117. + registerAction(CopyMediaUrlToClipboardAction, QT_TRANSLATE_NOOP("actions", "Copy Media Link to Clipboard"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  1118. + registerAction(MediaControlsAction, QT_TRANSLATE_NOOP("actions", "Show Controls"), QT_TRANSLATE_NOOP("actions", "Show Media Controls"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::MediaCategory);
  1119. + registerAction(MediaLoopAction, QT_TRANSLATE_NOOP("actions", "Looping"), QT_TRANSLATE_NOOP("actions", "Playback Looping"), {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::MediaCategory);
  1120. + registerAction(MediaPlayPauseAction, QT_TRANSLATE_NOOP("actions", "Play"), QT_TRANSLATE_NOOP("actions", "Play Media"), ThemesManager::createIcon(QLatin1String("media-playback-start")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  1121. + registerAction(MediaMuteAction, QT_TRANSLATE_NOOP("actions", "Mute"), QT_TRANSLATE_NOOP("actions", "Mute Media"), ThemesManager::createIcon(QLatin1String("audio-volume-muted")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::MediaCategory);
  1122. + registerAction(MediaPlaybackRateAction, QT_TRANSLATE_NOOP("actions", "Playback Rate"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsCheckableFlag, ActionDefinition::MediaCategory);
  1123. + registerAction(FillPasswordAction, QT_TRANSLATE_NOOP("actions", "Log In"), {}, ThemesManager::createIcon(QLatin1String("fill-password")), ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionDefinition::PageCategory);
  1124. + registerAction(GoAction, QT_TRANSLATE_NOOP("actions", "Go"), QT_TRANSLATE_NOOP("actions", "Go to URL"), ThemesManager::createIcon(QLatin1String("go-jump-locationbar")), ActionDefinition::MainWindowScope);
  1125. + registerAction(GoBackAction, QT_TRANSLATE_NOOP("actions", "Back"), QT_TRANSLATE_NOOP("actions", "Go Back"), ThemesManager::createIcon(QLatin1String("go-previous")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1126. + registerAction(GoForwardAction, QT_TRANSLATE_NOOP("actions", "Forward"), QT_TRANSLATE_NOOP("actions", "Go Forward"), ThemesManager::createIcon(QLatin1String("go-next")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1127. + registerAction(GoToHistoryIndexAction, QT_TRANSLATE_NOOP("actions", "Go to History Entry"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::RequiresParameters, ActionDefinition::NavigationCategory);
  1128. + registerAction(GoToPageAction, QT_TRANSLATE_NOOP("actions", "Go to Page or Search"), {}, {}, ActionDefinition::MainWindowScope);
  1129. + registerAction(GoToHomePageAction, QT_TRANSLATE_NOOP("actions", "Go to Home Page"), {}, ThemesManager::createIcon(QLatin1String("go-home")), ActionDefinition::MainWindowScope);
  1130. + registerAction(GoToParentDirectoryAction, QT_TRANSLATE_NOOP("actions", "Go to Parent Directory"), {}, {}, ActionDefinition::WindowScope);
  1131. + registerAction(RewindAction, QT_TRANSLATE_NOOP("actions", "Rewind"), QT_TRANSLATE_NOOP("actions", "Rewind History"), ThemesManager::createIcon(QLatin1String("go-first")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1132. + registerAction(FastForwardAction, QT_TRANSLATE_NOOP("actions", "Fast Forward"), {}, ThemesManager::createIcon(QLatin1String("go-last")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1133. + registerAction(RemoveHistoryIndexAction, QT_TRANSLATE_NOOP("actions", "Remove History Entry"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::RequiresParameters, ActionDefinition::NavigationCategory);
  1134. + registerAction(StopAction, QT_TRANSLATE_NOOP("actions", "Stop"), {}, ThemesManager::createIcon(QLatin1String("process-stop")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1135. + registerAction(StopScheduledReloadAction, QT_TRANSLATE_NOOP("actions", "Stop Scheduled Page Reload"), {}, {}, ActionDefinition::WindowScope);
  1136. + registerAction(StopAllAction, QT_TRANSLATE_NOOP("actions", "Stop All Pages"), {}, ThemesManager::createIcon(QLatin1String("process-stop")), ActionDefinition::MainWindowScope);
  1137. + registerAction(ReloadAction, QT_TRANSLATE_NOOP("actions", "Reload"), {}, ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1138. + registerAction(ReloadOrStopAction, QT_TRANSLATE_NOOP("actions", "Reload"), QT_TRANSLATE_NOOP("actions", "Reload or Stop"), ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::NavigationCategory);
  1139. + registerAction(ReloadAndBypassCacheAction, QT_TRANSLATE_NOOP("actions", "Reload and Bypass Cache"), {}, {}, ActionDefinition::WindowScope);
  1140. + registerAction(ReloadAllAction, QT_TRANSLATE_NOOP("actions", "Reload All Tabs"), {}, ThemesManager::createIcon(QLatin1String("view-refresh")), ActionDefinition::MainWindowScope);
  1141. + registerAction(ScheduleReloadAction, QT_TRANSLATE_NOOP("actions", "Schedule Page Reload"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  1142. + registerAction(ContextMenuAction, QT_TRANSLATE_NOOP("actions", "Show Context Menu"), {}, {}, ActionDefinition::WindowScope);
  1143. + registerAction(UndoAction, QT_TRANSLATE_NOOP("actions", "Undo"), {}, ThemesManager::createIcon(QLatin1String("edit-undo")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1144. + registerAction(RedoAction, QT_TRANSLATE_NOOP("actions", "Redo"), {}, ThemesManager::createIcon(QLatin1String("edit-redo")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1145. + registerAction(CutAction, QT_TRANSLATE_NOOP("actions", "Cut"), {}, ThemesManager::createIcon(QLatin1String("edit-cut")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1146. + registerAction(CopyAction, QT_TRANSLATE_NOOP("actions", "Copy"), {}, ThemesManager::createIcon(QLatin1String("edit-copy")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1147. + registerAction(CopyPlainTextAction, QT_TRANSLATE_NOOP("actions", "Copy as Plain Text"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsDeprecatedFlag, ActionDefinition::EditingCategory);
  1148. + registerAction(CopyAddressAction, QT_TRANSLATE_NOOP("actions", "Copy Address"), {}, {}, ActionDefinition::WindowScope);
  1149. + registerAction(CopyToNoteAction, QT_TRANSLATE_NOOP("actions", "Copy to Note"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1150. + registerAction(PasteAction, QT_TRANSLATE_NOOP("actions", "Paste"), {}, ThemesManager::createIcon(QLatin1String("edit-paste")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1151. + registerAction(PasteAndGoAction, QT_TRANSLATE_NOOP("actions", "Paste and Go"), {}, {}, ActionDefinition::WindowScope);
  1152. + registerAction(DeleteAction, QT_TRANSLATE_NOOP("actions", "Delete"), {}, ThemesManager::createIcon(QLatin1String("edit-delete")), ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1153. + registerAction(SelectAllAction, QT_TRANSLATE_NOOP("actions", "Select All"), {}, ThemesManager::createIcon(QLatin1String("edit-select-all")), ActionDefinition::EditorScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  1154. + registerAction(UnselectAction, QT_TRANSLATE_NOOP("actions", "Deselect"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1155. + registerAction(ClearAllAction, QT_TRANSLATE_NOOP("actions", "Clear All"), {}, {}, ActionDefinition::EditorScope, ActionDefinition::NoFlags, ActionDefinition::EditingCategory);
  1156. + registerAction(CheckSpellingAction, QT_TRANSLATE_NOOP("actions", "Check Spelling"), {}, {}, ActionDefinition::EditorScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::EditingCategory);
  1157. + registerAction(FindAction, QT_TRANSLATE_NOOP("actions", "Find…"), {}, ThemesManager::createIcon(QLatin1String("edit-find")), ActionDefinition::WindowScope);
  1158. + registerAction(FindNextAction, QT_TRANSLATE_NOOP("actions", "Find Next"), {}, ThemesManager::createIcon(QLatin1String("go-down")), ActionDefinition::WindowScope);
  1159. + registerAction(FindPreviousAction, QT_TRANSLATE_NOOP("actions", "Find Previous"), {}, ThemesManager::createIcon(QLatin1String("go-up")), ActionDefinition::WindowScope);
  1160. + registerAction(QuickFindAction, QT_TRANSLATE_NOOP("actions", "Quick Find"), {}, {}, ActionDefinition::WindowScope);
  1161. + registerAction(SearchAction, QT_TRANSLATE_NOOP("actions", "Search"), {}, ThemesManager::createIcon(QLatin1String("edit-find")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  1162. + registerAction(CreateSearchAction, QT_TRANSLATE_NOOP("actions", "Create Search…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::EditingCategory);
  1163. + registerAction(ZoomInAction, QT_TRANSLATE_NOOP("actions", "Zoom In"), {}, ThemesManager::createIcon(QLatin1String("zoom-in")), ActionDefinition::WindowScope);
  1164. + registerAction(ZoomOutAction, QT_TRANSLATE_NOOP("actions", "Zoom Out"), {}, ThemesManager::createIcon(QLatin1String("zoom-out")), ActionDefinition::WindowScope);
  1165. + registerAction(ZoomOriginalAction, QT_TRANSLATE_NOOP("actions", "Zoom Original"), {}, ThemesManager::createIcon(QLatin1String("zoom-original")), ActionDefinition::WindowScope);
  1166. + registerAction(ScrollToStartAction, QT_TRANSLATE_NOOP("actions", "Go to Start of the Page"), {}, {}, ActionDefinition::WindowScope);
  1167. + registerAction(ScrollToEndAction, QT_TRANSLATE_NOOP("actions", "Go to the End of the Page"), {}, {}, ActionDefinition::WindowScope);
  1168. + registerAction(ScrollPageUpAction, QT_TRANSLATE_NOOP("actions", "Page Up"), {}, {}, ActionDefinition::WindowScope);
  1169. + registerAction(ScrollPageDownAction, QT_TRANSLATE_NOOP("actions", "Page Down"), {}, {}, ActionDefinition::WindowScope);
  1170. + registerAction(ScrollPageLeftAction, QT_TRANSLATE_NOOP("actions", "Page Left"), {}, {}, ActionDefinition::WindowScope);
  1171. + registerAction(ScrollPageRightAction, QT_TRANSLATE_NOOP("actions", "Page Right"), {}, {}, ActionDefinition::WindowScope);
  1172. + registerAction(StartDragScrollAction, QT_TRANSLATE_NOOP("actions", "Enter Drag Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  1173. + registerAction(StartMoveScrollAction, QT_TRANSLATE_NOOP("actions", "Enter Move Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  1174. + registerAction(EndScrollAction, QT_TRANSLATE_NOOP("actions", "Exit Scroll Mode"), {}, {}, ActionDefinition::WindowScope);
  1175. + registerAction(PrintAction, QT_TRANSLATE_NOOP("actions", "Print…"), {}, ThemesManager::createIcon(QLatin1String("document-print")), ActionDefinition::WindowScope);
  1176. + registerAction(PrintPreviewAction, QT_TRANSLATE_NOOP("actions", "Print Preview"), {}, ThemesManager::createIcon(QLatin1String("document-print-preview")), ActionDefinition::WindowScope);
  1177. + registerAction(TakeScreenshotAction, QT_TRANSLATE_NOOP("actions", "Take Screenshot"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  1178. + registerAction(ActivateAddressFieldAction, QT_TRANSLATE_NOOP("actions", "Activate Address Field"), {}, {}, ActionDefinition::MainWindowScope);
  1179. + registerAction(ActivateSearchFieldAction, QT_TRANSLATE_NOOP("actions", "Activate Search Field"), {}, {}, ActionDefinition::MainWindowScope);
  1180. + registerAction(ActivateContentAction, QT_TRANSLATE_NOOP("actions", "Activate Content"), {}, {}, ActionDefinition::WindowScope);
  1181. + registerAction(ActivatePreviouslyUsedTabAction, QT_TRANSLATE_NOOP("actions", "Go to Previously Used Tab"), {}, {}, ActionDefinition::MainWindowScope);
  1182. + registerAction(ActivateLeastRecentlyUsedTabAction, QT_TRANSLATE_NOOP("actions", "Go to Least Recently Used Tab"), {}, {}, ActionDefinition::MainWindowScope);
  1183. + registerAction(ActivateTabAction, QT_TRANSLATE_NOOP("actions", "Activate Tab"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  1184. + registerAction(ActivateTabOnLeftAction, QT_TRANSLATE_NOOP("actions", "Go to Tab on Left"), {}, {}, ActionDefinition::MainWindowScope);
  1185. + registerAction(ActivateTabOnRightAction, QT_TRANSLATE_NOOP("actions", "Go to Tab on Right"), {}, {}, ActionDefinition::MainWindowScope);
  1186. + registerAction(ActivateWindowAction, QT_TRANSLATE_NOOP("actions", "Activate Window"), {}, {}, ActionDefinition::ApplicationScope, ActionDefinition::RequiresParameters);
  1187. + registerAction(BookmarksAction, QT_TRANSLATE_NOOP("actions", "Manage Bookmarks"), {}, ThemesManager::createIcon(QLatin1String("bookmarks-organize")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1188. + registerAction(BookmarkPageAction, QT_TRANSLATE_NOOP("actions", "Bookmark Page…"), {}, ThemesManager::createIcon(QLatin1String("bookmark-new")), ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::PageCategory);
  1189. + registerAction(BookmarkAllOpenPagesAction, QT_TRANSLATE_NOOP("actions", "Bookmark All Open Pages"), {}, {}, ActionDefinition::MainWindowScope);
  1190. + registerAction(OpenBookmarkAction, QT_TRANSLATE_NOOP("actions", "Open Bookmark"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  1191. + registerAction(QuickBookmarkAccessAction, QT_TRANSLATE_NOOP("actions", "Quick Bookmark Access"), {}, {}, ActionDefinition::MainWindowScope);
  1192. + registerAction(OpenFeedAction, QT_TRANSLATE_NOOP("actions", "Open Feed"), {}, {}, ActionDefinition::MainWindowScope, ActionDefinition::RequiresParameters);
  1193. + registerAction(CookiesAction, QT_TRANSLATE_NOOP("actions", "Cookies"), {}, ThemesManager::createIcon(QLatin1String("cookies")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1194. + registerAction(LoadPluginsAction, QT_TRANSLATE_NOOP("actions", "Load All Plugins on the Page"), {}, ThemesManager::createIcon(QLatin1String("preferences-plugin")), ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  1195. + registerAction(EnableJavaScriptAction, QT_TRANSLATE_NOOP("actions", "Enable JavaScript"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::PageCategory);
  1196. + registerAction(EnableReferrerAction, QT_TRANSLATE_NOOP("actions", "Enable Referrer"), {}, {}, ActionDefinition::WindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag), ActionDefinition::PageCategory);
  1197. + registerAction(ViewSourceAction, QT_TRANSLATE_NOOP("actions", "View Source"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags, ActionDefinition::NavigationCategory);
  1198. + registerAction(InspectPageAction, QT_TRANSLATE_NOOP("actions", "Inspect Page"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsCheckableFlag);
  1199. + registerAction(InspectElementAction, QT_TRANSLATE_NOOP("actions", "Inspect Element…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  1200. + registerAction(WorkOfflineAction, QT_TRANSLATE_NOOP("actions", "Work Offline"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  1201. + registerAction(FullScreenAction, QT_TRANSLATE_NOOP("actions", "Full Screen"), {}, ThemesManager::createIcon(QLatin1String("view-fullscreen")), ActionDefinition::MainWindowScope);
  1202. + registerAction(ShowTabSwitcherAction, QT_TRANSLATE_NOOP("actions", "Show Tab Switcher"), {}, {}, ActionDefinition::MainWindowScope);
  1203. + registerAction(ShowToolBarAction, QT_TRANSLATE_NOOP("actions", "Show Toolbar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsCheckableFlag | ActionDefinition::RequiresParameters));
  1204. + registerAction(ShowMenuBarAction, QT_TRANSLATE_NOOP("actions", "Show Menubar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  1205. + registerAction(ShowTabBarAction, QT_TRANSLATE_NOOP("actions", "Show Tabbar"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  1206. + registerAction(ShowSidebarAction, QT_TRANSLATE_NOOP("actions", "Show Sidebar"), {}, ThemesManager::createIcon(QLatin1String("sidebar-show")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  1207. + registerAction(ShowErrorConsoleAction, QT_TRANSLATE_NOOP("actions", "Show Error Console"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsDeprecatedFlag | ActionDefinition::IsCheckableFlag));
  1208. + registerAction(LockToolBarsAction, QT_TRANSLATE_NOOP("actions", "Lock Toolbars"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsCheckableFlag));
  1209. + registerAction(ResetToolBarsAction, QT_TRANSLATE_NOOP("actions", "Reset to Defaults…"), QT_TRANSLATE_NOOP("actions", "Reset Toolbars to Defaults…"), {}, ActionDefinition::ApplicationScope);
  1210. + registerAction(ShowPanelAction, QT_TRANSLATE_NOOP("actions", "Show Panel"), QT_TRANSLATE_NOOP("actions", "Show Specified Panel in Sidebar"), {}, ActionDefinition::MainWindowScope);
  1211. + registerAction(OpenPanelAction, QT_TRANSLATE_NOOP("actions", "Open Panel as Tab"), QT_TRANSLATE_NOOP("actions", "Open Curent Sidebar Panel as Tab"), ThemesManager::createIcon(QLatin1String("arrow-right")), ActionDefinition::MainWindowScope);
  1212. + registerAction(ContentBlockingAction, QT_TRANSLATE_NOOP("actions", "Content Blocking"), {}, ThemesManager::createIcon(QLatin1String("content-blocking")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1213. + registerAction(HistoryAction, QT_TRANSLATE_NOOP("actions", "View History"), {}, ThemesManager::createIcon(QLatin1String("view-history")), ActionDefinition::MainWindowScope);
  1214. + registerAction(ClearHistoryAction, QT_TRANSLATE_NOOP("actions", "Clear History…"), {}, ThemesManager::createIcon(QLatin1String("edit-clear-history")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1215. + registerAction(AddonsAction, QT_TRANSLATE_NOOP("actions", "Addons"), {}, ThemesManager::createIcon(QLatin1String("preferences-plugin")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1216. + registerAction(NotesAction, QT_TRANSLATE_NOOP("actions", "Notes"), {}, ThemesManager::createIcon(QLatin1String("notes")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1217. + registerAction(PasswordsAction, QT_TRANSLATE_NOOP("actions", "Passwords"), {}, ThemesManager::createIcon(QLatin1String("dialog-password")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1218. + registerAction(TransfersAction, QT_TRANSLATE_NOOP("actions", "Downloads"), {}, ThemesManager::createIcon(QLatin1String("transfers")), ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1219. + registerAction(PreferencesAction, QT_TRANSLATE_NOOP("actions", "Preferences…"), {}, {}, ActionDefinition::MainWindowScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1220. + registerAction(WebsitePreferencesAction, QT_TRANSLATE_NOOP("actions", "Website Preferences…"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::IsEnabledFlag, ActionDefinition::PageCategory);
  1221. + registerAction(QuickPreferencesAction, QT_TRANSLATE_NOOP("actions", "Quick Preferences"), {}, {}, ActionDefinition::WindowScope);
  1222. + registerAction(ResetQuickPreferencesAction, QT_TRANSLATE_NOOP("actions", "Reset Options"), {}, {}, ActionDefinition::WindowScope, ActionDefinition::NoFlags);
  1223. + registerAction(WebsiteInformationAction, QT_TRANSLATE_NOOP("actions", "Website Information…"), {}, {}, ActionDefinition::WindowScope);
  1224. + registerAction(WebsiteCertificateInformationAction, QT_TRANSLATE_NOOP("actions", "Website Certificate Information…"), {}, {}, ActionDefinition::WindowScope);
  1225. + registerAction(SwitchApplicationLanguageAction, QT_TRANSLATE_NOOP("actions", "Switch Application Language…"), {}, ThemesManager::createIcon(QLatin1String("preferences-desktop-locale")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1226. + registerAction(CheckForUpdatesAction, QT_TRANSLATE_NOOP("actions", "Check for Updates…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1227. + registerAction(DiagnosticReportAction, QT_TRANSLATE_NOOP("actions", "Diagnostic Report…"), {}, {}, ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1228. + registerAction(AboutApplicationAction, QT_TRANSLATE_NOOP("actions", "About Otter…"), {}, ThemesManager::createIcon(QLatin1String("otter-browser"), false), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1229. + registerAction(AboutQtAction, QT_TRANSLATE_NOOP("actions", "About Qt…"), {}, ThemesManager::createIcon(QLatin1String("qt")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1230. + registerAction(ExitAction, QT_TRANSLATE_NOOP("actions", "Exit"), {}, ThemesManager::createIcon(QLatin1String("application-exit")), ActionDefinition::ApplicationScope, (ActionDefinition::IsEnabledFlag | ActionDefinition::IsImmutableFlag));
  1231. +
  1232. + connect(SettingsManager::getInstance(), & SettingsManager::optionChanged, this, & ActionsManager::handleOptionChanged);
  1233. + }
  1234. +
  1235. + void ActionsManager::createInstance() {
  1236. + if (!m_instance) {
  1237. + m_instance = new ActionsManager(QCoreApplication::instance());
  1238. + m_actionIdentifierEnumerator = ActionsManager::staticMetaObject.indexOfEnumerator(QLatin1String("ActionIdentifier").data());
  1239. +
  1240. + loadProfiles();
  1241. + }
  1242. + }
  1243. +
  1244. + void ActionsManager::timerEvent(QTimerEvent * event) {
  1245. + if (event - > timerId() == m_reloadTimer) {
  1246. + killTimer(m_reloadTimer);
  1247. +
  1248. + m_reloadTimer = 0;
  1249. +
  1250. + loadProfiles();
  1251. + }
  1252. + }
  1253. +
  1254. + void ActionsManager::loadProfiles() {
  1255. + m_shortcuts.clear();
  1256. + m_extraShortcuts.clear();
  1257. +
  1258. + QVector < QKeySequence > allShortcuts;
  1259. + const QStringList profiles(SettingsManager::getOption(SettingsManager::Browser_KeyboardShortcutsProfilesOrderOption).toStringList());
  1260. +
  1261. + for (int i = 0; i < profiles.count(); ++i) {
  1262. + const QHash < int, QVector < KeyboardProfile::Action > > definitions(KeyboardProfile(profiles.at(i)).getDefinitions());
  1263. + QHash < int, QVector < KeyboardProfile::Action > > ::const_iterator iterator;
  1264. +
  1265. + for (iterator = definitions.constBegin(); iterator != definitions.constEnd(); ++iterator) {
  1266. + for (int j = 0; j < iterator.value().count(); ++j) {
  1267. + const KeyboardProfile::Action definition(iterator.value().at(j));
  1268. + QVector < QKeySequence > shortcuts;
  1269. +
  1270. + if (definition.parameters.isEmpty() && m_shortcuts.contains(definition.action)) {
  1271. + shortcuts = m_shortcuts[definition.action];
  1272. + } else if (!definition.parameters.isEmpty() && m_extraShortcuts.contains(definition.action)) {
  1273. + const QList < QPair < QVariantMap, QVector < QKeySequence > > > extraDefinitions(m_extraShortcuts.values(definition.action));
  1274. +
  1275. + for (int k = 0; k < extraDefinitions.count(); ++k) {
  1276. + if (extraDefinitions.at(k).first == definition.parameters) {
  1277. + shortcuts = extraDefinitions.at(k).second;
  1278. +
  1279. + break;
  1280. + }
  1281. + }
  1282. + }
  1283. +
  1284. + shortcuts.reserve(shortcuts.count() + definition.shortcuts.count());
  1285. +
  1286. + for (int k = 0; k < definition.shortcuts.count(); ++k) {
  1287. + const QKeySequence shortcut(definition.shortcuts.at(k));
  1288. +
  1289. + if (!allShortcuts.contains(shortcut)) {
  1290. + shortcuts.append(shortcut);
  1291. + allShortcuts.append(shortcut);
  1292. + }
  1293. + }
  1294. +
  1295. + if (!shortcuts.isEmpty()) {
  1296. + if (definition.parameters.isEmpty()) {
  1297. + m_shortcuts[definition.action] = shortcuts;
  1298. + } else {
  1299. + m_extraShortcuts.insert(definition.action, {
  1300. + definition.parameters,
  1301. + shortcuts
  1302. + });
  1303. + }
  1304. + }
  1305. + }
  1306. + }
  1307. + }
  1308. +
  1309. + emit m_instance - > shortcutsChanged();
  1310. + }
  1311. +
  1312. + void ActionsManager::registerAction(int identifier,
  1313. + const QString & text,
  1314. + const QString & description,
  1315. + const QIcon & icon, ActionDefinition::ActionScope scope, ActionDefinition::ActionFlags flags, ActionDefinition::ActionCategory category) {
  1316. + ActionsManager::ActionDefinition action;
  1317. + action.description = description;
  1318. + action.defaultState.text = text;
  1319. + action.defaultState.icon = icon;
  1320. + action.defaultState.isEnabled = flags.testFlag(ActionDefinition::IsEnabledFlag);
  1321. + action.identifier = identifier;
  1322. + action.flags = flags;
  1323. + action.category = category;
  1324. + action.scope = scope;
  1325. +
  1326. + m_definitions.append(action);
  1327. + }
  1328. +
  1329. + void ActionsManager::handleOptionChanged(int identifier) {
  1330. + switch (identifier) {
  1331. + case SettingsManager::Browser_EnableSingleKeyShortcutsOption:
  1332. + case SettingsManager::Browser_KeyboardShortcutsProfilesOrderOption:
  1333. + if (m_reloadTimer == 0) {
  1334. + m_reloadTimer = startTimer(250);
  1335. + }
  1336. +
  1337. + break;
  1338. + default:
  1339. + break;
  1340. + }
  1341. + }
  1342. +
  1343. + ActionsManager * ActionsManager::getInstance() {
  1344. + return m_instance;
  1345. + }
  1346. +
  1347. + QString ActionsManager::createReport() {
  1348. + QString report;
  1349. + QTextStream stream( & report);
  1350. + stream.setFieldAlignment(QTextStream::AlignLeft);
  1351. + stream << QLatin1String("Keyboard Shortcuts:\n");
  1352. +
  1353. + for (int i = 0; i < m_definitions.count(); ++i) {
  1354. + if (m_shortcuts.contains(i)) {
  1355. + const QVector < QKeySequence > shortcuts(m_shortcuts[i]);
  1356. +
  1357. + stream << QLatin1Char('\t');
  1358. + stream.setFieldWidth(30);
  1359. + stream << getActionName(i);
  1360. + stream.setFieldWidth(20);
  1361. +
  1362. + for (int j = 0; j < shortcuts.count(); ++j) {
  1363. + stream << shortcuts.at(j).toString(QKeySequence::PortableText);
  1364. + }
  1365. +
  1366. + stream.setFieldWidth(0);
  1367. + stream << QLatin1Char('\n');
  1368. + }
  1369. +
  1370. + if (m_extraShortcuts.contains(i)) {
  1371. + const QList < QPair < QVariantMap, QVector < QKeySequence > > > definitions(m_extraShortcuts.values(i));
  1372. +
  1373. + if (!m_shortcuts.contains(i)) {
  1374. + stream << QLatin1Char('\t');
  1375. + stream.setFieldWidth(30);
  1376. + stream << getActionName(i);
  1377. + stream.setFieldWidth(0);
  1378. + stream << QLatin1Char('\n');
  1379. + }
  1380. +
  1381. + for (int j = 0; j < definitions.count(); ++j) {
  1382. + const QVector < QKeySequence > shortcuts(definitions.at(j).second);
  1383. +
  1384. + stream << QLatin1Char('\t');
  1385. + stream.setFieldWidth(30);
  1386. + stream << QLatin1Char(' ') + QString::fromLatin1(QJsonDocument(QJsonObject::fromVariantMap(definitions.at(j).first)).toJson(QJsonDocument::Compact));
  1387. + stream.setFieldWidth(20);
  1388. +
  1389. + for (int k = 0; k < shortcuts.count(); ++k) {
  1390. + stream << shortcuts.at(k).toString(QKeySequence::PortableText);
  1391. + }
  1392. +
  1393. + stream.setFieldWidth(0);
  1394. + stream << QLatin1Char('\n');
  1395. + }
  1396. + }
  1397. + }
  1398. +
  1399. + stream << QLatin1Char('\n');
  1400. +
  1401. + return report;
  1402. + }
  1403. +
  1404. + QString ActionsManager::getActionName(int identifier) {
  1405. + QString name(ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).valueToKey(identifier));
  1406. +
  1407. + if (!name.isEmpty()) {
  1408. + name.chop(6);
  1409. +
  1410. + return name;
  1411. + }
  1412. +
  1413. + return {};
  1414. + }
  1415. +
  1416. + QKeySequence ActionsManager::getActionShortcut(int identifier,
  1417. + const QVariantMap & parameters) {
  1418. + if (parameters.isEmpty() && m_shortcuts.contains(identifier)) {
  1419. + return m_shortcuts[identifier].value(0);
  1420. + }
  1421. +
  1422. + if (!parameters.isEmpty() && m_extraShortcuts.contains(identifier)) {
  1423. + const QList < QPair < QVariantMap, QVector < QKeySequence > > > definitions(m_extraShortcuts.values(identifier));
  1424. +
  1425. + for (int i = 0; i < definitions.count(); ++i) {
  1426. + if (definitions.at(i).first == parameters) {
  1427. + return definitions.at(i).second.value(0);
  1428. + }
  1429. + }
  1430. + }
  1431. +
  1432. + return {};
  1433. + }
  1434. +
  1435. + QVector < QKeySequence > ActionsManager::getActionShortcuts(int identifier,
  1436. + const QVariantMap & parameters) {
  1437. + if (parameters.isEmpty() && m_shortcuts.contains(identifier)) {
  1438. + return m_shortcuts[identifier];
  1439. + }
  1440. +
  1441. + if (!parameters.isEmpty() && m_extraShortcuts.contains(identifier)) {
  1442. + const QList < QPair < QVariantMap, QVector < QKeySequence > > > definitions(m_extraShortcuts.values(identifier));
  1443. +
  1444. + for (int i = 0; i < definitions.count(); ++i) {
  1445. + if (definitions.at(i).first == parameters) {
  1446. + return definitions.at(i).second;
  1447. + }
  1448. + }
  1449. + }
  1450. +
  1451. + return {};
  1452. + }
  1453. +
  1454. + QVector < ActionsManager::ActionDefinition > ActionsManager::getActionDefinitions() {
  1455. + return m_definitions;
  1456. + }
  1457. +
  1458. + QVector < KeyboardProfile::Action > ActionsManager::getShortcutDefinitions() {
  1459. + QVector < KeyboardProfile::Action > definitions;
  1460. + definitions.reserve(m_shortcuts.count() + m_extraShortcuts.count());
  1461. +
  1462. + QMap < int, QVector < QKeySequence > > ::iterator shortcutsIterator;
  1463. +
  1464. + for (shortcutsIterator = m_shortcuts.begin(); shortcutsIterator != m_shortcuts.end(); ++shortcutsIterator) {
  1465. + KeyboardProfile::Action definition;
  1466. + definition.shortcuts = shortcutsIterator.value();
  1467. + definition.action = shortcutsIterator.key();
  1468. +
  1469. + definitions.append(definition);
  1470. + }
  1471. +
  1472. + QMultiMap < int, QPair < QVariantMap, QVector < QKeySequence > > > ::iterator extraShortcutsIterator;
  1473. +
  1474. + for (extraShortcutsIterator = m_extraShortcuts.begin(); extraShortcutsIterator != m_extraShortcuts.end(); ++extraShortcutsIterator) {
  1475. + KeyboardProfile::Action definition;
  1476. + definition.parameters = extraShortcutsIterator.value().first;
  1477. + definition.shortcuts = extraShortcutsIterator.value().second;
  1478. + definition.action = extraShortcutsIterator.key();
  1479. +
  1480. + definitions.append(definition);
  1481. + }
  1482. +
  1483. + return definitions;
  1484. + }
  1485. +
  1486. + ActionsManager::ActionDefinition ActionsManager::getActionDefinition(int identifier) {
  1487. + if (identifier < 0 || identifier >= m_definitions.count()) {
  1488. + return ActionsManager::ActionDefinition();
  1489. + }
  1490. +
  1491. + return m_definitions[identifier];
  1492. + }
  1493. +
  1494. + int ActionsManager::getActionIdentifier(const QString & name) {
  1495. + if (!name.endsWith(QLatin1String("Action"))) {
  1496. + return ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).keyToValue((name + QLatin1String("Action")).toLatin1());
  1497. + }
  1498. +
  1499. + return ActionsManager::staticMetaObject.enumerator(m_actionIdentifierEnumerator).keyToValue(name.toLatin1());
  1500. + }
  1501. +
  1502. + bool ActionsManager::isShortcutAllowed(const QKeySequence & shortcut, ShortcutCheck check, bool areSingleKeyShortcutsAllowed) {
  1503. + if (shortcut.isEmpty()) {
  1504. + return false;
  1505. + }
  1506. +
  1507. + if ((check == AllChecks || check == DisallowSingleKeyShortcutCheck) && (!areSingleKeyShortcutsAllowed && (shortcut[0] == Qt::Key_Plus || !shortcut.toString(QKeySequence::PortableText).contains(QLatin1Char('+'))) && shortcut[0] != Qt::Key_Delete && !(shortcut[0] >= Qt::Key_F1 && shortcut[0] <= Qt::Key_F35))) {
  1508. + return false;
  1509. + }
  1510. +
  1511. + if (check == AllChecks || check == DisallowStandardShortcutCheck) {
  1512. + if (m_disallowedShortcuts.isEmpty()) {
  1513. + m_disallowedShortcuts = {
  1514. + QKeySequence(QKeySequence::Copy),
  1515. + QKeySequence(QKeySequence::Cut),
  1516. + QKeySequence(QKeySequence::Delete),
  1517. + QKeySequence(QKeySequence::Paste),
  1518. + QKeySequence(QKeySequence::Redo),
  1519. + QKeySequence(QKeySequence::SelectAll),
  1520. + QKeySequence(QKeySequence::Undo)
  1521. + };
  1522. + }
  1523. +
  1524. + if (m_disallowedShortcuts.contains(shortcut)) {
  1525. + return false;
  1526. + }
  1527. + }
  1528. +
  1529. + return true;
  1530. + }
  1531.  
  1532. }
Add Comment
Please, Sign In to add comment