LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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#include "utils/uiobjectlist.h"
28
30
31#include <QtCore>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Workspace;
41
42namespace editor {
43
44class LibrariesModel;
45class LibraryEditor;
46class MainWindow;
47class Notification;
48class NotificationsModel;
49class ProjectEditor;
50class ProjectLibraryUpdater;
51class QuickAccessModel;
52class SlintKeyEventTextBuilder;
53
54/*******************************************************************************
55 * Class GuiApplication
56 ******************************************************************************/
57
61class GuiApplication final : public QObject {
62 Q_OBJECT
63
64public:
65 // Constructors / Destructor
66 GuiApplication() = delete;
67 GuiApplication(const GuiApplication& other) = delete;
68 explicit GuiApplication(Workspace& ws, bool fileFormatIsOutdated,
69 QObject* parent = nullptr) noexcept;
70 ~GuiApplication() noexcept;
71
72 // Workspace
73 Workspace& getWorkspace() noexcept { return mWorkspace; }
75 void openFile(const FilePath& fp, QWidget* parent) noexcept;
76 void switchWorkspace(QWidget* parent) noexcept;
77 void execWorkspaceSettingsDialog(QWidget* parent) noexcept;
78 void addExampleProjects(QWidget* parent) noexcept;
79
80 // Libraries
83 const QVector<std::shared_ptr<LibraryEditor>>& getLibraries() noexcept {
84 return mLibraries->values();
85 }
86 std::shared_ptr<LibraryEditor> getLibrary(const FilePath& libDir) noexcept;
87 std::shared_ptr<LibraryEditor> openLibrary(const FilePath& libDir) noexcept;
88 void closeLibrary(const FilePath& libDir) noexcept;
89 bool requestClosingAllLibraries() noexcept;
90
91 // Projects
92 const QVector<std::shared_ptr<ProjectEditor>>& getProjects() noexcept {
93 return mProjects->values();
94 }
95 void createProject(const FilePath& parentDir, bool eagleImport,
96 QWidget* parent) noexcept;
106 std::shared_ptr<ProjectEditor> openProject(FilePath fp,
107 QWidget* parent) noexcept;
108 void closeProject(int index) noexcept;
109 bool requestClosingAllProjects() noexcept;
110
111 // Window Management
113 void createNewWindow(int id = -1, int projectIndex = -1) noexcept;
114 int getWindowCount() const noexcept;
115 void stopWindowStateAutosaveTimer() noexcept;
116
117 // General Methods
118 void exec();
119 void quit(QPointer<QWidget> parent) noexcept;
120
121 // Operator Overloadings
122 GuiApplication& operator=(const GuiApplication& rhs) = delete;
123
124signals:
125 void statusBarMessageChanged(const QString& message, int timeoutMs);
127
128protected:
129 bool eventFilter(QObject* watched, QEvent* event) noexcept override;
130
131private:
132 void openProjectsPassedByCommandLine() noexcept;
133 void openProjectPassedByOs(const QString& file, bool silent = false) noexcept;
134 void openProjectLibraryUpdater(const FilePath& project) noexcept;
135
136 std::shared_ptr<MainWindow> getCurrentWindow() noexcept;
140
150 std::shared_ptr<UiObjectList<ProjectEditor, ui::ProjectData>> mProjects;
151 std::shared_ptr<UiObjectList<LibraryEditor, ui::LibraryData>> mLibraries;
153 QList<std::shared_ptr<MainWindow>> mWindows;
155};
156
157/*******************************************************************************
158 * End of File
159 ******************************************************************************/
160
161} // namespace editor
162} // namespace librepcb
163
164#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:61
QuickAccessModel & getQuickAccess() noexcept
Definition guiapplication.h:74
void exec()
Definition guiapplication.cpp:723
void openFile(const FilePath &fp, QWidget *parent) noexcept
Definition guiapplication.cpp:240
QTimer mSaveOpenedWindowsCountdown
Definition guiapplication.h:154
void updateLibrariesContainStandardComponents() noexcept
Definition guiapplication.cpp:818
bool eventFilter(QObject *watched, QEvent *event) noexcept override
Definition guiapplication.cpp:745
void switchWorkspace(QWidget *parent) noexcept
Definition guiapplication.cpp:249
QList< std::shared_ptr< MainWindow > > mWindows
Definition guiapplication.h:153
std::shared_ptr< UiObjectList< LibraryEditor, ui::LibraryData > > mLibraries
Definition guiapplication.h:151
std::shared_ptr< LibrariesModel > mLocalLibraries
Definition guiapplication.h:147
NotificationsModel & getNotifications() noexcept
Definition guiapplication.h:112
bool requestClosingAllProjects() noexcept
Definition guiapplication.cpp:527
std::shared_ptr< LibraryEditor > openLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:305
bool mLibrariesContainStandardComponents
Definition guiapplication.h:142
void openProjectsPassedByCommandLine() noexcept
Definition guiapplication.cpp:759
void updateDesktopIntegrationNotification() noexcept
Definition guiapplication.cpp:849
std::unique_ptr< ProjectLibraryUpdater > mProjectLibraryUpdater
Definition guiapplication.h:152
std::shared_ptr< ProjectEditor > openProject(FilePath fp, QWidget *parent) noexcept
Open a project with the editor.
Definition guiapplication.cpp:411
void updateNoLibrariesInstalledNotification() noexcept
Definition guiapplication.cpp:833
LibrariesModel & getLocalLibraries() noexcept
Definition guiapplication.h:81
const QVector< std::shared_ptr< LibraryEditor > > & getLibraries() noexcept
Definition guiapplication.h:83
int getWindowCount() const noexcept
Definition guiapplication.cpp:711
void openProjectLibraryUpdater(const FilePath &project) noexcept
Definition guiapplication.cpp:780
std::shared_ptr< MainWindow > getCurrentWindow() noexcept
Definition guiapplication.cpp:807
Workspace & getWorkspace() noexcept
Definition guiapplication.h:73
const QVector< std::shared_ptr< ProjectEditor > > & getProjects() noexcept
Definition guiapplication.h:92
std::shared_ptr< Notification > mNotificationDesktopIntegration
Definition guiapplication.h:145
GuiApplication(const GuiApplication &other)=delete
void statusBarMessageChanged(const QString &message, int timeoutMs)
std::shared_ptr< UiObjectList< ProjectEditor, ui::ProjectData > > mProjects
Definition guiapplication.h:150
void openProjectPassedByOs(const QString &file, bool silent=false) noexcept
Definition guiapplication.cpp:769
std::shared_ptr< QuickAccessModel > mQuickAccessModel
Definition guiapplication.h:146
void quit(QPointer< QWidget > parent) noexcept
Definition guiapplication.cpp:727
void stopWindowStateAutosaveTimer() noexcept
Definition guiapplication.cpp:715
std::shared_ptr< NotificationsModel > mNotifications
Definition guiapplication.h:143
void execWorkspaceSettingsDialog(QWidget *parent) noexcept
Definition guiapplication.cpp:266
bool requestClosingAllLibraries() noexcept
Definition guiapplication.cpp:374
void addExampleProjects(QWidget *parent) noexcept
Definition guiapplication.cpp:273
Workspace & mWorkspace
Definition guiapplication.h:141
void createNewWindow(int id=-1, int projectIndex=-1) noexcept
Definition guiapplication.cpp:542
void closeProject(int index) noexcept
Definition guiapplication.cpp:520
std::shared_ptr< Notification > mNotificationNoLibrariesInstalled
Definition guiapplication.h:144
std::shared_ptr< LibraryEditor > getLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:295
std::shared_ptr< LibrariesModel > mRemoteLibraries
Definition guiapplication.h:148
void librariesContainStandardComponentsChanged(bool contains)
LibrariesModel & getRemoteLibraries() noexcept
Definition guiapplication.h:82
std::unique_ptr< SlintKeyEventTextBuilder > mLibrariesFilter
Definition guiapplication.h:149
void closeLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:365
void createProject(const FilePath &parentDir, bool eagleImport, QWidget *parent) noexcept
Definition guiapplication.cpp:389
The LibrariesModel class.
Definition librariesmodel.h:55
The LibraryEditor class.
Definition libraryeditor.h:57
The MainWindow class.
Definition mainwindow.h:56
The Notification class.
Definition notification.h:43
The NotificationsModel class.
Definition notificationsmodel.h:52
The ProjectEditor class.
Definition projecteditor.h:63
The ProjectLibraryUpdater class.
Definition projectlibraryupdater.h:60
The QuickAccessModel class.
Definition quickaccessmodel.h:49
The SlintKeyEventTextBuilder class.
Definition slintkeyeventtextbuilder.h:43
The UiObjectList class.
Definition uiobjectlist.h:47
Definition occmodel.cpp:77
Definition uuid.h:186