Simple application launcher for Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
qsrun/singleinstanceserver.cpp

33 lines
717 B

#include <QDataStream>
#include <QLocalSocket>
#include <QFile>
#include "singleinstanceserver.h"
SingleInstanceServer::SingleInstanceServer()
{
connect(&this->server, &QLocalServer::newConnection, this, &SingleInstanceServer::handleNewConnection);
}
bool SingleInstanceServer::listen(QString socketPath)
{
QFile::remove(socketPath);
return this->server.listen(socketPath);
}
void SingleInstanceServer::handleNewConnection()
{
QScopedPointer<QLocalSocket> socket { this->server.nextPendingConnection() };
if(!socket.isNull())
{
socket->waitForReadyRead();
QDataStream stream ( socket.get());
int command;
stream >> command;
if(command == 0x01)
{
emit receivedMaximizationRequest();
}
}
}