Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
CommandProvider.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
6#include <PhosphorShellLauncher/phosphorshelllauncher_export.h>
7
8#include <QList>
9#include <QString>
10
11namespace PhosphorShellLauncher {
12
13// Runs what was typed as a shell command line. Enter runs it detached;
14// Alt+Enter runs it inside a terminal.
15//
16// Offered only when the first word resolves to an executable (on PATH,
17// or an absolute path), so ordinary searches like "fire" do not grow a
18// "run fire" row. Scores 1, which is below any solid fuzzy match, so an
19// application matching the same text outranks the raw command.
20//
21// Not a true floor, though the name suggests one: fuzzy scores go NEGATIVE
22// for a sparse, heavily gapped match, so a barely-matching application can
23// still rank below this row. That is the right order when it happens: a
24// command the user typed exactly beats a word the matcher had to stretch
25// to reach.
26class PHOSPHORSHELLLAUNCHER_EXPORT CommandProvider : public PhosphorRegistry::ILauncherProvider
27{
28 Q_OBJECT
29
30public:
31 explicit CommandProvider(QObject* parent = nullptr);
32 ~CommandProvider() override;
33
34 [[nodiscard]] QString id() const override;
35 [[nodiscard]] QString displayName() const override;
36 [[nodiscard]] QString iconName() const override;
37
38 void setQuery(const QString& query) override;
39 [[nodiscard]] QList<PhosphorRegistry::LauncherResult> results() const override;
40 [[nodiscard]] bool activate(const QString& resultId, Activation activation) override;
41
42 // The executable the command line would start, resolved the way the
43 // provider resolves it, or empty when it would not start anything.
44 // Public and static so the gating rule is testable on its own.
45 [[nodiscard]] static QString resolveProgram(const QString& commandLine);
46
47private:
48 QString m_query;
49 QList<PhosphorRegistry::LauncherResult> m_results;
50};
51
52} // namespace PhosphorShellLauncher
Definition ILauncherProvider.h:106
Activation
Definition ILauncherProvider.h:112
CommandProvider(QObject *parent=nullptr)
QList< PhosphorRegistry::LauncherResult > results() const override
QString displayName() const override
static QString resolveProgram(const QString &commandLine)
bool activate(const QString &resultId, Activation activation) override
void setQuery(const QString &query) override
QString iconName() const override
Definition AppsProvider.h:19