diff --git a/TTKCommon/TTKApplication/TTKApplication.pri b/TTKCommon/TTKApplication/TTKApplication.pri
index d1cbb0b..30f87f3 100644
--- a/TTKCommon/TTKApplication/TTKApplication.pri
+++ b/TTKCommon/TTKApplication/TTKApplication.pri
@@ -25,8 +25,8 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/ttklocalpeer.h \
- $$PWD/ttkrunapplication.h
+ $$PWD/ttkapplication.h
SOURCES += \
$$PWD/ttklocalpeer.cpp \
- $$PWD/ttkrunapplication.cpp
+ $$PWD/ttkapplication.cpp
diff --git a/TTKCommon/TTKApplication/TTKCoreApplication.pri b/TTKCommon/TTKApplication/TTKCoreApplication.pri
new file mode 100644
index 0000000..1da78fc
--- /dev/null
+++ b/TTKCommon/TTKApplication/TTKCoreApplication.pri
@@ -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 .
+# ***************************************************************************
+
+QT += core network
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/ttklocalpeer.h \
+ $$PWD/ttkcoreapplication.h
+
+SOURCES += \
+ $$PWD/ttklocalpeer.cpp \
+ $$PWD/ttkcoreapplication.cpp
diff --git a/TTKCommon/TTKApplication/TTKGuiApplication.pri b/TTKCommon/TTKApplication/TTKGuiApplication.pri
new file mode 100644
index 0000000..d78556b
--- /dev/null
+++ b/TTKCommon/TTKApplication/TTKGuiApplication.pri
@@ -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 .
+# ***************************************************************************
+
+QT += core gui network
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/ttklocalpeer.h \
+ $$PWD/ttkguiapplication.h
+
+SOURCES += \
+ $$PWD/ttklocalpeer.cpp \
+ $$PWD/ttkguiapplication.cpp
diff --git a/TTKCommon/TTKApplication/ttkrunapplication.cpp b/TTKCommon/TTKApplication/ttkapplication.cpp
similarity index 50%
rename from TTKCommon/TTKApplication/ttkrunapplication.cpp
rename to TTKCommon/TTKApplication/ttkapplication.cpp
index e448b93..3bca3e4 100644
--- a/TTKCommon/TTKApplication/ttkrunapplication.cpp
+++ b/TTKCommon/TTKApplication/ttkapplication.cpp
@@ -1,64 +1,64 @@
-#include "ttkrunapplication.h"
+#include "ttkapplication.h"
#include "ttklocalpeer.h"
#include
-/*! @brief The class of the ttk run application private.
+/*! @brief The class of the ttk application private.
* @author Greedysky
*/
-class TTKRunApplicationPrivate : public TTKPrivate
+class TTKApplicationPrivate : public TTKPrivate
{
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)));
}
diff --git a/TTKCommon/TTKApplication/ttkrunapplication.h b/TTKCommon/TTKApplication/ttkapplication.h
similarity index 83%
rename from TTKCommon/TTKApplication/ttkrunapplication.h
rename to TTKCommon/TTKApplication/ttkapplication.h
index 6adeecf..ec0ac88 100644
--- a/TTKCommon/TTKApplication/ttkrunapplication.h
+++ b/TTKCommon/TTKApplication/ttkapplication.h
@@ -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
#include "ttkprivate.h"
-class TTKRunApplicationPrivate;
+class TTKApplicationPrivate;
-/*! @brief The class of the ttk run application.
+/*! @brief The class of the ttk application.
* @author Greedysky
*/
-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
diff --git a/TTKCommon/TTKApplication/ttkcoreapplication.h.cpp b/TTKCommon/TTKApplication/ttkcoreapplication.h.cpp
new file mode 100644
index 0000000..45e69ff
--- /dev/null
+++ b/TTKCommon/TTKApplication/ttkcoreapplication.h.cpp
@@ -0,0 +1,66 @@
+#include "ttkcoreapplication.h"
+#include "ttklocalpeer.h"
+
+/*! @brief The class of the ttk core application private.
+ * @author Greedysky
+ */
+class TTKCoreApplicationPrivate : public TTKPrivate
+{
+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)));
+}
diff --git a/TTKCommon/TTKApplication/ttkcoreapplication.h.h b/TTKCommon/TTKApplication/ttkcoreapplication.h.h
new file mode 100644
index 0000000..967290f
--- /dev/null
+++ b/TTKCommon/TTKApplication/ttkcoreapplication.h.h
@@ -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 .
+ ***************************************************************************/
+
+#include
+#include "ttkprivate.h"
+
+class TTKCoreApplicationPrivate;
+
+/*! @brief The class of the ttk core application.
+ * @author Greedysky
+ */
+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
diff --git a/TTKCommon/TTKApplication/ttkguiapplication.cpp b/TTKCommon/TTKApplication/ttkguiapplication.cpp
new file mode 100644
index 0000000..e8699f3
--- /dev/null
+++ b/TTKCommon/TTKApplication/ttkguiapplication.cpp
@@ -0,0 +1,68 @@
+#include "ttkguiapplication.h"
+#include "ttklocalpeer.h"
+
+#include
+
+/*! @brief The class of the ttk gui application private.
+ * @author Greedysky
+ */
+class TTKGuiApplicationPrivate : public TTKPrivate
+{
+public:
+ TTKGuiApplicationPrivate();
+ ~TTKGuiApplicationPrivate();
+
+ TTKLocalPeer *m_peer;
+};
+
+TTKGuiApplicationPrivate::TTKGuiApplicationPrivate()
+ : m_peer(nullptr)
+{
+
+}
+
+TTKGuiApplicationPrivate::~TTKGuiApplicationPrivate()
+{
+ delete m_peer;
+}
+
+
+
+TTKGuiApplication::TTKGuiApplication(int &argc, char **argv)
+ : QGuiApplication(argc, argv)
+{
+ TTK_INIT_PRIVATE(TTKGuiApplication);
+ initialize();
+}
+
+TTKGuiApplication::TTKGuiApplication(const QString &id, int &argc, char **argv)
+ : QGuiApplication(argc, argv)
+{
+ TTK_INIT_PRIVATE(TTKGuiApplication);
+ initialize(id);
+}
+
+bool TTKGuiApplication::isRunning() const
+{
+ TTK_D(TTKGuiApplication);
+ return d->m_peer->isClient();
+}
+
+QString TTKGuiApplication::id() const
+{
+ TTK_D(TTKGuiApplication);
+ return d->m_peer->applicationId();
+}
+
+bool TTKGuiApplication::sendMessage(const QString &message, int timeout)
+{
+ TTK_D(TTKGuiApplication);
+ return d->m_peer->sendMessage(message, timeout);
+}
+
+void TTKGuiApplication::initialize(const QString &id)
+{
+ TTK_D(TTKGuiApplication);
+ d->m_peer = new TTKLocalPeer(this, id);
+ connect(d->m_peer, SIGNAL(messageReceived(QString)), SIGNAL(messageReceived(QString)));
+}
diff --git a/TTKCommon/TTKApplication/ttkguiapplication.h b/TTKCommon/TTKApplication/ttkguiapplication.h
new file mode 100644
index 0000000..0b34707
--- /dev/null
+++ b/TTKCommon/TTKApplication/ttkguiapplication.h
@@ -0,0 +1,72 @@
+#ifndef TTKGUIAPPLICATION_H
+#define TTKGUIAPPLICATION_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 .
+ ***************************************************************************/
+
+#include
+#include "ttkprivate.h"
+
+class TTKGuiApplicationPrivate;
+
+/*! @brief The class of the ttk gui application.
+ * @author Greedysky
+ */
+class TTK_MODULE_EXPORT TTKGuiApplication : public QGuiApplication
+{
+ Q_OBJECT
+public:
+ /*!
+ * Object constructor.
+ */
+ TTKGuiApplication(int &argc, char **argv);
+ TTKGuiApplication(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(TTKGuiApplication)
+
+};
+
+#endif // TTKGUIAPPLICATION_H
diff --git a/TTKRun/TTKApp/weatherapplicationmain.cpp b/TTKRun/TTKApp/weatherapplicationmain.cpp
index 30c6245..85d9edc 100644
--- a/TTKRun/TTKApp/weatherapplicationmain.cpp
+++ b/TTKRun/TTKApp/weatherapplicationmain.cpp
@@ -1,4 +1,4 @@
-#include "ttkrunapplication.h"
+#include "ttkapplication.h"
#include "weatherapplication.h"
#include "weatherobject.h"
#include "ttkdumper.h"
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
{
loadAppScaledFactor(argc, argv);
- TTKRunApplication app(argc, argv);
+ TTKApplication app(argc, argv);
QCoreApplication::setOrganizationName(TTK_APP_NAME);
QCoreApplication::setOrganizationDomain(TTK_APP_COME_NAME);