LibrePCB Developers Documentation
WorkspaceSettings Class Referencefinal

Container for all workspace related settings. More...

#include <workspacesettings.h>

Inherits QObject.

+ Collaboration diagram for WorkspaceSettings:

Public Types

enum  PdfOpenBehavior : int
 

Public Member Functions

 WorkspaceSettings (const WorkspaceSettings &other)=delete
 
 WorkspaceSettings (QObject *parent=nullptr)
 
 ~WorkspaceSettings () noexcept
 
void load (const SExpression &node, const Version &fileFormat)
 Load settings from file. More...
 
void restoreDefaults () noexcept
 Reset all settings to their default value. More...
 
SExpression serialize ()
 Serialize settings to librepcb::SExpression. More...
 
WorkspaceSettingsoperator= (const WorkspaceSettings &rhs)=delete
 

Public Attributes

WorkspaceSettingsItem_GenericValue< QString > userName
 User name. More...
 
WorkspaceSettingsItem_GenericValue< QString > applicationLocale
 The application's locale (e.g. "en_US") More...
 
WorkspaceSettingsItem_GenericValue< LengthUnitdefaultLengthUnit
 The application's default length unit. More...
 
WorkspaceSettingsItem_GenericValue< uint > projectAutosaveIntervalSeconds
 Project autosave interval [seconds] (0 = autosave disabled) More...
 
WorkspaceSettingsItem_GenericValue< bool > useOpenGl
 Use OpenGL hardware acceleration. More...
 
WorkspaceSettingsItem_GenericValueList< QStringList > libraryLocaleOrder
 Preferred library locales (like "de_CH") in the right order. More...
 
WorkspaceSettingsItem_GenericValueList< QStringList > libraryNormOrder
 Preferred library norms (like "DIN EN 81346") in the right order. More...
 
WorkspaceSettingsItem_GenericValueList< QList< QUrl > > repositoryUrls
 The list of API repository URLs in the right order. More...
 
WorkspaceSettingsItem_GenericValue< bool > useCustomPdfReader
 Use a PDF Reader other than the system default. More...
 
WorkspaceSettingsItem_GenericValue< QString > pdfReaderCommand
 Custom command to open a PDF reader. More...
 
WorkspaceSettingsItem_GenericValue< PdfOpenBehaviorpdfOpenBehavior
 Behavior after a PDF has been exported. More...
 
WorkspaceSettingsItem_KeyboardShortcuts keyboardShortcuts
 Keyboard shortcuts. More...
 

Private Member Functions

QList< WorkspaceSettingsItem * > getAllItems () const noexcept
 Get all librepcb::WorkspaceSettingsItem objects. More...
 

Private Attributes

QMap< QString, SExpressionmFileContent
 Settings nodes loaded by load() More...
 

Detailed Description

Container for all workspace related settings.

The "settings.lp" file in a workspace is used to store workspace related settings. This class is an interface to those settings. A librepcb::WorkspaceSettings object is created in the constructor of the librepcb::Workspace object.

Each settings item is represented by an instance of a librepcb::WorkspaceSettingsItem subclass.

See also
librepcb::WorkspaceSettingsItem

Member Enumeration Documentation

◆ PdfOpenBehavior

enum PdfOpenBehavior : int
strong
See also
librepcb::WorkspaceSettings::pdfOpenBehavior
Enumerator
ALWAYS 
NEVER 
ASK 

Constructor & Destructor Documentation

◆ WorkspaceSettings() [1/2]

WorkspaceSettings ( const WorkspaceSettings other)
delete

◆ WorkspaceSettings() [2/2]

WorkspaceSettings ( QObject *  parent = nullptr)
explicit

◆ ~WorkspaceSettings()

~WorkspaceSettings ( )
noexcept

Member Function Documentation

◆ load()

void load ( const SExpression node,
const Version fileFormat 
)

Load settings from file.

Parameters
nodeS-Expression node of settings file.
fileFormatFile format of settings file.
+ Here is the call graph for this function:

◆ restoreDefaults()

void restoreDefaults ( )
noexcept

Reset all settings to their default value.

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

◆ serialize()

SExpression serialize ( )

Serialize settings to librepcb::SExpression.

Returns
librepcb::SExpression node containing all settings.
+ Here is the call graph for this function:

◆ operator=()

WorkspaceSettings& operator= ( const WorkspaceSettings rhs)
delete

◆ getAllItems()

QList< WorkspaceSettingsItem * > getAllItems ( ) const
privatenoexcept

Get all librepcb::WorkspaceSettingsItem objects.

Returns
List of librepcb::WorkspaceSettingsItem objects
+ Here is the caller graph for this function:

Member Data Documentation

◆ mFileContent

QMap<QString, SExpression> mFileContent
private

Settings nodes loaded by load()

This map is filled with all settings S-Expression nodes when loading the settings from file. When modifying settings with the workspace settings dialog, the nodes in this map are updated accordingly. When saving the settings to file, these S-Expression nodes will be written to the file.

  • Key: Settings key, e.g. "use_opengl"
  • Value: The corresponding serialization, e.g. "(use_opengl true)"

Important:

  • Keeping unknown settings is important to not loose them when opening a workspace after an application downgrade.
  • When restoring default settings, the corresponding (or all) entries are removed from this map (i.e. not written to file at all). This ensures that users will automatically profit from improved default values after an application upgrade unless they have manually changed them.
  • QMap is sorted by key, which will lead to sorted entries in the S-Expression file for a clean file format.

◆ userName

User name.

Used when creating new library elements or projects.

Default: "" (but gets initialized when creating a new workspace)

◆ applicationLocale

WorkspaceSettingsItem_GenericValue<QString> applicationLocale

The application's locale (e.g. "en_US")

An empty string means that the system locale will be used.

Default: ""

◆ defaultLengthUnit

The application's default length unit.

Default: millimeters

◆ projectAutosaveIntervalSeconds

WorkspaceSettingsItem_GenericValue<uint> projectAutosaveIntervalSeconds

Project autosave interval [seconds] (0 = autosave disabled)

Default: 600

◆ useOpenGl

Use OpenGL hardware acceleration.

Default: False

◆ libraryLocaleOrder

WorkspaceSettingsItem_GenericValueList<QStringList> libraryLocaleOrder

Preferred library locales (like "de_CH") in the right order.

The locale which should be used first is at index 0 of the list. If no translation strings are found for all locales in this list, the fallback locale "en_US" will be used automatically, so the list do not have to contain "en_US". An empty list is also valid, then the fallback locale "en_US" will be used.

Default: []

◆ libraryNormOrder

WorkspaceSettingsItem_GenericValueList<QStringList> libraryNormOrder

Preferred library norms (like "DIN EN 81346") in the right order.

The norm which should be used first is at index 0 of the list.

Default: []

◆ repositoryUrls

WorkspaceSettingsItem_GenericValueList<QList<QUrl> > repositoryUrls

The list of API repository URLs in the right order.

The repository with the highest priority is at index 0 of the list. In case of version conflicts, the repository with the higher priority will be used.

Default: ["https://api.librepcb.org"]

◆ useCustomPdfReader

WorkspaceSettingsItem_GenericValue<bool> useCustomPdfReader

Use a PDF Reader other than the system default.

Default: false

◆ pdfReaderCommand

WorkspaceSettingsItem_GenericValue<QString> pdfReaderCommand

Custom command to open a PDF reader.

Default: ""

◆ pdfOpenBehavior

Behavior after a PDF has been exported.

Default: PdfOpenBehavior::ALWAYS

◆ keyboardShortcuts

Keyboard shortcuts.

Note
Expected to contain only the shortcuts explicitly set (overridden) by the user, not all available shortcuts. This way we are able to improve the default shortcuts with each new release without users staying at the old shortcuts.
See also
librepcb::WorkspaceSettingsItem_KeyboardShortcuts

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