LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_WORKSPACESETTINGS_H
21 #define LIBREPCB_WORKSPACESETTINGS_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
28 
29 #include <QtCore>
30 
31 // All Settings Classes
33 #include "items/wsi_appearance.h"
34 #include "items/wsi_applocale.h"
35 #include "items/wsi_debugtools.h"
39 #include "items/wsi_repositories.h"
40 #include "items/wsi_user.h"
41 
42 /*******************************************************************************
43  * Namespace / Forward Declarations
44  ******************************************************************************/
45 namespace librepcb {
46 namespace workspace {
47 
48 class Workspace;
49 class WorkspaceSettingsDialog;
50 
51 /*******************************************************************************
52  * Class WorkspaceSettings
53  ******************************************************************************/
54 
66 class WorkspaceSettings final : public QObject, public SerializableObject {
67  Q_OBJECT
68 
69 public:
70  // Constructors / Destructor
71  WorkspaceSettings() = delete;
72  WorkspaceSettings(const WorkspaceSettings& other) = delete;
73  explicit WorkspaceSettings(const Workspace& workspace);
74  ~WorkspaceSettings() noexcept;
75 
76  // Getters: Settings Items
77  WSI_User& getUser() const noexcept { return *mUser; }
78  WSI_AppLocale& getAppLocale() const noexcept { return *mAppLocale; }
80  return *mAppDefMeasUnits;
81  }
84  }
85  WSI_Appearance& getAppearance() const noexcept { return *mAppearance; }
87  return *mLibraryLocaleOrder;
88  }
90  return *mLibraryNormOrder;
91  }
92  WSI_Repositories& getRepositories() const noexcept { return *mRepositories; }
93  WSI_DebugTools& getDebugTools() const noexcept { return *mDebugTools; }
94 
95  // General Methods
96  void restoreDefaults() noexcept;
97  void applyAll();
98  void revertAll() noexcept;
99 
100  // Operator Overloadings
101  WorkspaceSettings& operator=(const WorkspaceSettings& rhs) = delete;
102 
103 public slots:
104 
111  void showSettingsDialog() noexcept;
112 
113 private: // Methods
114  template <typename T>
115  void loadSettingsItem(QScopedPointer<T>& member, SExpression& root);
116  void saveToFile() const;
118  void serialize(SExpression& root) const override;
119 
120 private: // Data
121  // General Attributes
124 
125  // Settings Items
126  QList<WSI_Base*> mItems;
127  QScopedPointer<WSI_User> mUser;
128  QScopedPointer<WSI_AppLocale> mAppLocale;
131  QScopedPointer<WSI_Appearance> mAppearance;
135  QScopedPointer<WSI_DebugTools> mDebugTools;
136 };
137 
138 /*******************************************************************************
139  * End of File
140  ******************************************************************************/
141 
142 } // namespace workspace
143 } // namespace librepcb
144 
145 #endif // LIBREPCB_WORKSPACESETTINGS_H
QScopedPointer< WSI_ProjectAutosaveInterval > mProjectAutosaveInterval
Definition: workspacesettings.h:130
void revertAll() noexcept
Definition: workspacesettings.cpp:93
The WSI_Appearance class.
Definition: wsi_appearance.h:41
void applyAll()
Definition: workspacesettings.cpp:87
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:62
The WSI_LibraryNormOrder class contains a list of norms which should be used for all library elements...
Definition: wsi_librarynormorder.h:42
QScopedPointer< WSI_LibraryNormOrder > mLibraryNormOrder
Definition: workspacesettings.h:133
FilePath mFilePath
path to the "settings.lp" file
Definition: workspacesettings.h:122
The WSI_DebugTools class contains some tools/settings which are useful for debugging.
Definition: wsi_debugtools.h:42
The WSI_ProjectAutosaveInterval class represents the project autosave interval setting.
Definition: wsi_projectautosaveinterval.h:46
QScopedPointer< WSI_DebugTools > mDebugTools
Definition: workspacesettings.h:135
WSI_Repositories & getRepositories() const noexcept
Definition: workspacesettings.h:92
QList< WSI_Base * > mItems
contains all settings items
Definition: workspacesettings.h:126
QScopedPointer< WSI_LibraryLocaleOrder > mLibraryLocaleOrder
Definition: workspacesettings.h:132
The WSI_User class contains the default author used for projects and libraries.
Definition: wsi_user.h:42
WSI_User & getUser() const noexcept
Definition: workspacesettings.h:77
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
void loadSettingsItem(QScopedPointer< T > &member, SExpression &root)
Definition: workspacesettings.cpp:110
void saveToFile() const
Definition: workspacesettings.cpp:116
WSI_AppLocale & getAppLocale() const noexcept
Definition: workspacesettings.h:78
WSI_Appearance & getAppearance() const noexcept
Definition: workspacesettings.h:85
The WorkspaceSettingsDialog class.
Definition: workspacesettingsdialog.h:53
void showSettingsDialog() noexcept
Open the workspace settings dialog.
Definition: workspacesettings.cpp:101
The WSI_Base class is the base class of all workspace settings items.
Definition: wsi_base.h:48
QScopedPointer< WSI_AppDefaultMeasurementUnits > mAppDefMeasUnits
Definition: workspacesettings.h:129
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: workspacesettings.cpp:121
QScopedPointer< WSI_User > mUser
Definition: workspacesettings.h:127
The WSI_AppDefaultMeasurementUnits class represents the application's default measurement units (for ...
Definition: wsi_appdefaultmeasurementunits.h:44
WSI_DebugTools & getDebugTools() const noexcept
Definition: workspacesettings.h:93
WSI_LibraryNormOrder & getLibNormOrder() const noexcept
Definition: workspacesettings.h:89
void restoreDefaults() noexcept
Definition: workspacesettings.cpp:83
The WSI_AppLocale class represents the application's locale settings (for translation and localizatio...
Definition: wsi_applocale.h:42
WSI_LibraryLocaleOrder & getLibLocaleOrder() const noexcept
Definition: workspacesettings.h:86
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
QScopedPointer< WSI_AppLocale > mAppLocale
Definition: workspacesettings.h:128
QScopedPointer< WSI_Repositories > mRepositories
Definition: workspacesettings.h:134
QScopedPointer< WorkspaceSettingsDialog > mDialog
the settings dialog
Definition: workspacesettings.h:123
WSI_AppDefaultMeasurementUnits & getAppDefMeasUnits() const noexcept
Definition: workspacesettings.h:79
QScopedPointer< WSI_Appearance > mAppearance
Definition: workspacesettings.h:131
WSI_ProjectAutosaveInterval & getProjectAutosaveInterval() const noexcept
Definition: workspacesettings.h:82
The WSI_LibraryLocaleOrder class contains a list of locales which should be used for all (translatabl...
Definition: wsi_librarylocaleorder.h:43
The WorkspaceSettings class manages all workspace related settings.
Definition: workspacesettings.h:66
The SExpression class.
Definition: sexpression.h:57
~WorkspaceSettings() noexcept
Definition: workspacesettings.cpp:74
The WSI_Repositories class contains a list of used repositories.
Definition: wsi_repositories.h:44