File indexing completed on 2024-05-12 05:36:15
0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #include "settings.h" 0005 0006 #include <KConfigGroup> 0007 #include <KRuntimePlatform> 0008 0009 const QString CONFIG_FILE = QStringLiteral("plasmamobilerc"); 0010 const QString INITIAL_START_CONFIG_GROUP = QStringLiteral("InitialStart"); 0011 0012 Settings::Settings(QObject *parent) 0013 : QObject{parent} 0014 , m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)} 0015 , m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(QStringLiteral("phone"))} 0016 { 0017 } 0018 0019 bool Settings::shouldStartWizard() 0020 { 0021 if (!m_isMobilePlatform) { 0022 return false; 0023 } 0024 0025 auto group = KConfigGroup{m_mobileConfig, INITIAL_START_CONFIG_GROUP}; 0026 return !group.readEntry("wizardRun", false); 0027 } 0028 0029 void Settings::setWizardFinished() 0030 { 0031 auto group = KConfigGroup{m_mobileConfig, INITIAL_START_CONFIG_GROUP}; 0032 group.writeEntry("wizardRun", true, KConfigGroup::Notify); 0033 m_mobileConfig->sync(); 0034 } 0035 0036 Settings *Settings::self() 0037 { 0038 static auto instance = new Settings; 0039 return instance; 0040 }