Mapper  0.9.0
API documentation
Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
OpenOrienteering::Settings Class Reference

Singleton which handles the global application settings. More...

#include <settings.h>

Inheritance diagram for OpenOrienteering::Settings:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::Settings:
Collaboration graph
[legend]

Public Types

enum  SettingsEnum {
  MapDisplay_Antialiasing = 0, MapDisplay_TextAntialiasing, MapEditor_ClickToleranceMM, MapEditor_SnapDistanceMM,
  MapEditor_FixedAngleStepping, MapEditor_ChangeSymbolWhenSelecting, MapEditor_ZoomOutAwayFromCursor, MapEditor_DrawLastPointOnRightClick,
  EditTool_DeleteBezierPointAction, EditTool_DeleteBezierPointActionAlternative, RectangleTool_HelperCrossRadiusMM, RectangleTool_PreviewLineWidth,
  Templates_KeepSettingsOfClosed, SymbolWidget_IconSizeMM, SymbolWidget_ShowCustomIcons, ActionGridBar_ButtonSizeMM,
  General_RetainCompatiblity, General_SaveUndoRedo, General_AutosaveInterval, General_Language,
  General_PixelsPerInch, General_RecentFilesList, General_TranslationFile, General_OpenMRUFile,
  General_Local8BitEncoding, General_StartDragDistance, HomeScreen_TipsVisible, HomeScreen_CurrentTip,
  END_OF_SETTINGSENUM
}
 List of all application settings to prevent having the QSettings path strings in multiple places. More...
 
enum  DeleteBezierPointAction { DeleteBezierPoint_RetainExistingShape = 0, DeleteBezierPoint_ResetHandles, DeleteBezierPoint_KeepHandles }
 

Signals

void settingsChanged ()
 

Public Member Functions

QVariant getSetting (SettingsEnum setting) const
 Retrieve a setting from QSettings without caching. More...
 
QVariant getSettingCached (SettingsEnum setting)
 Can be used to cache and retrieve settings which are only changed in the settings dialog (i.e. applySettings() must be called after they are changed) More...
 
void setSettingInCache (Settings::SettingsEnum setting, const QVariant &value)
 Change a setting, but only in the cache. Do not use this if in doubt. More...
 
void applySettings ()
 This must be called after cached settings have been changed and on application startup. More...
 
void setSetting (Settings::SettingsEnum setting, const QVariant &value)
 Change a setting immediately. More...
 
void remove (Settings::SettingsEnum setting)
 Removes a setting immediately. Next reading will return the default value. More...
 
QString getSettingPath (SettingsEnum setting) const
 Returns the path to use with QSettings. More...
 
QVariant getDefaultValue (SettingsEnum setting) const
 Returns the default value for the setting. More...
 
int getSymbolWidgetIconSizePx ()
 
qreal getMapEditorClickTolerancePx ()
 
qreal getMapEditorSnapDistancePx ()
 
qreal getRectangleToolHelperCrossRadiusPx ()
 
int getStartDragDistancePx ()
 
bool touchModeEnabled () const noexcept
 Returns true if the user wants to use a touch device. More...
 
void setTouchModeEnabled (bool enabled)
 Enables or disables touch mode on PCs. More...
 
QString positionSource () const
 Returns the name of the position source to be used. More...
 
void setPositionSource (const QString &name)
 Changes the name of the position source. More...
 
QString nmeaSerialPort () const
 Returns the name of the serial port for reading NMEA data. More...
 
void setNmeaSerialPort (const QString &name)
 Changes the name of the serial port for reading NMEA data. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Member Functions

static SettingsgetInstance ()
 
static bool mobileModeEnforced () noexcept
 Returns true if the developer wants a PC user experience most closely to mobile devices. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Singleton which handles the global application settings.

If you need to do any action when the application settings are changed, connect to the settingsChanged() signal.

Member Enumeration Documentation

◆ DeleteBezierPointAction

Enumerator
DeleteBezierPoint_RetainExistingShape 
DeleteBezierPoint_ResetHandles 
DeleteBezierPoint_KeepHandles 

◆ SettingsEnum

List of all application settings to prevent having the QSettings path strings in multiple places.

Enumerator
MapDisplay_Antialiasing 
MapDisplay_TextAntialiasing 
MapEditor_ClickToleranceMM 
MapEditor_SnapDistanceMM 
MapEditor_FixedAngleStepping 
MapEditor_ChangeSymbolWhenSelecting 
MapEditor_ZoomOutAwayFromCursor 
MapEditor_DrawLastPointOnRightClick 
EditTool_DeleteBezierPointAction 
EditTool_DeleteBezierPointActionAlternative 
RectangleTool_HelperCrossRadiusMM 
RectangleTool_PreviewLineWidth 
Templates_KeepSettingsOfClosed 
SymbolWidget_IconSizeMM 
SymbolWidget_ShowCustomIcons 
ActionGridBar_ButtonSizeMM 
General_RetainCompatiblity 
General_SaveUndoRedo 
General_AutosaveInterval 
General_Language 
General_PixelsPerInch 
General_RecentFilesList 
General_TranslationFile 
General_OpenMRUFile 
General_Local8BitEncoding 
General_StartDragDistance 
HomeScreen_TipsVisible 
HomeScreen_CurrentTip 
END_OF_SETTINGSENUM 

Member Function Documentation

◆ applySettings()

void OpenOrienteering::Settings::applySettings ( )

This must be called after cached settings have been changed and on application startup.

◆ getDefaultValue()

QVariant OpenOrienteering::Settings::getDefaultValue ( SettingsEnum  setting) const
inline

Returns the default value for the setting.

◆ getInstance()

Settings & OpenOrienteering::Settings::getInstance ( )
static

◆ getMapEditorClickTolerancePx()

qreal OpenOrienteering::Settings::getMapEditorClickTolerancePx ( )

◆ getMapEditorSnapDistancePx()

qreal OpenOrienteering::Settings::getMapEditorSnapDistancePx ( )

◆ getRectangleToolHelperCrossRadiusPx()

qreal OpenOrienteering::Settings::getRectangleToolHelperCrossRadiusPx ( )

◆ getSetting()

QVariant OpenOrienteering::Settings::getSetting ( Settings::SettingsEnum  setting) const

Retrieve a setting from QSettings without caching.

◆ getSettingCached()

QVariant OpenOrienteering::Settings::getSettingCached ( Settings::SettingsEnum  setting)

Can be used to cache and retrieve settings which are only changed in the settings dialog (i.e. applySettings() must be called after they are changed)

◆ getSettingPath()

QString OpenOrienteering::Settings::getSettingPath ( SettingsEnum  setting) const
inline

Returns the path to use with QSettings.

◆ getStartDragDistancePx()

int OpenOrienteering::Settings::getStartDragDistancePx ( )

◆ getSymbolWidgetIconSizePx()

int OpenOrienteering::Settings::getSymbolWidgetIconSizePx ( )

◆ mobileModeEnforced()

bool OpenOrienteering::Settings::mobileModeEnforced ( )
staticnoexcept

Returns true if the developer wants a PC user experience most closely to mobile devices.

This is intended as a utility for developers wanting to test or to debug Android features without taking the slow deployment path to a real device.

The property does not change during execution. On Android, it is constexpr true, giving the compile the chance for extra optimizations. On PCs, it is enabled by setting the environment variable MAPPER_MOBILE_GUI to a value different from '0'.

Controllers and widgets shall use this property to enable at run-time what is otherwise enabled by compile-time macros for Android.

Enabling this property enforces touch mode, too.

◆ nmeaSerialPort()

QString OpenOrienteering::Settings::nmeaSerialPort ( ) const
inline

Returns the name of the serial port for reading NMEA data.

If this is empty, port selection is left to Qt which either reads the port name from the environment variable QT_NMEA_SERIAL_PORT, or recognizes a few GPS chipsets by serial port vendor IDs.

See also
qtlocation/src/plugins/position/serialnmea/qgeopositioninfosourcefactory_serialnmea.cpp

◆ positionSource()

QString OpenOrienteering::Settings::positionSource ( ) const
inline

Returns the name of the position source to be used.

If this is empty, the system's default source shall be used.

See also
QGeoPositionInfoSource::createSource
QGeoPositionInfoSource::createDefaultSource

◆ remove()

void OpenOrienteering::Settings::remove ( Settings::SettingsEnum  setting)

Removes a setting immediately. Next reading will return the default value.

◆ setNmeaSerialPort()

void OpenOrienteering::Settings::setNmeaSerialPort ( const QString name)

Changes the name of the serial port for reading NMEA data.

Setting this to an empty string activates Qt's default port selection behaviour.

◆ setPositionSource()

void OpenOrienteering::Settings::setPositionSource ( const QString name)

Changes the name of the position source.

Setting this to an empty string selects the system's default source.

◆ setSetting()

void OpenOrienteering::Settings::setSetting ( Settings::SettingsEnum  setting,
const QVariant value 
)

Change a setting immediately.

◆ setSettingInCache()

void OpenOrienteering::Settings::setSettingInCache ( Settings::SettingsEnum  setting,
const QVariant value 
)

Change a setting, but only in the cache. Do not use this if in doubt.

◆ settingsChanged

void OpenOrienteering::Settings::settingsChanged ( )
signal

◆ setTouchModeEnabled()

void OpenOrienteering::Settings::setTouchModeEnabled ( bool  enabled)

Enables or disables touch mode on PCs.

On Android, or with enforced mobile mode, this function does nothing.

◆ touchModeEnabled()

bool OpenOrienteering::Settings::touchModeEnabled ( ) const
inlinenoexcept

Returns true if the user wants to use a touch device.

Main window controllers may use this property to adjust their user interface, e.g. to select child widget types or to hide menubar and statusbar.

On PCs, the setting may be changed while multiple windows are opened. For consistent behaviour, main window controllers and widgets are expected to not adapt instantaneously to a change, but to capture the current setting at construction time, and to tear down accordingly on destruction.

On Android, or with enforced mobile mode, touch mode is always active (constexpr true) and cannot be disabled.

Member Data Documentation

◆ nmea_serialport

QString OpenOrienteering::Settings::nmea_serialport = {}

◆ position_source

QString OpenOrienteering::Settings::position_source = {}

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