diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index f7b7daee49..1eb8fd2761 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -127,7 +127,7 @@ if(WIN32) set(QT_USE_QTMAIN TRUE) 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}) qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index e05ebcdeb2..c339d87699 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -2,6 +2,8 @@ #include "editor.hpp" #include +#include +#include #include "model/doc/document.hpp" #include "model/world/data.hpp" @@ -114,6 +116,15 @@ void CS::Editor::createNewFile() mFileDialog.hide(); } +bool CS::Editor::makeIPCServer() +{ + server = new QLocalServer(this); + if(server->listen("IPCServer")) + return true; + server->close(); + return false; +} + int CS::Editor::run() { mStartup.show(); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 380e434c24..2d50b68fe3 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -1,6 +1,8 @@ #ifndef CS_EDITOR_H #define CS_EDITOR_H +#include + #include #ifndef Q_MOC_RUN #include @@ -35,6 +37,8 @@ namespace CS Editor(); + bool makeIPCServer(); + int run(); ///< \return error status @@ -45,6 +49,10 @@ namespace CS void loadDocument(); void openFiles(); void createNewFile(); + + private: + + QLocalServer *server; }; } diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 7f6f9302ed..3e40ee8ccb 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -39,5 +39,10 @@ int main(int argc, char *argv[]) CS::Editor editor; + if(!editor.makeIPCServer()) + { + return 0; + } + return editor.run(); }