libyui
 
Loading...
Searching...
No Matches
YShortcut Class Reference

#include <YShortcut.h>

Inheritance diagram for YShortcut:
Collaboration diagram for YShortcut:

Public Types

enum  { None = 0 }
 

Public Member Functions

 YShortcut (YWidget *shortcut_widget)
 
virtual ~YShortcut ()
 
YWidgetwidget () const
 
const char * widgetClass () const
 
bool isButton () const
 
bool isWizardButton () const
 
virtual bool isMenuItem () const
 
std::string shortcutString ()
 
std::string cleanShortcutString ()
 
char preferred ()
 
char shortcut ()
 
virtual void setShortcut (char newShortcut)
 
void clearShortcut ()
 
bool conflict ()
 
void setConflict (bool newConflictState=true)
 
int distinctShortcutChars ()
 
bool hasValidShortcutChar ()
 
virtual std::string debugLabel () const
 

Static Public Member Functions

static std::string cleanShortcutString (std::string shortcutString)
 
static char shortcutMarker ()
 
static std::string::size_type findShortcutPos (const std::string &str, std::string::size_type start_pos=0)
 
static char findShortcut (const std::string &str, std::string::size_type start_pos=0)
 
static bool isValid (char c)
 
static char normalized (char c)
 
static std::string getShortcutString (const YWidget *widget)
 

Protected Member Functions

virtual std::string getShortcutString ()
 

Protected Attributes

YWidget_widget
 (not owned)
 
std::string _shortcutString
 
bool _shortcutStringCached
 is _shortcutString initialized
 
std::string _cleanShortcutString
 
bool _cleanShortcutStringCached
 always false :facepalm:
 
int _preferred
 
int _shortcut
 
bool _conflict
 
bool _isButton
 
bool _isWizardButton
 
int _distinctShortcutChars
 

Detailed Description

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

Notice that there is also a derived class YItemShortcut for item-based widgets that may have multiple shortcuts like YDumbTab, YMenuBar, YItemSelector.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Marker for "no shortcut"

Constructor & Destructor Documentation

◆ YShortcut()

YShortcut::YShortcut ( YWidget * shortcut_widget)

Constructor

Parameters
shortcut_widget(not owned, not nullptr)

◆ ~YShortcut()

YShortcut::~YShortcut ( )
virtual

Destructor

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.

◆ cleanShortcutString() [2/2]

static std::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.

◆ clearShortcut()

void YShortcut::clearShortcut ( )

Clear the shortcut: Override the shortcut character with nothing. This may happen if a conflict cannot be resolved.

◆ 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.

◆ debugLabel()

virtual std::string YShortcut::debugLabel ( ) const
inlinevirtual

Label of this shortcut suitable for debugging

Reimplemented in YItemShortcut.

◆ 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.

◆ 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.

◆ 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.

◆ getShortcutString() [1/2]

string YShortcut::getShortcutString ( )
protectedvirtual

Obtain the the shortcut property of this shortcut's widget - the string that contains "&" to designate a shortcut.

Reimplemented in YItemShortcut.

◆ getShortcutString() [2/2]

string YShortcut::getShortcutString ( const YWidget * widget)
static

Obtain a widget's shortcut property - the string that contains "&" to designate a shortcut.

◆ hasValidShortcutChar()

bool YShortcut::hasValidShortcutChar ( )

Return true if this shortcut contains any character that would be valid as a shortcut character.

◆ isButton()

bool YShortcut::isButton ( ) const
inline

Returns 'true' if the widget that is associated with this shortcut is a button (derived from YPushButton).

◆ isMenuItem()

virtual bool YShortcut::isMenuItem ( ) const
inlinevirtual

Returns 'true' if this is a shortcut for a (toplevel) menu item.

This default implementation always returns 'false'. Derived classes like YItemShortcut can choose to overwrite this.

Reimplemented in YItemShortcut.

◆ isValid()

bool YShortcut::isValid ( char c)
static

Returns 'true' if 'c' is a valid shortcut character, i.e. [a-zA-Z0-9], 'false' otherwise.

◆ isWizardButton()

bool YShortcut::isWizardButton ( ) const
inline

Returns 'true' if the widget that is associated with this shortcut is a wizard button (one of the navigation buttons of a wizard).

◆ 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.

◆ 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.

◆ setConflict()

void YShortcut::setConflict ( bool newConflictState = true)
inline

Set or unset the internal 'conflict' marker.

◆ setShortcut()

void YShortcut::setShortcut ( char newShortcut)
virtual

Set (override) the shortcut character.

Reimplemented in YItemShortcut.

◆ shortcut()

char YShortcut::shortcut ( )

The actual shortcut character. 0 if none.

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

◆ shortcutMarker()

static char YShortcut::shortcutMarker ( )
inlinestatic

Static function: Returns the character used for marking keyboard shortcuts.

◆ 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.

◆ widget()

YWidget * YShortcut::widget ( ) const
inline

Returns the YWidget this shortcut data belong to.

◆ widgetClass()

const char * YShortcut::widgetClass ( ) const
inline

Returns the textual representation of the widget class of the widget this shortcut data belongs to.

Member Data Documentation

◆ _conflict

bool YShortcut::_conflict
protected
See also
conflict

◆ _distinctShortcutChars

int YShortcut::_distinctShortcutChars
protected

-1 means uninitialized

See also
distinctShortcutChars

◆ _isButton

bool YShortcut::_isButton
protected
See also
isButton

◆ _isWizardButton

bool YShortcut::_isWizardButton
protected
See also
isWizardButton

◆ _preferred

int YShortcut::_preferred
protected

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

See also
preferred

◆ _shortcut

int YShortcut::_shortcut
protected

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

See also
shortcut

◆ _shortcutString

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

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