LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
guiapplication.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_GUIAPPLICATION_H
21#define LIBREPCB_EDITOR_GUIAPPLICATION_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Workspace;
40
41namespace editor {
42
43class LibrariesModel;
44class LibraryEditor;
45class MainWindow;
46class Notification;
47class NotificationsModel;
48class ProjectEditor;
49class ProjectLibraryUpdater;
50class QuickAccessModel;
51class SlintKeyEventTextBuilder;
52
53/*******************************************************************************
54 * Class GuiApplication
55 ******************************************************************************/
56
60class GuiApplication final : public QObject {
61 Q_OBJECT
62
63public:
64 // Constructors / Destructor
65 GuiApplication() = delete;
66 GuiApplication(const GuiApplication& other) = delete;
67 explicit GuiApplication(Workspace& ws, bool fileFormatIsOutdated,
68 QObject* parent = nullptr) noexcept;
69 ~GuiApplication() noexcept;
70
71 // Getters
72 Workspace& getWorkspace() noexcept { return mWorkspace; }
77
78 // General Methods
79 void openFile(const FilePath& fp, QWidget* parent) noexcept;
80 void switchWorkspace(QWidget* parent) noexcept;
81 void execWorkspaceSettingsDialog(QWidget* parent) noexcept;
82 void addExampleProjects(QWidget* parent) noexcept;
83 void createProject(const FilePath& parentDir, bool eagleImport,
84 QWidget* parent) noexcept;
95 ProjectEditor* openProject(FilePath filepath, QWidget* parent) noexcept;
96 void createNewWindow(int id = -1) noexcept;
97 bool requestClosingWindow(QWidget* parent) noexcept;
98 void exec();
99 void quit(QPointer<QWidget> parent) noexcept;
100
101 // Operator Overloadings
102 GuiApplication& operator=(const GuiApplication& rhs) = delete;
103
104protected:
105 bool eventFilter(QObject* watched, QEvent* event) noexcept override;
106
107private:
108 void openProjectsPassedByCommandLine() noexcept;
109 void openProjectPassedByOs(const QString& file, bool silent = false) noexcept;
110
123 ProjectEditor* getOpenProject(const FilePath& filepath) const noexcept;
124
135 static bool askForRestoringBackup(const FilePath& dir);
136
146 bool closeAllProjects(bool askForSave, QWidget* parent) noexcept;
147
148 void projectEditorClosed() noexcept;
149 void openProjectLibraryUpdater(const FilePath& project) noexcept;
150
151 void openLibraryEditor(const FilePath& libDir) noexcept;
152 void libraryEditorDestroyed() noexcept;
153
162 bool closeAllLibraryEditors(bool askForSave) noexcept;
163
164 std::shared_ptr<MainWindow> getCurrentWindow() noexcept;
167
179 QList<std::shared_ptr<MainWindow>> mWindows;
181};
182
183/*******************************************************************************
184 * End of File
185 ******************************************************************************/
186
187} // namespace editor
188} // namespace librepcb
189
190#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The GuiApplication class.
Definition guiapplication.h:60
QuickAccessModel & getQuickAccess() noexcept
Definition guiapplication.h:74
void exec()
Definition guiapplication.cpp:499
void libraryEditorDestroyed() noexcept
Definition guiapplication.cpp:655
void openFile(const FilePath &fp, QWidget *parent) noexcept
Definition guiapplication.cpp:229
QTimer mSaveOpenedWindowsCountdown
Definition guiapplication.h:180
bool eventFilter(QObject *watched, QEvent *event) noexcept override
Definition guiapplication.cpp:521
void switchWorkspace(QWidget *parent) noexcept
Definition guiapplication.cpp:238
QList< std::shared_ptr< MainWindow > > mWindows
Definition guiapplication.h:179
QHash< FilePath, LibraryEditor * > mOpenLibraryEditors
Definition guiapplication.h:177
std::shared_ptr< LibrariesModel > mLocalLibraries
Definition guiapplication.h:173
NotificationsModel & getNotifications() noexcept
Definition guiapplication.h:73
void openLibraryEditor(const FilePath &libDir) noexcept
Definition guiapplication.cpp:627
void openProjectsPassedByCommandLine() noexcept
Definition guiapplication.cpp:535
void updateDesktopIntegrationNotification() noexcept
Definition guiapplication.cpp:706
std::unique_ptr< ProjectLibraryUpdater > mProjectLibraryUpdater
Definition guiapplication.h:178
static bool askForRestoringBackup(const FilePath &dir)
Ask the user whether to restore a backup of a project.
Definition guiapplication.cpp:564
void updateNoLibrariesInstalledNotification() noexcept
Definition guiapplication.cpp:690
LibrariesModel & getLocalLibraries() noexcept
Definition guiapplication.h:75
void openProjectLibraryUpdater(const FilePath &project) noexcept
Definition guiapplication.cpp:608
std::shared_ptr< MainWindow > getCurrentWindow() noexcept
Definition guiapplication.cpp:679
Workspace & getWorkspace() noexcept
Definition guiapplication.h:72
std::shared_ptr< Notification > mNotificationDesktopIntegration
Definition guiapplication.h:171
GuiApplication(const GuiApplication &other)=delete
QHash< QString, ProjectEditor * > mOpenProjectEditors
Definition guiapplication.h:176
void openProjectPassedByOs(const QString &file, bool silent=false) noexcept
Definition guiapplication.cpp:545
std::shared_ptr< QuickAccessModel > mQuickAccessModel
Definition guiapplication.h:172
void quit(QPointer< QWidget > parent) noexcept
Definition guiapplication.cpp:503
std::shared_ptr< NotificationsModel > mNotifications
Definition guiapplication.h:169
void execWorkspaceSettingsDialog(QWidget *parent) noexcept
Definition guiapplication.cpp:255
void addExampleProjects(QWidget *parent) noexcept
Definition guiapplication.cpp:262
ProjectEditor * getOpenProject(const FilePath &filepath) const noexcept
Get the pointer to an already open project editor by its project filepath.
Definition guiapplication.cpp:556
Workspace & mWorkspace
Definition guiapplication.h:168
ProjectEditor * openProject(FilePath filepath, QWidget *parent) noexcept
Open a project with the editor (or bring an already opened editor to front)
Definition guiapplication.cpp:302
std::shared_ptr< Notification > mNotificationNoLibrariesInstalled
Definition guiapplication.h:170
bool requestClosingWindow(QWidget *parent) noexcept
Definition guiapplication.cpp:487
bool closeAllProjects(bool askForSave, QWidget *parent) noexcept
Close all open project editors.
Definition guiapplication.cpp:582
std::shared_ptr< LibrariesModel > mRemoteLibraries
Definition guiapplication.h:174
void createNewWindow(int id=-1) noexcept
Definition guiapplication.cpp:386
LibrariesModel & getRemoteLibraries() noexcept
Definition guiapplication.h:76
std::unique_ptr< SlintKeyEventTextBuilder > mLibrariesFilter
Definition guiapplication.h:175
bool closeAllLibraryEditors(bool askForSave) noexcept
Close all open library editors.
Definition guiapplication.cpp:667
void createProject(const FilePath &parentDir, bool eagleImport, QWidget *parent) noexcept
Definition guiapplication.cpp:280
void projectEditorClosed() noexcept
Definition guiapplication.cpp:595
The LibrariesModel class.
Definition librariesmodel.h:54
The LibraryEditor class.
Definition libraryeditor.h:66
The MainWindow class.
Definition mainwindow.h:52
The Notification class.
Definition notification.h:43
The NotificationsModel class.
Definition notificationsmodel.h:52
The ProjectEditor class.
Definition projecteditor.h:66
The ProjectLibraryUpdater class.
Definition projectlibraryupdater.h:60
The QuickAccessModel class.
Definition quickaccessmodel.h:49
The SlintKeyEventTextBuilder class.
Definition slintkeyeventtextbuilder.h:43
Definition occmodel.cpp:77
Definition uuid.h:186