Plasma-workspace

plasma6.4-migrate-fullscreen-notifications-to-dnd.cpp
1/*
2 SPDX-FileCopyrightText: 2025 Kristen McWilliam <kmcwilliampublic@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include <iostream>
8
9#include <KConfigGroup>
10#include <KSharedConfig>
11
12#include <QStringLiteral>
13
14/**
15 * If the user has enabled the "Show over full screen windows" option,
16 * this script will migrate that preference by setting the new
17 * "Do Not Disturb when full screen windows are present" false.
18 *
19 * @since 6.4
20 */
21int main()
22{
23 const KSharedConfigPtr configPtr = KSharedConfig::openConfig(QStringLiteral("plasmanotifyrc"), KConfig::SimpleConfig);
24 KConfigGroup notificationsGroup(configPtr, QStringLiteral("Notifications"));
25 if (!notificationsGroup.exists()) {
26 std::cout << "plasmanotifyrc doesn't have a Notifications group. No need to update config." << std::endl;
27 return EXIT_SUCCESS;
28 }
29
30 // Check if the legacy "Show over full screen windows" option is enabled.
31 bool showOverFullScreen = notificationsGroup.readEntry("NormalAlwaysOnTop", false);
32 if (!showOverFullScreen) {
33 std::cout << "The 'Show over full screen windows' option is not enabled. No need to update config." << std::endl;
34 return EXIT_SUCCESS;
35 }
36
37 // Remove the old setting.
38 notificationsGroup.deleteEntry("NormalAlwaysOnTop");
39
40 // Disable the new setting to preserve the old behavior.
41 KConfigGroup dndGroup(configPtr, QStringLiteral("DoNotDisturb"));
42 dndGroup.writeEntry("WhenFullscreen", false);
43
44 // Save the changes to the configuration file.
45 if (!configPtr->sync()) {
46 std::cerr << "Failed to save changes to plasmanotifyrc." << std::endl;
47 return EXIT_FAILURE;
48 }
49
50 return EXIT_SUCCESS;
51}
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:55:44 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.