Mapper  0.9.0
API documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
OpenOrienteering::ModifierKey Class Reference

A class that helps to deal efficiently with platform and localization issues of modifier keys. More...

#include <modifier_key.h>

Public Member Functions

 ModifierKey (Qt::KeyboardModifiers keys)
 Constructs a new ModifierKey for the given combination of KeyboardModifiers. More...
 
 ModifierKey (Qt::Key key)
 Constructs a new ModifierKey for the given key. More...
 
 operator QString () const
 Returns a string representation for user interface purposes. More...
 

Static Public Member Functions

static const ModifierKeyalt ()
 Returns a shared Alt modifier key. More...
 
static const ModifierKeycontrol ()
 Returns a shared Control modifier key. More...
 
static const ModifierKeycontrolShift ()
 Returns a shared Control+Shift modifier key. More...
 
static const ModifierKeymeta ()
 Returns a shared Meta modifier key. More...
 
static const ModifierKeyshift ()
 Returns a shared Shift modifier key. More...
 
static const ModifierKeyspace ()
 Returns a shared Space key. More...
 
static const ModifierKeyreturn_key ()
 Returns a shared Return key. More...
 
static const ModifierKeybackspace ()
 Returns a shared Backspace key. More...
 
static const ModifierKeyescape ()
 Returns a shared Escape modifier key. More...
 

Protected Member Functions

 ModifierKey (int key)
 Constructs a new ModifierKey for the given key. More...
 

Detailed Description

A class that helps to deal efficiently with platform and localization issues of modifier keys.

It is based on QKeySequence::toString(QKeySequence::NativeText) which provides localization and deals with swapping Ctrl and Cmd on Mac OS X. In contrast to QKeySequence, ModifierKey has an implicit operator for casting to QString, and it removes the trailing '+' from pseudo key sequences which consist of modifier keys only. Static methods provide efficient translations of the pure modifier keys.

For true QKeySequences, call QKeySequence::toString(QKeySequence::NativeText) directly.

On Windows and Linux, the keys will be displayed as word ("Shift" etc.). On OS X, the keys will be displayed as graphical symbols ("⇧", i.e. Unicode character U+21E7, etc.).

Synopsis:

QString text = tr("%1+Click to add a point.").arg(ModifierKey::control());
QString more = tr("%1+Click to select a point.").arg(ModifierKey(Qt::ALT + Qt::ShiftModifier));

// BUT:
QString help = help_action.shortcut().toString(QKeySequence::NativeText);

Constructor & Destructor Documentation

◆ ModifierKey() [1/3]

OpenOrienteering::ModifierKey::ModifierKey ( int  key)
explicitprotected

Constructs a new ModifierKey for the given key.

◆ ModifierKey() [2/3]

OpenOrienteering::ModifierKey::ModifierKey ( Qt::KeyboardModifiers  keys)
explicit

Constructs a new ModifierKey for the given combination of KeyboardModifiers.

◆ ModifierKey() [3/3]

OpenOrienteering::ModifierKey::ModifierKey ( Qt::Key  key)
explicit

Constructs a new ModifierKey for the given key.

Member Function Documentation

◆ alt()

const ModifierKey & OpenOrienteering::ModifierKey::alt ( )
static

Returns a shared Alt modifier key.

◆ backspace()

const ModifierKey & OpenOrienteering::ModifierKey::backspace ( )
static

Returns a shared Backspace key.

◆ control()

const ModifierKey & OpenOrienteering::ModifierKey::control ( )
static

Returns a shared Control modifier key.

◆ controlShift()

const ModifierKey & OpenOrienteering::ModifierKey::controlShift ( )
static

Returns a shared Control+Shift modifier key.

◆ escape()

const ModifierKey & OpenOrienteering::ModifierKey::escape ( )
static

Returns a shared Escape modifier key.

◆ meta()

const ModifierKey & OpenOrienteering::ModifierKey::meta ( )
static

Returns a shared Meta modifier key.

◆ operator QString()

OpenOrienteering::ModifierKey::operator QString ( ) const
inline

Returns a string representation for user interface purposes.

This operator is intended to be used for implicit type casts.

◆ return_key()

const ModifierKey & OpenOrienteering::ModifierKey::return_key ( )
static

Returns a shared Return key.

◆ shift()

const ModifierKey & OpenOrienteering::ModifierKey::shift ( )
static

Returns a shared Shift modifier key.

◆ space()

const ModifierKey & OpenOrienteering::ModifierKey::space ( )
static

Returns a shared Space key.


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