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;
39
40namespace editor {
41
42class GuiApplication;
43class LibraryEditor;
44class MainWindowTestAdapter;
45class ProjectReadmeRenderer;
46class WindowSection;
47class WindowTab;
48
49/*******************************************************************************
50 * Class MainWindow
51 ******************************************************************************/
52
56class MainWindow final : public QObject {
57 Q_OBJECT
58
59public:
60 // Constructors / Destructor
61 MainWindow() = delete;
62 MainWindow(const MainWindow& other) = delete;
63 explicit MainWindow(GuiApplication& app,
64 slint::ComponentHandle<ui::AppWindow> win, int id,
65 QObject* parent = nullptr) noexcept;
66 ~MainWindow() noexcept;
67
68 // General Methods
69 int getId() const noexcept { return mId; }
70 bool isCurrentWindow() const noexcept;
71 void makeCurrentWindow() noexcept;
72 void showPanelPage(ui::PanelPage page) noexcept;
73 void popUpNotifications() noexcept;
74 void showStatusBarMessage(const QString& message, int timeoutMs);
75 void setCurrentLibrary(int index) noexcept;
76 void setCurrentProject(int index) noexcept;
77
78 // Operator Overloadings
79 MainWindow& operator=(const MainWindow& rhs) = delete;
80
81signals:
83
84private:
85 slint::CloseRequestResponse closeRequested() noexcept;
86 void trigger(ui::Action a) noexcept;
87 void triggerSection(int section, ui::WindowSectionAction a) noexcept;
88 void triggerTab(int section, int tab, ui::TabAction a) noexcept;
89 void triggerLibrary(slint::SharedString path, ui::LibraryAction a) noexcept;
90 void triggerLibraryElement(slint::SharedString path,
91 ui::LibraryElementAction a) noexcept;
92 void triggerProject(int index, ui::ProjectAction a) noexcept;
93 void triggerSchematic(int project, int schematic,
94 ui::SchematicAction a) noexcept;
95 void triggerBoard(int project, int board, ui::BoardAction a) noexcept;
96 void openLibraryTab(const FilePath& fp, bool wizardMode) noexcept;
97 void openComponentCategoryTab(LibraryEditor& editor, const FilePath& fp,
98 bool copyFrom) noexcept;
99 void openPackageCategoryTab(LibraryEditor& editor, const FilePath& fp,
100 bool copyFrom) noexcept;
101 void openSymbolTab(LibraryEditor& editor, const FilePath& fp,
102 bool copyFrom) noexcept;
103 void openPackageTab(LibraryEditor& editor, const FilePath& fp) noexcept;
104 void openComponentTab(LibraryEditor& editor, const FilePath& fp) noexcept;
105 void openDeviceTab(LibraryEditor& editor, const FilePath& fp) noexcept;
106 void openSchematicTab(int projectIndex, int index) noexcept;
107 void openBoard2dTab(int projectIndex, int index) noexcept;
108 void openBoard3dTab(int projectIndex, int index) noexcept;
109 void splitSection(int index, bool makeCurrent) noexcept;
110 void updateHomeTabSection() noexcept;
111 void addTab(std::shared_ptr<WindowTab> tab) noexcept;
112 template <typename T>
113 bool switchToTab() noexcept;
114 template <typename T>
115 bool switchToLibraryElementTab(const FilePath& fp) noexcept;
116 template <typename T>
117 bool switchToProjectTab(int prjIndex, int objIndex) noexcept;
118
119 const int mId;
120 const QString mSettingsPrefix;
122 slint::ComponentHandle<ui::AppWindow> mWindow;
123 QWidget* mWidget;
124 std::shared_ptr<UiObjectList<WindowSection, ui::WindowSectionData>> mSections;
127
129};
130
131/*******************************************************************************
132 * End of File
133 ******************************************************************************/
134
135} // namespace editor
136} // namespace librepcb
137
138#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The GuiApplication class.
Definition guiapplication.h:61
The LibraryEditor class.
Definition libraryeditor.h:57
The MainWindow class.
Definition mainwindow.h:56
void openComponentCategoryTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:826
void triggerProject(int index, ui::ProjectAction a) noexcept
Definition mainwindow.cpp:674
slint::CloseRequestResponse closeRequested() noexcept
Definition mainwindow.cpp:387
std::unique_ptr< MainWindowTestAdapter > mTestAdapter
Definition mainwindow.h:126
void addTab(std::shared_ptr< WindowTab > tab) noexcept
Definition mainwindow.cpp:1052
void popUpNotifications() noexcept
Definition mainwindow.cpp:354
void triggerSection(int section, ui::WindowSectionAction a) noexcept
Definition mainwindow.cpp:521
void trigger(ui::Action a) noexcept
Definition mainwindow.cpp:420
void showPanelPage(ui::PanelPage page) noexcept
Definition mainwindow.cpp:350
void openPackageTab(LibraryEditor &editor, const FilePath &fp) noexcept
Definition mainwindow.cpp:969
std::unique_ptr< ProjectReadmeRenderer > mProjectPreviewRenderer
Definition mainwindow.h:125
void openBoard3dTab(int projectIndex, int index) noexcept
Definition mainwindow.cpp:1004
bool isCurrentWindow() const noexcept
Definition mainwindow.cpp:340
void updateHomeTabSection() noexcept
Definition mainwindow.cpp:1046
bool switchToLibraryElementTab(const FilePath &fp) noexcept
Definition mainwindow.cpp:1072
void openComponentTab(LibraryEditor &editor, const FilePath &fp) noexcept
Definition mainwindow.cpp:974
int getId() const noexcept
Definition mainwindow.h:69
void openDeviceTab(LibraryEditor &editor, const FilePath &fp) noexcept
Definition mainwindow.cpp:979
void openPackageCategoryTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:865
void splitSection(int index, bool makeCurrent) noexcept
Definition mainwindow.cpp:1014
void triggerBoard(int project, int board, ui::BoardAction a) noexcept
Definition mainwindow.cpp:730
const QString mSettingsPrefix
Definition mainwindow.h:120
void triggerLibraryElement(slint::SharedString path, ui::LibraryElementAction a) noexcept
Definition mainwindow.cpp:622
bool switchToProjectTab(int prjIndex, int objIndex) noexcept
Definition mainwindow.cpp:1082
slint::ComponentHandle< ui::AppWindow > mWindow
Definition mainwindow.h:122
void setCurrentLibrary(int index) noexcept
Definition mainwindow.cpp:373
void triggerLibrary(slint::SharedString path, ui::LibraryAction a) noexcept
Definition mainwindow.cpp:553
std::shared_ptr< UiObjectList< WindowSection, ui::WindowSectionData > > mSections
Definition mainwindow.h:124
MainWindow(const MainWindow &other)=delete
void openSchematicTab(int projectIndex, int index) noexcept
Definition mainwindow.cpp:984
void triggerTab(int section, int tab, ui::TabAction a) noexcept
Definition mainwindow.cpp:547
const int mId
Definition mainwindow.h:119
void openBoard2dTab(int projectIndex, int index) noexcept
Definition mainwindow.cpp:994
void openLibraryTab(const FilePath &fp, bool wizardMode) noexcept
Definition mainwindow.cpp:805
void makeCurrentWindow() noexcept
Definition mainwindow.cpp:344
QWidget * mWidget
Definition mainwindow.h:123
bool switchToTab() noexcept
Definition mainwindow.cpp:1062
void openSymbolTab(LibraryEditor &editor, const FilePath &fp, bool copyFrom) noexcept
Definition mainwindow.cpp:904
void triggerSchematic(int project, int schematic, ui::SchematicAction a) noexcept
Definition mainwindow.cpp:704
void setCurrentProject(int index) noexcept
Definition mainwindow.cpp:378
void showStatusBarMessage(const QString &message, int timeoutMs)
Definition mainwindow.cpp:360
GuiApplication & mApp
Definition mainwindow.h:121
Adapter class for automated GUI tests.
Definition mainwindowtestadapter.h:47
Renders a README.md or other file types as a QPixmap.
Definition projectreadmerenderer.h:44
The UiObjectList class.
Definition uiobjectlist.h:47
The WindowSection class.
Definition windowsection.h:56
The WindowTab class.
Definition windowtab.h:51
Definition occmodel.cpp:77
Definition uuid.h:186