File indexing completed on 2024-05-19 04:36:07

0001 /* SPDX-FileCopyrightText: 2023 Noah Davis <noahadvs@gmail.com>
0002  * SPDX-License-Identifier: LGPL-2.0-or-later
0003  */
0004 
0005 #include "ConfigUtils.h"
0006 #include <KConfigGroup>
0007 #include <KSharedConfig>
0008 
0009 using namespace Qt::StringLiterals;
0010 
0011 int main()
0012 {
0013     const auto fileName = u"spectaclerc"_s;
0014     if (!continueUpdate(fileName, u"2024-02-28T00:00:00Z"_s)) {
0015         return 0;
0016     }
0017 
0018     // We only need to read spectaclerc, so we use SimpleConfig.
0019     auto spectaclerc = KSharedConfig::openConfig(fileName, KConfig::SimpleConfig);
0020 
0021     // Preserve old defaults for existing users that didn't already have these set.
0022     auto imageSaveGroup = spectaclerc->group(QStringLiteral("ImageSave"));
0023     if (isEntryDefault(imageSaveGroup, "imageFilenameTemplate")) {
0024         imageSaveGroup.writeEntry("imageFilenameTemplate", "Screenshot_%Y%M%D_%H%m%S");
0025     }
0026 
0027     auto videoSaveGroup = spectaclerc->group(QStringLiteral("VideoSave"));
0028     if (isEntryDefault(videoSaveGroup, "videoFilenameTemplate")) {
0029         videoSaveGroup.writeEntry("videoFilenameTemplate", "Screencast_%Y%M%D_%H%m%S");
0030     }
0031 
0032     return spectaclerc->sync() ? 0 : 1;
0033 }