Skip to content

Commit 29af6a2

Browse files
Update
1 parent cf52a39 commit 29af6a2

File tree

9 files changed

+192
-276
lines changed

9 files changed

+192
-276
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HIDE_UNDOC_MEMBERS = YES
2525
HIDE_UNDOC_CLASSES = YES
2626
HIDE_FRIEND_COMPOUNDS = YES
2727
HIDE_IN_BODY_DOCS = YES
28-
EXCLUDE_SYMBOLS = albert::detail
28+
EXCLUDE_SYMBOLS = albert::ResultItem albert::util::Dependency
2929

3030
JAVADOC_AUTOBRIEF = YES
3131
LAYOUT_FILE = DoxygenLayout.xml

src/_sass/custom/custom.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ body {
1717

1818
kbd {
1919
border: .5px solid gray;
20-
border-radius: 4px;
21-
box-shadow: 0px 2px 4px gray;
20+
border-radius: 6px;
21+
box-shadow: 0px 1px 2px 0px gray;
2222
display: inline-block;
2323
font-size: .9em;
24-
padding: 0.1em .5em 0em .5em;
24+
padding: .1em .5em 0.0em .5em;
2525
margin: 0em .3em;
2626
color: gray;
2727
white-space: nowrap;

src/gettingstarted/basics.md

Lines changed: 71 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,101 +10,108 @@ nav_order: 1
1010
- TOC
1111
{:toc}
1212

13-
## User interface
1413

15-
The following uses [Qt terminology](https://doc.qt.io/qt-6/qt.html#KeyboardModifier-enum) for modifier key names.
16-
The following table shows the mapping of modifier keys on different keyboards:
14+
## Plugins
15+
16+
A **plugin** is a physical module that can be loaded/unloaded at runtime.
17+
It could be native or provided by plugin provider plugins.
18+
Nested plugins are accessible when their provider is loaded.
19+
20+
Users can **enable**/**disable** and **load**/**unload** plugins via the plugins tab in the settings
21+
or using the built-in plugin query handler.
22+
Enabled plugins load automatically at launch.
23+
Plugins with graphical interfaces for configuration can be accessed via the plugins tab in the settings.
1724

18-
| Qt | Linux/Win | MacOS |
19-
|-----------------|-----------------|------------------------------------|
20-
| <kbd>Ctrl</kbd> | <kbd>Ctrl</kbd> | <kbd>command</kbd> /<kbd>⌘</kbd> |
21-
| <kbd>Meta</kbd> | <kbd>Win</kbd> | <kbd>control</kbd> /<kbd>⌃</kbd> |
22-
| <kbd>Alt</kbd> | <kbd>Alt</kbd> | <kbd>option</kbd> /<kbd>⌥</kbd> |
25+
Each plugin has an identifier.
26+
Plugin providers search multiple implementation- and platform-specific plugin paths.
27+
The search order proceeds from user-specific to system-wide locations.
28+
The **first plugin found for an identifier is used**.
2329

2430

25-
Besides its primary function, the input line displays the *input action text* and *input hint* and contains the *settings button*.
31+
## Extensions
32+
33+
An **extension** is a logical unit extending the app with a particular functionality.
34+
Each plugin can provide multiple *extension implementations* and expose its own *extension interfaces*.
35+
More on this topic can be found in the [Extension](/gettingstarted/extension/) section
2636

27-
If available the **input action text** will be displayed right beside your input.
28-
It is provided by the currently selected item in the *results list*.
37+
38+
## Queries
39+
40+
There are three built-in extension interfaces that handle user input:
41+
42+
If the query starts with a trigger of a **trigger query handler extension**,
43+
the query is handled _exclusively_ by the corresponding handler.
44+
This allows the handler to _set an inline input hint_, _asynchronously add match items_ and as such _define their order_.
45+
46+
If the query does _not_ start with a trigger,
47+
the query is handled by all enabled **global query handler extensions** in _parallel_
48+
and eventually the match items are _merged_ and _sorted by match and usage score_.
49+
50+
There is one special
51+
52+
In any case the enabled **fallback handler extensions** provide a separate set of _fallbacks items_,
53+
which are displayed when the matches are empty or when the user explicitly requests them.
54+
55+
56+
## Result items
57+
58+
Besides the obvious **icon**, **title** and **description**,
59+
each item provides a **list of actions** the user can execute.
60+
Items may also define an **input action text**,
61+
which is used to replace the current input on input action activation.
2962
Its semantics are loosely defined; it may be a completion, an evaluation, or something else.
30-
Hit <kbd>Tab</kbd> to replace the current input with this text.
3163

32-
If space permits, the **input hint** will be displayed right-aligned in the input box.
33-
It serves as a reminder for hard-to-remember synopses.
3464

35-
The **settings button** is located in the top-right corner of the input line.
36-
It appears on mouse hover and also serves as a **busy indicator**, e.g., when a query is being processed.
65+
## User interface
66+
67+
<picture>
68+
<source srcset="/img/ui_dark.png" media="(prefers-color-scheme: dark)">
69+
<img src="/img/ui_light.png" alt="Logo">
70+
</picture>
71+
72+
Besides its primary function, the input line displays the *input action text* and *input hint* and contains the *settings button*.
73+
If the input starts with a **trigger** of a trigger query handler, it is highlighted.
74+
If available the **input action text** of the currently selected item will be displayed right beside your input.
75+
Hit <kbd>Tab</kbd> to replace the current input with it.
76+
If space permits, the **input hint** of the query handler will be displayed right-aligned in the input box.
77+
The **settings button** is appears on the right side of the input line if you hover over it
78+
or if a query a query is being processed.
3779
Left-clicking opens the **settings window**, while right-clicking shows a context menu.
3880

3981
The manually entered text of the input line is stored in the **input history** when the window is hidden.
4082
This input history can be used to search and browse your past input.
41-
When the results list is hidden or the first item is selected <kbd>⬆</kbd> iterates the input history in reverse order.
42-
Holding <kbd>Shift</kbd> enables **input history navigation** for <kbd>⬆</kbd> and <kbd></kbd> no matter which item is selected.
83+
Holding <kbd>Shift</kbd> enables **input history navigation** for <kbd>⬆</kbd> and <kbd>⬇</kbd> no matter which item is selected.
84+
When the results list is hidden or the first item is selected <kbd>⬆</kbd> works without holding <kbd>Shift</kbd>.
4385

4486
If enabled, the (manually set) input text is used for **input history search**.
4587
Input history navigation then only shows input history entries matching the input text.
4688

4789
The results list displays **result items** of a query.
48-
Hold and release <kbd>Meta</kbd> to switch between **match items** and **fallback items**.
90+
Hold and release <kbd>Super⌃</kbd> to switch between **match items** and **fallback items**.
4991

5092
Result items can have multiple associated *actions*.
5193
The **default action** of an item is activated by pressing <kbd>Return</kbd> or <kbd>Enter</kbd>.
52-
To display and navigate the list of **alternative actions** of an item hold <kbd>Alt</kbd> .
53-
54-
55-
### Key map
94+
To display the list of **alternative actions** of an item <kbd>Ctrl⌘</kbd>+<kbd>Return</kbd> or hold <kbd>Alt⌥</kbd> .
5695

5796
As a reference the following table lists the keys you can use to control Albert:
5897

5998
| Key | Action |
6099
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
61100
| <kbd>Esc</kbd> | Hide the window. |
62-
| <kbd>Alt (Hold)</kbd><br><kbd>Ctrl</kbd>+<kbd>Return</kbd> | Show actions. |
63-
| <kbd>Meta (Hold)</kbd> | Show fallbacks. |
101+
| <kbd>Alt (Hold)</kbd><br><kbd>Ctrl</kbd>+<kbd>Return</kbd> | Show actions. |
102+
| <kbd>Super⌃ (Hold)</kbd> | Show fallbacks. |
64103
| <kbd>Shift</kbd>+<kbd>⬆</kbd> | Next entry in input history. |
65104
| <kbd>Shift</kbd>+<kbd>⬇</kbd> | Previous entry in input history. |
66105
| <kbd>Tab</kbd> | Activate input action of the selected item (evaluation, completion, etc). |
67-
| <kbd>Return</kbd>,<kbd>Ctrl</kbd>+<kbd>O</kbd> | Activate item. |
106+
| <kbd>Return</kbd>,<kbd>Ctrl</kbd>+<kbd>O</kbd> | Activate item. |
68107
| <kbd>Shift</kbd>+<kbd>Return</kbd> | Insert new line. |
69-
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Return</kbd><br><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>O</kbd> | Activate item but do not hide. |
70-
| <kbd>Ctrl</kbd>+<kbd>,</kbd> | Open settings window. |
108+
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Return</kbd><br><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>O</kbd> | Activate item but do not hide. |
109+
| <kbd>Ctrl</kbd>+<kbd>,</kbd> | Open settings window. |
71110
| <kbd>⬆</kbd>,<kbd>⬇</kbd>,<br><kbd>PgUp</kbd>,<kbd>PgDn</kbd> | Navigation in item lists. |
72-
| <kbd>Alt</kbd>+<kbd>F4</kbd>,<kbd>⌘</kbd>+<kbd>Q</kbd> | Quit Albert (Depends on settings). |
73-
| <kbd>Ctrl</kbd>+<kbd>H</kbd>/<kbd>J</kbd>/<kbd>K</kbd>/<kbd>L</kbd> | Vim bindings. Synthesize to arrows. |
74-
| <kbd>Ctrl</kbd>+<kbd>N</kbd>/<kbd>P</kbd> | Emacs bindings. Synthesize to arrows. |
75-
76-
77-
## Plugins and extensions
78-
79-
A **plugin** is a physical module that can be loaded/unloaded at runtime.
80-
It could be native or provided by plugin provider plugins.
81-
Nested plugins are accessible when their provider is loaded.
82-
83-
Users can **enable**/**disable** or **load**/**unload** plugins via the plugins tab in the settings
84-
or using the built-in plugin query handler.
85-
Enabled plugins load automatically at launch.
86-
Plugins with graphical interfaces for configuration can be accessed via the plugins tab in the settings.
87-
88-
An **extension** is a logical module that can be used to add functionality to the app.
89-
Each plugin can provide multiple *extension implementations* or even expose its own *extension interfaces*.
90-
More on this topic can be found in the [Extension](/gettingstarted/extension/) section
91-
92-
93-
## Queries
94-
95-
The core of the app is the query engine which parses user input and determines the **mode of a query**.
96-
97-
If the input starts with a trigger of a **trigger query handler**, the query engine instantiates a
98-
**trigger query** execution that is exclusively handled by the corresponding handler.
99-
This allows the handler to *asynchronously* add matches and as such define their *order*.
100-
101-
If the user input does *not* start with a trigger of a trigger query handler, the query engine
102-
instantiates a **global query** execution that executes the enabled **global query handlers** *in parallel*
103-
and eventually gathers and *sorts* their matches.
111+
| <kbd>Alt⌥</kbd>+<kbd>F4</kbd>,<kbd>⌘</kbd>+<kbd>Q</kbd> | Quit Albert (Depends on settings). |
112+
| <kbd>Ctrl⌘</kbd>+<kbd>H</kbd>/<kbd>J</kbd>/<kbd>K</kbd>/<kbd>L</kbd> | Vim bindings. Synthesize to arrows. |
113+
| <kbd>Ctrl⌘</kbd>+<kbd>N</kbd>/<kbd>P</kbd> | Emacs bindings. Synthesize to arrows. |
104114

105-
Both query executions eventually yield a set of **query matches** which may be empty.
106115

107-
The **fallback handlers** of a query provide a separate set of result items, the **query fallbacks**,
108-
which can handle any string.
109-
They are displayed when no matches were found or when the user explicitly requests them.
110116

117+

src/gettingstarted/extension/cplusplus.md

Lines changed: 26 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,55 @@
22
title: C++
33
parent: Extension
44
grand_parent: Getting started
5-
nav_order: 1
5+
nav_order: 0
66
---
77

88
# Extending Albert using C++
99
{: .no_toc }
1010

1111
{: .note }
1212
This page focuses on the practical aspects of extending Albert using C++ and its peculiarities.
13-
To get a high level overview of common concepts of the API refer to the [general](/gettingstarted/extension/general) section.
13+
To get an overview of the API refer to the general [extension](/gettingstarted/extension/) section.
1414

1515
- TOC
1616
{:toc}
1717

18-
A native plugin is a [Qt Plugin](https://doc.qt.io/qt-6/plugins-howto.html#the-low-level-api-extending-qt-applications), i.e. a shared library providing an instance of the class `PluginInstance`.
18+
A native plugin is a [Qt Plugin](https://doc.qt.io/qt-6/plugins-howto.html#the-low-level-api-extending-qt-applications),
19+
i.e. a shared library providing an instance of the class `PluginInstance`.
1920

20-
Albert provides `C` and `CMake` macros that implement conventions to streamline the plugin development
21-
process and to reduce the considerable amount of boilerplate code required to a few lines of code.
2221

23-
## CMake
22+
## Writing native C++ plugins
2423

25-
Having a standardized plugin project structure the `albert_plugin` macro takes care of most of the CMake boilerplate code.
26-
It is part of the `albert` CMake module and can be included using `find_package(Albert REQUIRED)`.
27-
Read its documentation in the header of the [CMake module](https://raw.githubusercontent.com/albertlauncher/albert/main/cmake/albert-macros.cmake) before you proceed.
24+
Albert provides `C` and `CMake` macros that implement conventions to streamline the plugin development
25+
process and reduce the boilerplate code required to a few lines of code.
26+
Read the documentation in the header of the [`Albert` CMake module ](https://raw.githubusercontent.com/albertlauncher/albert/main/cmake/albert-macros.cmake) before you proceed.
2827

29-
A minimal working CMakeLists.txt (See also the [CMakeLists.txt files of the official plugins](https://github.com/search?q=repo%3Aalbertlauncher%2Fplugins+path%3A**%2FCMakeLists.txt&type=code)):
28+
A minimal `CMakeLists.txt`:
3029

3130
```cmake
3231
project(my_plugin VERSION 1.0)
3332
find_package(Albert REQUIRED)
3433
albert_plugin()
3534
```
3635

37-
This is the standard plugin directory structure of a plugin:
38-
39-
```
40-
─┬─ my_plugin
41-
├── CMakeLists.txt
42-
├── metadata.json
43-
├─┬─ src
44-
│ └── …
45-
└─┬─ i18n
46-
└── …
47-
```
48-
49-
A basic metadata file looks like this (See also the [metadata.json files of the official plugins](https://github.com/search?q=repo%3Aalbertlauncher%2Fplugins+path%3A**%2Fmetadata.json&type=code)):
36+
A minimal `metadata.json`:
5037

5138
```json
5239
{
5340
"name": "My Plugin",
5441
"description": "Do useful stuff",
5542
"authors": ["@myname"],
56-
"license": "MIT",
57-
"url": "https://github.com/myusername/my-albert-plugin",
43+
"license": "MIT"
5844
}
5945
```
6046

61-
## C++
62-
63-
Albert plugins ultimately have to inherit the `QObject` and [`PluginInstance`](https://albertlauncher.github.io/reference/classalbert_1_1PluginInstance.html) class and
64-
contain the `ALBERT_PLUGIN` macro in the declaration body.
65-
66-
A basic plugin looks like this (See also the [plugin header files of the official plugins](https://github.com/search?q=repo%3Aalbertlauncher%2Fplugins+path%3A**%2FPlugin.h&type=code)):
67-
68-
```cpp
69-
#pragma once
70-
#include <albert/extensionplugin.h>
71-
#include <albert/triggerqueryhandler.h>
72-
73-
class Plugin : public QObject, public albert::PluginInstance
74-
{
75-
ALBERT_PLUGIN
76-
};
77-
```
78-
79-
Usually you dont want to subclass `PluginInstance` directly but rather [`ExtensionPlugin`](https://albertlauncher.github.io/reference/classalbert_1_1ExtensionPlugin.html)
80-
which implements the [`Extension`](https://albertlauncher.github.io/reference/classalbert_1_1Extension.html) interface using the metadata of the plugin instance.
81-
47+
A plugin class has to be default-constructible,
48+
inherit `QObject` and [`PluginInstance`](https://albertlauncher.github.io/reference/classalbert_1_1PluginInstance.html)
49+
and contain the [`ALBERT_PLUGIN`](/reference/plugininstance_8h.html#a8787b7c8c0b456d908480300c22d3f5f) macro in its body.
50+
However, if subclassing an extension interface,
51+
you'd rather inherit [`util::ExtensionPlugin`](https://albertlauncher.github.io/reference/classalbert_1_1ExtensionPlugin.html) for convenience.
52+
A minimal trigger query handler plugin:
53+
8254
```cpp
8355
#pragma once
8456
#include <albert/extensionplugin.h>
@@ -88,31 +60,25 @@ class Plugin : public albert::ExtensionPlugin,
8860
public albert::TriggerQueryHandler
8961
{
9062
ALBERT_PLUGIN
91-
void handleTriggerQuery(albert::Query &) override {}
63+
void handleTriggerQuery(albert::Query &query) override
64+
{
65+
// Handle query
66+
}
9267
};
9368
```
9469

95-
From here on it depends on the interface you want to implement.
96-
Read through the [albert namespace reference](https://albertlauncher.github.io/reference/namespacealbert.html).
97-
See the [official native plugins](https://github.com/albertlauncher/plugins/tree/main/) as a reference.
98-
Concise examples to start with are: `debug`, `timezones`, `hash` or `urlhandler`.
70+
Next, skim through the [API reference](https://albertlauncher.github.io/reference/namespacealbert.html).
71+
For reference see the [official plugins](https://github.com/albertlauncher/albert/tree/main/plugins).
9972

100-
## Plugin directories
10173

102-
The plugin directories depends on the platform and the build type.
74+
## Plugin directories
10375

10476
- **Linux**:
10577
- `~/.local/{lib,lib64}/albert`
10678
- `/usr/local/{lib,lib64}/albert`
10779
- `/usr/lib/${MULTIARCH_TUPLE}/albert`
10880
- `/usr/{lib,lib64}/albert`
10981
- **macOS**:
110-
- `$BUNDLE_PATH/Contents/PlugIns`
11182
- `~/Library/Application Support/Albert/plugins`
112-
113-
The plugin directories are scanned in the order of the above list.
114-
On start Albert scans the plugin directories for available plugins.
115-
Since identifiers have to be unique, duplicate plugins with the same identifier (project name) are skipped.
116-
117-
83+
- `$BUNDLE_PATH/Contents/PlugIns`
11884

0 commit comments

Comments
 (0)