keepassxc/src/gui/Application.h

80 lines
2.2 KiB
C++
Raw Normal View History

2012-05-10 10:42:17 -04:00
/*
* Copyright (C) 2012 Tobias Tangemann
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
2017-06-09 17:40:36 -04:00
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
2012-05-10 10:42:17 -04:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_APPLICATION_H
#define KEEPASSX_APPLICATION_H
#include <QApplication>
2016-07-25 00:41:13 -04:00
#include <QtNetwork/QLocalServer>
2012-05-10 10:42:17 -04:00
#if defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
#include <QScopedPointer>
class OSEventFilter;
#endif
class QLockFile;
class QSocketNotifier;
class Application : public QApplication
2012-05-10 10:42:17 -04:00
{
Q_OBJECT
2012-05-10 10:42:17 -04:00
public:
Application(int& argc, char** argv);
~Application() override;
2012-05-10 10:42:17 -04:00
2015-07-24 12:28:12 -04:00
bool event(QEvent* event) override;
2016-07-25 00:41:13 -04:00
bool isAlreadyRunning() const;
bool sendFileNamesToRunningInstance(const QStringList& fileNames);
signals:
2012-05-21 16:11:26 -04:00
void openFile(const QString& filename);
2016-07-25 00:41:13 -04:00
void anotherInstanceStarted();
void applicationActivated();
void quitSignalReceived();
private slots:
2017-01-17 18:33:47 -05:00
#if defined(Q_OS_UNIX)
void quitBySignal();
2017-01-17 18:33:47 -05:00
#endif
void processIncomingConnection();
void socketReadyRead();
2017-01-17 18:33:47 -05:00
private:
#if defined(Q_OS_UNIX)
/**
* Register Unix signals such as SIGINT and SIGTERM for clean shutdown.
*/
void registerUnixSignals();
QSocketNotifier* m_unixSignalNotifier;
static void handleUnixSignal(int sig);
static int unixSignalSocket[2];
#endif
bool m_alreadyRunning;
QLockFile* m_lockFile;
QLocalServer m_lockServer;
QString m_socketName;
#if defined(Q_OS_WIN) || (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
QScopedPointer<OSEventFilter> m_osEventFilter;
#endif
};
#endif // KEEPASSX_APPLICATION_H