QAction *newTabActionPointer = actionCollectionPointer->addAction(QLatin1String("new_tab"));
QAction *newWindowActionPointer = actionCollectionPointer->addAction(QLatin1String("new_window"));
QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
+ viewSourceActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source"));
+ QAction *viewSourceInNewTabActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source_in_new_tab"));
userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser"));
userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default"));
userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux"));
localStorageActionPointer->setCheckable(true);
domStorageActionPointer->setCheckable(true);
findCaseSensitiveActionPointer->setCheckable(true);
+ viewSourceActionPointer->setCheckable(true);
userAgentPrivacyBrowserActionPointer->setCheckable(true);
userAgentWebEngineDefaultActionPointer->setCheckable(true);
userAgentFirefoxLinuxActionPointer->setCheckable(true);
UserAgentHelper *userAgentHelperPointer = new UserAgentHelper();
// Set the action text.
+ viewSourceActionPointer->setText(i18nc("View source action", "View Source"));
+ viewSourceInNewTabActionPointer->setText(i18nc("View source in new tab action", "View Source in New Tab"));
newTabActionPointer->setText(i18nc("New tab action", "New Tab"));
newWindowActionPointer->setText(i18nc("New window action", "New Window"));
reloadAndBypassCacheActionPointer->setText(i18nc("Reload and bypass cache action", "Reload and Bypass Cache"));
newTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("tab-new")));
newWindowActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-new")));
reloadAndBypassCacheActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-refresh")));
+ viewSourceActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
+ viewSourceInNewTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode.svg"));
- userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"),
- QIcon::fromTheme(QLatin1String("contact-new")))));
+ userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr"), QIcon::fromTheme(QLatin1String("user-group-properties"),
QIcon::fromTheme(QLatin1String("contact-new")))));
- userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium"), QIcon::fromTheme(QLatin1String("user-group-properties"),
- QIcon::fromTheme(QLatin1String("contact-new")))));
+ userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr"), QIcon::fromTheme(QLatin1String("user-group-properties"),
QIcon::fromTheme(QLatin1String("contact-new")))));
- userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium"), QIcon::fromTheme(QLatin1String("user-group-properties"),
- QIcon::fromTheme(QLatin1String("contact-new")))));
+ userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new"))));
userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new"))));
userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new"))));
QKeySequence ctrlTKeySequence = QKeySequence(i18nc("The open new tab key sequence.", "Ctrl+T"));
QKeySequence ctrlNKeySequence = QKeySequence(i18nc("The open new window key sequence.", "Ctrl+N"));
QKeySequence ctrlF5KeySequence = QKeySequence(i18nc("The reload and bypass cache key sequence.", "Ctrl+F5"));
+ QKeySequence ctrlUKeySequence = QKeySequence(i18nc("The view source key sequence.", "Ctrl+U"));
+ QKeySequence ctrlShiftUKeySequence = QKeySequence(i18nc("The view source in new tab key sequence.", "Ctrl+Shift+U"));
QKeySequence ctrlShiftPKeySequence = QKeySequence(i18nc("The print preview key sequence.", "Ctrl+Shift+P"));
QKeySequence ctrlAltPKeySequence = QKeySequence(i18nc("The Privacy Browser user agent key sequence.", "Ctrl+Alt+P"));
QKeySequence ctrlAltWKeySequence = QKeySequence(i18nc("The WebEngine Default user agent key sequence.", "Ctrl+Alt+W"));
actionCollectionPointer->setDefaultShortcut(newTabActionPointer, ctrlTKeySequence);
actionCollectionPointer->setDefaultShortcut(newWindowActionPointer, ctrlNKeySequence);
actionCollectionPointer->setDefaultShortcut(reloadAndBypassCacheActionPointer, ctrlF5KeySequence);
+ actionCollectionPointer->setDefaultShortcut(viewSourceActionPointer, ctrlUKeySequence);
+ actionCollectionPointer->setDefaultShortcut(viewSourceInNewTabActionPointer, ctrlShiftUKeySequence);
actionCollectionPointer->setDefaultShortcut(printPreviewActionPointer, ctrlShiftPKeySequence);
actionCollectionPointer->setDefaultShortcut(userAgentPrivacyBrowserActionPointer, ctrlAltPKeySequence);
actionCollectionPointer->setDefaultShortcut(userAgentWebEngineDefaultActionPointer, ctrlAltWKeySequence);
connect(newTabActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(addTab()));
connect(newWindowActionPointer, SIGNAL(triggered()), this, SLOT(newWindow()));
connect(reloadAndBypassCacheActionPointer, SIGNAL(triggered()), this, SLOT(reloadAndBypassCache()));
+ connect(viewSourceActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSource()));
+ connect(viewSourceInNewTabActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSourceInNewTab()));
connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser()));
connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog()));
connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog()));
}
}
+void BrowserWindow::toggleViewSource() const
+{
+ // Get the current URL.
+ QString url = urlLineEditPointer->text();
+
+ // Toggle the URL.
+ if (url.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
+ {
+ // Remove `view-source:` from the URL.
+ url = url.remove(0, 12);
+ }
+ else // The source is not currently being viewed.
+ {
+ // Prepend `view-source:` from the URL.
+ url = url.prepend(QLatin1String("view-source:"));
+ }
+
+ // Make it so.
+ loadUrlFromLineEdit(url);
+}
+
+void BrowserWindow::toggleViewSourceInNewTab() const
+{
+ // Get the current URL.
+ QString url = urlLineEditPointer->text();
+
+ // Toggle the URL.
+ if (url.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
+ {
+ // Remove `view-source:` from the URL.
+ url = url.remove(0, 12);
+ }
+ else // The source is not currently being viewed.
+ {
+ // Prepend `view-source:` from the URL.
+ url = url.prepend(QLatin1String("view-source:"));
+ }
+
+ // Add the new tab. `true` removes the URL line edit focus, `false` does not open a background tab.
+ tabWidgetPointer->addTab(true, false, url);
+}
+
void BrowserWindow::updateCookiesAction(const int numberOfCookies) const
{
// Update the action text.
void BrowserWindow::updateUrlLineEdit(const QUrl &newUrl)
{
+ // Get the new URL string.
+ QString newUrlString = newUrl.toString();
+
+ // Update the view source checkbox.
+ viewSourceActionPointer->setChecked(newUrlString.startsWith(QLatin1String("view-source:")));
+
// Update the URL line edit if it does not have focus.
if (!urlLineEditPointer->hasFocus())
{
- // Get the new URL string.
- QString newUrlString = newUrl.toString();
-
// Update the URL line edit.
urlLineEditPointer->setText(newUrlString);