From 35ee984d7239244a757f77e8621d4983d08fbc6c Mon Sep 17 00:00:00 2001 From: Vlad Pyatnichenko Date: Fri, 4 Mar 2016 20:15:13 +0200 Subject: Adaptation to Qt's pimpl idiom design. Improved inheritance safety. Details: * Improved unsafe C-style macros inheritance approach to the project-wide DEFINES: it is unspecified in which order source files are being preprocessed ones, so in singleapplication.cpp the class might be inherent of default-specified base, while in main.cpp this can be a user-provided QAPPLICATION_CLASS definition. * Replace Qt's pseudo-keywords to more library-independent counterparts ('emit -> Q_EMIT', etc) * Indentation fixes (80 character column-width) * Rearragned #include statements: from most platform-independen to more app-specific. * Fixed some grammar typos. * README.md updated respectively. --- singleapplication.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'singleapplication.h') diff --git a/singleapplication.h b/singleapplication.h index 1fe5c12..dc6beb3 100644 --- a/singleapplication.h +++ b/singleapplication.h @@ -1,14 +1,8 @@ #ifndef SINGLE_APPLICATION_H #define SINGLE_APPLICATION_H +#include -// Change this to inherit from QGuiApplication or QCoreApplication -#ifndef QAPPLICATION_CLASS - #define QAPPLICATION_CLASS QCoreApplication -#endif - -#define QUOTE(C) #C -#define INCLUDE_FILE(C) QUOTE(C) -#include INCLUDE_FILE(QAPPLICATION_CLASS) +#include QT_STRINGIFY(QAPPLICATION_CLASS) class SingleApplicationPrivate; @@ -18,19 +12,25 @@ class SingleApplicationPrivate; */ class SingleApplication : public QAPPLICATION_CLASS { - Q_OBJECT + Q_OBJECT + Q_DECLARE_PRIVATE(SingleApplication) + + typedef QAPPLICATION_CLASS app_t; + public: - explicit SingleApplication(int&, char *[]); - ~SingleApplication(); + explicit SingleApplication(int&, char *[]); + ~SingleApplication(); -signals: - void showUp(); +Q_SIGNALS: + void showUp(); -private slots: - void slotConnectionEstablished(); +private Q_SLOTS: + void slotConnectionEstablished(); private: - SingleApplicationPrivate *d_ptr; + SingleApplicationPrivate *d_ptr; + + }; #endif // SINGLE_APPLICATION_H -- cgit v1.2.1