Raise windows also on other platforms
And unify code related to unique application handling
This commit is contained in:
55
src/main.cpp
55
src/main.cpp
@@ -137,20 +137,6 @@ int main(int argc, char *argv[])
|
|||||||
KAboutData::setApplicationData(about);
|
KAboutData::setApplicationData(about);
|
||||||
QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.neochat")));
|
QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.neochat")));
|
||||||
|
|
||||||
#ifdef HAVE_KDBUSADDONS
|
|
||||||
KDBusService service(KDBusService::Unique);
|
|
||||||
service.connect(&service, &KDBusService::activateRequested, &RoomManager::instance(), [](const QStringList &arguments, const QString &workingDirectory) {
|
|
||||||
Q_UNUSED(workingDirectory);
|
|
||||||
if (arguments.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto args = arguments;
|
|
||||||
args.removeFirst();
|
|
||||||
for (const auto &arg : args) {
|
|
||||||
RoomManager::instance().openResource(arg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEOCHAT_FLATPAK
|
#ifdef NEOCHAT_FLATPAK
|
||||||
// Copy over the included FontConfig configuration to the
|
// Copy over the included FontConfig configuration to the
|
||||||
@@ -248,17 +234,35 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_KDBUSADDONS
|
#ifdef HAVE_KDBUSADDONS
|
||||||
QObject::connect(&service, &KDBusService::activateRequested, &engine, [&engine](const QStringList & /*arguments*/, const QString & /*workingDirectory*/) {
|
KDBusService service(KDBusService::Unique);
|
||||||
const auto rootObjects = engine.rootObjects();
|
service.connect(&service,
|
||||||
for (auto obj : rootObjects) {
|
&KDBusService::activateRequested,
|
||||||
auto view = qobject_cast<QQuickWindow *>(obj);
|
&RoomManager::instance(),
|
||||||
if (view) {
|
[&engine](const QStringList &arguments, const QString &workingDirectory) {
|
||||||
view->show();
|
Q_UNUSED(workingDirectory);
|
||||||
raiseWindow(view);
|
|
||||||
return;
|
// Raise windows
|
||||||
}
|
const auto rootObjects = engine.rootObjects();
|
||||||
}
|
for (auto obj : rootObjects) {
|
||||||
});
|
auto view = qobject_cast<QQuickWindow *>(obj);
|
||||||
|
if (view) {
|
||||||
|
view->show();
|
||||||
|
raiseWindow(view);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open matrix uri
|
||||||
|
if (arguments.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto args = arguments;
|
||||||
|
args.removeFirst();
|
||||||
|
for (const auto &arg : args) {
|
||||||
|
RoomManager::instance().openResource(arg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
const auto rootObjects = engine.rootObjects();
|
const auto rootObjects = engine.rootObjects();
|
||||||
for (auto obj : rootObjects) {
|
for (auto obj : rootObjects) {
|
||||||
auto view = qobject_cast<QQuickWindow *>(obj);
|
auto view = qobject_cast<QQuickWindow *>(obj);
|
||||||
@@ -269,6 +273,5 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user