mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-30 00:36:39 +00:00
content file loading progress bar
This commit is contained in:
parent
e09218f164
commit
e0e2ad8316
8 changed files with 78 additions and 3 deletions
|
@ -3,9 +3,11 @@
|
|||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
#include <QMetaType>
|
||||
|
||||
#include <extern/shiny/Main/Factory.hpp>
|
||||
|
||||
|
@ -15,6 +17,8 @@
|
|||
#include <QDir>
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE (std::string)
|
||||
|
||||
class Application : public QApplication
|
||||
{
|
||||
private:
|
||||
|
@ -42,6 +46,8 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
Q_INIT_RESOURCE (resources);
|
||||
|
||||
qRegisterMetaType<std::string> ("std::string");
|
||||
|
||||
OgreInit::OgreInit ogreInit;
|
||||
|
||||
std::auto_ptr<sh::Factory> shinyFactory;
|
||||
|
|
|
@ -29,6 +29,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
|
|||
this, SLOT (documentNotLoaded (Document *, const std::string&)));
|
||||
connect (this, SIGNAL (loadRequest (CSMDoc::Document *)),
|
||||
&mLoader, SLOT (loadDocument (CSMDoc::Document *)));
|
||||
connect (&mLoader, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)),
|
||||
this, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)));
|
||||
}
|
||||
|
||||
CSMDoc::DocumentManager::~DocumentManager()
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace CSMDoc
|
|||
|
||||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||
const std::string& error);
|
||||
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,16 @@ void CSMDoc::Loader::load()
|
|||
{
|
||||
if (iter->second.mFile<size)
|
||||
{
|
||||
document->getData().loadFile (document->getContentFiles()[iter->second.mFile],
|
||||
iter->second.mFile<size-1, false);
|
||||
boost::filesystem::path path = document->getContentFiles()[iter->second.mFile];
|
||||
|
||||
emit nextStage (document, path.filename().string());
|
||||
|
||||
document->getData().loadFile (path, iter->second.mFile<size-1, false);
|
||||
}
|
||||
else if (iter->second.mFile==size)
|
||||
{
|
||||
emit nextStage (document, "Project File");
|
||||
|
||||
document->getData().loadFile (document->getProjectPath(), false, true);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace CSMDoc
|
|||
void documentNotLoaded (Document *document, const std::string& error);
|
||||
///< Document load has been interrupted either because of a call to abortLoading
|
||||
/// or a problem during loading). In the former case error will be an empty string.
|
||||
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,50 @@
|
|||
|
||||
#include "loader.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
#include <QCursor>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||
{
|
||||
setWindowTitle (("Loading " + document->getSavePath().filename().string()).c_str());
|
||||
setWindowTitle (("Opening " + document->getSavePath().filename().string()).c_str());
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout (this);
|
||||
|
||||
mFileProgress = new QProgressBar (this);
|
||||
|
||||
layout->addWidget (mFileProgress);
|
||||
|
||||
int size = static_cast<int> (document->getContentFiles().size())+1;
|
||||
if (document->isNew())
|
||||
--size;
|
||||
|
||||
mFileProgress->setMinimum (0);
|
||||
mFileProgress->setMaximum (size);
|
||||
mFileProgress->setTextVisible (true);
|
||||
mFileProgress->setValue (0);
|
||||
|
||||
mFile = new QLabel (this);
|
||||
|
||||
layout->addWidget (mFile);
|
||||
|
||||
setLayout (layout);
|
||||
|
||||
move (QCursor::pos());
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::nextStage (const std::string& name)
|
||||
{
|
||||
mFile->setText (QString::fromUtf8 (("Loading: " + name).c_str()));
|
||||
|
||||
mFileProgress->setValue (mFileProgress->value()+1);
|
||||
}
|
||||
|
||||
|
||||
CSVDoc::Loader::Loader()
|
||||
{
|
||||
|
@ -41,4 +77,12 @@ void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed,
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSVDoc::Loader::nextStage (CSMDoc::Document *document, const std::string& name)
|
||||
{
|
||||
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
|
||||
|
||||
if (iter!=mDocuments.end())
|
||||
iter->second->nextStage (name);
|
||||
}
|
|
@ -6,6 +6,9 @@
|
|||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QProgressBar;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
|
@ -17,9 +20,14 @@ namespace CSVDoc
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
QLabel *mFile;
|
||||
QProgressBar *mFileProgress;
|
||||
|
||||
public:
|
||||
|
||||
LoadingDocument (CSMDoc::Document *document);
|
||||
|
||||
void nextStage (const std::string& name);
|
||||
};
|
||||
|
||||
class Loader : public QObject
|
||||
|
@ -40,6 +48,8 @@ namespace CSVDoc
|
|||
|
||||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||
const std::string& error);
|
||||
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,10 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
connect (
|
||||
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
|
||||
&mLoader, SLOT (loadingStopped (CSMDoc::Document *, bool, const std::string&)));
|
||||
|
||||
connect (
|
||||
&mDocumentManager, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)),
|
||||
&mLoader, SLOT (nextStage (CSMDoc::Document *, const std::string&)));
|
||||
}
|
||||
|
||||
CSVDoc::ViewManager::~ViewManager()
|
||||
|
|
Loading…
Reference in a new issue