Do not launch the application twice
If the application is already running, simply raise the running instance.
This commit is contained in:
committed by
Aleix Pol Gonzalez
parent
0c28ec4041
commit
092f8ee75d
@@ -34,6 +34,7 @@ if(ANDROID)
|
|||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
else()
|
else()
|
||||||
find_package(Qt5Keychain REQUIRED)
|
find_package(Qt5Keychain REQUIRED)
|
||||||
|
find_package(KF5DBusAddons REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Quotient 0.6)
|
find_package(Quotient 0.6)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ if(ANDROID)
|
|||||||
"search"
|
"search"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(neochat PRIVATE Qt5::Widgets ${QTKEYCHAIN_LIBRARIES})
|
target_link_libraries(neochat PRIVATE Qt5::Widgets KF5::DBusAddons ${QTKEYCHAIN_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS neochat ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
|
install(TARGETS neochat ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|||||||
19
src/main.cpp
19
src/main.cpp
@@ -11,8 +11,12 @@
|
|||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
#include <KDBusService>
|
||||||
|
#endif
|
||||||
#include <KLocalizedContext>
|
#include <KLocalizedContext>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
@@ -58,6 +62,10 @@ int main(int argc, char *argv[])
|
|||||||
app.setOrganizationName("KDE");
|
app.setOrganizationName("KDE");
|
||||||
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
||||||
|
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
KDBusService service(KDBusService::Unique);
|
||||||
|
#endif
|
||||||
|
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
auto config = NeoChatConfig::self();
|
auto config = NeoChatConfig::self();
|
||||||
|
|
||||||
@@ -115,5 +123,16 @@ int main(int argc, char *argv[])
|
|||||||
if (engine.rootObjects().isEmpty())
|
if (engine.rootObjects().isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#ifndef Q_OS_ANDROID
|
||||||
|
QObject::connect(&service, &KDBusService::activateRequested, &engine, [&engine](const QStringList &/*arguments*/, const QString &/*workingDirectory*/) {
|
||||||
|
for (auto obj : engine.rootObjects()) {
|
||||||
|
auto view = qobject_cast<QQuickWindow*>(obj);
|
||||||
|
if (view) {
|
||||||
|
view->raise();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user