Changeset View
Changeset View
Standalone View
Standalone View
kded/daemon.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 45 | K_PLUGIN_FACTORY_WITH_JSON(KScreenDaemonFactory, | |||
---|---|---|---|---|---|
46 | "kscreen.json", | 46 | "kscreen.json", | ||
47 | registerPlugin<KScreenDaemon>();) | 47 | registerPlugin<KScreenDaemon>();) | ||
48 | 48 | | |||
49 | KScreenDaemon::KScreenDaemon(QObject* parent, const QList< QVariant >& ) | 49 | KScreenDaemon::KScreenDaemon(QObject* parent, const QList< QVariant >& ) | ||
50 | : KDEDModule(parent) | 50 | : KDEDModule(parent) | ||
51 | , m_monitoredConfig(nullptr) | 51 | , m_monitoredConfig(nullptr) | ||
52 | , m_monitoring(false) | 52 | , m_monitoring(false) | ||
53 | , m_changeCompressor(new QTimer(this)) | 53 | , m_changeCompressor(new QTimer(this)) | ||
54 | , m_saveTimer(new QTimer(this)) | 54 | , m_saveTimer(nullptr) | ||
55 | , m_lidClosedTimer(new QTimer(this)) | 55 | , m_lidClosedTimer(new QTimer(this)) | ||
56 | 56 | | |||
57 | { | 57 | { | ||
58 | KScreen::Log::instance(); | 58 | KScreen::Log::instance(); | ||
59 | QMetaObject::invokeMethod(this, "requestConfig", Qt::QueuedConnection); | 59 | QMetaObject::invokeMethod(this, "requestConfig", Qt::QueuedConnection); | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | void KScreenDaemon::requestConfig() | 62 | void KScreenDaemon::requestConfig() | ||
Show All 29 Lines | 88 | { | |||
92 | QList<QKeySequence> switchDisplayShortcuts({Qt::Key_Display, Qt::MetaModifier + Qt::Key_P}); | 92 | QList<QKeySequence> switchDisplayShortcuts({Qt::Key_Display, Qt::MetaModifier + Qt::Key_P}); | ||
93 | KGlobalAccel::self()->setGlobalShortcut(action, switchDisplayShortcuts); | 93 | KGlobalAccel::self()->setGlobalShortcut(action, switchDisplayShortcuts); | ||
94 | connect(action, &QAction::triggered, this, &KScreenDaemon::displayButton); | 94 | connect(action, &QAction::triggered, this, &KScreenDaemon::displayButton); | ||
95 | 95 | | |||
96 | new KScreenAdaptor(this); | 96 | new KScreenAdaptor(this); | ||
97 | // Initialize OSD manager to register its dbus interface | 97 | // Initialize OSD manager to register its dbus interface | ||
98 | m_osdManager = new KScreen::OsdManager(this); | 98 | m_osdManager = new KScreen::OsdManager(this); | ||
99 | 99 | | |||
100 | m_saveTimer->setInterval(300); | | |||
101 | m_saveTimer->setSingleShot(true); | | |||
102 | connect(m_saveTimer, &QTimer::timeout, this, &KScreenDaemon::saveCurrentConfig); | | |||
103 | | ||||
104 | m_changeCompressor->setInterval(10); | 100 | m_changeCompressor->setInterval(10); | ||
105 | m_changeCompressor->setSingleShot(true); | 101 | m_changeCompressor->setSingleShot(true); | ||
106 | connect(m_changeCompressor, &QTimer::timeout, this, &KScreenDaemon::applyConfig); | 102 | connect(m_changeCompressor, &QTimer::timeout, this, &KScreenDaemon::applyConfig); | ||
107 | 103 | | |||
108 | m_lidClosedTimer->setInterval(1000); | 104 | m_lidClosedTimer->setInterval(1000); | ||
109 | m_lidClosedTimer->setSingleShot(true); | 105 | m_lidClosedTimer->setSingleShot(true); | ||
110 | connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::lidClosedTimeout); | 106 | connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::lidClosedTimeout); | ||
111 | 107 | | |||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 238 | Q_FOREACH(const KScreen::OutputPtr &output, m_monitoredConfig->outputs()) { | |||
243 | if (output->isConnected() && output->isEnabled() && output->currentMode().isNull()) { | 239 | if (output->isConnected() && output->isEnabled() && output->currentMode().isNull()) { | ||
244 | qCDebug(KSCREEN_KDED) << "Current mode" << output->currentModeId() << "invalid, setting preferred mode" << output->preferredModeId(); | 240 | qCDebug(KSCREEN_KDED) << "Current mode" << output->currentModeId() << "invalid, setting preferred mode" << output->preferredModeId(); | ||
245 | output->setCurrentModeId(output->preferredModeId()); | 241 | output->setCurrentModeId(output->preferredModeId()); | ||
246 | doApplyConfig(m_monitoredConfig); | 242 | doApplyConfig(m_monitoredConfig); | ||
247 | } | 243 | } | ||
248 | } | 244 | } | ||
249 | 245 | | |||
250 | // Reset timer, delay the writeback | 246 | // Reset timer, delay the writeback | ||
247 | if (!m_saveTimer) { | ||||
248 | m_saveTimer = new QTimer(this); | ||||
249 | m_saveTimer->setInterval(300); | ||||
250 | m_saveTimer->setSingleShot(true); | ||||
251 | connect(m_saveTimer, &QTimer::timeout, this, &KScreenDaemon::saveCurrentConfig); | ||||
252 | } | ||||
251 | m_saveTimer->start(); | 253 | m_saveTimer->start(); | ||
252 | } | 254 | } | ||
253 | 255 | | |||
254 | void KScreenDaemon::saveCurrentConfig() | 256 | void KScreenDaemon::saveCurrentConfig() | ||
255 | { | 257 | { | ||
256 | qCDebug(KSCREEN_KDED) << "Saving current config to file"; | 258 | qCDebug(KSCREEN_KDED) << "Saving current config to file"; | ||
257 | 259 | | |||
258 | // We assume the config is valid, since it's what we got, but we are interested | 260 | // We assume the config is valid, since it's what we got, but we are interested | ||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |