LibrePCB Developers Documentation
Loading...
Searching...
No Matches
mainwindow.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_MAINWINDOW_H
21#define LIBREPCB_EDITOR_MAINWINDOW_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27#include "utils/uiobjectlist.h"
28
29#include <QtCore>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class FilePath;
39class RuleCheckMessage;
40
41namespace editor {
42
43class GuiApplication;
44class LibraryEditor;
45class MainWindowTestAdapter;
46class ProjectEditor;
47class ProjectReadmeRenderer;
48class SchematicTab;
49class WindowSection;
50class WindowTab;
51
52/*******************************************************************************
53 * Class MainWindow
54 ******************************************************************************/
55
59class MainWindow final : public QObject {
60 Q_OBJECT
61
62public:
63 // Constructors / Destructor
64 MainWindow() = delete;
65 MainWindow(const MainWindow& other) = delete;
66 explicit MainWindow(GuiApplication& app,
67 slint::ComponentHandle<ui::AppWindow> win, int id,
68 QObject* parent = nullptr) noexcept;
69 ~MainWindow() noexcept;
70
71 // General Methods
72 int getId() const noexcept { return mId; }
73 bool isCurrentWindow() const noexcept;
74 void makeCurrentWindow() noexcept;
75 QWidget& getWidget() noexcept { return *mWidget; }
76 void addSection(int newIndex, bool makeCurrent) noexcept;
77 void addTab(std::shared_ptr<WindowTab> tab, int section = -1, int index = -1,
78 bool switchToTab = true, bool switchToSection = true) noexcept;
79 std::shared_ptr<WindowTab> removeTab(
80 int section, int tab, bool* wasCurrentTab = nullptr,
81 bool* wasCurrentSection = nullptr) noexcept;
82 void showPanelPage(ui::PanelPage page) noexcept;
83 void popUpNotifications() noexcept;
84 void showStatusBarMessage(const QString& message, int timeoutMs);
85 void highlightErcMessage(ProjectEditor& prjEditor,
86 std::shared_ptr<const RuleCheckMessage> msg,
87 bool zoomTo) noexcept;
88 void setCurrentLibrary(int index) noexcept;
89 void setCurrentProject(int index) noexcept;
90 std::shared_ptr<SchematicTab> openSchematicTab(int projectIndex,
91 int index) noexcept;
92 void openBoard2dTab(int projectIndex, int index,
93 bool switchToTab = true) noexcept;
94
95 // Operator Overloadings
96 MainWindow& operator=(const MainWindow& rhs) = delete;
97
98signals:
100
101private:
102 slint::CloseRequestResponse closeRequested() noexcept;
103 void trigger(ui::Action a) noexcept;
104 void triggerSection(int section, ui::WindowSectionAction a) noexcept;
105 void triggerTab(int section, int tab, ui::TabAction a) noexcept;
106 void triggerLibrary(slint::SharedString path, ui::LibraryAction a) noexcept;
107 void triggerLibraryElement(slint::SharedString path,
108 ui::LibraryElementAction a) noexcept;
109 void triggerProject(int index, ui::ProjectAction a) noexcept;
110 void triggerSchematic(int project, int schematic,
111 ui::SchematicAction a) noexcept;
112 void triggerBoard(int project, int board, ui::BoardAction a) noexcept;
113 void openLibraryTab(const FilePath& fp, bool wizardMode) noexcept;
114 void openComponentCategoryTab(LibraryEditor& editor, const FilePath& fp,
115 bool copyFrom) noexcept;
116 void openPackageCategoryTab(LibraryEditor& editor, const FilePath& fp,
117 bool copyFrom) noexcept;
118 void openSymbolTab(LibraryEditor& editor, const FilePath& fp,
119 bool copyFrom) noexcept;
120 void openPackageTab(LibraryEditor& editor, const FilePath& fp,
121 bool copyFrom) noexcept;
122 void openComponentTab(LibraryEditor& editor, const FilePath& fp,
123 bool copyFrom) noexcept;
124 void openDeviceTab(LibraryEditor& editor, const FilePath& fp,
125 bool copyFrom) noexcept;
126 void openOrganizationTab(LibraryEditor& editor, const FilePath& fp,
127 bool copyFrom) noexcept;
128 void openBoard3dTab(int projectIndex, int index) noexcept;
129 void updateHomeTabSection() noexcept;
130 template <typename T>
131 bool switchToTab() noexcept;
132 template <typename T>
133 bool switchToLibraryElementTab(const FilePath& fp) noexcept;
134 template <typename T>
135 std::shared_ptr<T> switchToProjectTab(int prjIndex, int objIndex) noexcept;
136
137 const int mId;
138 const QString mSettingsPrefix;
140 slint::ComponentHandle<ui::AppWindow> mWindow;
141 QWidget* mWidget;
142 std::shared_ptr<UiObjectList<WindowSection, ui::WindowSectionData>> mSections;
145
147};
148
149/*******************************************************************************
150 * End of File
151 ******************************************************************************/
152
153} // namespace editor
154} // namespace librepcb
155
156#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The GuiApplication class.
Definition guiapplication.h:75
The LibraryEditor class.
Definition libraryeditor.h:56
The MainWindow class.
Definition mainwindow.h:59
void openComponentCategoryTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:974
void triggerProject(int index, ui::ProjectAction a) noexcept
Definition mainwindow.cpp:820
std::shared_ptr< WindowTab > removeTab(int section, int tab, bool *wasCurrentTab=nullptr, bool *wasCurrentSection=nullptr) noexcept
Definition mainwindow.cpp:432
slint::CloseRequestResponse closeRequested() noexcept
Definition mainwindow.cpp:508
std::unique_ptr< MainWindowTestAdapter > mTestAdapter
Definition mainwindow.h:144
void popUpNotifications() noexcept
Definition mainwindow.cpp:450
void triggerSection(int section, ui::WindowSectionAction a) noexcept
Definition mainwindow.cpp:656
void trigger(ui::Action a) noexcept
Definition mainwindow.cpp:543
void highlightErcMessage(ProjectEditor &prjEditor, std::shared_ptr< const RuleCheckMessage > msg, bool zoomTo) noexcept
Definition mainwindow.cpp:469
void showPanelPage(ui::PanelPage page) noexcept
Definition mainwindow.cpp:446
std::unique_ptr< ProjectReadmeRenderer > mProjectPreviewRenderer
Definition mainwindow.h:143
void openBoard3dTab(int projectIndex, int index) noexcept
Definition mainwindow.cpp:1476
bool isCurrentWindow() const noexcept
Definition mainwindow.cpp:369
void updateHomeTabSection() noexcept
Definition mainwindow.cpp:1486
bool switchToLibraryElementTab(const FilePath &fp) noexcept
Definition mainwindow.cpp:1503
std::shared_ptr< T > switchToProjectTab(int prjIndex, int objIndex) noexcept
Definition mainwindow.cpp:1513
int getId() const noexcept
Definition mainwindow.h:72
void openPackageCategoryTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1014
void openComponentTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1270
void triggerBoard(int project, int board, ui::BoardAction a) noexcept
Definition mainwindow.cpp:876
void openPackageTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1136
const QString mSettingsPrefix
Definition mainwindow.h:138
std::shared_ptr< SchematicTab > openSchematicTab(int projectIndex, int index) noexcept
Definition mainwindow.cpp:1450
void triggerLibraryElement(slint::SharedString path, ui::LibraryElementAction a) noexcept
Definition mainwindow.cpp:766
slint::ComponentHandle< ui::AppWindow > mWindow
Definition mainwindow.h:140
void setCurrentLibrary(int index) noexcept
Definition mainwindow.cpp:494
void triggerLibrary(slint::SharedString path, ui::LibraryAction a) noexcept
Definition mainwindow.cpp:688
void openDeviceTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1358
void openBoard2dTab(int projectIndex, int index, bool switchToTab=true) noexcept
Definition mainwindow.cpp:1464
std::shared_ptr< UiObjectList< WindowSection, ui::WindowSectionData > > mSections
Definition mainwindow.h:142
MainWindow(const MainWindow &other)=delete
void triggerTab(int section, int tab, ui::TabAction a) noexcept
Definition mainwindow.cpp:682
const int mId
Definition mainwindow.h:137
void openLibraryTab(const FilePath &fp, bool wizardMode) noexcept
Definition mainwindow.cpp:951
void makeCurrentWindow() noexcept
Definition mainwindow.cpp:373
QWidget & getWidget() noexcept
Definition mainwindow.h:75
QWidget * mWidget
Definition mainwindow.h:141
bool switchToTab() noexcept
Definition mainwindow.cpp:1493
void addTab(std::shared_ptr< WindowTab > tab, int section=-1, int index=-1, bool switchToTab=true, bool switchToSection=true) noexcept
Definition mainwindow.cpp:412
void openOrganizationTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1402
void addSection(int newIndex, bool makeCurrent) noexcept
Definition mainwindow.cpp:379
void openSymbolTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:1054
void triggerSchematic(int project, int schematic, ui::SchematicAction a) noexcept
Definition mainwindow.cpp:850
void setCurrentProject(int index) noexcept
Definition mainwindow.cpp:499
void showStatusBarMessage(const QString &message, int timeoutMs)
Definition mainwindow.cpp:456
GuiApplication & mApp
Definition mainwindow.h:139
Adapter class for automated GUI tests.
Definition mainwindowtestadapter.h:47
The ProjectEditor class.
Definition projecteditor.h:64
Renders a README.md or other file types as a QPixmap.
Definition projectreadmerenderer.h:44
The SchematicTab class.
Definition schematictab.h:63
The UiObjectList class.
Definition uiobjectlist.h:47
The WindowSection class.
Definition windowsection.h:57
The WindowTab class.
Definition windowtab.h:52
Definition occmodel.cpp:77
Definition uuid.h:186