LibrePCB Developers Documentation
workspacesettings.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_WORKSPACESETTINGS_H
21#define LIBREPCB_CORE_WORKSPACESETTINGS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../exceptions.h"
27#include "../types/lengthunit.h"
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class SExpression;
41class Version;
42
43/*******************************************************************************
44 * Class WorkspaceSettings
45 ******************************************************************************/
46
60class WorkspaceSettings final : public QObject {
61 Q_OBJECT
62
63public:
64 // Constructors / Destructor
65 WorkspaceSettings(const WorkspaceSettings& other) = delete;
66 explicit WorkspaceSettings(QObject* parent = nullptr);
67 ~WorkspaceSettings() noexcept;
68
75 void load(const SExpression& node, const Version& fileFormat);
76
80 void restoreDefaults() noexcept;
81
87 std::unique_ptr<SExpression> serialize();
88
89 // Operator Overloadings
90 WorkspaceSettings& operator=(const WorkspaceSettings& rhs) = delete;
91
92private: // Methods
98 QList<WorkspaceSettingsItem*> getAllItems() const noexcept;
99
100private: // Data
124 QMap<QString, SExpression> mFileContent;
125
130
131public:
132 // All settings item objects below. The order is not relevant for saving,
133 // it should be ordered logically.
134 //
135 // Note: Generally we don't make member variables public, but in this case
136 // it would create a lot of boilerplate to wrap all objects with
137 // both const- and non-const methods, and it's totally safe to access
138 // them directly.
139
148
157
164
171
178
191
200
210
217
231
245
258
270
277
289};
290
291/*******************************************************************************
292 * End of File
293 ******************************************************************************/
294
295} // namespace librepcb
296
297#endif
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition: lengthunit.h:60
The SExpression class.
Definition: sexpression.h:69
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
Container for all workspace related settings.
Definition: workspacesettings.h:60
~WorkspaceSettings() noexcept
Definition: workspacesettings.cpp:68
WorkspaceSettingsItem_GenericValueList< QList< QUrl > > apiEndpoints
The list of API endpoint URLs in the right order.
Definition: workspacesettings.h:209
std::unique_ptr< SExpression > serialize()
Serialize settings to librepcb::SExpression.
Definition: workspacesettings.cpp:103
WorkspaceSettingsItem_GenericValue< bool > useOpenGl
Use OpenGL hardware acceleration.
Definition: workspacesettings.h:177
WorkspaceSettingsItem_GenericValueList< QStringList > libraryLocaleOrder
Preferred library locales (like "de_CH") in the right order.
Definition: workspacesettings.h:190
WorkspaceSettingsItem_GenericValue< bool > autofetchLivePartInformation
Enable auto-fetch of live parts information (through apiEndpoints)
Definition: workspacesettings.h:216
WorkspaceSettingsItem_GenericValue< uint > projectAutosaveIntervalSeconds
Project autosave interval [seconds] (0 = autosave disabled)
Definition: workspacesettings.h:170
WorkspaceSettingsItem_GenericValueList< QStringList > libraryNormOrder
Preferred library norms (like "DIN EN 81346") in the right order.
Definition: workspacesettings.h:199
WorkspaceSettingsItem_GenericValueList< QSet< QString > > dismissedMessages
Dismissed messages.
Definition: workspacesettings.h:288
WorkspaceSettingsItem_GenericValue< LengthUnit > defaultLengthUnit
The application's default length unit.
Definition: workspacesettings.h:163
QList< WorkspaceSettingsItem * > getAllItems() const noexcept
Get all librepcb::WorkspaceSettingsItem objects.
Definition: workspacesettings.cpp:130
WorkspaceSettingsItem_GenericValue< QString > applicationLocale
The application's locale (e.g. "en_US")
Definition: workspacesettings.h:156
WorkspaceSettings(const WorkspaceSettings &other)=delete
void load(const SExpression &node, const Version &fileFormat)
Load settings from file.
Definition: workspacesettings.cpp:75
WorkspaceSettingsItem_KeyboardShortcuts keyboardShortcuts
Keyboard shortcuts.
Definition: workspacesettings.h:269
QMap< QString, SExpression > mFileContent
Settings nodes loaded by load()
Definition: workspacesettings.h:124
WorkspaceSettingsItem_Themes themes
Themes.
Definition: workspacesettings.h:276
WorkspaceSettingsItem_GenericValueList< QStringList > externalPdfReaderCommands
Custom command(s) to be used for opening PDF files.
Definition: workspacesettings.h:257
WorkspaceSettingsItem_GenericValueList< QStringList > externalWebBrowserCommands
Custom command(s) to be used for opening web URLs.
Definition: workspacesettings.h:230
bool mUpgradeRequired
Whether mFileContent needs to be upgraded or not.
Definition: workspacesettings.h:129
WorkspaceSettingsItem_GenericValue< QString > userName
User name.
Definition: workspacesettings.h:147
void restoreDefaults() noexcept
Reset all settings to their default value.
Definition: workspacesettings.cpp:96
WorkspaceSettingsItem_GenericValueList< QStringList > externalFileManagerCommands
Custom command(s) to be used for opening directories.
Definition: workspacesettings.h:244
Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-type settings.
Definition: workspacesettingsitem_genericvalue.h:44
Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-in-list-type settings.
Definition: workspacesettingsitem_genericvaluelist.h:47
Implementation of librepcb::WorkspaceSettingsItem to store keyboard shortcuts settings.
Definition: workspacesettingsitem_keyboardshortcuts.h:44
Implementation of librepcb::WorkspaceSettingsItem to store theme configurations.
Definition: workspacesettingsitem_themes.h:44
Base class for all workspace settings items.
Definition: workspacesettingsitem.h:49
Definition: occmodel.cpp:77