kdeconnectpluginkcm.cpp 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/**
 * Copyright 2013 Albert Vaca <albertvaka@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License or (at your option) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
 * by the membership of KDE e.V.), which shall act as a proxy
 * defined in Section 14 of version 3 of the license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 20 21 22 23 24 25 26 27
 */

#include "kdeconnectpluginkcm.h"

#include <KAboutData>
#include <KService>

struct KdeConnectPluginKcmPrivate
{
28 29 30
    QString m_deviceId;
    QString m_pluginName;
    KdeConnectPluginConfig* m_config;
31 32 33 34 35 36 37
};

KdeConnectPluginKcm::KdeConnectPluginKcm(QWidget* parent, const QVariantList& args, const QString& componentName)
    : KCModule(KAboutData::pluginData(componentName), parent, args)
    , d(new KdeConnectPluginKcmPrivate())
{

38
    d->m_deviceId = args.at(0).toString();
39
    //The parent of the config should be the plugin itself
40
    d->m_pluginName = KService::serviceByDesktopName(componentName).constData()->property(QStringLiteral("X-KDE-ParentComponents")).toString();
41

42
    d->m_config = new KdeConnectPluginConfig(d->m_deviceId, d->m_pluginName);
43 44 45 46
}

KdeConnectPluginKcm::~KdeConnectPluginKcm()
{
47
    delete d->m_config;
48 49 50 51
}

KdeConnectPluginConfig* KdeConnectPluginKcm::config() const
{
52
    return d->m_config;
53 54 55 56
}

QString KdeConnectPluginKcm::deviceId() const
{
57
    return d->m_deviceId;
58 59 60
}