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 RuleCheckMessage;
41class Workspace;
42
43namespace editor {
44
45class GraphicsLayerList;
46class LibrariesModel;
47class LibraryEditor;
48class LibraryElementCache;
49class MainWindow;
50class Notification;
51class NotificationsModel;
52class OrganizationsDbModel;
53class ProjectEditor;
54class ProjectLibraryUpdater;
55class QuickAccessModel;
56class SlintKeyEventTextBuilder;
57
58/*******************************************************************************
59 * Translation Function
60 ******************************************************************************/
61
62void slintTr(slint::private_api::Slice<uint8_t> string,
63 slint::private_api::Slice<uint8_t> ctx,
64 slint::private_api::Slice<uint8_t> domain, int32_t n,
65 slint::private_api::Slice<uint8_t> plural,
66 slint::SharedString* out) noexcept;
67
68/*******************************************************************************
69 * Class GuiApplication
70 ******************************************************************************/
71
75class GuiApplication final : public QObject {
76 Q_OBJECT
77
78public:
79 // Constructors / Destructor
80 GuiApplication() = delete;
81 GuiApplication(const GuiApplication& other) = delete;
82 explicit GuiApplication(Workspace& ws, bool fileFormatIsOutdated,
83 QObject* parent = nullptr) noexcept;
84 ~GuiApplication() noexcept;
85
86 // Workspace
87 Workspace& getWorkspace() noexcept { return mWorkspace; }
89 void openFile(const FilePath& fp, QWidget* parent) noexcept;
90 void switchWorkspace(QWidget* parent) noexcept;
91 void execWorkspaceSettingsDialog(QWidget* parent) noexcept;
92 void addExampleProjects(QWidget* parent) noexcept;
93
94 // General
95 const GraphicsLayerList& getPreviewLayers() const noexcept {
96 return *mPreviewLayers;
97 }
100 }
101
102 // Libraries
105 const QVector<std::shared_ptr<LibraryEditor>>& getLibraries() noexcept {
106 return mLibraries->values();
107 }
108 std::shared_ptr<LibraryEditor> getLibrary(const FilePath& libDir) noexcept;
109 std::shared_ptr<LibraryEditor> openLibrary(const FilePath& libDir) noexcept;
110 void closeLibrary(const FilePath& libDir) noexcept;
111 bool requestClosingAllLibraries() noexcept;
112
113 // Projects
114 const QVector<std::shared_ptr<ProjectEditor>>& getProjects() noexcept {
115 return mProjects->values();
116 }
117 void createProject(const FilePath& parentDir, bool eagleImport,
118 QWidget* parent) noexcept;
128 std::shared_ptr<ProjectEditor> openProject(FilePath fp,
129 QWidget* parent) noexcept;
130 void closeProject(int index) noexcept;
131 bool requestClosingAllProjects() noexcept;
132
133 // Window Management
135 void createNewWindow(int id = -1, int projectIndex = -1) noexcept;
136 int getWindowCount() const noexcept;
137 void stopWindowStateAutosaveTimer() noexcept;
138
139 // General Methods
140 void exec();
141 void quit(QPointer<QWidget> parent) noexcept;
142
143 // Operator Overloadings
144 GuiApplication& operator=(const GuiApplication& rhs) = delete;
145
146signals:
147 void statusBarMessageChanged(const QString& message, int timeoutMs);
149
150protected:
151 bool eventFilter(QObject* watched, QEvent* event) noexcept override;
152
153private:
154 void openProjectsPassedByCommandLine() noexcept;
155 void openProjectPassedByOs(const QString& file, bool silent = false) noexcept;
156 void openProjectLibraryUpdater(const FilePath& project) noexcept;
157
158 void highlightErcMessage(std::shared_ptr<const RuleCheckMessage> msg,
159 bool zoomTo, int windowId) noexcept;
160
161 std::shared_ptr<MainWindow> getCurrentWindow() noexcept;
165
166 void moveTab(int srcWindowId, int srcSectionIndex, int srcTabIndex,
167 int dstWindowId, int dstSectionIndex, int dstTabIndex,
168 bool forceSwitchToTab) noexcept;
169 std::shared_ptr<MainWindow> getWindowById(int id) noexcept;
170
182 std::shared_ptr<UiObjectList<ProjectEditor, ui::ProjectData>> mProjects;
183 std::shared_ptr<UiObjectList<LibraryEditor, ui::LibraryData>> mLibraries;
185 QList<std::shared_ptr<MainWindow>> mWindows;
187
188 // Cache
190};
191
192/*******************************************************************************
193 * End of File
194 ******************************************************************************/
195
196} // namespace editor
197} // namespace librepcb
198
199#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GuiApplication class.
Definition guiapplication.h:75
QuickAccessModel & getQuickAccess() noexcept
Definition guiapplication.h:88
void exec()
Definition guiapplication.cpp:880
const LibraryElementCache & getLibraryElementCache() const noexcept
Definition guiapplication.h:98
void openFile(const FilePath &fp, QWidget *parent) noexcept
Definition guiapplication.cpp:317
QTimer mSaveOpenedWindowsCountdown
Definition guiapplication.h:186
void updateLibrariesContainStandardComponents() noexcept
Definition guiapplication.cpp:990
bool eventFilter(QObject *watched, QEvent *event) noexcept override
Definition guiapplication.cpp:902
void switchWorkspace(QWidget *parent) noexcept
Definition guiapplication.cpp:326
QList< std::shared_ptr< MainWindow > > mWindows
Definition guiapplication.h:185
std::shared_ptr< UiObjectList< LibraryEditor, ui::LibraryData > > mLibraries
Definition guiapplication.h:183
std::shared_ptr< LibrariesModel > mLocalLibraries
Definition guiapplication.h:179
const GraphicsLayerList & getPreviewLayers() const noexcept
Definition guiapplication.h:95
NotificationsModel & getNotifications() noexcept
Definition guiapplication.h:134
bool requestClosingAllProjects() noexcept
Definition guiapplication.cpp:620
std::shared_ptr< LibraryEditor > openLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:382
bool mLibrariesContainStandardComponents
Definition guiapplication.h:172
void openProjectsPassedByCommandLine() noexcept
Definition guiapplication.cpp:916
void updateDesktopIntegrationNotification() noexcept
Definition guiapplication.cpp:1021
std::weak_ptr< OrganizationsDbModel > mOrganizationsWithPcbDesignRules
Definition guiapplication.h:189
std::unique_ptr< ProjectLibraryUpdater > mProjectLibraryUpdater
Definition guiapplication.h:184
std::shared_ptr< ProjectEditor > openProject(FilePath fp, QWidget *parent) noexcept
Open a project with the editor.
Definition guiapplication.cpp:488
void updateNoLibrariesInstalledNotification() noexcept
Definition guiapplication.cpp:1005
LibrariesModel & getLocalLibraries() noexcept
Definition guiapplication.h:103
const QVector< std::shared_ptr< LibraryEditor > > & getLibraries() noexcept
Definition guiapplication.h:105
int getWindowCount() const noexcept
Definition guiapplication.cpp:868
std::shared_ptr< MainWindow > getWindowById(int id) noexcept
Definition guiapplication.cpp:1073
void openProjectLibraryUpdater(const FilePath &project) noexcept
Definition guiapplication.cpp:937
std::shared_ptr< MainWindow > getCurrentWindow() noexcept
Definition guiapplication.cpp:979
Workspace & getWorkspace() noexcept
Definition guiapplication.h:87
std::unique_ptr< GraphicsLayerList > mPreviewLayers
Definition guiapplication.h:173
const QVector< std::shared_ptr< ProjectEditor > > & getProjects() noexcept
Definition guiapplication.h:114
std::shared_ptr< Notification > mNotificationDesktopIntegration
Definition guiapplication.h:177
GuiApplication(const GuiApplication &other)=delete
void statusBarMessageChanged(const QString &message, int timeoutMs)
std::shared_ptr< UiObjectList< ProjectEditor, ui::ProjectData > > mProjects
Definition guiapplication.h:182
void openProjectPassedByOs(const QString &file, bool silent=false) noexcept
Definition guiapplication.cpp:926
std::shared_ptr< QuickAccessModel > mQuickAccessModel
Definition guiapplication.h:178
void quit(QPointer< QWidget > parent) noexcept
Definition guiapplication.cpp:884
void stopWindowStateAutosaveTimer() noexcept
Definition guiapplication.cpp:872
std::shared_ptr< NotificationsModel > mNotifications
Definition guiapplication.h:175
void execWorkspaceSettingsDialog(QWidget *parent) noexcept
Definition guiapplication.cpp:343
bool requestClosingAllLibraries() noexcept
Definition guiapplication.cpp:451
void addExampleProjects(QWidget *parent) noexcept
Definition guiapplication.cpp:350
std::shared_ptr< LibraryElementCache > mLibraryElementCache
Definition guiapplication.h:174
Workspace & mWorkspace
Definition guiapplication.h:171
void createNewWindow(int id=-1, int projectIndex=-1) noexcept
Definition guiapplication.cpp:635
void closeProject(int index) noexcept
Definition guiapplication.cpp:613
void moveTab(int srcWindowId, int srcSectionIndex, int srcTabIndex, int dstWindowId, int dstSectionIndex, int dstTabIndex, bool forceSwitchToTab) noexcept
Definition guiapplication.cpp:1033
std::shared_ptr< Notification > mNotificationNoLibrariesInstalled
Definition guiapplication.h:176
std::shared_ptr< LibraryEditor > getLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:372
std::shared_ptr< LibrariesModel > mRemoteLibraries
Definition guiapplication.h:180
void librariesContainStandardComponentsChanged(bool contains)
LibrariesModel & getRemoteLibraries() noexcept
Definition guiapplication.h:104
void highlightErcMessage(std::shared_ptr< const RuleCheckMessage > msg, bool zoomTo, int windowId) noexcept
Definition guiapplication.cpp:964
std::unique_ptr< SlintKeyEventTextBuilder > mLibrariesFilter
Definition guiapplication.h:181
void closeLibrary(const FilePath &libDir) noexcept
Definition guiapplication.cpp:442
void createProject(const FilePath &parentDir, bool eagleImport, QWidget *parent) noexcept
Definition guiapplication.cpp:466
The LibrariesModel class.
Definition librariesmodel.h:55
The LibraryEditor class.
Definition libraryeditor.h:56
Cache for fast access to library elements.
Definition libraryelementcache.h:56
The MainWindow class.
Definition mainwindow.h:59
The Notification class.
Definition notification.h:43
The NotificationsModel class.
Definition notificationsmodel.h:52
The OrganizationsDbModel class.
Definition organizationsdbmodel.h:50
The ProjectEditor class.
Definition projecteditor.h:64
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
void slintTr(slint::private_api::Slice< uint8_t > string, slint::private_api::Slice< uint8_t > ctx, slint::private_api::Slice< uint8_t > domain, int32_t n, slint::private_api::Slice< uint8_t > plural, slint::SharedString *out) noexcept
Definition guiapplication.cpp:73
Definition occmodel.cpp:77
Definition uuid.h:186