LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 // Types
65 struct ApiEndpoint {
66 QUrl url;
67 bool useForLibraries = false;
68 bool useForPartsInfo = false;
69 bool useForOrder = false;
70
71 bool operator==(const ApiEndpoint& rhs) const noexcept = default;
72 };
73
74 // Constructors / Destructor
75 WorkspaceSettings(const WorkspaceSettings& other) = delete;
76 explicit WorkspaceSettings(QObject* parent = nullptr);
77 ~WorkspaceSettings() noexcept;
78
85 void load(const SExpression& node, const Version& fileFormat);
86
90 void restoreDefaults() noexcept;
91
97 std::unique_ptr<SExpression> serialize();
98
104 std::optional<ApiEndpoint> getApiEndpointForPartsInfo() const noexcept;
105
111 std::optional<ApiEndpoint> getApiEndpointForOrder() const noexcept;
112
113 // Operator Overloadings
114 WorkspaceSettings& operator=(const WorkspaceSettings& rhs) = delete;
115
116private: // Methods
122 QList<WorkspaceSettingsItem*> getAllItems() const noexcept;
123
124private: // Data
148 QMap<QString, SExpression> mFileContent;
149
154
155public:
156 // All settings item objects below. The order is not relevant for saving,
157 // it should be ordered logically.
158 //
159 // Note: Generally we don't make member variables public, but in this case
160 // it would create a lot of boilerplate to wrap all objects with
161 // both const- and non-const methods, and it's totally safe to access
162 // them directly.
163
172
181
188
195
202
215
224
234
241
255
269
282
294
301
313};
314
315/*******************************************************************************
316 * End of File
317 ******************************************************************************/
318
319} // namespace librepcb
320
321#endif
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:62
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
std::optional< ApiEndpoint > getApiEndpointForPartsInfo() const noexcept
Get the API endpoint which is configured for parts information.
Definition workspacesettings.cpp:172
~WorkspaceSettings() noexcept
Definition workspacesettings.cpp:113
std::unique_ptr< SExpression > serialize()
Serialize settings to librepcb::SExpression.
Definition workspacesettings.cpp:148
WorkspaceSettingsItem_GenericValue< bool > useOpenGl
Use OpenGL hardware acceleration.
Definition workspacesettings.h:201
WorkspaceSettingsItem_GenericValueList< QStringList > libraryLocaleOrder
Preferred library locales (like "de_CH") in the right order.
Definition workspacesettings.h:214
WorkspaceSettingsItem_GenericValue< bool > autofetchLivePartInformation
Enable auto-fetch of live parts information (through apiEndpoints)
Definition workspacesettings.h:240
WorkspaceSettingsItem_GenericValueList< QList< ApiEndpoint >, true > apiEndpoints
The list of API endpoint URLs in the right order.
Definition workspacesettings.h:233
WorkspaceSettingsItem_GenericValue< uint > projectAutosaveIntervalSeconds
Project autosave interval [seconds] (0 = autosave disabled)
Definition workspacesettings.h:194
WorkspaceSettingsItem_GenericValueList< QStringList > libraryNormOrder
Preferred library norms (like "DIN EN 81346") in the right order.
Definition workspacesettings.h:223
WorkspaceSettingsItem_GenericValueList< QSet< QString > > dismissedMessages
Dismissed messages.
Definition workspacesettings.h:312
WorkspaceSettingsItem_GenericValue< LengthUnit > defaultLengthUnit
The application's default length unit.
Definition workspacesettings.h:187
QList< WorkspaceSettingsItem * > getAllItems() const noexcept
Get all librepcb::WorkspaceSettingsItem objects.
Definition workspacesettings.cpp:195
WorkspaceSettingsItem_GenericValue< QString > applicationLocale
The application's locale (e.g. "en_US")
Definition workspacesettings.h:180
WorkspaceSettings(const WorkspaceSettings &other)=delete
void load(const SExpression &node, const Version &fileFormat)
Load settings from file.
Definition workspacesettings.cpp:120
WorkspaceSettingsItem_KeyboardShortcuts keyboardShortcuts
Keyboard shortcuts.
Definition workspacesettings.h:293
QMap< QString, SExpression > mFileContent
Settings nodes loaded by load()
Definition workspacesettings.h:148
WorkspaceSettingsItem_Themes themes
Themes.
Definition workspacesettings.h:300
WorkspaceSettingsItem_GenericValueList< QStringList > externalPdfReaderCommands
Custom command(s) to be used for opening PDF files.
Definition workspacesettings.h:281
WorkspaceSettingsItem_GenericValueList< QStringList > externalWebBrowserCommands
Custom command(s) to be used for opening web URLs.
Definition workspacesettings.h:254
bool mUpgradeRequired
Whether mFileContent needs to be upgraded or not.
Definition workspacesettings.h:153
WorkspaceSettingsItem_GenericValue< QString > userName
User name.
Definition workspacesettings.h:171
void restoreDefaults() noexcept
Reset all settings to their default value.
Definition workspacesettings.cpp:141
std::optional< ApiEndpoint > getApiEndpointForOrder() const noexcept
Get the API endpoint which is configured for ordering projects.
Definition workspacesettings.cpp:182
WorkspaceSettingsItem_GenericValueList< QStringList > externalFileManagerCommands
Custom command(s) to be used for opening directories.
Definition workspacesettings.h:268
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
Definition uuid.h:186
Definition workspacesettings.h:65
QUrl url
Definition workspacesettings.h:66
bool operator==(const ApiEndpoint &rhs) const noexcept=default
bool useForOrder
Can be set on 0..1 endpoints.
Definition workspacesettings.h:69
bool useForPartsInfo
Can be set on 0..1 endpoints.
Definition workspacesettings.h:68
bool useForLibraries
Can be set on 0..n endpoints.
Definition workspacesettings.h:67