libyui  3.12.1
YShortcut Class Reference

Helper class for shortcut management: This class holds data about the shortcut for one single widget. More...

#include <YShortcut.h>

Inheritance diagram for YShortcut:
Collaboration diagram for YShortcut:

Public Types

enum  { None = 0 }
 Marker for "no shortcut".
 

Public Member Functions

 YShortcut (YWidget *shortcut_widget)
 Constructor. More...
 
virtual ~YShortcut ()
 Destructor.
 
YWidgetwidget () const
 Returns the YWidget this shortcut data belong to.
 
const char * widgetClass () const
 Returns the textual representation of the widget class of the widget this shortcut data belongs to.
 
bool isButton () const
 Returns 'true' if the widget that is associated with this shortcut is a button (derived from YPushButton).
 
bool isWizardButton () const
 Returns 'true' if the widget that is associated with this shortcut is a wizard button (one of the navigation buttons of a wizard).
 
std::string shortcutString ()
 Returns the complete shortcut string (which may or may not contain "&"), i.e. More...
 
std::string cleanShortcutString ()
 Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers. More...
 
char preferred ()
 The preferred shortcut character, i.e. More...
 
char shortcut ()
 The actual shortcut character. More...
 
virtual void setShortcut (char newShortcut)
 Set (override) the shortcut character.
 
void clearShortcut ()
 Clear the shortcut: Override the shortcut character with nothing. More...
 
bool conflict ()
 Query the internal 'conflict' marker. More...
 
void setConflict (bool newConflictState=true)
 Set or unset the internal 'conflict' marker.
 
int distinctShortcutChars ()
 Obtain the number of distinct valid shortcut characters in the shortcut string, i.e. More...
 
bool hasValidShortcutChar ()
 Return true if this shortcut contains any character that would be valid as a shortcut character.
 

Static Public Member Functions

static std::string cleanShortcutString (std::string shortcutString)
 Static version of the above for general use: Returns the specified string without any "&" markers. More...
 
static char shortcutMarker ()
 Static function: Returns the character used for marking keyboard shortcuts.
 
static std::string::size_type findShortcutPos (const std::string &str, std::string::size_type start_pos=0)
 Static function: Find the next occurrence of the shortcut marker ('&') in a string, beginning at starting position start_pos. More...
 
static char findShortcut (const std::string &str, std::string::size_type start_pos=0)
 Static function: Find the next shortcut marker in a string, beginning at starting position start_pos. More...
 
static bool isValid (char c)
 Returns 'true' if 'c' is a valid shortcut character, i.e. More...
 
static char normalized (char c)
 Return the normalized version of shortcut character 'c', i.e. More...
 
static std::string getShortcutString (const YWidget *widget)
 Obtain a widget's shortcut property - the string that contains "&" to designate a shortcut.
 

Protected Member Functions

virtual std::string getShortcutString ()
 Obtain the the shortcut property of this shortcut's widget - the string that contains "&" to designate a shortcut.
 

Protected Attributes

YWidget_widget
 (not owned)
 
std::string _shortcutString
 
bool _shortcutStringCached
 is _shortcutString initialized
 
std::string _cleanShortcutString
 
bool _cleanShortcutStringCached
 always false :facepalm:
 
int _preferred
 char or 0 (none found) or -1 (not initialized yet) More...
 
int _shortcut
 char or 0 (none found) or -1 (not initialized yet) More...
 
bool _conflict
 
bool _isButton
 
bool _isWizardButton
 
int _distinctShortcutChars
 -1 means uninitialized More...
 

Detailed Description

Helper class for shortcut management: This class holds data about the shortcut for one single widget.

Definition at line 40 of file YShortcut.h.

Constructor & Destructor Documentation

◆ YShortcut()

YShortcut::YShortcut ( YWidget shortcut_widget)

Constructor.

Parameters
shortcut_widget(not owned, not nullptr)

Definition at line 43 of file YShortcut.cc.

Here is the call graph for this function:

Member Function Documentation

◆ cleanShortcutString() [1/2]

string YShortcut::cleanShortcutString ( )

Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers.

But an escaped "&&" is preserved.

Definition at line 93 of file YShortcut.cc.

Here is the call graph for this function:

◆ cleanShortcutString() [2/2]

string YShortcut::cleanShortcutString ( std::string  shortcutString)
static

Static version of the above for general use: Returns the specified string without any "&" markers.

But an escaped "&&" is preserved.

Definition at line 105 of file YShortcut.cc.

Here is the call graph for this function:

◆ clearShortcut()

void YShortcut::clearShortcut ( )

Clear the shortcut: Override the shortcut character with nothing.

This may happen if a conflict cannot be resolved.

Definition at line 175 of file YShortcut.cc.

Here is the call graph for this function:

◆ conflict()

bool YShortcut::conflict ( )
inline

Query the internal 'conflict' marker.

This class doesn't care about that flag, it just stores it for the convenience of higher-level classes.

Definition at line 135 of file YShortcut.h.

◆ distinctShortcutChars()

int YShortcut::distinctShortcutChars ( )

Obtain the number of distinct valid shortcut characters in the shortcut string, i.e.

how many different shortcuts that widget could get.

Definition at line 182 of file YShortcut.cc.

Here is the call graph for this function:

◆ findShortcut()

char YShortcut::findShortcut ( const std::string &  str,
std::string::size_type  start_pos = 0 
)
static

Static function: Find the next shortcut marker in a string, beginning at starting position start_pos.

Returns the shortcut character or 0 if none found.

Definition at line 282 of file YShortcut.cc.

Here is the call graph for this function:

◆ findShortcutPos()

string::size_type YShortcut::findShortcutPos ( const std::string &  str,
std::string::size_type  start_pos = 0 
)
static

Static function: Find the next occurrence of the shortcut marker ('&') in a string, beginning at starting position start_pos.

An escaped "&&" does not count.

Returns string::npos if not found or the position of the shortcut marker (not the shortcut character!) if found.

Definition at line 256 of file YShortcut.cc.

Here is the call graph for this function:

◆ isValid()

bool YShortcut::isValid ( char  c)
static

Returns 'true' if 'c' is a valid shortcut character, i.e.

[a-zA-Z0-9], 'false' otherwise.

Definition at line 291 of file YShortcut.cc.

◆ normalized()

char YShortcut::normalized ( char  c)
static

Return the normalized version of shortcut character 'c', i.e.

a lowercase letter or a digit [a-z0-9]. Returns 0 if 'c' is invalid.

Definition at line 301 of file YShortcut.cc.

◆ preferred()

char YShortcut::preferred ( )

The preferred shortcut character, i.e.

the character that had been preceded by "&" before checking / resolving conflicts began. 0 if none.

Definition at line 119 of file YShortcut.cc.

Here is the call graph for this function:

◆ shortcut()

char YShortcut::shortcut ( )

The actual shortcut character.

0 if none.

This may be different from preferred() if it is overridden.

Definition at line 131 of file YShortcut.cc.

Here is the call graph for this function:

◆ shortcutString()

string YShortcut::shortcutString ( )

Returns the complete shortcut string (which may or may not contain "&"), i.e.

the value of the widget's shortcut property. For PushButtons, this is the label on the button ( e.g., "&Details..." ), for other widgets usually the caption above it.

This value is chached, i.e. this isn't a too expensive operation.

Definition at line 77 of file YShortcut.cc.

Here is the call graph for this function:

Member Data Documentation

◆ _conflict

bool YShortcut::_conflict
protected
See also
conflict

Definition at line 223 of file YShortcut.h.

◆ _distinctShortcutChars

int YShortcut::_distinctShortcutChars
protected

-1 means uninitialized

See also
distinctShortcutChars

Definition at line 228 of file YShortcut.h.

◆ _isButton

bool YShortcut::_isButton
protected
See also
isButton

Definition at line 224 of file YShortcut.h.

◆ _isWizardButton

bool YShortcut::_isWizardButton
protected
See also
isWizardButton

Definition at line 225 of file YShortcut.h.

◆ _preferred

int YShortcut::_preferred
protected

char or 0 (none found) or -1 (not initialized yet)

See also
preferred

Definition at line 218 of file YShortcut.h.

◆ _shortcut

int YShortcut::_shortcut
protected

char or 0 (none found) or -1 (not initialized yet)

See also
shortcut

Definition at line 221 of file YShortcut.h.

◆ _shortcutString

std::string YShortcut::_shortcutString
protected
See also
shortcutString

Definition at line 210 of file YShortcut.h.


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