Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open URLs in Private Mode / Incognito #9694

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

varjolintu
Copy link
Member

Adds a new menu item and keyboard shortcut for opening a URL using Private Mode / Incognito with the operating system default browser.

  • Linux/Unix retrieves the application from xdg-settings
  • macOS is using direct NSWorkspace::URLForApplicationToOpenURL() call
  • Windows retrieves the path from registry entries associated with the URL scheme

With Firefox based browsers Firefox itself and Librewolf are detected automatically to use -private-window command line parameter. Chromium-based browsers will use -incognito

Fixes #9468.

Testing strategy

Manually.

Type of change

  • ✅ New feature (change that adds functionality)

@varjolintu varjolintu added this to the v2.8.0 milestone Aug 5, 2023
.arg(url.scheme());
QSettings defaultBrowserRegistry(registryPath, QSettings::NativeFormat);
auto defaultBrowser = defaultBrowserRegistry.value("ProgId").toString();
if (defaultBrowser.isEmpty()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible for UserChoice not to exist, then you must find the progid the classic way.

}

// Get the executable path from program ID
registryPath = QString("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\%1\\shell\\open\\command").arg(defaultBrowser);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HKEY_CLASSES_ROOT

@@ -142,6 +142,34 @@ bool WinUtils::isHighContrastMode() const
return (settings.value("Flags").toInt() & 1u) != 0;
}

QString WinUtils::getDefaultApplicationForUrl(const QUrl& url)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this incorrect registry handling, just call AssocQueryStringW(ASSOCF_NOTRUNCATE | ASSOCF_INIT_IGNOREUNKNOWN, ASSOCSTR_EXECUTABLE, L"http", 0, ...)

@droidmonkey droidmonkey modified the milestones: v2.8.0, v2.7.10 Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to open URL in Incognito / Private Mode
3 participants