Logo Search packages:      
Sourcecode: kcm-tablet version File versions  Download package

wacominterface.cpp

/*
 * Copyright 2009, 2010 Jörg Ehrichs <joerg.ehichs@gmx.de>
 *
 * 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) any later version.
 *
 * 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
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "wacominterface.h"
#include "devicehandler.h"

//KDE includes
#include <KDE/KConfigGroup>
#include <KDE/KSharedConfig>
#include <KDE/KStandardDirs>

// Qt includes
#include <QtCore/QString>
#include <QtCore/QProcess>
#include <QtCore/QRegExp>

using namespace Wacom;

00033 WacomInterface::WacomInterface()
        : DeviceInterface()
{

}

00039 WacomInterface::~WacomInterface()
{
}

00043 void WacomInterface::applyProfile(const QString & device, const QString & section, KConfigGroup *gtprofile) const
{
    KConfigGroup deviceGroup(gtprofile, section);

    foreach(const QString &key, deviceGroup.keyList()) {
        setConfiguration(device, key, deviceGroup.readEntry(key));
    }
}

00052 void WacomInterface::setConfiguration(const QString & device, const QString & param, const QString & value) const
{
    QString modifiedParam = param;
    QString cmd = QString("xsetwacom set \"%1\" %2 \"%3\"").arg(device).arg(modifiedParam.replace(QRegExp("^[0-9]"), "")).arg(value);

    QProcess setConf;
    setConf.start(cmd);

    if (!setConf.waitForStarted()) {
        return;
    }

    if (!setConf.waitForFinished()) {
        return;
    }
}

00069 QString WacomInterface::getConfiguration(const QString & device, const QString & param) const
{
    QString modifiedParam = param;
    QString cmd = QString("xsetwacom get \"%1\" %2").arg(device).arg(modifiedParam.replace(QRegExp("^[0-9]"), ""));
    QProcess getConf;
    getConf.start(cmd);

    if (!getConf.waitForStarted()) {
        return QString();
    }

    if (!getConf.waitForFinished()) {
        return QString();
    }

    QString result = QString(getConf.readAll());
    return result.remove('\n');
}

00088 QString WacomInterface::getDefaultConfiguration(const QString & device, const QString & param) const
{
    QString modifiedParam = param;
    QString cmd = QString("xsetwacom getdefault \"%1\" %2").arg(device).arg(modifiedParam.replace(QRegExp("^[0-9]"), ""));
    QProcess getConf;
    getConf.start(cmd);

    if (!getConf.waitForStarted()) {
        return QString();
    }

    if (!getConf.waitForFinished()) {
        return QString();
    }

    QString result = QString(getConf.readAll());
    return result.remove('\n');
}

Generated by  Doxygen 1.6.0   Back to index