[OpenDocString] kdeconnect-kde (cpp)
clipboard_config.cpp
ClipboardConfig::ClipboardConfig(QWidget* parent, const QVariantList &args)
    : KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_clipboard"))
    , m_ui(new Ui::ClipboardConfigUi())
{
    m_ui->setupUi(this);

    connect(m_ui->check_unknown, SIGNAL(toggled(bool)), this, SLOT(changed()));
    connect(m_ui->check_password, SIGNAL(toggled(bool)), this, SLOT(changed()));
}
Constructs a clipboard config object and sets up signal/slot connections for unknown and password change events.
ClipboardConfig::~ClipboardConfig()
{
    delete m_ui;
}
This removes the UI object upon destruction.
void ClipboardConfig::defaults()
{
    KCModule::defaults();
    m_ui->check_unknown->setChecked(true);
    m_ui->check_password->setChecked(true);
    Q_EMIT changed(true);
}
Sets all default settings to their respective states. First it sets check_unknown and check_password to true. Then it emits the signal 'changed'.
void ClipboardConfig::load()
{
    KCModule::load();
    bool unknown = config()->getBool(QStringLiteral("sendUnknown"), true);
    bool password = config()->getBool(QStringLiteral("sendPassword"), true);
    m_ui->check_unknown->setChecked(unknown);
    m_ui->check_password->setChecked(password);

    Q_EMIT changed(false);
}
This loads the clipping configuration from the module. It checks if the unknown flag is set and sets the check_unknown and check_password widgets accordingly.
void ClipboardConfig::save()
{
    config()->set(QStringLiteral("sendUnknown"), m_ui->check_unknown->isChecked());
    config()->set(QStringLiteral("sendPassword"), m_ui->check_password->isChecked());
    KCModule::save();
    Q_EMIT changed(false);
}
Saves the clipping configuration to the internal configuration object. First it sets the send unknown and send password values to the internal configuration object and marks the module as changed. Finally it emits the signal changed.