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

presscurvedialog.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 "presscurvedialog.h"
#include "ui_presscurvedialog.h"

#include "presscurve.h"

//KDE includes
#include <KDE/KDebug>

//Qt includes
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>

using namespace Wacom;

00032 PressCurveDialog::PressCurveDialog(QWidget *parent) :
        QDialog(parent),
        m_ui(new Ui::PressCurveDialog),
        m_deviceInterface(0)
{
    m_ui->setupUi(this);

    connect(m_ui->pc_Widget, SIGNAL(controlPointsChanged(QString)), SLOT(updateControlPoints(QString)));
}

00042 PressCurveDialog::~PressCurveDialog()
{
    delete m_ui;
}

00047 void PressCurveDialog::setDeviceHandler(QDBusInterface *deviceInterface, const QString & device)
{
    m_deviceInterface = deviceInterface;
    m_device = device;
}

00053 void PressCurveDialog::setControllPoints(const QString & points)
{
    QStringList splitPoints = points.split(' ');

    if (splitPoints.count() != 4) {
        splitPoints.insert(0, QString('0'));
        splitPoints.insert(1, QString('0'));
        splitPoints.insert(2, QString("100"));
        splitPoints.insert(3, QString("100"));
    }

    qreal p1 = splitPoints.at(0).toDouble();
    qreal p2 = splitPoints.at(1).toDouble();
    qreal p3 = splitPoints.at(2).toDouble();
    qreal p4 = splitPoints.at(3).toDouble();
    m_ui->pc_Widget->setControlPoints(p1, p2, p3, p4);
    m_ui->pc_Values->setText(QString("%1 %2 %3 %4").arg(p1).arg(p2).arg(p3).arg(p4));
}

00072 QString PressCurveDialog::getControllPoints()
{
    return m_ui->pc_Values->text();
}

00077 void PressCurveDialog::updateControlPoints(const QString & points)
{
    m_ui->pc_Values->setText(points);

    if (!m_deviceInterface) {
        kError() << "DBus tablet /Device Interface not available";
        return;
    }

    m_deviceInterface->call("setConfiguration", m_device, "PressCurve", points);
}

00089 void PressCurveDialog::accept()
{
    done(KDialog::Accepted);
}
00093 void PressCurveDialog::recejct()
{
    done(KDialog::Rejected);
}

Generated by  Doxygen 1.6.0   Back to index