Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
ShortcutsSettingsWidget Class Referencefinal

A widget for configuring keyboard shortcuts for various application actions. More...

#include <shortcuts_settings_widget.h>

Inheritance diagram for ShortcutsSettingsWidget:
Collaboration diagram for ShortcutsSettingsWidget:

Public Member Functions

void LoadSettings () const
 Loads the current shortcut settings from WavelengthConfig and updates the UI elements (QKeySequenceEdit widgets).
 
void SaveSettings () const
 Saves the currently configured shortcuts from the UI (QKeySequenceEdit widgets) back to WavelengthConfig. Note: Changes are saved to the config object but require an application restart to become active.
 
 ShortcutsSettingsWidget (QWidget *parent=nullptr)
 Constructs the ShortcutsSettingsWidget. Initializes the UI, loads current shortcut settings from WavelengthConfig.
 
 ~ShortcutsSettingsWidget () override=default
 Default destructor.
 

Private Slots

void RestoreDefaultShortcuts ()
 Restores all keyboard shortcuts to their default values defined in WavelengthConfig. Prompts the user for confirmation before proceeding. Updates the UI to reflect the restored defaults.
 

Private Member Functions

void SetupUi ()
 Creates and arranges all the UI elements (labels, input fields, layouts, button) for the widget. Dynamically creates QKeySequenceEdit widgets based on the actions defined in WavelengthConfig.
 

Static Private Member Functions

static QString GetActionDescription (const QString &action_id)
 Static utility function to get a user-friendly description for a given shortcut action ID.
 

Private Attributes

WavelengthConfigconfig_
 Pointer to the WavelengthConfig singleton instance.
 
QFormLayout * form_layout_
 Layout used to arrange the action labels and shortcut edit widgets.
 
QPushButton * restore_button_
 Button to trigger the restoration of default shortcuts.
 
QMap< QString, QKeySequenceEdit * > shortcut_edits_
 Map storing pointers to the QKeySequenceEdit widgets, keyed by their corresponding action ID.
 
TranslationManagertranslator_
 Pointer to the TranslationManager for handling UI translations.
 

Detailed Description

A widget for configuring keyboard shortcuts for various application actions.

This widget displays a list of available actions and their currently assigned keyboard shortcuts using QKeySequenceEdit widgets. Users can modify these shortcuts. It interacts with the WavelengthConfig singleton to load the current shortcuts and save the modified ones. A button is provided to restore all shortcuts to their default values. Changes require an application restart to take effect.

Constructor & Destructor Documentation

◆ ShortcutsSettingsWidget()

ShortcutsSettingsWidget::ShortcutsSettingsWidget ( QWidget * parent = nullptr)
explicit

Constructs the ShortcutsSettingsWidget. Initializes the UI, loads current shortcut settings from WavelengthConfig.

Parameters
parentOptional parent widget.
Here is the call graph for this function:

◆ ~ShortcutsSettingsWidget()

ShortcutsSettingsWidget::~ShortcutsSettingsWidget ( )
overridedefault

Default destructor.

Member Function Documentation

◆ GetActionDescription()

QString ShortcutsSettingsWidget::GetActionDescription ( const QString & action_id)
staticprivate

Static utility function to get a user-friendly description for a given shortcut action ID.

Parameters
action_idThe internal identifier for the shortcut action (e.g., "MainWindow.CreateWavelength").
Returns
A human-readable string describing the action, or an empty string if the ID is unknown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadSettings()

void ShortcutsSettingsWidget::LoadSettings ( ) const

Loads the current shortcut settings from WavelengthConfig and updates the UI elements (QKeySequenceEdit widgets).

Here is the caller graph for this function:

◆ RestoreDefaultShortcuts

void ShortcutsSettingsWidget::RestoreDefaultShortcuts ( )
privateslot

Restores all keyboard shortcuts to their default values defined in WavelengthConfig. Prompts the user for confirmation before proceeding. Updates the UI to reflect the restored defaults.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveSettings()

void ShortcutsSettingsWidget::SaveSettings ( ) const

Saves the currently configured shortcuts from the UI (QKeySequenceEdit widgets) back to WavelengthConfig. Note: Changes are saved to the config object but require an application restart to become active.

◆ SetupUi()

void ShortcutsSettingsWidget::SetupUi ( )
private

Creates and arranges all the UI elements (labels, input fields, layouts, button) for the widget. Dynamically creates QKeySequenceEdit widgets based on the actions defined in WavelengthConfig.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ config_

WavelengthConfig* ShortcutsSettingsWidget::config_
private

Pointer to the WavelengthConfig singleton instance.

◆ form_layout_

QFormLayout* ShortcutsSettingsWidget::form_layout_
private

Layout used to arrange the action labels and shortcut edit widgets.

◆ restore_button_

QPushButton* ShortcutsSettingsWidget::restore_button_
private

Button to trigger the restoration of default shortcuts.

◆ shortcut_edits_

QMap<QString, QKeySequenceEdit *> ShortcutsSettingsWidget::shortcut_edits_
private

Map storing pointers to the QKeySequenceEdit widgets, keyed by their corresponding action ID.

◆ translator_

TranslationManager* ShortcutsSettingsWidget::translator_
private

Pointer to the TranslationManager for handling UI translations.


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