mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
6911868f2a
closeAllWindows() to ensure ViewManager::closeRequest is called on the last open window. Exit will close all open windows but the last one in cases of active save operation or modified file.
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
|
|
#include "editor.hpp"
|
|
|
|
#include <sstream>
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include "model/doc/document.hpp"
|
|
#include "model/world/data.hpp"
|
|
|
|
CS::Editor::Editor() : mViewManager (mDocumentManager), mNewDocumentIndex (0)
|
|
{
|
|
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
|
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
|
|
|
connect (&mStartup, SIGNAL (createDocument()), this, SLOT (createDocument ()));
|
|
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
|
|
|
|
connect (&mOpenDialog, SIGNAL(accepted()), this, SLOT(openFiles()));
|
|
}
|
|
|
|
void CS::Editor::createDocument()
|
|
{
|
|
mStartup.hide();
|
|
|
|
/// \todo open the ESX picker instead
|
|
|
|
std::ostringstream stream;
|
|
|
|
stream << "NewDocument" << (++mNewDocumentIndex);
|
|
|
|
std::vector<boost::filesystem::path> files;
|
|
files.push_back (stream.str());
|
|
|
|
CSMDoc::Document *document = mDocumentManager.addDocument (files, true);
|
|
|
|
mViewManager.addView (document);
|
|
}
|
|
|
|
void CS::Editor::loadDocument()
|
|
{
|
|
mStartup.hide();
|
|
mOpenDialog.show();
|
|
mOpenDialog.raise();
|
|
mOpenDialog.activateWindow();
|
|
}
|
|
|
|
void CS::Editor::openFiles()
|
|
{
|
|
std::vector<boost::filesystem::path> paths;
|
|
mOpenDialog.getFileList(paths);
|
|
CSMDoc::Document *document = mDocumentManager.addDocument(paths, false);
|
|
|
|
mViewManager.addView (document);
|
|
}
|
|
|
|
int CS::Editor::run()
|
|
{
|
|
mStartup.show();
|
|
|
|
QApplication::setQuitOnLastWindowClosed (true);
|
|
|
|
return QApplication::exec();
|
|
}
|