forked from mapeditor/tiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The ScriptManager depends on the project to get the project-specific extensions folder. However, the project was owned by the ProjectModel, which was owned by the ProjectView, which was owned by the ProjectDock, which was owned by the MainWindow. And the MainWindow is not created when scripts are used for exporting on the command-line. Now the ScriptManager can instead talk to the ProjectManager directly. Similarly, the ScriptModule depended on the DocumentManager, which was since recently however only instantiated as part of the MainWindow. Since the relevant part of the scripting API is not useful when running export scripts on the command-line, this dependency was made optional. This change also reduces the rather hacky direct use of the MainWindow. Closes mapeditor#2842
- Loading branch information
Showing
18 changed files
with
222 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* projectmanager.cpp | ||
* Copyright 2020, Thorbjørn Lindeijer <bjorn@lindeijer.nl> | ||
* | ||
* This file is part of Tiled. | ||
* | ||
* 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 2 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/>. | ||
*/ | ||
|
||
#include "projectmanager.h" | ||
|
||
#include "projectmodel.h" | ||
|
||
namespace Tiled { | ||
|
||
ProjectManager *ProjectManager::ourInstance; | ||
|
||
ProjectManager::ProjectManager(QObject *parent) | ||
: QObject(parent) | ||
, mProjectModel(new ProjectModel(this)) | ||
{ | ||
Q_ASSERT(!ourInstance); | ||
ourInstance = this; | ||
} | ||
|
||
/** | ||
* Replaces the current project with the given \a project. | ||
*/ | ||
void ProjectManager::setProject(Project project) | ||
{ | ||
mProjectModel->setProject(std::move(project)); | ||
emit projectChanged(); | ||
} | ||
|
||
Project &ProjectManager::project() | ||
{ | ||
return mProjectModel->project(); | ||
} | ||
|
||
} // namespace Tiled |
Oops, something went wrong.