Ensure backward compatibility and some cosmetic changes.

This commit is contained in:
Vlad Pyatnichenko 2016-04-05 20:31:05 +03:00
parent 7a3858a214
commit 8eb993a7f8
3 changed files with 11 additions and 6 deletions

View File

@ -39,11 +39,12 @@ The SingleApplication class implements a `showUp()` signal. You can bind to that
Note that since `SingleApplication` extends the `QApplication` class you can do the following: Note that since `SingleApplication` extends the `QApplication` class you can do the following:
```cpp ```cpp
// Truly raise your window. // Truly raise your window.
QObject::connect(&app, &SingleApplication::showUp, [&]{ QObject::connect(&app, &SingleApplication::showUp, [&]
window.show(); {
window.raise(); window.show();
window.activateWindow(); window.raise();
}); // 'window' is your QWindow instance window.activateWindow();
}); // 'window' is your QWindow instance
``` ```
Using `QApplication::instance()` is a neat way to get the `SingleApplication` instance at any place in your program. Using `QApplication::instance()` is a neat way to get the `SingleApplication` instance at any place in your program.

View File

@ -115,7 +115,7 @@ SingleApplication::SingleApplication(int &argc, char *argv[])
// terminated. // terminated.
if( d->socket->waitForConnected(100) ) if( d->socket->waitForConnected(100) )
{ {
// Terminate the program using STDLib's exit function. // Terminate the program using STDLib's exit function
::exit(EXIT_SUCCESS); ::exit(EXIT_SUCCESS);
} else { } else {
delete d->memory; delete d->memory;

View File

@ -2,6 +2,10 @@
#define SINGLE_APPLICATION_H #define SINGLE_APPLICATION_H
#include <QtCore/QtGlobal> #include <QtCore/QtGlobal>
#ifndef QAPPLICATION_CLASS
#define QAPPLICATION_CLASS QApplication
#endif
#include QT_STRINGIFY(QAPPLICATION_CLASS) #include QT_STRINGIFY(QAPPLICATION_CLASS)
class SingleApplicationPrivate; class SingleApplicationPrivate;