| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2006-2008 fullmetalcoder <[email protected]> |
| 4 | ** |
| 5 | ** This file is part of the Edyuk project <http://edyuk.org> |
| 6 | ** |
| 7 | ** This file may be used under the terms of the GNU General Public License |
| 8 | ** version 2 as published by the Free Software Foundation and appearing in the |
| 9 | ** file GPL.txt included in the packaging of this file. |
| 10 | ** |
| 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | ** |
| 14 | ****************************************************************************/ |
| 15 | |
| 16 | #ifndef _QSINGLE_APPLICATION_H_ |
| 17 | #define _QSINGLE_APPLICATION_H_ |
| 18 | |
| 19 | #include "qcumber.h" |
| 20 | |
| 21 | /*! |
| 22 | \file qsingleapplication.h |
| 23 | |
| 24 | \brief Definition of the QSingleApplication class. |
| 25 | */ |
| 26 | |
| 27 | #include <QApplication> |
| 28 | |
| 29 | class QInterProcessChannel; |
| 30 | |
| 31 | class QCUMBER_EXPORT QSingleApplication : public QApplication { |
| 32 | Q_OBJECT |
| 33 | |
| 34 | public: |
| 35 | enum InstanciationPolicy { None, ForwardArguments }; |
| 36 | |
| 37 | enum MessagingPolicy { Ignore, Events, Signals }; |
| 38 | |
| 39 | QSingleApplication(int& argc, char** argv, bool useGui, |
| 40 | const QString& appName); |
| 41 | virtual ~QSingleApplication(); |
| 42 | |
| 43 | bool isInstanceAllowed() const; |
| 44 | |
| 45 | MessagingPolicy messagingPolicy() const; |
| 46 | void setMessagingPolicy(MessagingPolicy p); |
| 47 | |
| 48 | InstanciationPolicy instanciationPolicy() const; |
| 49 | void setInstanciationPolicy(InstanciationPolicy p); |
| 50 | |
| 51 | public slots: |
| 52 | virtual int exec(); |
| 53 | |
| 54 | void sendRequest(const QString& s); |
| 55 | void sendRequest(const QStringList& l); |
| 56 | |
| 57 | signals: |
| 58 | void request(const QString& s); |
| 59 | |
| 60 | protected: |
| 61 | virtual bool event(QEvent* e); |
| 62 | |
| 63 | protected slots: |
| 64 | virtual void message(const QString& msg); |
| 65 | virtual void request(const QStringList& r); |
| 66 | |
| 67 | private: |
| 68 | QInterProcessChannel* pChannel; |
| 69 | |
| 70 | MessagingPolicy m_messaging; |
| 71 | InstanciationPolicy m_instanciation; |
| 72 | }; |
| 73 | |
| 74 | #endif // !_QSINGLE_APPLICATION_H_ |