2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-01 07:05:13 +00:00

Integrate GApplication with QFileOpenEvent and Core::Application::activate

This commit is contained in:
Ilya Fedin
2023-05-27 17:49:43 +04:00
committed by John Preston
parent 54841de991
commit 6aef6d7f4e
3 changed files with 31 additions and 39 deletions

View File

@@ -262,11 +262,8 @@ void LaunchGApplication() {
app->signal_activate().connect([] {
Core::Sandbox::Instance().customEnterFromEventLoop([] {
const auto window = Core::IsAppLaunched()
? Core::App().activePrimaryWindow()
: nullptr;
if (window) {
window->activate();
if (Core::IsAppLaunched()) {
Core::App().activate();
}
});
}, true);
@@ -276,33 +273,9 @@ void LaunchGApplication() {
const Glib::ustring &hint) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
for (const auto &file : files) {
if (file->get_uri_scheme() == "file") {
gSendPaths.append(
QString::fromStdString(file->get_path()));
continue;
}
const auto url = QString::fromStdString(file->get_uri());
if (url.isEmpty()) {
continue;
}
if (url.startsWith(qstr("interpret://"))) {
gSendPaths.append(url);
continue;
}
if (Core::StartUrlRequiresActivate(url)) {
const auto window = Core::IsAppLaunched()
? Core::App().activePrimaryWindow()
: nullptr;
if (window) {
window->activate();
}
}
cSetStartUrl(url);
Core::App().checkStartUrl();
}
if (!cSendPaths().isEmpty()) {
Core::App().checkSendPaths();
QFileOpenEvent e(
QUrl(QString::fromStdString(file->get_uri())));
QGuiApplication::sendEvent(qApp, &e);
}
});
}, true);