| 20 | |
| 21 | #ifdef USE_PORTALS |
| 22 | static void onPortalBackgroundRequest(GObject *source_object, GAsyncResult *res, gpointer data) { |
| 23 | Q_UNUSED(source_object) |
| 24 | Q_UNUSED(data) |
| 25 | |
| 26 | g_autoptr(GError) error = nullptr; |
| 27 | |
| 28 | if (xdp_portal_request_background_finish(XdpQt::globalPortalObject(), res, &error) == 0) { |
| 29 | QString reason; |
| 30 | QString explanation; |
| 31 | |
| 32 | if (error != nullptr && error->code == 19) { |
| 33 | reason = QObject::tr("Auto-start permission has been denied"); |
| 34 | explanation = QObject::tr("Please run 'flatpak permission-set background background %1 yes' and reenable auto-start.").arg(FLATPAK_APP_ID); |
| 35 | } else { |
| 36 | reason = QObject::tr("Unknown error"); |
| 37 | explanation = QObject::tr("Please make sure a XDG Background Portal implementation is available and active to use auto-start. %1").arg((error) != nullptr ? error->message : ""); |
| 38 | } |
| 39 | |
| 40 | Log::error(reason); |
| 41 | Log::error(explanation); |
| 42 | // QMessageBox::critical(nullptr, reason, explanation); |
| 43 | |
| 44 | Log::error("Auto-start disabled"); |
| 45 | AppConfig::instance().set(AppConfig::AutoStartEnabled, false); |
| 46 | } |
| 47 | |
| 48 | Log::information("Background request granted"); |
| 49 | } |
| 50 | #endif |
| 51 | |
| 52 | void AutostartManager::setEnabled(bool enabled) |