Albert
Loading...
Searching...
No Matches
albert::util Namespace Reference

Albert utility namespace. More...

Classes

class  BackgroundExecutor
 Provides a lean interface for recurring indexing tasks. More...
 
class  Dependency
 
class  Download
 Downloads a file from the given URL to the given path. More...
 
class  ExtensionPlugin
 Convenience base class for extension plugins. More...
 
class  IndexItem
 An item utlized by ItemIndex. More...
 
class  IndexQueryHandler
 Index query handler class. More...
 
class  InputHistory
 Input history class. More...
 
class  Match
 Augmented match score. More...
 
class  MatchConfig
 Configuration for string matching. More...
 
class  Matcher
 Configurable string matcher. More...
 
class  Notification
 The notification class. More...
 
class  OAuth2
 Provides OAuth2 authentication with support for the Authorization Code Flow with PKCE and refresh tokens. More...
 
class  OAuthConfigWidget
 
class  StandardItem
 General purpose Item implementation. More...
 
class  StrongDependency
 Convenience holder class for plugin hard dependencies. More...
 
class  WeakDependency
 Convenience holder class for plugin soft dependencies. More...
 

Functions

const QRegularExpression default_separator_regex (QStringLiteral("([\\s\\\\/\\-\\[\\](){}#!?<>\"'=+*.:,;_]+)"))
 
bool question (const QString &text, QWidget *parent=nullptr)
 Shows a question message box with Yes and No buttons.
 
void information (const QString &text, QWidget *parent=nullptr)
 Shows an information message box with a single Ok button.
 
void warning (const QString &text, QWidget *parent=nullptr)
 Shows a warning message box with a single Ok button.
 
void critical (const QString &text, QWidget *parent=nullptr)
 Shows a critical message box with a single Ok button.
 
QNetworkAccessManager & network ()
 Returns a global, threadlocal QNetworkAccessManager.
 
QNetworkReply * await (QNetworkReply *reply)
 Blocks until reply is finished.
 
void openUrl (const QString &url)
 Opens url with the default handler for the scheme.
 
void open (const QUrl &url)
 Opens url with the default handler for the scheme.
 
void open (const QString &path)
 Opens a file at path with the associated default application.
 
void open (const std::filesystem::path &path)
 Opens a file at path with the associated default application.
 
void setClipboardText (const QString &text)
 Sets the system clipboard to text.
 
bool havePasteSupport ()
 Returns the true if the platform supports pasting, else false.
 
void setClipboardTextAndPaste (const QString &text)
 Sets the system clipboard to text and pastes text to the front-most window.
 
long long runDetachedProcess (const QStringList &commandline)
 Run the commandline as detached process. Returns the process id.
 
long long runDetachedProcess (const QStringList &commandline, const QString &working_dir)
 Run the commandline with working_dir as detached process. Returns the process id.
 
void tryCreateDirectory (const std::filesystem::path &path)
 Tries to create a directory at path.
 
QString toQString (const std::filesystem::path &path)
 Returns a QString representation of path.
 
template<typename T , typename GET , typename SET >
void bind (QCheckBox *checkbox, T *object, GET get, SET set)
 Binds a property of type bool of object to checkbox.
 
template<typename T , typename GET , typename SET , typename SIG >
void bind (QCheckBox *checkbox, T *object, GET get, SET set, SIG sig)
 Binds a property of type bool of object to checkbox.
 
template<typename T , typename GET , typename SET >
void bind (QLineEdit *lineedit, T *object, GET get, SET set)
 Binds a property of type QString of object to lineedit.
 
template<typename T , typename GET , typename SET , typename SIG >
void bind (QLineEdit *lineedit, T *object, GET get, SET set, SIG sig)
 Binds a property of type QString of object to lineedit.
 
template<typename T , typename GET , typename SET >
void bind (QSpinBox *spinbox, T *object, GET get, SET set)
 Binds a property of type int of object to spinbox.
 
template<typename T , typename GET , typename SET , typename SIG >
void bind (QSpinBox *spinbox, T *object, GET get, SET set, SIG sig)
 Binds a property of type int of object to spinbox.
 
template<typename T , typename GET , typename SET >
void bind (QDoubleSpinBox *spinbox, T *object, GET get, SET set)
 Binds a property of type double of object to spinbox.
 
template<typename T , typename GET , typename SET , typename SIG >
void bind (QDoubleSpinBox *spinbox, T *object, GET get, SET set, SIG sig)
 Binds a property of type double of object to spinbox.
 

Detailed Description

Albert utility namespace.

Function Documentation

◆ await()

QNetworkReply * albert::util::await ( QNetworkReply *  reply)

Blocks until reply is finished.

◆ bind() [1/8]

template<typename T , typename GET , typename SET >
void albert::util::bind ( QCheckBox *  checkbox,
T *  object,
GET  get,
SET  set 
)

Binds a property of type bool of object to checkbox.

Initializes checkbox using get and connects the toggled signal to set.

◆ bind() [2/8]

template<typename T , typename GET , typename SET , typename SIG >
void albert::util::bind ( QCheckBox *  checkbox,
T *  object,
GET  get,
SET  set,
SIG  sig 
)

Binds a property of type bool of object to checkbox.

Initializes checkbox using get, connects the toggled signal to set and connects the signal sig to setChecked.

◆ bind() [3/8]

template<typename T , typename GET , typename SET >
void albert::util::bind ( QDoubleSpinBox *  spinbox,
T *  object,
GET  get,
SET  set 
)

Binds a property of type double of object to spinbox.

Initializes spinbox using get and connects the valueChanged signal to set.

◆ bind() [4/8]

template<typename T , typename GET , typename SET , typename SIG >
void albert::util::bind ( QDoubleSpinBox *  spinbox,
T *  object,
GET  get,
SET  set,
SIG  sig 
)

Binds a property of type double of object to spinbox.

Initializes spinbox using get, connects the valueChanged signal to set and connects the signal sig to setValue.

◆ bind() [5/8]

template<typename T , typename GET , typename SET >
void albert::util::bind ( QLineEdit *  lineedit,
T *  object,
GET  get,
SET  set 
)

Binds a property of type QString of object to lineedit.

Initializes lineedit using get and connects the editingFinished signal to set.

◆ bind() [6/8]

template<typename T , typename GET , typename SET , typename SIG >
void albert::util::bind ( QLineEdit *  lineedit,
T *  object,
GET  get,
SET  set,
SIG  sig 
)

Binds a property of type QString of object to lineedit.

Initializes lineedit using get, connects the editingFinished signal to set and connects the signal sig to setText.

◆ bind() [7/8]

template<typename T , typename GET , typename SET >
void albert::util::bind ( QSpinBox *  spinbox,
T *  object,
GET  get,
SET  set 
)

Binds a property of type int of object to spinbox.

Initializes spinbox using get and connects the valueChanged signal to set.

◆ bind() [8/8]

template<typename T , typename GET , typename SET , typename SIG >
void albert::util::bind ( QSpinBox *  spinbox,
T *  object,
GET  get,
SET  set,
SIG  sig 
)

Binds a property of type int of object to spinbox.

Initializes spinbox using get, connects the valueChanged signal to set and connects the signal sig to setValue.

◆ critical()

void albert::util::critical ( const QString &  text,
QWidget *  parent = nullptr 
)

Shows a critical message box with a single Ok button.

The title of the message box is set to the application name and the message to text. The message box will appear modal to parent or the main window if undefined.

◆ default_separator_regex()

const QRegularExpression albert::util::default_separator_regex ( QStringLiteral("([\\s\\\\/\\-\\[\\](){}#!?<>\"'=+*.:,;_]+)")  )

◆ havePasteSupport()

bool albert::util::havePasteSupport ( )

Returns the true if the platform supports pasting, else false.

◆ information()

void albert::util::information ( const QString &  text,
QWidget *  parent = nullptr 
)

Shows an information message box with a single Ok button.

The title of the message box is set to the application name and the message to text. The message box will appear modal to parent or the main window if undefined.

◆ network()

QNetworkAccessManager & albert::util::network ( )

Returns a global, threadlocal QNetworkAccessManager.

◆ open() [1/3]

void albert::util::open ( const QString &  path)

Opens a file at path with the associated default application.

◆ open() [2/3]

void albert::util::open ( const QUrl &  url)

Opens url with the default handler for the scheme.

◆ open() [3/3]

void albert::util::open ( const std::filesystem::path &  path)

Opens a file at path with the associated default application.

◆ openUrl()

void albert::util::openUrl ( const QString &  url)

Opens url with the default handler for the scheme.

Does nothing if url is not a valid URL.

◆ question()

bool albert::util::question ( const QString &  text,
QWidget *  parent = nullptr 
)

Shows a question message box with Yes and No buttons.

The title of the message box is set to the application name and the message to text. The message box will appear modal to parent or the main window if undefined. Returns true if the user pressed yes, false otherwise.

◆ runDetachedProcess() [1/2]

long long albert::util::runDetachedProcess ( const QStringList commandline)

Run the commandline as detached process. Returns the process id.

◆ runDetachedProcess() [2/2]

long long albert::util::runDetachedProcess ( const QStringList commandline,
const QString &  working_dir 
)

Run the commandline with working_dir as detached process. Returns the process id.

◆ setClipboardText()

void albert::util::setClipboardText ( const QString &  text)

Sets the system clipboard to text.

◆ setClipboardTextAndPaste()

void albert::util::setClipboardTextAndPaste ( const QString &  text)

Sets the system clipboard to text and pastes text to the front-most window.

Check albert::havePasteSupport before using this function.

◆ toQString()

QString albert::util::toQString ( const std::filesystem::path &  path)

Returns a QString representation of path.

◆ tryCreateDirectory()

void albert::util::tryCreateDirectory ( const std::filesystem::path &  path)

Tries to create a directory at path.

Throws std::runtime_error if the directory could not be created. This is a utility function for use with the *Location functions.

◆ warning()

void albert::util::warning ( const QString &  text,
QWidget *  parent = nullptr 
)

Shows a warning message box with a single Ok button.

The title of the message box is set to the application name and the message to text. The message box will appear modal to parent or the main window if undefined.