File indexing completed on 2024-12-22 04:40:50
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 0004 ** Contact: http://www.qt-project.org/legal 0005 ** 0006 ** This file is part of the Qt Solutions component. 0007 ** 0008 ** $QT_BEGIN_LICENSE:BSD$ 0009 ** You may use this file under the terms of the BSD license as follows: 0010 ** 0011 ** "Redistribution and use in source and binary forms, with or without 0012 ** modification, are permitted provided that the following conditions are 0013 ** met: 0014 ** * Redistributions of source code must retain the above copyright 0015 ** notice, this list of conditions and the following disclaimer. 0016 ** * Redistributions in binary form must reproduce the above copyright 0017 ** notice, this list of conditions and the following disclaimer in 0018 ** the documentation and/or other materials provided with the 0019 ** distribution. 0020 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 0021 ** of its contributors may be used to endorse or promote products derived 0022 ** from this software without specific prior written permission. 0023 ** 0024 ** 0025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 0036 ** 0037 ** $QT_END_LICENSE$ 0038 ** 0039 ****************************************************************************/ 0040 0041 #ifndef QTSINGLEAPPLICATION_H 0042 #define QTSINGLEAPPLICATION_H 0043 0044 #include <QApplication> 0045 0046 #include "qzcommon.h" 0047 0048 class QtLocalPeer; 0049 0050 class FALKON_EXPORT QtSingleApplication : public QApplication 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 0056 QtSingleApplication(const QString &id, int &argc, char **argv); 0057 #if QT_VERSION < 0x050000 0058 QtSingleApplication(int &argc, char **argv, Type type); 0059 # if defined(Q_WS_X11) 0060 QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 0061 QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 0062 QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 0063 # endif // Q_WS_X11 0064 #endif // QT_VERSION < 0x050000 0065 0066 bool isRunning(); 0067 void setAppId(const QString &id); 0068 QString id() const; 0069 0070 void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 0071 QWidget* activationWindow() const; 0072 0073 // Obsolete: 0074 void initialize(bool dummy = true) 0075 { isRunning(); Q_UNUSED(dummy) } 0076 0077 void removeLockFile(); 0078 0079 public Q_SLOTS: 0080 bool sendMessage(const QString &message, int timeout = 5000); 0081 void activateWindow(); 0082 0083 0084 Q_SIGNALS: 0085 void messageReceived(const QString &message); 0086 0087 0088 private: 0089 void sysInit(const QString &appId = QString()); 0090 QtLocalPeer *peer; 0091 QWidget *actWin; 0092 }; 0093 0094 #endif // QTSINGLEAPPLICATION_H