MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / setup

Method setup

src/utils/AutoStartManager.cpp:58–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void AutostartManager::setup()
59{
60 bool enabled = AppConfig::instance().get<bool>(AppConfig::AutoStartEnabled);
61
62#ifdef USE_PORTALS
63 QMainWindow* window = qobject_cast<QMainWindow*>(parent());
64 // Important: windowHandle returns null if the window has not yet finished initialising!
65 assert(window && window->windowHandle() && "AutostartManager class must be instantiated using the visible calling window as the parent");
66 XdpParent* xdpParent = xdp_parent_new_qt(window->windowHandle());
67
68 g_autoptr(GPtrArray) commandLine = nullptr;
69 if(enabled) {
70 commandLine = g_ptr_array_new_with_free_func(g_free);
71 g_ptr_array_add(commandLine, g_strdup("jamesdsp"));
72 g_ptr_array_add(commandLine, g_strdup("--tray"));
73 }
74
75 xdp_portal_request_background(
76 XdpQt::globalPortalObject(),
77 xdpParent,
78 tr("Manage auto-start permission for JamesDSP").toLocal8Bit().data(),
79 commandLine,
80 enabled ? XdpBackgroundFlags::XDP_BACKGROUND_FLAG_AUTOSTART : XdpBackgroundFlags::XDP_BACKGROUND_FLAG_NONE,
81 nullptr,
82 onPortalBackgroundRequest,
83 nullptr
84 );
85#else
86 if(!enabled && QFile::exists(getAutostartPath())) {
87 QFile::remove(getAutostartPath());
88 }
89 else if(enabled && !QFile::exists(getAutostartPath())) {
90 ConfigContainer *conf = new ConfigContainer();
91 conf->setValue("Exec", QString("%0 --tray").arg(AppConfig::instance().get<QString>(AppConfig::ExecutablePath)));
92 conf->setValue("Name", "JamesDSP for Linux");
93 conf->setValue("Icon", "jamesdsp");
94 conf->setValue("StartupNotify", false);
95 conf->setValue("Terminal", false);
96 conf->setValue("Type", "Application");
97 conf->setValue("Version", "1.0");
98 conf->setValue("X-GNOME-Autostart-Delay", 6);
99 conf->setValue("X-GNOME-Autostart-enabled", true);
100 conf->setValue("X-KDE-autostart-after", "panel");
101 conf->setValue("X-KDE-autostart-phase", 2);
102 conf->setValue("X-MATE-Autostart-Delay", 6);
103 ConfigIO::writeFile(getAutostartPath(), conf->getConfigMap(), "[Desktop Entry]");
104 }
105#endif
106}
107
108bool AutostartManager::isEnabled()
109{

Callers 1

showEventMethod · 0.45

Calls 4

getConfigMapMethod · 0.80
QStringClass · 0.50
dataMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected