mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
[Feature #881] Raise OpenCS New Window After Re-execution
The OpenCS startup window of the existing exist is raised when trying to start a new instance. This is done by the new instance connection to the existing instance's QLocalServer. Once the connection is established the existing instance raises the startup window.
This commit is contained in:
parent
51332b86a1
commit
563bd0b430
@ -10,6 +10,8 @@
|
||||
|
||||
CS::Editor::Editor() : mViewManager (mDocumentManager)
|
||||
{
|
||||
ipcServerName = "IPCServer";
|
||||
|
||||
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||
|
||||
@ -116,15 +118,35 @@ void CS::Editor::createNewFile()
|
||||
mFileDialog.hide();
|
||||
}
|
||||
|
||||
void CS::Editor::showStartup()
|
||||
{
|
||||
if(mStartup.isHidden())
|
||||
mStartup.show();
|
||||
mStartup.raise();
|
||||
mStartup.activateWindow();
|
||||
}
|
||||
|
||||
bool CS::Editor::makeIPCServer()
|
||||
{
|
||||
server = new QLocalServer(this);
|
||||
if(server->listen("IPCServer"))
|
||||
|
||||
if(server->listen(ipcServerName))
|
||||
{
|
||||
connect(server, SIGNAL(newConnection()), this, SLOT(showStartup()));
|
||||
return true;
|
||||
}
|
||||
|
||||
server->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
void CS::Editor::connectToIPCServer()
|
||||
{
|
||||
clientToServerSocket = new QLocalSocket(this);
|
||||
clientToServerSocket->connectToServer(ipcServerName);
|
||||
clientToServerSocket->close();
|
||||
}
|
||||
|
||||
int CS::Editor::run()
|
||||
{
|
||||
mStartup.show();
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef CS_EDITOR_H
|
||||
#define CS_EDITOR_H
|
||||
|
||||
#include <QLocalServer>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#endif
|
||||
@ -38,6 +40,7 @@ namespace CS
|
||||
Editor();
|
||||
|
||||
bool makeIPCServer();
|
||||
void connectToIPCServer();
|
||||
|
||||
int run();
|
||||
///< \return error status
|
||||
@ -50,9 +53,13 @@ namespace CS
|
||||
void openFiles();
|
||||
void createNewFile();
|
||||
|
||||
void showStartup();
|
||||
|
||||
private:
|
||||
|
||||
QString ipcServerName;
|
||||
QLocalServer *server;
|
||||
QLocalSocket *clientToServerSocket;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(!editor.makeIPCServer())
|
||||
{
|
||||
editor.connectToIPCServer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user