File indexing completed on 2024-05-12 05:38:23
0001 /* 0002 SPDX-FileCopyrightText: 2024 Niccolò Venerandi <niccolo@venerandi.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <cstdlib> 0008 #include <iostream> 0009 0010 #include <KConfigGroup> 0011 #include <KSharedConfig> 0012 #include <QDebug> 0013 0014 using namespace Qt::StringLiterals; 0015 0016 /** 0017 * If the user had specified a custom position for its panel, then 0018 * set "Custom" as the panel length mode; this will make the panel 0019 * preserve location and size in Plasma 6. 0020 * 0021 * @since 6.0 0022 */ 0023 int main() 0024 { 0025 const KSharedConfigPtr configPtr = KSharedConfig::openConfig(QStringLiteral("plasmashellrc"), KConfig::FullConfig); 0026 KConfigGroup views(configPtr, QStringLiteral("PlasmaViews")); 0027 if (!views.exists() || views.groupList().empty()) { 0028 std::cout << "plasmashellrc doesn't have any PlasmaViews. No need to update config." << std::endl; 0029 return EXIT_SUCCESS; 0030 } 0031 0032 // Update default floating setting in config groups like [PlasmaViews][Panel 114][Defaults] 0033 const QStringList groupList = views.groupList(); 0034 for (const QString &name : groupList) { 0035 if (!name.startsWith(QLatin1String("Panel "))) { 0036 continue; 0037 } 0038 0039 KConfigGroup panelConfigGroup(&views, name); 0040 if (!panelConfigGroup.hasGroup(u"Defaults"_s)) { 0041 continue; 0042 } 0043 0044 KConfigGroup defaultConfigGroup(&panelConfigGroup, u"Defaults"_s); 0045 if (!panelConfigGroup.hasKey("panelLengthMode") && (defaultConfigGroup.hasKey("maxLength") || defaultConfigGroup.hasKey("minLength"))) { 0046 // Since this panel has a custom size, we will 0047 // set the custom size length mode flag. 0048 panelConfigGroup.writeEntry("panelLengthMode", 2); 0049 } 0050 } 0051 0052 return configPtr->sync() ? EXIT_SUCCESS : EXIT_FAILURE; 0053 }