added run log

deque
Marc Zinnschlag 10 years ago
parent 5e022195b8
commit cf05d3c69f

@ -44,7 +44,7 @@ opencs_units_noqt (model/tools
opencs_units (view/doc
viewmanager view operations operation subview startup filedialog newgame
filewidget adjusterwidget loader globaldebugprofilemenu
filewidget adjusterwidget loader globaldebugprofilemenu runlogsubview
)

@ -2399,6 +2399,11 @@ void CSMDoc::Document::stopRunning()
mRunner.stop();
}
QTextDocument *CSMDoc::Document::getRunLog()
{
return mRunner.getLog();
}
void CSMDoc::Document::runStateChanged()
{
emit stateChanged (getState(), this);

@ -122,6 +122,8 @@ namespace CSMDoc
void stopRunning();
QTextDocument *getRunLog();
signals:
void stateChanged (int state, CSMDoc::Document *document);

@ -11,6 +11,11 @@ CSMDoc::Runner::Runner() : mRunning (false), mStartup (0)
connect (&mProcess, SIGNAL (finished (int, QProcess::ExitStatus)),
this, SLOT (finished (int, QProcess::ExitStatus)));
connect (&mProcess, SIGNAL (readyReadStandardOutput()),
this, SLOT (readyReadStandardOutput()));
mProcess.setProcessChannelMode (QProcess::MergedChannels);
mProfile.blank();
}
@ -34,6 +39,8 @@ void CSMDoc::Runner::start (bool delayed)
if (!delayed)
{
mLog.clear();
QString path = "openmw";
#ifdef Q_OS_WIN
path.append(QString(".exe"));
@ -107,6 +114,17 @@ void CSMDoc::Runner::finished (int exitCode, QProcess::ExitStatus exitStatus)
emit runStateChanged();
}
QTextDocument *CSMDoc::Runner::getLog()
{
return &mLog;
}
void CSMDoc::Runner::readyReadStandardOutput()
{
mLog.setPlainText (
mLog.toPlainText() + QString::fromUtf8 (mProcess.readAllStandardOutput()));
}
CSMDoc::SaveWatcher::SaveWatcher (Runner *runner, Operation *operation)
: QObject (runner), mRunner (runner)

@ -3,6 +3,7 @@
#include <QObject>
#include <QProcess>
#include <QTextDocument>
#include <components/esm/debugprofile.hpp>
@ -19,6 +20,7 @@ namespace CSMDoc
ESM::DebugProfile mProfile;
std::string mStartupInstruction;
QTemporaryFile *mStartup;
QTextDocument mLog;
public:
@ -39,6 +41,8 @@ namespace CSMDoc
void configure (const ESM::DebugProfile& profile,
const std::string& startupInstruction);
QTextDocument *getLog();
signals:
void runStateChanged();
@ -46,6 +50,8 @@ namespace CSMDoc
private slots:
void finished (int exitCode, QProcess::ExitStatus exitStatus);
void readyReadStandardOutput();
};
class Operation;

@ -51,6 +51,7 @@ namespace
{ CSMWorld::UniversalId::Class_ResourceList, CSMWorld::UniversalId::Type_Textures, "Textures", 0 },
{ CSMWorld::UniversalId::Class_ResourceList, CSMWorld::UniversalId::Type_Videos, "Videos", 0 },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_DebugProfiles, "Debug Profiles", 0 },
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
};

@ -121,7 +121,8 @@ namespace CSMWorld
Type_Videos,
Type_Video,
Type_DebugProfiles,
Type_DebugProfile
Type_DebugProfile,
Type_RunLog
};
enum { NumberOfTypes = Type_DebugProfile+1 };

@ -0,0 +1,20 @@
#include "runlogsubview.hpp"
#include <QTextEdit>
CSVDoc::RunLogSubView::RunLogSubView (const CSMWorld::UniversalId& id,
CSMDoc::Document& document)
: SubView (id)
{
QTextEdit *edit = new QTextEdit (this);
edit->setDocument (document.getRunLog());
edit->setReadOnly (true);
setWidget (edit);
}
void CSVDoc::RunLogSubView::setEditLock (bool locked)
{
// ignored since this SubView does not have editing
}

@ -0,0 +1,20 @@
#ifndef CSV_DOC_RUNLOGSUBVIEW_H
#define CSV_DOC_RUNLOGSUBVIEW_H
#include "subview.hpp"
namespace CSVDoc
{
class RunLogSubView : public SubView
{
Q_OBJECT
public:
RunLogSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
virtual void setEditLock (bool locked);
};
}
#endif

@ -22,6 +22,8 @@
#include "operations.hpp"
#include "subview.hpp"
#include "globaldebugprofilemenu.hpp"
#include "runlogsubview.hpp"
#include "subviewfactoryimp.hpp"
void CSVDoc::View::closeEvent (QCloseEvent *event)
{
@ -258,6 +260,10 @@ void CSVDoc::View::setupDebugMenu()
mStopDebug = new QAction (tr ("Shutdown OpenMW"), this);
connect (mStopDebug, SIGNAL (triggered()), this, SLOT (stop()));
debug->addAction (mStopDebug);
QAction *runLog = new QAction (tr ("Run Log"), this);
connect (runLog, SIGNAL (triggered()), this, SLOT (addRunLogSubView()));
debug->addAction (runLog);
}
void CSVDoc::View::setupUi()
@ -333,6 +339,8 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
CSVWorld::addSubViewFactories (mSubViewFactory);
CSVTools::addSubViewFactories (mSubViewFactory);
mSubViewFactory.add (CSMWorld::UniversalId::Type_RunLog, new SubViewFactory<RunLogSubView>);
connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int)));
}
@ -583,6 +591,11 @@ void CSVDoc::View::addDebugProfilesSubView()
addSubView (CSMWorld::UniversalId::Type_DebugProfiles);
}
void CSVDoc::View::addRunLogSubView()
{
addSubView (CSMWorld::UniversalId::Type_RunLog);
}
void CSVDoc::View::abortOperation (int type)
{
mDocument->abortOperation (type);

@ -201,6 +201,8 @@ namespace CSVDoc
void addDebugProfilesSubView();
void addRunLogSubView();
void toggleShowStatusBar (bool show);
void loadErrorLog();

Loading…
Cancel
Save