forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'marcrbouvier/master'
This commit is contained in:
commit
6cd7da6547
4 changed files with 55 additions and 1 deletions
|
@ -135,7 +135,7 @@ if(WIN32)
|
||||||
set(QT_USE_QTMAIN TRUE)
|
set(QT_USE_QTMAIN TRUE)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtXmlPatterns REQUIRED)
|
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtXml QtXmlPatterns REQUIRED)
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
|
||||||
qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
|
qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
#include "editor.hpp"
|
#include "editor.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
#include "model/doc/document.hpp"
|
#include "model/doc/document.hpp"
|
||||||
#include "model/world/data.hpp"
|
#include "model/world/data.hpp"
|
||||||
|
|
||||||
CS::Editor::Editor() : mViewManager (mDocumentManager)
|
CS::Editor::Editor() : mViewManager (mDocumentManager)
|
||||||
{
|
{
|
||||||
|
mIpcServerName = "org.openmw.OpenCS";
|
||||||
|
|
||||||
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
||||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||||
|
|
||||||
|
@ -114,6 +118,35 @@ void CS::Editor::createNewFile()
|
||||||
mFileDialog.hide();
|
mFileDialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CS::Editor::showStartup()
|
||||||
|
{
|
||||||
|
if(mStartup.isHidden())
|
||||||
|
mStartup.show();
|
||||||
|
mStartup.raise();
|
||||||
|
mStartup.activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CS::Editor::makeIPCServer()
|
||||||
|
{
|
||||||
|
mServer = new QLocalServer(this);
|
||||||
|
|
||||||
|
if(mServer->listen(mIpcServerName))
|
||||||
|
{
|
||||||
|
connect(mServer, SIGNAL(newConnection()), this, SLOT(showStartup()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mServer->close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CS::Editor::connectToIPCServer()
|
||||||
|
{
|
||||||
|
mClientSocket = new QLocalSocket(this);
|
||||||
|
mClientSocket->connectToServer(mIpcServerName);
|
||||||
|
mClientSocket->close();
|
||||||
|
}
|
||||||
|
|
||||||
int CS::Editor::run()
|
int CS::Editor::run()
|
||||||
{
|
{
|
||||||
mStartup.show();
|
mStartup.show();
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
#define CS_EDITOR_H
|
#define CS_EDITOR_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,6 +39,9 @@ namespace CS
|
||||||
|
|
||||||
Editor();
|
Editor();
|
||||||
|
|
||||||
|
bool makeIPCServer();
|
||||||
|
void connectToIPCServer();
|
||||||
|
|
||||||
int run();
|
int run();
|
||||||
///< \return error status
|
///< \return error status
|
||||||
|
|
||||||
|
@ -45,6 +52,14 @@ namespace CS
|
||||||
void loadDocument();
|
void loadDocument();
|
||||||
void openFiles();
|
void openFiles();
|
||||||
void createNewFile();
|
void createNewFile();
|
||||||
|
|
||||||
|
void showStartup();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QString mIpcServerName;
|
||||||
|
QLocalServer *mServer;
|
||||||
|
QLocalSocket *mClientSocket;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,5 +39,11 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
CS::Editor editor;
|
CS::Editor editor;
|
||||||
|
|
||||||
|
if(!editor.makeIPCServer())
|
||||||
|
{
|
||||||
|
editor.connectToIPCServer();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return editor.run();
|
return editor.run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue