1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/***************************************************************************
* Copyright (C) 2003 by Hans Karlsson *
* karlsson.h@home.se *
* *
* Copyright (C) 2004,2005 Luke Kenneth Casson Leighton <lkcl@lkcl.net> *
* *
* 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"
#include <kservicegroup.h>
ClickArea::ClickArea(karamba* k, int x, int y, int w, int h )
: Meter(k, x, y, w, h )
{
value = "";
rect = TQRect( x, y, w, h );
}
ClickArea::~ClickArea()
{}
bool ClickArea::click( TQMouseEvent *e )
{
if( rect.contains( e->x(), e->y() ) )
{
//qDebug(TQString::number(e->type()));
//KShellProcess ksp;
if( e->button() != Qt::LeftButton )
return false;
if (!svc_name.isEmpty())
{
KService sv(svc_name, svc_onClick, svc_icon);
KURL::List l;
KRun::run(sv, l);
return false;
}
else
{
TQString program;
program = onClick;
program.replace( TQRegExp("%v", false), value );
if( !program.isEmpty() )
{
//qDebug(program);
KRun::runCommand(program);
}
}
}
return false;
}
void ClickArea::setOnClick( TQString oc )
{
onClick = oc;
}
void ClickArea::setServiceOnClick( TQString name , TQString exec, TQString icon )
{
svc_name = name;
svc_onClick = exec;
svc_icon = icon;
}
void ClickArea::setOnMiddleClick( TQString oc )
{
onMiddleClick = oc;
}
TQRect ClickArea::getRectangle()
{
return rect;
}
void ClickArea::mUpdate( TQPainter *p )
{
p->drawRect(boundingBox);
}
void ClickArea::setValue( long v)
{
setValue( TQString::number( v ) );
}
void ClickArea::setValue( TQString v )
{
value = v;
}
#include "clickarea.moc"
|