-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add more single application[046056]
- Loading branch information
Showing
10 changed files
with
374 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# *************************************************************************** | ||
# * This file is part of the TTK Library Module project | ||
# * Copyright (C) 2015 - 2024 Greedysky Studio | ||
# | ||
# * This program is free software; you can redistribute it and/or modify | ||
# * it under the terms of the GNU Lesser General Public License as published by | ||
# * the Free Software Foundation; either version 3 of the License, or | ||
# * (at your option) any later version. | ||
# | ||
# * 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 Lesser General Public License for more details. | ||
# | ||
# * You should have received a copy of the GNU Lesser General Public License along | ||
# * with this program; If not, see <http://www.gnu.org/licenses/>. | ||
# *************************************************************************** | ||
|
||
QT += core network | ||
|
||
INCLUDEPATH += $$PWD | ||
|
||
HEADERS += \ | ||
$$PWD/ttklocalpeer.h \ | ||
$$PWD/ttkcoreapplication.h | ||
|
||
SOURCES += \ | ||
$$PWD/ttklocalpeer.cpp \ | ||
$$PWD/ttkcoreapplication.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# *************************************************************************** | ||
# * This file is part of the TTK Library Module project | ||
# * Copyright (C) 2015 - 2024 Greedysky Studio | ||
# | ||
# * This program is free software; you can redistribute it and/or modify | ||
# * it under the terms of the GNU Lesser General Public License as published by | ||
# * the Free Software Foundation; either version 3 of the License, or | ||
# * (at your option) any later version. | ||
# | ||
# * 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 Lesser General Public License for more details. | ||
# | ||
# * You should have received a copy of the GNU Lesser General Public License along | ||
# * with this program; If not, see <http://www.gnu.org/licenses/>. | ||
# *************************************************************************** | ||
|
||
QT += core gui network | ||
|
||
INCLUDEPATH += $$PWD | ||
|
||
HEADERS += \ | ||
$$PWD/ttklocalpeer.h \ | ||
$$PWD/ttkguiapplication.h | ||
|
||
SOURCES += \ | ||
$$PWD/ttklocalpeer.cpp \ | ||
$$PWD/ttkguiapplication.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
#include "ttkrunapplication.h" | ||
#include "ttkapplication.h" | ||
#include "ttklocalpeer.h" | ||
|
||
#include <QWidget> | ||
|
||
/*! @brief The class of the ttk run application private. | ||
/*! @brief The class of the ttk application private. | ||
* @author Greedysky <[email protected]> | ||
*/ | ||
class TTKRunApplicationPrivate : public TTKPrivate<TTKRunApplication> | ||
class TTKApplicationPrivate : public TTKPrivate<TTKApplication> | ||
{ | ||
public: | ||
TTKRunApplicationPrivate(); | ||
~TTKRunApplicationPrivate(); | ||
TTKApplicationPrivate(); | ||
~TTKApplicationPrivate(); | ||
|
||
TTKLocalPeer *m_peer; | ||
QWidget *m_activeWindow; | ||
}; | ||
|
||
TTKRunApplicationPrivate::TTKRunApplicationPrivate() | ||
TTKApplicationPrivate::TTKApplicationPrivate() | ||
: m_peer(nullptr), | ||
m_activeWindow(nullptr) | ||
{ | ||
|
||
} | ||
|
||
TTKRunApplicationPrivate::~TTKRunApplicationPrivate() | ||
TTKApplicationPrivate::~TTKApplicationPrivate() | ||
{ | ||
delete m_peer; | ||
} | ||
|
||
|
||
|
||
TTKRunApplication::TTKRunApplication(int &argc, char **argv) | ||
TTKApplication::TTKApplication(int &argc, char **argv) | ||
: QApplication(argc, argv) | ||
{ | ||
TTK_INIT_PRIVATE(TTKRunApplication); | ||
TTK_INIT_PRIVATE(TTKApplication); | ||
initialize(); | ||
} | ||
|
||
TTKRunApplication::TTKRunApplication(const QString &id, int &argc, char **argv) | ||
TTKApplication::TTKApplication(const QString &id, int &argc, char **argv) | ||
: QApplication(argc, argv) | ||
{ | ||
TTK_INIT_PRIVATE(TTKRunApplication); | ||
TTK_INIT_PRIVATE(TTKApplication); | ||
initialize(id); | ||
} | ||
|
||
bool TTKRunApplication::isRunning() const | ||
bool TTKApplication::isRunning() const | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
return d->m_peer->isClient(); | ||
} | ||
|
||
QString TTKRunApplication::id() const | ||
QString TTKApplication::id() const | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
return d->m_peer->applicationId(); | ||
} | ||
|
||
void TTKRunApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) const | ||
void TTKApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) const | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
d->m_activeWindow = aw; | ||
|
||
if(activateOnMessage) | ||
|
@@ -71,21 +71,21 @@ void TTKRunApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) | |
} | ||
} | ||
|
||
QWidget* TTKRunApplication::activationWindow() const | ||
QWidget* TTKApplication::activationWindow() const | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
return d->m_activeWindow; | ||
} | ||
|
||
bool TTKRunApplication::sendMessage(const QString &message, int timeout) | ||
bool TTKApplication::sendMessage(const QString &message, int timeout) | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
return d->m_peer->sendMessage(message, timeout); | ||
} | ||
|
||
void TTKRunApplication::activateWindow() | ||
void TTKApplication::activateWindow() | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
if(d->m_activeWindow) | ||
{ | ||
d->m_activeWindow->setWindowState(d->m_activeWindow->windowState() & ~Qt::WindowMinimized); | ||
|
@@ -94,9 +94,9 @@ void TTKRunApplication::activateWindow() | |
} | ||
} | ||
|
||
void TTKRunApplication::initialize(const QString &id) | ||
void TTKApplication::initialize(const QString &id) | ||
{ | ||
TTK_D(TTKRunApplication); | ||
TTK_D(TTKApplication); | ||
d->m_peer = new TTKLocalPeer(this, id); | ||
connect(d->m_peer, SIGNAL(messageReceived(QString)), SIGNAL(messageReceived(QString))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#ifndef TTKRUNAPPLICATION_H | ||
#define TTKRUNAPPLICATION_H | ||
#ifndef TTKAPPLICATION_H | ||
#define TTKAPPLICATION_H | ||
|
||
/*************************************************************************** | ||
* This file is part of the TTK Library Module project | ||
|
@@ -22,20 +22,20 @@ | |
#include <QApplication> | ||
#include "ttkprivate.h" | ||
|
||
class TTKRunApplicationPrivate; | ||
class TTKApplicationPrivate; | ||
|
||
/*! @brief The class of the ttk run application. | ||
/*! @brief The class of the ttk application. | ||
* @author Greedysky <[email protected]> | ||
*/ | ||
class TTK_MODULE_EXPORT TTKRunApplication : public QApplication | ||
class TTK_MODULE_EXPORT TTKApplication : public QApplication | ||
{ | ||
Q_OBJECT | ||
public: | ||
/*! | ||
* Object constructor. | ||
*/ | ||
TTKRunApplication(int &argc, char **argv); | ||
TTKRunApplication(const QString &id, int &argc, char **argv); | ||
TTKApplication(int &argc, char **argv); | ||
TTKApplication(const QString &id, int &argc, char **argv); | ||
|
||
/*! | ||
* Check the current server is running or not. | ||
|
@@ -78,8 +78,8 @@ public Q_SLOTS: | |
void initialize(const QString &id = {}); | ||
|
||
private: | ||
TTK_DECLARE_PRIVATE(TTKRunApplication) | ||
TTK_DECLARE_PRIVATE(TTKApplication) | ||
|
||
}; | ||
|
||
#endif // TTKRUNAPPLICATION_H | ||
#endif // TTKAPPLICATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "ttkcoreapplication.h" | ||
#include "ttklocalpeer.h" | ||
|
||
/*! @brief The class of the ttk core application private. | ||
* @author Greedysky <[email protected]> | ||
*/ | ||
class TTKCoreApplicationPrivate : public TTKPrivate<TTKCoreApplication> | ||
{ | ||
public: | ||
TTKCoreApplicationPrivate(); | ||
~TTKCoreApplicationPrivate(); | ||
|
||
TTKLocalPeer *m_peer; | ||
}; | ||
|
||
TTKCoreApplicationPrivate::TTKCoreApplicationPrivate() | ||
: m_peer(nullptr) | ||
{ | ||
|
||
} | ||
|
||
TTKCoreApplicationPrivate::~TTKCoreApplicationPrivate() | ||
{ | ||
delete m_peer; | ||
} | ||
|
||
|
||
|
||
TTKCoreApplication::TTKCoreApplication(int &argc, char **argv) | ||
: QCoreApplication(argc, argv) | ||
{ | ||
TTK_INIT_PRIVATE(TTKCoreApplication); | ||
initialize(); | ||
} | ||
|
||
TTKCoreApplication::TTKCoreApplication(const QString &id, int &argc, char **argv) | ||
: QCoreApplication(argc, argv) | ||
{ | ||
TTK_INIT_PRIVATE(TTKCoreApplication); | ||
initialize(id); | ||
} | ||
|
||
bool TTKCoreApplication::isRunning() const | ||
{ | ||
TTK_D(TTKCoreApplication); | ||
return d->m_peer->isClient(); | ||
} | ||
|
||
QString TTKCoreApplication::id() const | ||
{ | ||
TTK_D(TTKCoreApplication); | ||
return d->m_peer->applicationId(); | ||
} | ||
|
||
bool TTKCoreApplication::sendMessage(const QString &message, int timeout) | ||
{ | ||
TTK_D(TTKCoreApplication); | ||
return d->m_peer->sendMessage(message, timeout); | ||
} | ||
|
||
void TTKCoreApplication::initialize(const QString &id) | ||
{ | ||
TTK_D(TTKCoreApplication); | ||
d->m_peer = new TTKLocalPeer(this, id); | ||
connect(d->m_peer, SIGNAL(messageReceived(QString)), SIGNAL(messageReceived(QString))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef TTKCOREAPPLICATION_H | ||
#define TTKCOREAPPLICATION_H | ||
|
||
/*************************************************************************** | ||
* This file is part of the TTK Library Module project | ||
* Copyright (C) 2015 - 2024 Greedysky Studio | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* 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 Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with this program; If not, see <http://www.gnu.org/licenses/>. | ||
***************************************************************************/ | ||
|
||
#include <QCoreApplication> | ||
#include "ttkprivate.h" | ||
|
||
class TTKCoreApplicationPrivate; | ||
|
||
/*! @brief The class of the ttk core application. | ||
* @author Greedysky <[email protected]> | ||
*/ | ||
class TTK_MODULE_EXPORT TTKCoreApplication : public QCoreApplication | ||
{ | ||
Q_OBJECT | ||
public: | ||
/*! | ||
* Object constructor. | ||
*/ | ||
TTKCoreApplication(int &argc, char **argv); | ||
TTKCoreApplication(const QString &id, int &argc, char **argv); | ||
|
||
/*! | ||
* Check the current server is running or not. | ||
*/ | ||
bool isRunning() const; | ||
/*! | ||
* Get current server id. | ||
*/ | ||
QString id() const; | ||
|
||
Q_SIGNALS: | ||
/*! | ||
* Emit when the current message received. | ||
*/ | ||
void messageReceived(const QString &message); | ||
|
||
public Q_SLOTS: | ||
/*! | ||
* Emit when the current message received. | ||
*/ | ||
bool sendMessage(const QString &message, int timeout = 5000); | ||
|
||
private: | ||
/*! | ||
* Init the system parameter. | ||
*/ | ||
void initialize(const QString &id = {}); | ||
|
||
private: | ||
TTK_DECLARE_PRIVATE(TTKCoreApplication) | ||
|
||
}; | ||
|
||
#endif // TTKCOREAPPLICATION_H |
Oops, something went wrong.