Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F131435
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/singleapplication.cpp b/singleapplication.cpp
index 083ea30..7ae333d 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -1,52 +1,47 @@
#include "singleapplication.h"
#include <cstdlib>
/**
- * @brief Constructor. Checks and fires up LocalServer or closes the
-program
+ * @brief Constructor. Checks and fires up LocalServer or closes the program
* if another instance already exists
* @param argc
* @param argv
*/
SingleApplication::SingleApplication(int argc, char *argv[])
: QApplication(argc, argv)
{
- QString serverName = QApplication::organizationName() +
-QApplication::applicationName();
+ QString serverName = QApplication::organizationName() + QApplication::applicationName();
serverName.replace(QRegExp("[^\\w\\-. ]"), "");
// Attempt to connect to the LocalServer
socket = new QLocalSocket();
socket->connectToServer(serverName);
if(socket->waitForConnected(1000)){
socket->close();
- ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's
-exit function
+ ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function
} else {
// If the connection is insuccessful, this is the main process
// So we create a Local Server
server = new QLocalServer();
server->removeServer(serverName);
server->listen(serverName);
- QObject::connect(server, SIGNAL(newConnection()), this,
-SLOT(slotConnectionEstablished()));
+ QObject::connect(server, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
}
}
/**
* @brief Destructor
*/
SingleApplication::~SingleApplication()
{
server->close();
}
/**
* @brief Executed when the showUp command is sent to LocalServer
*/
void SingleApplication::slotConnectionEstablished()
{
server->nextPendingConnection();
emit showUp();
}
-
diff --git a/singleapplication.h b/singleapplication.h
index 2fabfbd..7fab2a7 100644
--- a/singleapplication.h
+++ b/singleapplication.h
@@ -1,33 +1,31 @@
#ifndef SINGLE_APPLICATION_H
#define SINGLE_APPLICATION_H
#include <QApplication>
#include <QLocalSocket>
#include <QLocalServer>
/**
- * @brief The SingleApplication class handles multipe instances of the
-same Application
+ * @brief The SingleApplication class handles multipe instances of the same Application
* @see QApplication
*/
class SingleApplication : public QApplication
{
Q_OBJECT
public:
explicit SingleApplication(int, char *[]);
~SingleApplication();
signals:
void showUp();
private slots:
void slotConnectionEstablished();
private:
QLocalSocket *socket;
QLocalServer *server;
};
#endif // SINGLE_APPLICATION_H
-
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:13 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71547
Default Alt Text
(2 KB)
Attached To
Mode
R64 cKaiser's QSingleApplicaiton
Attached
Detach File
Event Timeline