browserchooser 0.0.2
A simple browser chooser.
Loading...
Searching...
No Matches
backend.h File Reference
#include <QtCore/QList>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include "browseroption.h"
Include dependency graph for backend.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  IncludeNoDisplay { No , Yes }

Functions

QList< BrowserOption > getBrowsers (IncludeNoDisplay includeNoDisplay=IncludeNoDisplay::No)
void launchBrowser (const BrowserOption &option, const QStringList &urls=QStringList())
QString getCommandLineForDisplay (const BrowserOption &option, const QString &url=QString())
QString getExecutablePath (const BrowserOption &option)
QString getConfigFilePath ()
void setConfigFilePathOverride (const QString &path)
void clearConfigFilePathOverride ()
QString getChromeProfileDisplayName (const QString &desktopPath, const QString &profileId)
QString getChromeProfilePicturePath (const QString &desktopPath, const QString &profileId)
QString getChromeUserDataDir (const QString &desktopPath)
QStringList readCommaSeparatedList (const QString &key)
bool listContainsIdentifier (const QStringList &list, const QString &identifier)
bool isBrowserHidden (const BrowserOption &option, const QStringList &hiddenIdentifiers)
QString quoteArg (const QString &arg)
void sortBrowserOptionsByDisplayName (QList< BrowserOption > &options)
QList< QStringList > getPreLaunchCommands (const QString &desktopPath, const QString &profileName)
QList< QStringList > getPostLaunchCommands (const QString &desktopPath, const QString &profileName)
void runLaunchHookCommand (const QStringList &argv, bool wait)
void runPreLaunchCommands (const QString &desktopPath, const QString &profileName)
void runPostLaunchCommands (const QString &desktopPath, const QString &profileName)

Enumeration Type Documentation

◆ IncludeNoDisplay

enum class IncludeNoDisplay
strong

If entries with NoDisplay=true should be included (Linux XDG).

Function Documentation

◆ clearConfigFilePathOverride()

void clearConfigFilePathOverride ( )

Clears the config file path override.

◆ getBrowsers()

QList< BrowserOption > getBrowsers ( IncludeNoDisplay includeNoDisplay = IncludeNoDisplay::No)
nodiscard

Finds available web browsers on the current platform.

Parameters
includeNoDisplayWhether to include entries with NoDisplay=true (Linux only).
Returns
List of BrowserOption objects.

◆ getChromeProfileDisplayName()

QString getChromeProfileDisplayName ( const QString & desktopPath,
const QString & profileId )
nodiscard

Resolves the profile display name for a saved option (Linux: Chromium profile; other backends may return empty).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileIdProfile identifier.
Returns
Display name for the profile, or empty if not found or not applicable.

◆ getChromeProfilePicturePath()

QString getChromeProfilePicturePath ( const QString & desktopPath,
const QString & profileId )
nodiscard

Resolves the full path to the Chrome/Chromium profile picture (gaia_picture_file_name in Local State).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileIdProfile identifier.
Returns
Full path to the picture file, or empty if not found or not applicable.

◆ getChromeUserDataDir()

QString getChromeUserDataDir ( const QString & desktopPath)
nodiscard

Returns the Chrome/Chromium user data directory for the given browser path. Used by getChromeProfileDisplayName and getChromeProfilePicturePath.

Parameters
desktopPathPath to the .desktop file (Linux), .app (macOS), or .exe (Windows).
Returns
User data directory path, or empty if not Chrome/Chromium or not found.

◆ getCommandLineForDisplay()

QString getCommandLineForDisplay ( const BrowserOption & option,
const QString & url = QString() )
nodiscard

Builds the command line for display (e.g. tooltip).

Parameters
optionThe browser option.
urlSingle URL to substitute, or empty.
Returns
The full command line string.

◆ getConfigFilePath()

QString getConfigFilePath ( )
nodiscard

Returns the path to the configuration file for the current platform. If setConfigFilePathOverride was called, returns that path instead.

Returns
Full path to the config file.

◆ getExecutablePath()

QString getExecutablePath ( const BrowserOption & option)
nodiscard

Returns the resolved full path to the browser executable.

Parameters
optionThe browser option.
Returns
Full path to the executable, or empty if not found.

◆ getPostLaunchCommands()

QList< QStringList > getPostLaunchCommands ( const QString & desktopPath,
const QString & profileName )
nodiscard

Returns the post-launch commands from config for the given browser or browser+profile. Key is the same as RememberedBrowsers: desktopPath, or desktopPath + "|" + profileName. Under group PostLaunchCommands. Value is a JSON array of arrays of strings. If no entry for browser+profile, falls back to browser-only (desktopPath).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileNameProfile identifier.
Returns
List of command argument lists.

◆ getPreLaunchCommands()

QList< QStringList > getPreLaunchCommands ( const QString & desktopPath,
const QString & profileName )
nodiscard

Returns the pre-launch commands from config for the given browser or browser+profile. Key is the same as RememberedBrowsers: desktopPath, or desktopPath + "|" + profileName. Under group PreLaunchCommands. Value is a JSON array of arrays of strings. If no entry for browser+profile, falls back to browser-only (desktopPath).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileNameProfile identifier.
Returns
List of command argument lists.

◆ isBrowserHidden()

bool isBrowserHidden ( const BrowserOption & option,
const QStringList & hiddenIdentifiers )
nodiscard

Returns true if the given option should be hidden (its desktop file base name is in hiddenIdentifiers, case-insensitive).

Parameters
optionThe browser option.
hiddenIdentifiersList of identifiers (e.g. desktop base names) to hide.

◆ launchBrowser()

void launchBrowser ( const BrowserOption & option,
const QStringList & urls = QStringList() )

Launches the given browser option with the specified URLs.

Parameters
optionThe browser and optional profile to launch.
urlsList of URLs to open; defaults to empty.

◆ listContainsIdentifier()

bool listContainsIdentifier ( const QStringList & list,
const QString & identifier )
nodiscard

Returns true if list contains identifier (case-insensitive).

Parameters
listList of strings to search.

◆ quoteArg()

QString quoteArg ( const QString & arg)
nodiscard

Quotes arg for display in a command line (handles space, quotes, backslash).

Parameters
argArgument to quote.

◆ readCommaSeparatedList()

QStringList readCommaSeparatedList ( const QString & key)
nodiscard

Reads a comma-separated list from the config file (e.g. Advanced/hideProfileBrowsers).

Parameters
keySettings key to read.

◆ runLaunchHookCommand()

void runLaunchHookCommand ( const QStringList & argv,
bool wait )

Runs a launch-hook command (pre or post). Executes argv directly (no shell).

Parameters
argvProgram as first element, then arguments. Empty or single empty string is a no-op.
waitIf true, block until the command exits; if false, start detached.

◆ runPostLaunchCommands()

void runPostLaunchCommands ( const QString & desktopPath,
const QString & profileName )

Runs all post-launch commands for the given browser or browser+profile (detached).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileNameProfile identifier.

◆ runPreLaunchCommands()

void runPreLaunchCommands ( const QString & desktopPath,
const QString & profileName )

Runs all pre-launch commands for the given browser or browser+profile (synchronously).

Parameters
desktopPathPath to the .desktop file (Linux) or backend-specific identifier.
profileNameProfile identifier.

◆ setConfigFilePathOverride()

void setConfigFilePathOverride ( const QString & path)

Overrides the config file path (for tests). getConfigFilePath() returns this until cleared.

Parameters
pathOverride path, or empty to clear.

◆ sortBrowserOptionsByDisplayName()

void sortBrowserOptionsByDisplayName ( QList< BrowserOption > & options)

Sorts browser options by display name (case-insensitive).

Parameters
optionsList of BrowserOption objects to sort.