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 #include <QUrl> 0009 0010 using namespace Qt::StringLiterals; 0011 0012 int main() 0013 { 0014 const auto fileName = u"spectaclerc"_s; 0015 if (!continueUpdate(fileName, u"2024-02-28T00:00:00Z"_s)) { 0016 return 0; 0017 } 0018 0019 // We only need to read spectaclerc, so we use SimpleConfig. 0020 auto spectaclerc = KSharedConfig::openConfig(fileName, KConfig::SimpleConfig); 0021 0022 // Preserve old defaults for existing users that didn't already have these set. 0023 auto imageSaveGroup = spectaclerc->group(QStringLiteral("ImageSave")); 0024 if (isEntryDefault(imageSaveGroup, "imageSaveLocation")) { 0025 const auto url = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + u'/'); 0026 imageSaveGroup.writeEntry("imageSaveLocation", url); 0027 } 0028 0029 auto videoSaveGroup = spectaclerc->group(QStringLiteral("VideoSave")); 0030 if (isEntryDefault(videoSaveGroup, "videoSaveLocation")) { 0031 const auto url = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation) + u'/'); 0032 videoSaveGroup.writeEntry("videoSaveLocation", url); 0033 } 0034 0035 return spectaclerc->sync() ? 0 : 1; 0036 }