160 void showEvent(QShowEvent* event)
override;
161 bool eventFilter(QObject* obj, QEvent* event)
override;
164 void onSearchTextChanged(
const QString& text);
165 void onItemActivated(QListWidgetItem* item);
166 void onItemDoubleClicked(QListWidgetItem* item);
170 void populateResults(
const QString& query);
171 void executeCommand(
const QString& commandId);
172 void addToRecentCommands(
const QString& commandId);
173 void selectNextItem();
174 void selectPreviousItem();
179 std::vector<PaletteCommand> staticCommands_;
180 std::vector<std::function<std::vector<PaletteCommand>()>> dynamicProviders_;
183 QStringList recentCommands_;
184 static constexpr int MAX_RECENT_COMMANDS = 10;
187 QLineEdit* searchEdit_ =
nullptr;
188 QListWidget* resultsList_ =
nullptr;
189 QLabel* hintLabel_ =
nullptr;
192 QTimer* searchDebounceTimer_ =
nullptr;
193 static constexpr int SEARCH_DEBOUNCE_MS = 50;
259 cmd_.
action = std::move(fn);
264 cmd_.isEnabled = std::move(fn);
269 cmd_.isVisible = std::move(fn);
CommandBuilder & visibleWhen(std::function< bool()> fn)
CommandBuilder & priority(int p)
CommandBuilder & icon(const QString &icon)
CommandBuilder & shortcut(const QString &sc)
CommandBuilder & category(const QString &cat)
CommandBuilder & enabledWhen(std::function< bool()> fn)
CommandBuilder & label(const QString &label)
CommandBuilder & description(const QString &desc)
PaletteCommand build() const
CommandBuilder(const QString &id)
CommandBuilder & action(std::function< void()> fn)
void clearCommands()
Clear all registered commands.
void showPalette()
Show the palette and focus the search field.
void unregisterCategory(const QString &category)
Remove all commands in a category.
void registerCommands(const std::vector< PaletteCommand > &commands)
Register multiple commands at once.
void keyPressEvent(QKeyEvent *event) override
void unregisterCommand(const QString &id)
Remove a command by ID.
bool eventFilter(QObject *obj, QEvent *event) override
void registerCommand(const PaletteCommand &cmd)
Register a single command.
void showEvent(QShowEvent *event) override
void registerDynamicProvider(std::function< std::vector< PaletteCommand >()> provider)
Register a provider for dynamic commands.
CommandPalette(MainWindow *parent, ThemeManager *themeManager=nullptr)
~CommandPalette() override
QStringList getRecentCommands(int limit=5) const
Get the list of recently used command IDs.
Represents a single command in the palette.
int matchScore(const QString &query) const
std::function< bool()> isEnabled
std::function< bool()> isVisible
std::function< void()> action