game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
CommandPalette Class Reference

Modal dialog providing fuzzy-searchable command list. More...

#include <command_palette.h>

Inheritance diagram for CommandPalette:
Collaboration diagram for CommandPalette:

Public Member Functions

 CommandPalette (MainWindow *parent, ThemeManager *themeManager=nullptr)
 ~CommandPalette () override
void clearCommands ()
 Clear all registered commands.
QStringList getRecentCommands (int limit=5) const
 Get the list of recently used command IDs.
void registerCommand (const PaletteCommand &cmd)
 Register a single command.
void registerCommands (const std::vector< PaletteCommand > &commands)
 Register multiple commands at once.
void registerDynamicProvider (std::function< std::vector< PaletteCommand >()> provider)
 Register a provider for dynamic commands.
void showPalette ()
 Show the palette and focus the search field.
void unregisterCategory (const QString &category)
 Remove all commands in a category.
void unregisterCommand (const QString &id)
 Remove a command by ID.

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
void keyPressEvent (QKeyEvent *event) override
void showEvent (QShowEvent *event) override

Detailed Description

Modal dialog providing fuzzy-searchable command list.

Features:

  • Fuzzy search with scoring (prefix matches score higher)
  • Keyboard navigation (Up/Down/Enter/Escape)
  • Recently used commands shown first
  • Category grouping in results
  • Dynamic command state (enabled/disabled based on context)

Usage: auto palette = new CommandPalette(mainWindow); palette->registerCommands(commands); palette->show(); // Or connect to Ctrl+Shift+P shortcut

Definition at line 88 of file command_palette.h.

Constructor & Destructor Documentation

◆ CommandPalette()

CommandPalette::CommandPalette ( MainWindow * parent,
ThemeManager * themeManager = nullptr )
explicit

Definition at line 250 of file command_palette.cpp.

References ThemeManager::themeChanged().

◆ ~CommandPalette()

CommandPalette::~CommandPalette ( )
override

Definition at line 268 of file command_palette.cpp.

Member Function Documentation

◆ clearCommands()

void CommandPalette::clearCommands ( )

Clear all registered commands.

Definition at line 428 of file command_palette.cpp.

◆ eventFilter()

bool CommandPalette::eventFilter ( QObject * obj,
QEvent * event )
overrideprotected

Definition at line 494 of file command_palette.cpp.

◆ getRecentCommands()

QStringList CommandPalette::getRecentCommands ( int limit = 5) const

Get the list of recently used command IDs.

Parameters
limitMaximum number to return
Returns
List of command IDs, most recent first

Definition at line 775 of file command_palette.cpp.

◆ keyPressEvent()

void CommandPalette::keyPressEvent ( QKeyEvent * event)
overrideprotected

Definition at line 469 of file command_palette.cpp.

◆ registerCommand()

void CommandPalette::registerCommand ( const PaletteCommand & cmd)

Register a single command.

Parameters
cmdCommand to register

Definition at line 390 of file command_palette.cpp.

Referenced by registerCommands().

◆ registerCommands()

void CommandPalette::registerCommands ( const std::vector< PaletteCommand > & commands)

Register multiple commands at once.

Parameters
commandsVector of commands to register

Definition at line 405 of file command_palette.cpp.

References registerCommand().

◆ registerDynamicProvider()

void CommandPalette::registerDynamicProvider ( std::function< std::vector< PaletteCommand >()> provider)

Register a provider for dynamic commands.

Parameters
providerFunction that returns commands based on current state

Dynamic providers are called each time the palette opens to add context-sensitive commands (e.g., "Stop [Game Name]" when a game is running).

Definition at line 433 of file command_palette.cpp.

◆ showEvent()

void CommandPalette::showEvent ( QShowEvent * event)
overrideprotected

Definition at line 463 of file command_palette.cpp.

◆ showPalette()

void CommandPalette::showPalette ( )

Show the palette and focus the search field.

Definition at line 438 of file command_palette.cpp.

◆ unregisterCategory()

void CommandPalette::unregisterCategory ( const QString & category)

Remove all commands in a category.

Parameters
categoryCategory name

Definition at line 420 of file command_palette.cpp.

◆ unregisterCommand()

void CommandPalette::unregisterCommand ( const QString & id)

Remove a command by ID.

Parameters
idCommand ID to remove

Definition at line 413 of file command_palette.cpp.


The documentation for this class was generated from the following files: