Files
create/src/Mod/Start/Gui/StartView.h
wmayer 17829d6383 Start: Make the Start Page a passive view
Do not attach the Start Page to an existing document as otherwise weird behaviour can be observed:
1. Start FreeCAD
2. Open a project file or data file
3. Open the Start Page
4. Make a change to the document
5. Close the document. You won't be asked to save your change
6. In the tree view the document is still shown because the Start Page is attached to the document
7. Close the Start Page. Now you will be asked to save your change
2024-07-04 22:18:42 +02:00

111 lines
3.6 KiB
C++

// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2024 The FreeCAD Project Association AISBL *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#ifndef FREECAD_STARTVIEW_H
#define FREECAD_STARTVIEW_H
#include <Mod/Start/StartGlobal.h>
#include <Base/Type.h>
#include <Gui/MDIView.h>
#include "../App/DisplayedFilesModel.h"
#include "../App/RecentFilesModel.h"
#include "../App/ExamplesModel.h"
class QCheckBox;
class QEvent;
class QGridLayout;
class QLabel;
class QListView;
class QScrollArea;
namespace Gui
{
class Document;
}
namespace StartGui
{
class StartGuiExport StartView: public Gui::MDIView
{
Q_OBJECT
TYPESYSTEM_HEADER_WITH_OVERRIDE(); // NOLINT
public:
StartView(QWidget* parent);
const char* getName() const override
{
return "StartView";
}
void newEmptyFile() const;
void newPartDesignFile() const;
void openExistingFile() const;
void newAssemblyFile() const;
void newDraftFile() const;
void newArchFile() const;
public:
enum class PostStartBehavior
{
switchWorkbench,
doNotSwitchWorkbench
};
protected:
void changeEvent(QEvent* e) override;
void configureNewFileButtons(QLayout* layout) const;
static void configureFileCardWidget(QListView* fileCardWidget);
void configureRecentFilesListWidget(QListView* recentFilesListWidget, QLabel* recentFilesLabel);
void configureExamplesListWidget(QListView* examplesListWidget);
void postStart(PostStartBehavior behavior) const;
void fileCardSelected(const QModelIndex& index);
void showOnStartupChanged(bool checked);
QString fileCardStyle() const;
private:
void retranslateUi();
QScrollArea* _contents = nullptr;
Start::RecentFilesModel _recentFilesModel;
Start::ExamplesModel _examplesModel;
QLabel* _newFileLabel;
QLabel* _examplesLabel;
QLabel* _recentFilesLabel;
QCheckBox* _showOnStartupCheckBox;
}; // namespace StartGui
} // namespace StartGui
#endif // FREECAD_STARTVIEW_H