LibrePCB Developers Documentation
WorkspaceSettings Class Referencefinal

Container for all workspace related settings. More...

#include <workspacesettings.h>

Inherits QObject.

+ Collaboration diagram for WorkspaceSettings:

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_GenericValueList< QStringList > externalWebBrowserCommands
 Custom command(s) to be used for opening web URLs. More...
 
WorkspaceSettingsItem_GenericValueList< QStringList > externalFileManagerCommands
 Custom command(s) to be used for opening directories. More...
 
WorkspaceSettingsItem_GenericValueList< QStringList > externalPdfReaderCommands
 Custom command(s) to be used for opening PDF files. More...
 
WorkspaceSettingsItem_KeyboardShortcuts keyboardShortcuts
 Keyboard shortcuts. More...
 
WorkspaceSettingsItem_GenericValueList< QSet< QString > > dismissedMessages
 Dismissed messages. 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...
 
bool mUpgradeRequired
 Whether mFileContent needs to be upgraded or not. 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

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.

◆ mUpgradeRequired

bool mUpgradeRequired
private

Whether mFileContent needs to be upgraded or not.

◆ 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"]

◆ externalWebBrowserCommands

WorkspaceSettingsItem_GenericValueList<QStringList> externalWebBrowserCommands

Custom command(s) to be used for opening web URLs.

When opening an URL, the application will iterate through this list of commands until a command was successful. If none was successful, the system's default command will be used as fallback.

Supported placeholders: {{URL}}

Default: []

◆ externalFileManagerCommands

WorkspaceSettingsItem_GenericValueList<QStringList> externalFileManagerCommands

Custom command(s) to be used for opening directories.

When opening a directory, the application will iterate through this list of commands until a command was successful. If none was successful, the system's default command will be used as fallback.

Supported placeholders: {{URL}}, {{FILEPATH}}

Default: []

◆ externalPdfReaderCommands

WorkspaceSettingsItem_GenericValueList<QStringList> externalPdfReaderCommands

Custom command(s) to be used for opening PDF files.

When opening a PDF file, the application will iterate through this list of commands until a command was successful. If none was successful, the system's default command will be used as fallback.

Supported placeholders: {{URL}}, {{FILEPATH}}

Default: []

◆ 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

◆ dismissedMessages

WorkspaceSettingsItem_GenericValueList<QSet<QString> > dismissedMessages

Dismissed messages.

List of messages which the user dismissed with "do not show again". It's just a generic list of strings, where each message is identified by some locale-independent string. It's recommended to use UPPER_SNAKE_CASE strings, For example: "WORKSPACE_V0.1_HAS_NO_LIBRARIES".

Default: []


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