Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

clickarea.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #include "clickarea.h"
00011 
00012 
00013 ClickArea::ClickArea( int x, int y, int w, int h )
00014         : Meter( x, y, w, h )
00015 {
00016     value = "";
00017     rect = QRect( x, y, w, h );
00018 }
00019 
00020 ClickArea::~ClickArea()
00021 {}
00022 
00023 
00024 void ClickArea::click( QMouseEvent *e )
00025 {
00026     KSimpleConfig conf("karambarc",true);
00027     conf.setGroup("karamba");
00028     QString Viewer =  conf.readEntry("ImgViewer", "");
00029     if( rect.contains( e->x(), e->y() ) )
00030     {
00031         QString program;
00032         if( e->button() == Qt::LeftButton ){
00033             program = onClick;
00034         }
00035         program.replace( QRegExp("%viewer", false), Viewer );
00036         program.replace( QRegExp("%v", false), value );
00037 
00038         if( program != "" ){
00039                 kdDebug("ClickArea") << "Running " << program << endl;
00040                 KRun::runCommand(program);
00041         }
00042     }
00043 
00044 }
00045 
00046 void ClickArea::setOnClick( QString oc )
00047 {
00048     onClick = oc;
00049 }
00050 
00051 void ClickArea::setOnMiddleClick( QString oc )
00052 {
00053     onMiddleClick = oc;
00054 }
00055 
00056 
00057 QRect ClickArea::getRectangle()
00058 {
00059     return rect;
00060 }
00061 
00062 void ClickArea::mUpdate( QPainter *p )
00063 {
00064 
00065         //p->setPen(Qt::color0);
00066         //p->drawRect( x, y, width, height );
00067 
00068 }
00069 
00070 
00071 void ClickArea::setValue( int v)
00072 {
00073 
00074     setValue( QString::number( v ) );
00075 
00076 }
00077 
00078 
00079 void ClickArea::setValue( QString v )
00080 {
00081     value = v;
00082 }
00083 
00084 void ClickArea::setTooltip(QString txt)
00085 {
00086         QRect rect(x,y,width,height);
00087         QToolTip::add(myKaramba, rect, txt);
00088 }
00089 
00090 void ClickArea::setKaramba(karamba* k)
00091 {
00092         myKaramba = k;
00093 }
00094 
00095 
00096 

Generated on Mon May 16 13:59:20 2005 for karamba by  doxygen 1.3.9.1