forked from teamnwah/openmw-tes3coop
track state of OpenMW process and enable/disable run/stop actions accordingly
This commit is contained in:
parent
1b4ab6e130
commit
c88b3a1520
7 changed files with 45 additions and 15 deletions
|
@ -2256,6 +2256,8 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
|||
connect (
|
||||
&mSaving, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)),
|
||||
this, SLOT (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)));
|
||||
|
||||
connect (&mRunner, SIGNAL (runStateChanged()), this, SLOT (runStateChanged()));
|
||||
}
|
||||
|
||||
CSMDoc::Document::~Document()
|
||||
|
@ -2277,6 +2279,9 @@ int CSMDoc::Document::getState() const
|
|||
if (mSaving.isRunning())
|
||||
state |= State_Locked | State_Saving | State_Operation;
|
||||
|
||||
if (mRunner.isRunning())
|
||||
state |= State_Locked | State_Running;
|
||||
|
||||
if (int operations = mTools.getRunningOperations())
|
||||
state |= State_Locked | State_Operation | operations;
|
||||
|
||||
|
@ -2378,6 +2383,11 @@ void CSMDoc::Document::stopRunning()
|
|||
mRunner.stop();
|
||||
}
|
||||
|
||||
void CSMDoc::Document::runStateChanged()
|
||||
{
|
||||
emit stateChanged (getState(), this);
|
||||
}
|
||||
|
||||
void CSMDoc::Document::progress (int current, int max, int type)
|
||||
{
|
||||
emit progress (current, max, type, 1, this);
|
||||
|
|
|
@ -137,6 +137,8 @@ namespace CSMDoc
|
|||
|
||||
void operationDone (int type);
|
||||
|
||||
void runStateChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
void progress (int current, int max, int type);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "runner.hpp"
|
||||
|
||||
|
||||
CSMDoc::Runner::Runner()
|
||||
CSMDoc::Runner::Runner() : mRunning (false)
|
||||
{
|
||||
connect (&mProcess, SIGNAL (finished (int, QProcess::ExitStatus)),
|
||||
this, SLOT (finished (int, QProcess::ExitStatus)));
|
||||
|
@ -21,7 +21,8 @@ void CSMDoc::Runner::start()
|
|||
#endif
|
||||
|
||||
mProcess.start (path);
|
||||
emit runStateChanged (true);
|
||||
mRunning = true;
|
||||
emit runStateChanged();
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::stop()
|
||||
|
@ -29,7 +30,13 @@ void CSMDoc::Runner::stop()
|
|||
mProcess.kill();
|
||||
}
|
||||
|
||||
bool CSMDoc::Runner::isRunning() const
|
||||
{
|
||||
return mRunning;
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::finished (int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
emit runStateChanged (false);
|
||||
mRunning = false;
|
||||
emit runStateChanged();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace CSMDoc
|
|||
Q_OBJECT
|
||||
|
||||
QProcess mProcess;
|
||||
bool mRunning;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -20,9 +21,13 @@ namespace CSMDoc
|
|||
|
||||
void stop();
|
||||
|
||||
/// \note Running state is entered when the start function is called. This
|
||||
/// is not necessarily identical to the moment the child process is started.
|
||||
bool isRunning() const;
|
||||
|
||||
signals:
|
||||
|
||||
void runStateChanged (bool running);
|
||||
void runStateChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ namespace CSMDoc
|
|||
State_Modified = 1,
|
||||
State_Locked = 2,
|
||||
State_Operation = 4,
|
||||
State_Running = 8,
|
||||
|
||||
State_Saving = 8,
|
||||
State_Verifying = 16,
|
||||
State_Compiling = 32, // not implemented yet
|
||||
State_Searching = 64, // not implemented yet
|
||||
State_Loading = 128 // pseudo-state; can not be encountered in a loaded document
|
||||
State_Saving = 16,
|
||||
State_Verifying = 32,
|
||||
State_Compiling = 64, // not implemented yet
|
||||
State_Searching = 128, // not implemented yet
|
||||
State_Loading = 256 // pseudo-state; can not be encountered in a loaded document
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -242,13 +242,13 @@ void CSVDoc::View::setupDebugMenu()
|
|||
|
||||
debug->addSeparator();
|
||||
|
||||
QAction *run = new QAction (tr ("Run OpenMW"), this);
|
||||
connect (run, SIGNAL (triggered()), this, SLOT (run()));
|
||||
debug->addAction (run);
|
||||
mRunDebug = new QAction (tr ("Run OpenMW"), this);
|
||||
connect (mRunDebug, SIGNAL (triggered()), this, SLOT (run()));
|
||||
debug->addAction (mRunDebug);
|
||||
|
||||
QAction *stop = new QAction (tr ("Shutdown OpenMW"), this);
|
||||
connect (stop, SIGNAL (triggered()), this, SLOT (stop()));
|
||||
debug->addAction (stop);
|
||||
mStopDebug = new QAction (tr ("Shutdown OpenMW"), this);
|
||||
connect (mStopDebug, SIGNAL (triggered()), this, SLOT (stop()));
|
||||
debug->addAction (mStopDebug);
|
||||
}
|
||||
|
||||
void CSVDoc::View::setupUi()
|
||||
|
@ -290,6 +290,9 @@ void CSVDoc::View::updateActions()
|
|||
|
||||
mSave->setEnabled (!(mDocument->getState() & CSMDoc::State_Saving));
|
||||
mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying));
|
||||
|
||||
mRunDebug->setEnabled (!(mDocument->getState() & CSMDoc::State_Running));
|
||||
mStopDebug->setEnabled ((mDocument->getState() & CSMDoc::State_Running));
|
||||
}
|
||||
|
||||
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace CSVDoc
|
|||
QAction *mSave;
|
||||
QAction *mVerify;
|
||||
QAction *mShowStatusBar;
|
||||
QAction *mRunDebug;
|
||||
QAction *mStopDebug;
|
||||
std::vector<QAction *> mEditingActions;
|
||||
Operations *mOperations;
|
||||
SubViewFactoryManager mSubViewFactory;
|
||||
|
|
Loading…
Reference in a new issue