Logo Search packages:      
Sourcecode: karamba version File versions  Download package

clickarea.cpp

/***************************************************************************
 *   Copyright (C) 2003 by Hans Karlsson                                   *
 *   karlsson.h@home.se                                                      *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#include "clickarea.h"


ClickArea::ClickArea( int x, int y, int w, int h )
        : Meter( x, y, w, h )
{
    value = "";
    rect = QRect( x, y, w, h );
}

ClickArea::~ClickArea()
{}


void ClickArea::click( QMouseEvent *e )
{
    if( rect.contains( e->x(), e->y() ) )
    {
        //qDebug(QString::number(e->type()));
      //KShellProcess ksp;
        QString program;
        if( e->button() == Qt::LeftButton )
            program = onClick;
        program.replace( QRegExp("%v", false), value );

        if( program != "" )
        {
            //qDebug(program);
          KRun::runCommand(program);
        //  ksp << program;
          //  ksp.start(KProcIO::DontCare, KProcIO::NoCommunication);
        }
    }

}

void ClickArea::setOnClick( QString oc )
{
    onClick = oc;
}

void ClickArea::setOnMiddleClick( QString oc )
{
    onMiddleClick = oc;
}


QRect ClickArea::getRectangle()
{
    return rect;
}

void ClickArea::mUpdate( QPainter *p )
{

    p->drawRect( x, y, width, height );

}


void ClickArea::setValue( int v)
{

    setValue( QString::number( v ) );

}


void ClickArea::setValue( QString v )
{
    value = v;
}





Generated by  Doxygen 1.6.0   Back to index