File indexing completed on 2025-04-20 04:33:18
0001 /** 0002 * SPDX-FileCopyrightText: 2022 Yuchen Shi <bolshaya_schists@mail.gravitide.co> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "clipboard_config.h" 0008 0009 #include <KPluginFactory> 0010 0011 K_PLUGIN_CLASS(ClipboardConfig) 0012 0013 ClipboardConfig::ClipboardConfig(QObject *parent, const KPluginMetaData &data, const QVariantList &args) 0014 : KdeConnectPluginKcm(parent, data, args) 0015 { 0016 m_ui.setupUi(widget()); 0017 0018 connect(m_ui.check_autoshare, &QCheckBox::toggled, this, &ClipboardConfig::autoShareChanged); 0019 connect(m_ui.check_password, &QCheckBox::toggled, this, &ClipboardConfig::markAsChanged); 0020 } 0021 0022 void ClipboardConfig::autoShareChanged() 0023 { 0024 m_ui.check_password->setEnabled(m_ui.check_autoshare->isChecked()); 0025 markAsChanged(); 0026 } 0027 0028 void ClipboardConfig::defaults() 0029 { 0030 KCModule::defaults(); 0031 m_ui.check_autoshare->setChecked(true); 0032 m_ui.check_password->setChecked(true); 0033 markAsChanged(); 0034 } 0035 0036 void ClipboardConfig::load() 0037 { 0038 KCModule::load(); 0039 // "sendUnknown" is the legacy name for this setting 0040 bool autoShare = config()->getBool(QStringLiteral("autoShare"), config()->getBool(QStringLiteral("sendUnknown"), true)); 0041 bool password = config()->getBool(QStringLiteral("sendPassword"), true); 0042 m_ui.check_autoshare->setChecked(autoShare); 0043 m_ui.check_password->setChecked(password); 0044 autoShareChanged(); 0045 } 0046 0047 void ClipboardConfig::save() 0048 { 0049 config()->set(QStringLiteral("autoShare"), m_ui.check_autoshare->isChecked()); 0050 config()->set(QStringLiteral("sendPassword"), m_ui.check_password->isChecked()); 0051 KCModule::save(); 0052 } 0053 0054 #include "clipboard_config.moc" 0055 #include "moc_clipboard_config.cpp"