[OpenDocString] kdeconnect-kde (cpp)
share_config.cpp
ShareConfig::ShareConfig(QWidget *parent, const QVariantList &args)
    : KdeConnectPluginKcm(parent, args, QStringLiteral("kdeconnect_share"))
    , m_ui(new Ui::ShareConfigUi())
{
    m_ui->setupUi(this);
    // xgettext:no-c-format
    m_ui->commentLabel->setTextFormat(Qt::RichText);
    m_ui->commentLabel->setText(i18n("%1 in the path will be replaced with the specific device name."));

    connect(m_ui->kurlrequester, SIGNAL(textChanged(QString)), this, SLOT(changed()));
}
This constructor builds a share config object and sets the parent widget and sets the comment label to be translated with % 1 in the path. It also connects the signal signal 'changed'.
ShareConfig::~ShareConfig()
{
    delete m_ui;
}
Deletes the UI object upon destruction.
void ShareConfig::defaults()
{
    KCModule::defaults();

    m_ui->kurlrequester->setText(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));

    Q_EMIT changed(true);
}
Sets the default values for the module to their defaults. It sets the download location in the ui widget and emits the signal changed.
void ShareConfig::load()
{
    KCModule::load();

    const auto standardPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
    m_ui->kurlrequester->setText(config()->getString(QStringLiteral("incoming_path"), standardPath));

    Q_EMIT changed(false);
}
This loads the module and sets the incoming path as the download path. It sets the signal changed to false.
void ShareConfig::save()
{
    config()->set(QStringLiteral("incoming_path"), m_ui->kurlrequester->text());

    KCModule::save();

    Q_EMIT changed(false);
}
Saves the current configuration to the shared config object. First it sets the incoming path value in the config object and then saves the module to the module cache. Then it emits the signal changed.