LibrePCB Developers Documentation
controlpanel.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_EDITOR_CONTROLPANEL_H
21#define LIBREPCB_EDITOR_CONTROLPANEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class FilePath;
37class Library;
38class Project;
39class Workspace;
40
41namespace editor {
42
43class FavoriteProjectsModel;
44class LibraryEditor;
45class LibraryManager;
46class ProjectEditor;
47class ProjectLibraryUpdater;
48class ProjectTreeModel;
49class RecentProjectsModel;
50class StandardEditorCommandHandler;
51
52namespace Ui {
53class ControlPanel;
54}
55
56/*******************************************************************************
57 * Class ControlPanel
58 ******************************************************************************/
59
63class ControlPanel final : public QMainWindow {
64 Q_OBJECT
65
66 // ProjectLibraryUpdater needs access to openProject() and getOpenProject()
68
69public:
70 // Constructors / Destructor
71 ControlPanel() = delete;
72 ControlPanel(const ControlPanel& other) = delete;
73 explicit ControlPanel(Workspace& workspace, bool fileFormatIsOutdated);
74 virtual ~ControlPanel() noexcept;
75
76 // Operator Overloadings
77 ControlPanel& operator=(const ControlPanel& rhs) = delete;
78
79public slots:
80 void showControlPanel() noexcept;
81 void openProjectLibraryUpdater(const FilePath& project) noexcept;
82
83protected:
84 // Inherited Methods
85 virtual void closeEvent(QCloseEvent* event) override;
86 virtual bool eventFilter(QObject* watched, QEvent* event) override;
87
88private slots:
89 // private slots
90 void openProjectsPassedByCommandLine() noexcept;
91 void openProjectPassedByOs(const QString& file, bool silent = false) noexcept;
92 void projectEditorClosed() noexcept;
93
94 // Actions
95 void on_projectTreeView_clicked(const QModelIndex& index);
96 void on_projectTreeView_doubleClicked(const QModelIndex& index);
98 void on_recentProjectsListView_entered(const QModelIndex& index);
99 void on_favoriteProjectsListView_entered(const QModelIndex& index);
100 void on_recentProjectsListView_clicked(const QModelIndex& index);
101 void on_favoriteProjectsListView_clicked(const QModelIndex& index);
104 const QPoint& pos);
105
106private:
107 // General private methods
108 void createActions() noexcept;
109 void createMenus() noexcept;
110 void saveSettings();
111 void loadSettings();
112 void updateDesktopIntegrationMessage() noexcept;
113 void openLibraryManager() noexcept;
114 void addExampleProjects() noexcept;
115 void switchWorkspace() noexcept;
116 void showProjectReadmeInBrowser(const FilePath& projectFilePath) noexcept;
117 void removeProjectsTreeItem(const FilePath& fp) noexcept;
118
119 // Project Management
120
121 ProjectEditor* newProject(bool eagleImport = false,
122 FilePath parentDir = FilePath()) noexcept;
123
133 ProjectEditor* openProject(FilePath filepath = FilePath()) noexcept;
134
143 bool closeProject(ProjectEditor& editor, bool askForSave) noexcept;
144
153 bool closeProject(const FilePath& filepath, bool askForSave) noexcept;
154
163 bool closeAllProjects(bool askForSave) noexcept;
164
177 ProjectEditor* getOpenProject(const FilePath& filepath) const noexcept;
178
189 static bool askForRestoringBackup(const FilePath& dir);
190
191 // Library Management
192 void openLibraryEditor(const FilePath& libDir) noexcept;
193 void libraryEditorDestroyed() noexcept;
194
203 bool closeAllLibraryEditors(bool askForSave) noexcept;
204
205 // Attributes
207 QScopedPointer<Ui::ControlPanel> mUi;
216
217 // Actions
218 QScopedPointer<QAction> mActionLibraryManager;
219 QScopedPointer<QAction> mActionWorkspaceSettings;
220 QScopedPointer<QAction> mActionRescanLibraries;
221 QScopedPointer<QAction> mActionSwitchWorkspace;
222 QScopedPointer<QAction> mActionNewProject;
223 QScopedPointer<QAction> mActionOpenProject;
224 QScopedPointer<QAction> mActionCloseAllProjects;
225 QScopedPointer<QAction> mActionAddExampleProjects;
226 QScopedPointer<QAction> mActionImportEagleProject;
227 QScopedPointer<QAction> mActionAboutLibrePcb;
228 QScopedPointer<QAction> mActionAboutQt;
229 QScopedPointer<QAction> mActionOnlineDocumentation;
230 QScopedPointer<QAction> mActionKeyboardShortcutsReference;
231 QScopedPointer<QAction> mActionWebsite;
232 QScopedPointer<QAction> mActionQtQuickTest;
233 QScopedPointer<QAction> mActionQuit;
234};
235
236/*******************************************************************************
237 * End of File
238 ******************************************************************************/
239
240} // namespace editor
241} // namespace librepcb
242
243#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition: workspace.h:54
The ControlPanel class.
Definition: controlpanel.h:63
QScopedPointer< QAction > mActionQtQuickTest
Definition: controlpanel.h:232
void showControlPanel() noexcept
Definition: controlpanel.cpp:246
QScopedPointer< QAction > mActionLibraryManager
Definition: controlpanel.h:218
void libraryEditorDestroyed() noexcept
Definition: controlpanel.cpp:708
void loadSettings()
Definition: controlpanel.cpp:412
ProjectEditor * openProject(FilePath filepath=FilePath()) noexcept
Open a project with the editor (or bring an already opened editor to front)
Definition: controlpanel.cpp:551
QHash< FilePath, LibraryEditor * > mOpenLibraryEditors
Definition: controlpanel.h:214
QScopedPointer< QAction > mActionKeyboardShortcutsReference
Definition: controlpanel.h:230
QScopedPointer< QAction > mActionQuit
Definition: controlpanel.h:233
void removeProjectsTreeItem(const FilePath &fp) noexcept
Definition: controlpanel.cpp:499
void openLibraryEditor(const FilePath &libDir) noexcept
Definition: controlpanel.cpp:686
QScopedPointer< RecentProjectsModel > mRecentProjectsModel
Definition: controlpanel.h:210
QScopedPointer< QAction > mActionImportEagleProject
Definition: controlpanel.h:226
QScopedPointer< QAction > mActionNewProject
Definition: controlpanel.h:222
void openProjectsPassedByCommandLine() noexcept
Definition: controlpanel.cpp:736
QScopedPointer< LibraryManager > mLibraryManager
Definition: controlpanel.h:212
static bool askForRestoringBackup(const FilePath &dir)
Ask the user whether to restore a backup of a project.
Definition: controlpanel.cpp:664
void createMenus() noexcept
Definition: controlpanel.cpp:347
QScopedPointer< QAction > mActionRescanLibraries
Definition: controlpanel.h:220
QScopedPointer< QAction > mActionAboutLibrePcb
Definition: controlpanel.h:227
ControlPanel(const ControlPanel &other)=delete
virtual ~ControlPanel() noexcept
Definition: controlpanel.cpp:206
void on_recentProjectsListView_clicked(const QModelIndex &index)
Definition: controlpanel.cpp:882
QScopedPointer< FavoriteProjectsModel > mFavoriteProjectsModel
Definition: controlpanel.h:211
void openProjectLibraryUpdater(const FilePath &project) noexcept
Definition: controlpanel.cpp:252
void on_favoriteProjectsListView_clicked(const QModelIndex &index)
Definition: controlpanel.cpp:887
QScopedPointer< QAction > mActionWebsite
Definition: controlpanel.h:231
void on_favoriteProjectsListView_entered(const QModelIndex &index)
Definition: controlpanel.cpp:876
QScopedPointer< ProjectLibraryUpdater > mProjectLibraryUpdater
Definition: controlpanel.h:215
virtual void closeEvent(QCloseEvent *event) override
Definition: controlpanel.cpp:214
QScopedPointer< QAction > mActionWorkspaceSettings
Definition: controlpanel.h:219
QHash< QString, ProjectEditor * > mOpenProjectEditors
Definition: controlpanel.h:213
ProjectEditor * newProject(bool eagleImport=false, FilePath parentDir=FilePath()) noexcept
Definition: controlpanel.cpp:529
virtual bool eventFilter(QObject *watched, QEvent *event) override
Definition: controlpanel.cpp:236
void openProjectPassedByOs(const QString &file, bool silent=false) noexcept
Definition: controlpanel.cpp:746
void on_favoriteProjectsListView_customContextMenuRequested(const QPoint &pos)
Definition: controlpanel.cpp:928
QScopedPointer< StandardEditorCommandHandler > mStandardCommandHandler
Definition: controlpanel.h:208
QScopedPointer< QAction > mActionSwitchWorkspace
Definition: controlpanel.h:221
QScopedPointer< QAction > mActionAddExampleProjects
Definition: controlpanel.h:225
void addExampleProjects() noexcept
Definition: controlpanel.cpp:453
QScopedPointer< QAction > mActionCloseAllProjects
Definition: controlpanel.h:224
void on_recentProjectsListView_entered(const QModelIndex &index)
Definition: controlpanel.cpp:871
ProjectEditor * getOpenProject(const FilePath &filepath) const noexcept
Get the pointer to an already open project editor by its project filepath.
Definition: controlpanel.cpp:656
QScopedPointer< ProjectTreeModel > mProjectTreeModel
Definition: controlpanel.h:209
QScopedPointer< QAction > mActionOpenProject
Definition: controlpanel.h:223
void on_projectTreeView_doubleClicked(const QModelIndex &index)
Definition: controlpanel.cpp:783
Workspace & mWorkspace
Definition: controlpanel.h:206
QScopedPointer< QAction > mActionOnlineDocumentation
Definition: controlpanel.h:229
void on_projectTreeView_clicked(const QModelIndex &index)
Definition: controlpanel.cpp:774
void on_recentProjectsListView_customContextMenuRequested(const QPoint &pos)
Definition: controlpanel.cpp:893
bool closeProject(ProjectEditor &editor, bool askForSave) noexcept
Close an opened project editor.
Definition: controlpanel.cpp:625
void saveSettings()
Definition: controlpanel.cpp:385
void createActions() noexcept
Definition: controlpanel.cpp:262
void openLibraryManager() noexcept
Definition: controlpanel.cpp:446
QScopedPointer< QAction > mActionAboutQt
Definition: controlpanel.h:228
void switchWorkspace() noexcept
Definition: controlpanel.cpp:471
void showProjectReadmeInBrowser(const FilePath &projectFilePath) noexcept
Definition: controlpanel.cpp:487
bool closeAllProjects(bool askForSave) noexcept
Close all open project editors.
Definition: controlpanel.cpp:648
QScopedPointer< Ui::ControlPanel > mUi
Definition: controlpanel.h:207
bool closeAllLibraryEditors(bool askForSave) noexcept
Close all open library editors.
Definition: controlpanel.cpp:720
void on_projectTreeView_customContextMenuRequested(const QPoint &pos)
Definition: controlpanel.cpp:796
void updateDesktopIntegrationMessage() noexcept
Definition: controlpanel.cpp:439
void projectEditorClosed() noexcept
Definition: controlpanel.cpp:757
The FavoriteProjectsModel class.
Definition: favoriteprojectsmodel.h:47
The LibraryEditor class.
Definition: libraryeditor.h:66
The LibraryManager class.
Definition: librarymanager.h:55
The ProjectEditor class.
Definition: projecteditor.h:62
The ProjectLibraryUpdater class.
Definition: projectlibraryupdater.h:62
The ProjectTreeModel class.
Definition: projecttreemodel.h:45
The RecentProjectsModel class.
Definition: recentprojectsmodel.h:47
Helper to handle some of the librepcb::editor::EditorCommand actions.
Definition: standardeditorcommandhandler.h:48
Definition: occmodel.cpp:77