Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/*
* LibrePCB - Professional EDA for everyone!
* Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
* https://librepcb.org/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBREPCB_EDITOR_MAINWINDOW_H
#define LIBREPCB_EDITOR_MAINWINDOW_H
/*******************************************************************************
* Includes
******************************************************************************/
#include "ui.h"
#include "utils/uiobjectlist.h"
#include <librepcb/core/fileio/filepath.h>
#include <librepcb/core/utils/signalslot.h>
#include <QtCore>
#include <memory>
/*******************************************************************************
* Namespace / Forward Declarations
******************************************************************************/
namespace librepcb {
class Component;
class ComponentCategory;
class Device;
class Organization;
class Package;
class PackageCategory;
class RuleCheckMessage;
class Symbol;
namespace editor {
class GuiApplication;
class LibraryEditor;
class MainWindowTestAdapter;
class ProjectEditor;
class ProjectReadmeRenderer;
class SchematicTab;
class WindowSection;
class WindowTab;
/*******************************************************************************
* Class MainWindow
******************************************************************************/
/**
* @brief The MainWindow class
*/
class MainWindow final : public QObject {
Q_OBJECT
public:
// Signals
Signal<MainWindow> onUiDataChanged;
// Constructors / Destructor
MainWindow() = delete;
MainWindow(const MainWindow& other) = delete;
explicit MainWindow(GuiApplication& app,
slint::ComponentHandle<ui::AppWindow> win, int id,
QObject* parent = nullptr) noexcept;
~MainWindow() noexcept override;
// General Methods
int getId() const noexcept { return mId; }
int getUiData() const noexcept { return mId; }
void setUiData(int data) noexcept { Q_UNUSED(data); }
bool isCurrentWindow() const noexcept;
void makeCurrentWindow() noexcept;
QWidget& getWidget() noexcept { return *mWidget; }
void addSection(int newIndex, bool makeCurrent) noexcept;
void addTab(std::shared_ptr<WindowTab> tab, int section = -1, int index = -1,
bool switchToTab = true, bool switchToSection = true) noexcept;
std::shared_ptr<WindowTab> removeTab(
int section, int tab, bool* wasCurrentTab = nullptr,
bool* wasCurrentSection = nullptr) noexcept;
void showPanelPage(ui::PanelPage page) noexcept;
void popUpNotifications() noexcept;
void showStatusBarMessage(const QString& message, int timeoutMs);
void highlightErcMessage(ProjectEditor& prjEditor,
std::shared_ptr<const RuleCheckMessage> msg,
bool zoomTo) noexcept;
void setCurrentLibrary(int index) noexcept;
void setCurrentProject(int index) noexcept;
void openLibraryTab(const FilePath& fp, bool wizardMode) noexcept;
void openComponentCategoryTab(LibraryEditor& editor,
const FilePath& fp) noexcept;
bool openNewComponentCategoryTab(
LibraryEditor& editor, const FilePath& duplicateFromFp = {},
const ComponentCategory* duplicateFromObj = nullptr) noexcept;
void openPackageCategoryTab(LibraryEditor& editor,
const FilePath& fp) noexcept;
bool openNewPackageCategoryTab(
LibraryEditor& editor, const FilePath& duplicateFromFp = {},
const PackageCategory* duplicateFromObj = nullptr) noexcept;
void openSymbolTab(LibraryEditor& editor, const FilePath& fp) noexcept;
bool openNewSymbolTab(LibraryEditor& editor,
const FilePath& duplicateFromFp = {},
const Symbol* duplicateFromObj = nullptr) noexcept;
void openPackageTab(LibraryEditor& editor, const FilePath& fp) noexcept;
bool openNewPackageTab(LibraryEditor& editor,
const FilePath& duplicateFromFp = {},
const Package* duplicateFromObj = nullptr) noexcept;
void openComponentTab(LibraryEditor& editor, const FilePath& fp) noexcept;
bool openNewComponentTab(
LibraryEditor& editor, const FilePath& duplicateFromFp = {},
const Component* duplicateFromObj = nullptr) noexcept;
void openDeviceTab(LibraryEditor& editor, const FilePath& fp) noexcept;
bool openNewDeviceTab(LibraryEditor& editor,
const FilePath& duplicateFromFp = {},
const Device* duplicateFromObj = nullptr) noexcept;
void openOrganizationTab(LibraryEditor& editor, const FilePath& fp) noexcept;
bool openNewOrganizationTab(
LibraryEditor& editor, const FilePath& duplicateFromFp = {},
const Organization* duplicateFromObj = nullptr) noexcept;
std::shared_ptr<SchematicTab> openSchematicTab(int projectIndex,
int index) noexcept;
void openBoard2dTab(int projectIndex, int index,
bool switchToTab = true) noexcept;
void openBoard3dTab(int projectIndex, int index) noexcept;
void openProjectLibraryTab(int projectIndex) noexcept;
void requestDeviceTab(const FilePath& fp) noexcept;
void requestComponentTab(const FilePath& fp) noexcept;
void requestSymbolTab(const FilePath& fp) noexcept;
void requestPackageTab(const FilePath& fp) noexcept;
// Operator Overloadings
MainWindow& operator=(const MainWindow& rhs) = delete;
signals:
void aboutToClose();
private:
slint::CloseRequestResponse closeRequested() noexcept;
void trigger(ui::Action a) noexcept;
void triggerSection(int section, ui::WindowSectionAction a) noexcept;
void triggerTab(int section, int tab, ui::TabAction a) noexcept;
void triggerLibrary(slint::SharedString path, ui::LibraryAction a) noexcept;
void triggerLibraryElement(slint::SharedString path,
ui::LibraryElementAction a) noexcept;
void triggerProject(int index, ui::ProjectAction a) noexcept;
void triggerSchematic(int project, int schematic,
ui::SchematicAction a) noexcept;
void triggerBoard(int project, int board, ui::BoardAction a) noexcept;
void updateHomeTabSection() noexcept;
template <typename Element, typename Tab>
void openLibraryElementTab(LibraryEditor& editor,
const FilePath& fp) noexcept;
template <typename Element, typename Tab>
bool openNewLibraryElementTab(
LibraryEditor& editor, const FilePath& duplicateFromFp,
const Element* duplicateFromObj,
std::function<std::unique_ptr<Element>()> factory) noexcept;
template <typename T>
bool switchToTab() noexcept;
template <typename T>
bool switchToLibraryElementTab(const FilePath& fp) noexcept;
template <typename T>
std::shared_ptr<T> switchToProjectTab(int prjIndex, int objIndex) noexcept;
const int mId;
const QString mSettingsPrefix;
GuiApplication& mApp;
slint::ComponentHandle<ui::AppWindow> mWindow;
QWidget* mWidget;
std::shared_ptr<UiObjectList<WindowSection, ui::WindowSectionData>> mSections;
std::unique_ptr<ProjectReadmeRenderer> mProjectPreviewRenderer;
std::unique_ptr<MainWindowTestAdapter> mTestAdapter;
friend class MainWindowTestAdapter;
};
/*******************************************************************************
* End of File
******************************************************************************/
} // namespace editor
} // namespace librepcb
#endif
f187d7f67This file is pinned to the selected release. Download the original to open it in your design tool.