00001
00002
00003
00004
00005 #include "karamba.h"
00006 karamba::karamba(QWidget* parent, QString fn, bool noquit) : DCOPObject( "karamba" ), QWidget( parent,"karamba", Qt::WGroupLeader | WStyle_Customize | WRepaintNoErase | WStyle_NoBorder | WDestructiveClose ){
00007
00008 themePath = QFileInfo( fn ).dirPath(true);
00009 pr = parent;
00010 connect(qApp,SIGNAL(lastWindowClosed()),qApp,SLOT(quit()));
00011 connect( this, SIGNAL( karambaRun ( bool ) ), this, SLOT( status( bool ) ) );
00012 qApp->setGlobalMouseTracking( TRUE );
00013 MouseOver = false;
00014 nq = noquit;
00015
00016 info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState );
00017 info->setDesktop( NETWinInfo::OnAllDesktops );
00018 info->setState( NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager,NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager );
00019
00020
00021 kWinModule = new KWinModule();
00022 connect( kWinModule,SIGNAL(currentDesktopChanged(int)), this,SLOT(currentDesktopChanged(int)) );
00023
00024
00025 kpop = new KPopupMenu( this );
00026 ksubpop = new KPopupMenu( this );
00027 accColl = new KActionCollection( this );
00028
00029 kpop->insertItem( SmallIconSet("reload"),tr2i18n("&Update"), this, SLOT(updateSensors()), Key_F5 );
00030 toggleLocked = new KToggleAction ( tr2i18n("&Lock position"), CTRL+Key_L, this, SLOT( slotToggleLocked() ), accColl, tr2i18n("Locked position") );
00031 accColl->insert(toggleLocked);
00032 toggleLocked->plug(kpop);
00033
00034 kpop->insertSeparator();
00035
00036 kpop->insertItem( SmallIconSet("fileopen"),tr2i18n("Add &new configuration"), this, SLOT(startNewKaramba()), CTRL+Key_O );
00037 kpop->insertItem( SmallIconSet("edit"),tr2i18n("&Edit configuration"),this,SLOT(editConfig()), CTRL+Key_E );
00038 kpop->insertItem( SmallIconSet("reload3"),tr2i18n("&Reload configuration"),this,SLOT(reloadConfig()), CTRL+Key_R );
00039 if( !nq ){
00040 kpop->insertItem( SmallIconSet("fileclose"),tr2i18n("&Close this configuration"), this, SLOT(close()), CTRL+Key_D );
00041 }
00042 kpop->insertItem( SmallIconSet("configure"),tr2i18n("C&onfigure Karamba"), this, SLOT(Config()), CTRL+Key_K );
00043 kpop->insertItem( SmallIconSet("karamba"),tr2i18n("&About"), this, SLOT(about()), CTRL+Key_A );
00044 kpop->insertItem( SmallIconSet("about_kde"),tr2i18n("About &KDE"), this, SLOT(aboutKDE()), CTRL+Key_H );
00045
00046 if( !nq ){
00047 kpop->insertSeparator();
00048 kpop->insertItem( SmallIconSet("exit"),tr2i18n("&Quit"), qApp, SLOT(quit()), CTRL+Key_Q );
00049 }
00050 ksubpop->insertItem( SmallIconSet("configure"),tr2i18n("&Theme Creator"), this, SLOT(LaunchCreator()), CTRL+Key_T );
00051 kpop->insertItem( tr2i18n("Extra"), ksubpop );
00052
00053 kpop->polish();
00054 popupIsShown = false;
00055 connect(kpop, SIGNAL(aboutToShow()), this, SLOT(popupShown()));
00056 connect(kpop, SIGNAL(aboutToHide()), this, SLOT(popupHiden()));
00057
00058 foundKaramba = false;
00059 onTop = false;
00060 onBottom = false;
00061 fixedPosition = false;
00062 fade = false;
00063 shadow = true;
00064 shadowed = true;
00065
00066
00067 themeFile = fn;
00068
00069 meterList = new QObjectList();
00070 meterList->setAutoDelete( true );
00071 sensorList = new QObjectList();
00072 sensorList->setAutoDelete( true );
00073 childList = new QObjectList();
00074 clickList = new QObjectList();
00075 timeList = new QObjectList();
00076 imageList = new QObjectList();
00077 iconList = new QPtrList<IconLabel>();
00078 iconBoxList = new QPtrList<IconBoxLabel>();
00079 KarProcList = new QPtrList<karamba>();
00080 KarChildList = new QPtrList<karamba>();
00081
00082
00083 client = kapp->dcopClient();
00084 if (!client->isAttached()){
00085 client->attach();
00086 }
00087 appId = client->registerAs(kapp->name());
00088
00089
00090 if( !onTop){
00091 this->lower();
00092 }
00093
00094 KSimpleConfig conf("karambarc",true);
00095 conf.setGroup("Embed");
00096 bgColor = conf.readColorEntry("bgColor",0);
00097 fadeColor = conf.readColorEntry("fadeColor",0);
00098 fadeLevel = conf.readDoubleNumEntry("fadeLevel",0.2);
00099 if(pr){
00100 setPaletteBackgroundColor(bgColor);
00101 setBackgroundMode( PaletteBackground );
00102 }
00103 else{
00104 setBackgroundMode( NoBackground );
00105 }
00106
00107 toggleHide();
00108 if( !parseConfig() ){
00109 setFixedSize(0,0);
00110 QTimer::singleShot( 100, this, SLOT(close()) );
00111 }
00112 else{
00113 kroot = new KarambaRootPixmap((QWidget*)this);
00114 kroot->start();
00115 kroot->repaint( true );
00116 }
00117 }
00118
00119 karamba::~karamba(){
00120 kdDebug("Main") << "Closing Karamba" << endl;
00121 if(meterList != 0){
00122 meterList->clear();
00123 delete meterList;
00124 }
00125
00126 if( sensorList != 0 ){
00127 sensorList->clear();
00128 delete sensorList;
00129 }
00130
00131 if( imageList != 0 ){
00132 imageList->clear();
00133 delete imageList;
00134 }
00135
00136 if( iconList != 0 ){
00137 iconList->clear();
00138 delete iconList;
00139 }
00140
00141 if( iconBoxList != 0 ){
00142 iconBoxList->clear();
00143 delete iconBoxList;
00144 }
00145
00146 if( childList != 0 ){
00147 childList->clear();
00148 delete childList;
00149 }
00150
00151 if( clickList != 0 ){
00152 clickList->clear();
00153 delete clickList;
00154 }
00155
00156 if( timeList != 0 ){
00157 timeList->clear();
00158 delete timeList;
00159 }
00160
00161 if( KarProcList != 0 ){
00162 KarProcList->clear();
00163 delete KarProcList;
00164 }
00165
00166 if( KarChildList != 0 ){
00167 if(KarChildList->count()){
00168 karamba* kc;
00169 for ( kc = KarChildList->first(); kc; kc = KarChildList->next() ){
00170 if(kc->isShown()){
00171 kc->close();
00172 }
00173 }
00174 }
00175 KarChildList->clear();
00176 delete KarChildList;
00177 }
00178
00179 if( toggleLocked != 0)
00180 delete toggleLocked;
00181 if( accColl != 0)
00182 delete accColl;
00183
00184 if( kpop != 0)
00185 delete kpop;
00186 delete kWinModule;
00187 }
00188
00189 bool karamba::parseConfig(){
00190 m_sysTimer = new QTimer(this);
00191 QFileInfo inf(themeFile);
00192 if( inf.isRelative()){
00193 themeFile = themePath +"/" + themeFile;
00194 }
00195 kdDebug("Main") << "Parsing theme: " << themeFile << endl;
00196 QFile file(themeFile);
00197 QString line;
00198 QString meter;
00199 int interval = 0;
00200 TextLabel *defaultTextLabel = 0;
00201 int iconBoxId = 0;
00202 shadow = true;
00203 shadowed = true;
00204
00205 if ( file.open(IO_ReadOnly | IO_Translate) ){
00206 QTextStream t( &file );
00207 QValueStack<QPoint> offsetStack;
00208 offsetStack.push(QPoint(0,0));
00209
00210 int x=0;
00211 int y=0;
00212 int w=0;
00213 int h=0;
00214 m_meter_list = new QPtrList<MeterList>;
00215 int id = 0;
00216 while( ( line = t.readLine() ) !=0 ){
00217 QRegExp rx("^\\s*(\\S+)");
00218 rx.search(line);
00219 meter = rx.cap(1).upper();
00220
00221 x = getInt("X",line)+offsetStack.top().x();
00222 y = getInt("Y",line)+offsetStack.top().y();
00223 w = getInt("W",line);
00224 h = getInt("H",line);
00225
00226
00227
00228 if( meter == "KARAMBA" && !foundKaramba ){
00229
00230 m_meter = new MeterList;
00231 m_meter->line = id;
00232 m_meter->type = meter;
00233 m_meter->width = w;
00234 m_meter->height = h;
00235 m_meter->xPos = x;
00236 m_meter->yPos = y;
00237 m_meter_list->append(m_meter);
00238
00239 kdDebug("Main") << "KARAMBA is found" << endl;
00240 toggleLocked->setChecked( getBoolean( "LOCKED", line ) );
00241 slotToggleLocked();
00242 QDesktopWidget *d = QApplication::desktop();
00243
00244
00245 hidek = (getString( "HIDE", line )).upper();
00246
00247 if(hidek != ""){
00248 kdDebug("Main") << "Hide(" << hidek << ")" << endl;
00249 int limit = getInt( "LIMIT", line);
00250 Hlimit = (limit != 0)?limit:20;
00251 x = ( hidek == "RIGHT" ) ? d->width() - w:x;
00252 y = ( hidek == "BOTTOM" ) ? d->height() - h:y;
00253 }
00254
00255 themeX = x;
00256 themeY = y;
00257 if( w == 0 || h == 0){
00258 w = 300;
00259 h = 300;
00260 }
00261 themeW = w;
00262 themeH = h;
00263
00264 fade = getBoolean("FADE",line);
00265 shadow = !getBoolean("NOSHADOW",line);
00266 bool center = getBoolean("CENTER",line);
00267 if(center == true){
00268 x = (d->width() - w)/2;
00269 y = (d->height() - h)/2;
00270 }
00271 kdDebug("Main") << "X: " << x << " | Y: " << y << endl;
00272 setMinimumSize(w,h);
00273 resize(w,h);
00274
00275 if( getBoolean( "RIGHT", line ) ){
00276 x = d->width() - w;
00277 }
00278 else if( getBoolean( "LEFT", line ) ){
00279 x = 0;
00280 }
00281 else if( getBoolean( "BOTTOM", line ) ){
00282 y = d->height() - h;
00283 }
00284 else if( getBoolean( " TOP", line ) ){
00285 y = 0;
00286 }
00287 move(x,y);
00288
00289 pm = QPixmap(size());
00290 if(pr){
00291 pm.fill(bgColor);
00292 }
00293
00294 if( getBoolean("ONTOP", line ) ){
00295 onTop = true;
00296 KWin::setState( winId(), NET::KeepAbove );
00297 }
00298 if( getBoolean("ONBACK", line ) ){
00299 onBottom = true;
00300 KWin::setState( winId(), NET::KeepBelow );
00301 }
00302
00303 if( getBoolean("TOPBAR", line ) ){
00304 move(x,0);
00305 KWin::setStrut( winId(), 0, 0, h, 0 );
00306 toggleLocked->setChecked( true );
00307 slotToggleLocked();
00308 toggleLocked->setEnabled(false);
00309
00310 }
00311
00312 if( getBoolean("BOTTOMBAR", line ) ){
00313 int dh = d->height();
00314 move( x, dh - h );
00315 KWin::setStrut( winId(), 0, 0, 0, h );
00316 toggleLocked->setChecked( true );
00317 slotToggleLocked();
00318 toggleLocked->setEnabled(false);
00319 }
00320
00321 interval = getInt("INTERVAL",line);
00322 interval = ( interval == 0 ) ? 5000 : interval;
00323 foundKaramba = true;
00324 }
00325
00326 if( meter == "THEME" ){
00327
00328 m_meter = new MeterList;
00329 m_meter->line = id;
00330 m_meter->type = meter;
00331 m_meter->width = w;
00332 m_meter->height = h;
00333 m_meter->xPos = x;
00334 m_meter->yPos = y;
00335 m_meter_list->append(m_meter);
00336
00337 QString path = getString( "PATH", line );
00338 QFileInfo info(path);
00339 if( info.isRelative()){
00340 path = themePath +"/" + path;
00341 }
00342 kdDebug("Main") << "Path: " << path << endl;
00343 kn = new karamba( pr, path, nq );
00344 kn->show();
00345 KarProcList->append( kn );
00346 }
00347
00348 if( meter == "<GROUP>" ){
00349
00350 m_meter = new MeterList;
00351 m_meter->line = id;
00352 m_meter->type = meter;
00353 m_meter->width = w;
00354 m_meter->height = h;
00355 m_meter->xPos = x;
00356 m_meter->yPos = y;
00357 m_meter_list->append(m_meter);
00358
00359 int offsetX = offsetStack.top().x();
00360 int offsetY = offsetStack.top().y();
00361 offsetStack.push( QPoint( offsetX + getInt("X",line), offsetY + getInt("Y",line) ) );
00362 }
00363
00364 if( meter == "</GROUP>" ){
00365
00366 m_meter = new MeterList;
00367 m_meter->line = id;
00368 m_meter->type = meter;
00369 m_meter->width = w;
00370 m_meter->height = h;
00371 m_meter->xPos = x;
00372 m_meter->yPos = y;
00373 m_meter_list->append(m_meter);
00374
00375 offsetStack.pop();
00376 }
00377
00378 if( meter == "CHILD" ){
00379
00380 m_meter = new MeterList;
00381 m_meter->line = id;
00382 m_meter->type = meter;
00383 m_meter->width = w;
00384 m_meter->height = h;
00385 m_meter->xPos = x;
00386 m_meter->yPos = y;
00387 m_meter_list->append(m_meter);
00388
00389 if( !hasMouseTracking() ){
00390 setMouseTracking(true);
00391 }
00392 Child *tmp = new Child( x, y, w, h );
00393 tmp->setValue( getString( "SRC", line ) );
00394 tmp->setEvent( getString( "MOUSE", line ) );
00395 tmp->setKaramba(this);
00396 tmp->setEmbed( getBoolean("EMBED", line ) );
00397 QString tiptext = getString("TOOLTIP",line);
00398 if (!tiptext.isEmpty()){
00399 tmp->setTooltip(tiptext);
00400 }
00401 childList->append( tmp );
00402 }
00403
00404 if( meter == "CLICKAREA" ){
00405
00406 m_meter = new MeterList;
00407 m_meter->line = id;
00408 m_meter->type = meter;
00409 m_meter->width = w;
00410 m_meter->height = h;
00411 m_meter->xPos = x;
00412 m_meter->yPos = y;
00413 m_meter_list->append(m_meter);
00414
00415 if( !hasMouseTracking() )
00416 setMouseTracking(true);
00417 ClickArea *tmp = new ClickArea( x, y, w, h );
00418 tmp->setOnClick( getString( "ONCLICK", line ) );
00419 QString tiptext = getString("TOOLTIP",line);
00420 tmp->setKaramba(this);
00421
00422 if (!tiptext.isEmpty()){
00423 tmp->setTooltip(tiptext);
00424 }
00425
00426 setSensor( line, (Meter*) tmp );
00427 clickList->append( tmp );
00428 if( getBoolean( "PREVIEW", line ) ){
00429 meterList->append( tmp );
00430 }
00431 }
00432
00433
00434 if(meter == "SENSOR=PROGRAM"){
00435
00436 m_meter = new MeterList;
00437 m_meter->line = id;
00438 m_meter->type = meter;
00439 m_meter->width = w;
00440 m_meter->height = h;
00441 m_meter->xPos = x;
00442 m_meter->yPos = y;
00443 m_meter_list->append(m_meter);
00444
00445 setSensor(line, 0 );
00446 }
00447
00448 if(meter == "IMAGE"){
00449
00450 m_meter = new MeterList;
00451 m_meter->line = id;
00452 m_meter->type = meter;
00453 m_meter->width = w;
00454 m_meter->height = h;
00455 m_meter->xPos = x;
00456 m_meter->yPos = y;
00457 m_meter_list->append(m_meter);
00458
00459 QString file = getString("PATH",line);
00460 QString file_roll = getString("PATHROLL",line);
00461 int xon = getInt("XROLL",line);
00462 int yon = getInt("YROLL",line);
00463 QString tiptext = getString("TOOLTIP",line);
00464 bool center = getBoolean("CENTER",line);
00465 int w = getInt("W",line);
00466 int h = getInt("H",line);
00467 xon = ( xon <= 0 ) ? x:xon;
00468 yon = ( yon <= 0 ) ? y:yon;
00469
00470 ImageLabel *tmp = new ImageLabel(x,y,0,0);
00471 tmp->setThemePath( themePath );
00472 tmp->setValue( file );
00473 tmp->setCenter( center, w, h );
00474 tmp->parseImages(file, file_roll, x,y, xon, yon);
00475 tmp->setKaramba(this);
00476
00477 if (!tiptext.isEmpty()){
00478 tmp->setTooltip(tiptext);
00479 }
00480
00481 setSensor(line, (Meter*) tmp );
00482 meterList->append (tmp );
00483 imageList->append (tmp );
00484 }
00485
00486 if(meter == "ICONBOX"){
00487
00488 m_meter = new MeterList;
00489 m_meter->line = id;
00490 m_meter->type = meter;
00491 m_meter->width = w;
00492 m_meter->height = h;
00493 m_meter->xPos = x;
00494 m_meter->yPos = y;
00495 m_meter_list->append(m_meter);
00496
00497 iconBoxId++;
00498
00499 int roll = getInt("ROLL",line);
00500 int a = getInt("align",line);
00501 int s = getInt("S",line);
00502 if( !hasMouseTracking() && roll ){
00503 setMouseTracking(true);
00504 }
00505 if( !acceptDrops() ){
00506 setAcceptDrops(true);
00507 }
00508 bool resizable = getBoolean("RESIZE",line);
00509
00510 IconBoxLabel *tmp = new IconBoxLabel(x,y,s,a, roll, iconBoxId);
00511 tmp->setResizable(resizable);
00512 tmp->setKaramba(this);
00513 setSensor(line, (Meter*) tmp );
00514 meterList->append( tmp );
00515 iconBoxList->append( tmp );
00516 }
00517
00518 if(meter == "ICON"){
00519
00520 m_meter = new MeterList;
00521 m_meter->line = id;
00522 m_meter->type = meter;
00523 m_meter->width = w;
00524 m_meter->height = h;
00525 m_meter->xPos = x;
00526 m_meter->yPos = y;
00527 m_meter_list->append(m_meter);
00528
00529 QString file = getString("NAME",line);
00530 int roll = getInt("ROLL",line);
00531 int xon = getInt("XROLL",line);
00532 int yon = getInt("YROLL",line);
00533 QString tiptext = getString("TOOLTIP",line);
00534 bool center = getBoolean("CENTER",line);
00535 int s = getInt("S",line);
00536 int w = getInt("W",line);
00537 int h = getInt("H",line);
00538 xon = ( xon <= 0 ) ? x:xon;
00539 yon = ( yon <= 0 ) ? y:yon;
00540 if( !hasMouseTracking() && roll ){
00541 setMouseTracking(true);
00542 }
00543
00544 IconLabel *tmp = new IconLabel(x,y,0,0);
00545 tmp->setThemePath( themePath );
00546 tmp->setSize( s );
00547 tmp->setCenter( center, w, h );
00548 tmp->setKaramba(this);
00549 if(file != ""){
00550 tmp->setValue( file );
00551 }
00552 tmp->parseImages(file, x,y, xon, yon, roll);
00553
00554 if (!tiptext.isEmpty()){
00555 tmp->setTooltip(tiptext);
00556 }
00557
00558 setSensor(line, (Meter*) tmp );
00559 meterList->append( tmp );
00560 iconList->append( tmp );
00561 }
00562
00563 if( meter == "DEFAULTFONT" ){
00564
00565 m_meter = new MeterList;
00566 m_meter->line = id;
00567 m_meter->type = meter;
00568 m_meter->width = w;
00569 m_meter->height = h;
00570 m_meter->xPos = x;
00571 m_meter->yPos = y;
00572 m_meter_list->append(m_meter);
00573
00574 int r,g,b;
00575
00576 delete defaultTextLabel;
00577 defaultTextLabel = new TextLabel(x, y, w, h );
00578
00579 get3Int( "COLOR", line, r, g, b );
00580 defaultTextLabel->setColor( r, g, b );
00581 get3Int( "BGCOLOR", line, r, g, b );
00582 defaultTextLabel->setBGColor( r, g, b );
00583
00584 defaultTextLabel->setFont( getString( "FONT", line ) );
00585 defaultTextLabel->setFontSize( getInt( "FONTSIZE", line ) );
00586 defaultTextLabel->setAlignment( getString( "ALIGN", line ) );
00587 defaultTextLabel->setFixedPitch( getBoolean( "FIXEDPITCH", line ) );
00588 defaultTextLabel->setShadow( getInt( "SHADOW", line ) );
00589 }
00590
00591
00592 if(meter == "TEXT"){
00593
00594 m_meter = new MeterList;
00595 m_meter->line = id;
00596 m_meter->type = meter;
00597 m_meter->width = w;
00598 m_meter->height = h;
00599 m_meter->xPos = x;
00600 m_meter->yPos = y;
00601 m_meter_list->append(m_meter);
00602
00603 int r,g,b;
00604
00605 TextLabel *tmp = new TextLabel(x, y, w, h );
00606 tmp->setKaramba(this);
00607 bool paramFound = false;
00608
00609 get3Int( "COLOR", line, r, g, b, paramFound );
00610 if ( paramFound || !defaultTextLabel ){
00611 tmp->setColor ( r, g, b );
00612 }
00613 else{
00614 if ( defaultTextLabel ){
00615 defaultTextLabel->getColor().rgb ( &r, &g, &b );
00616 tmp->setColor( r, g, b );
00617 }
00618 }
00619
00620 get3Int( "BGCOLOR", line, r, g, b, paramFound );
00621 if ( paramFound || !defaultTextLabel ){
00622 tmp->setBGColor( r, g, b );
00623 }
00624 else{
00625 if ( defaultTextLabel ){
00626 defaultTextLabel->getBGColor().rgb ( &r, &g, &b );
00627 tmp->setBGColor( r, g, b );
00628 }
00629 }
00630
00631 QString dFont = getString("FONT", line, paramFound);
00632 if( paramFound || !defaultTextLabel ){
00633 tmp->setFont( dFont );
00634 }
00635 else{
00636 if( defaultTextLabel ){
00637 tmp->setFont( defaultTextLabel->getFont() );
00638 }
00639 }
00640
00641
00642 int dFontSize = getInt( "FONTSIZE", line, paramFound );
00643 if( paramFound || !defaultTextLabel ){
00644 tmp->setFontSize( dFontSize );
00645 }
00646 else{
00647 if( defaultTextLabel ){
00648 tmp->setFontSize( defaultTextLabel->getFontSize() );
00649 }
00650 }
00651
00652 int dMove = getInt( "MOVE", line, paramFound );
00653 if( paramFound || !defaultTextLabel ){
00654 tmp->setMove( dMove );
00655 }
00656
00657 int dMaxMove = getInt( "MAXMOVE", line, paramFound );
00658 if( paramFound || !defaultTextLabel ){
00659 tmp->setMaxMove( dMaxMove );
00660 }
00661
00662 QString dAlign = getString( "ALIGN", line, paramFound );
00663 if( paramFound || !defaultTextLabel ){
00664 tmp->setAlignment( dAlign );
00665 }
00666 else{
00667 if( defaultTextLabel ){
00668 tmp->setAlignment( defaultTextLabel->getAlignment() );
00669 }
00670 }
00671
00672 bool dFp = getBoolean( "FIXEDPITCH", line, paramFound );
00673 if( paramFound || !defaultTextLabel ){
00674 tmp->setFixedPitch( dFp );
00675 }
00676 else{
00677 if( defaultTextLabel ){
00678 tmp->setFixedPitch( defaultTextLabel->getFixedPitch() );
00679 }
00680 }
00681
00682 int dShadow = getInt( "SHADOW", line, paramFound );
00683 if( paramFound || !defaultTextLabel ){
00684 tmp->setShadow( dShadow );
00685 }
00686 else{
00687 if( defaultTextLabel ){
00688 tmp->setShadow( defaultTextLabel->getShadow() );
00689 }
00690 }
00691
00692 tmp->setValue( getString( "VALUE", line ) );
00693
00694 setSensor( line, (Meter*)tmp );
00695 meterList->append ( tmp );
00696
00697 }
00698
00699 if(meter == "BAR"){
00700
00701 m_meter = new MeterList;
00702 m_meter->line = id;
00703 m_meter->type = meter;
00704 m_meter->width = w;
00705 m_meter->height = h;
00706 m_meter->xPos = x;
00707 m_meter->yPos = y;
00708 m_meter_list->append(m_meter);
00709
00710 Bar *tmp = new Bar( x, y, w, h );
00711 tmp->setThemePath( themePath );
00712 tmp->setImage( getString( "PATH", line ) );
00713 tmp->setVertical( getBoolean( "VERTICAL", line ) );
00714 bool maxFound = false;
00715 int max = getInt( "MAX", line, maxFound );
00716 if( maxFound ){
00717 tmp->setMax( max );
00718 }
00719 bool minFound = false;
00720 int min = getInt( "MIN", line, minFound );
00721 if( minFound ){
00722 tmp->setMin( min );
00723 }
00724 tmp->setValue( getInt( "VALUE", line ) );
00725 setSensor( line, (Meter*)tmp );
00726 meterList->append ( tmp );
00727 }
00728
00729 if(meter == "GRAPH"){
00730
00731 m_meter = new MeterList;
00732 m_meter->line = id;
00733 m_meter->type = meter;
00734 m_meter->width = w;
00735 m_meter->height = h;
00736 m_meter->xPos = x;
00737 m_meter->yPos = y;
00738 m_meter_list->append(m_meter);
00739
00740 int r, g, b;
00741 int points = getInt("POINTS",line);
00742 get3Int("COLOR", line, r, g, b);
00743
00744 Graph *tmp = new Graph( x, y, w, h, points );
00745 bool maxFound = false;
00746 int max = getInt( "MAX", line, maxFound );
00747 if( maxFound ){
00748 tmp->setMax( max );
00749 }
00750 bool minFound = false;
00751 int min = getInt( "MIN", line, minFound );
00752 if( minFound ){
00753 tmp->setMin( min );
00754 }
00755 tmp->setColor( r , g, b );
00756
00757 setSensor( line, (Graph*)tmp );
00758 meterList->append ( tmp );
00759 }
00760 id++;
00761 }
00762 file.close();
00763 }
00764 if( !foundKaramba )
00765 {
00766 emit karambaRun( false );
00767 return false;
00768 }
00769 else
00770 {
00771 emit karambaRun( true );
00772 connect(m_sysTimer, SIGNAL(timeout()), SLOT(step()));
00773 MouseOver = false;
00774 interval = interval == 0 ? 1000 : interval;
00775 m_sysTimer->start(interval);
00776 QTimer::singleShot( 1000, this, SLOT(step()) );
00777 QTimer::singleShot( 5000, this, SLOT(step()) );
00778 QTimer::singleShot( 10000, this, SLOT(step()) );
00779
00780 if( !onTop ){
00781 lowerTimer.start();
00782 }
00783 step();
00784 show();
00785 toggleHide();
00786 return true;
00787 }
00788 }
00789
00790 void karamba::startNewKaramba(){
00791 QStringList fileNames;
00792 KSimpleConfig conf("karambarc",true);
00793 conf.setGroup("karamba");
00794 QString dDir = conf.readEntry("ThemeDir", locateLocal("data", "karamba/themes/"));
00795 fileNames = KFileDialog::getOpenFileNames(dDir, "*.theme", 0, "Open configurations");
00796 QStringList::ConstIterator end( fileNames.end() );
00797 for ( QStringList::ConstIterator it = fileNames.begin(); it != end; ++it ){
00798 QFileInfo file( *it );
00799 if( file.exists() ){
00800 (new karamba( pr, *it, nq ))->show();
00801 }
00802 }
00803 }
00804
00805 void karamba::Config(){
00806 KarambaConf *kc = 0;
00807 kc = new KarambaConf(0, "karconf", 0);
00808 if( kc->exec() ){
00809 if(pr){
00810 ChangeBgColor(kc->bgColor);
00811 }
00812 emit configChanged();
00813 }
00814 }
00815
00816 void karamba::ChangeBgColor(QColor c){
00817 bgColor = c;
00818 setPaletteBackgroundColor(bgColor);
00819 step();
00820 }
00821
00822 void karamba::reloadConfig(){
00823 this->erase();
00824 m_sysTimer->disconnect();
00825 m_sysTimer = NULL;
00826 m_sysTimer = new QTimer(this);
00827 foundKaramba = false;
00828 onTop = false;
00829 onBottom = false;
00830 fixedPosition = false;
00831 meterList = NULL;
00832 meterList = new QObjectList();
00833 sensorList = NULL;
00834 sensorList = new QObjectList();
00835 imageList = NULL;
00836 imageList = new QObjectList();
00837 iconList = NULL;
00838 iconList = new QPtrList<IconLabel>();
00839 childList = NULL;
00840 childList = new QObjectList();
00841 clickList = NULL;
00842 clickList = new QObjectList();
00843 timeList = NULL;
00844 timeList = new QObjectList();
00845 if( KarChildList != 0 ){
00846 if(KarChildList->count()){
00847 karamba* kc;
00848 for ( kc = KarChildList->first(); kc; kc = KarChildList->next() ){
00849 if(kc->isShown()){
00850 kc->close();
00851 }
00852 }
00853 }
00854 KarChildList->clear();
00855 delete KarChildList;
00856 KarChildList = new QPtrList<karamba>();
00857 }
00858
00859 parseConfig();
00860 }
00861
00862 void karamba::editConfig(){
00863 QFileInfo fileInfo( themeFile );
00864 QString path;
00865
00866 if( fileInfo.isRelative() ){
00867 path = themePath + "/" + themeFile;
00868 }
00869 else{
00870 path = themeFile;
00871 }
00872 KRun::runCommand("KarthemeCreator "+path);
00873
00874 }
00875
00876 int karamba::getInt(QString w, QString &line ){
00877 bool b;
00878 return getInt( w, line, b );
00879 }
00880
00881 int karamba::getInt(QString w, QString &line, bool &found ){
00882 QRegExp rx( "\\W+" + w +"=([-]?\\d+)", false );
00883 found = (rx.search(line)==-1)?false:true;
00884
00885 return rx.cap(1).toInt();
00886
00887
00888
00889
00890 }
00891
00892 void karamba::get3Int(QString w, QString &line, int &a, int &b, int &c ){
00893 bool bo;
00894 get3Int ( w, line, a, b, c, bo );
00895 }
00896
00897 void karamba::get3Int(QString w, QString &line, int &a, int &b, int &c, bool &found ){
00898 QRegExp rx( "\\W+" + w + "=([-]?\\d+),([-]?\\d+),([-]?\\d+)", false );
00899 found = (rx.search(line)==-1)?false:true;
00900 a = rx.cap(1).toInt();
00901 b = rx.cap(2).toInt();
00902 c = rx.cap(3).toInt();
00903 }
00904
00905 QString karamba::getString(QString w, QString &line){
00906 bool b;
00907 return getString ( w, line, b );
00908 }
00909
00910 QString karamba::getString(QString w, QString &line, bool &found){
00911 QRegExp rx( "\\W+" + w + "=\"([^\"]*)\"", false );
00912 found = (rx.search(line)==-1)?false:true;
00913 if (rx.cap(1).isEmpty()){
00914 rx = QRegExp(w + "=(\\S+)", false);
00915 rx.search(line);
00916 return rx.cap(1);
00917 }
00918 else{
00919 return rx.cap(1);
00920 }
00921
00922 }
00923
00924 bool karamba::getBoolean( QString w, QString &line ){
00925 bool b;
00926 return getBoolean ( w, line, b );
00927 }
00928
00929 bool karamba::getBoolean( QString w, QString &line, bool &found ){
00930 return ( getString( w, line, found ).lower() == "true")?true:false;
00931 }
00932
00933 void karamba::setSensor(QString &line, Meter* meter){
00934 Sensor* sensor = 0;
00935
00936 QString sens = getString("SENSOR",line).upper();
00937
00938 if( sens == "CPU" ){
00939 QString cpuNbr = getString( "CPU", line );
00940 sensor = sensorMap["CPU"+cpuNbr];
00941 if (sensor == 0){
00942 int interval = getInt("INTERVAL",line);
00943 interval = (interval == 0)?1000:interval;
00944 sensor = ( sensorMap["CPU"+cpuNbr] = new CPUSensor( cpuNbr, interval ) );
00945 sensorList->append( sensor );
00946 }
00947 SensorParams *sp = new SensorParams(meter);
00948 sp->addParam("FORMAT",getString("FORMAT",line));
00949 sp->addParam("DECIMALS",getString("DECIMALS",line));
00950 sensor->addMeter(sp);
00951 sensor->setMaxValue(sp);
00952 }
00953
00954 if( sens == "MEMORY" ){
00955 sensor = sensorMap["MEMORY"];
00956 if (sensor == 0){
00957 int interval = getInt("INTERVAL",line);
00958 interval = (interval == 0)?3000:interval;
00959 sensor = ( sensorMap["MEMORY"] = new MemSensor( interval ) );
00960 sensorList->append( sensor );
00961 }
00962 SensorParams *sp = new SensorParams(meter);
00963 sp->addParam("FORMAT",getString("FORMAT",line));
00964 sensor->addMeter(sp);
00965 sensor->setMaxValue(sp);
00966 }
00967
00968
00969 if( sens == "DISK" ){
00970 sensor = sensorMap["DISK"];
00971 if (sensor == 0){
00972 int interval = getInt("INTERVAL",line);
00973 interval = (interval == 0)?5000:interval;
00974 sensor = ( sensorMap["DISK"] = new DiskSensor( interval ) );
00975 sensorList->append( sensor );
00976 }
00977 SensorParams *sp = new SensorParams(meter);
00978 QString mntPt = getString("MOUNTPOINT",line);
00979 if( mntPt == "" ){
00980 mntPt = "/";
00981 }
00982 sp->addParam("MOUNTPOINT",mntPt);
00983 sp->addParam("FORMAT",getString("FORMAT",line));
00984 sensor->addMeter(sp);
00985 sensor->setMaxValue(sp);
00986 }
00987
00988 if( sens == "NETWORK"){
00989 int interval = getInt("INTERVAL",line );
00990 interval = (interval == 0)?2000:interval;
00991 QString device = getString("DEVICE", line );
00992 sensor = sensorMap["NETWORK"+device];
00993 if (sensor == 0){
00994 sensor = ( sensorMap["NETWORK"+device] = new NetworkSensor( device, interval ) );
00995 sensorList->append( sensor );
00996 }
00997 SensorParams *sp = new SensorParams(meter);
00998 sp->addParam( "FORMAT", getString( "FORMAT", line ) );
00999 sp->addParam( "DECIMALS", getString( "DECIMALS", line ) );
01000 sensor->addMeter(sp);
01001 }
01002
01003 if( sens == "UPTIME" ){
01004 sensor = sensorMap["UPTIME"];
01005 if (sensor == 0){
01006 int interval = getInt("INTERVAL",line);
01007 interval = (interval == 0)?60000:interval;
01008 sensor = ( sensorMap["UPTIME"] = new UptimeSensor( interval ));
01009 sensorList->append( sensor );
01010 }
01011 SensorParams *sp = new SensorParams(meter);
01012 sp->addParam( "FORMAT", getString( "FORMAT", line ) );
01013 sensor->addMeter(sp);
01014 }
01015
01016 if( sens == "SENSOR" ){
01017 sensor = sensorMap["SENSOR"];
01018 if (sensor == 0){
01019 int interval = getInt("INTERVAL",line);
01020 interval = (interval == 0)?30000:interval;
01021 sensor = ( sensorMap["SENSOR"] = new SensorSensor( interval ) );
01022 sensorList->append( sensor );
01023 }
01024 SensorParams *sp = new SensorParams(meter);
01025 sp->addParam("FORMAT",getString("FORMAT",line));
01026 sp->addParam("TYPE",getString("TYPE",line));
01027 sensor->addMeter(sp);
01028 }
01029
01030
01031 if( sens == "TEXTFILE" ){
01032 QString path = getString( "PATH", line );
01033 bool rdf = getBoolean( "RDF", line );
01034 sensor = sensorMap["TEXTFILE"+path];
01035 if (sensor == 0){
01036 int interval = getInt( "INTERVAL", line );
01037 interval = ( interval == 0 )?60000:interval;
01038 QString encoding = getString( "ENCODING", line );
01039
01040 sensor = ( sensorMap["TEXTFILE"+path] =
01041 new TextFileSensor( path, rdf, interval, encoding ) );
01042 sensorList->append( sensor );
01043 }
01044 SensorParams *sp = new SensorParams(meter);
01045 sp->addParam("LINE",QString::number(getInt("LINE",line)));
01046 sensor->addMeter(sp);
01047 }
01048
01049
01050 if( sens == "TIME"){
01051 sensor = sensorMap["DATE"];
01052 if (sensor == 0){
01053 int interval = getInt("INTERVAL",line);
01054 interval = (interval == 0)?60000:interval;
01055 sensor = ( sensorMap["DATE"] = new DateSensor( interval ) );
01056 sensorList->append( sensor );
01057 timeList->append( sensor );
01058 }
01059 SensorParams *sp = new SensorParams(meter);
01060 sp->addParam("FORMAT",getString("FORMAT",line));
01061 sp->addParam("CALWIDTH",getString("CALWIDTH",line));
01062 sp->addParam("CALHEIGHT",getString("CALHEIGHT",line));
01063 sensor->addMeter(sp);
01064 }
01065
01066 #ifdef HAVE_XMMS
01067
01068 if( sens == "XMMS" ){
01069 sensor = sensorMap["XMMS"];
01070 if (sensor == 0){
01071 int interval = getInt("INTERVAL",line);
01072 interval = (interval == 0)?1000:interval;
01073 QString encoding = getString( "ENCODING", line );
01074 int w = 0;
01075 int h = 0;
01076 w = getInt("W", line);
01077 h = getInt("H", line);
01078
01079 sensor = ( sensorMap["XMMS"] = new XMMSSensor( interval, encoding, w, h, this ) );
01080 sensorList->append( sensor );
01081 }
01082 SensorParams *sp = new SensorParams(meter);
01083 sp->addParam("FORMAT",getString("FORMAT",line));
01084 sp->addParam("X",getString("X",line));
01085 sp->addParam("Y",getString("Y",line));
01086 sensor->addMeter(sp);
01087 sensor->setMaxValue(sp);
01088 }
01089 #endif // HAVE_XMMS
01090
01091
01092 if( sens == "NOATUN" ){
01093 sensor = sensorMap["NOATUN"];
01094 if (sensor == 0){
01095 int interval = getInt("INTERVAL",line);
01096 interval = (interval == 0)?1000:interval;
01097 sensor = ( sensorMap["NOATUN"] = new NoatunSensor( interval, client ) );
01098 sensorList->append( sensor );
01099 }
01100 SensorParams *sp = new SensorParams(meter);
01101 sp->addParam("FORMAT",getString("FORMAT",line));
01102 sensor->addMeter(sp);
01103 sensor->setMaxValue(sp);
01104 }
01105
01106 if( sens == "PROGRAM"){
01107 QString progName = getString("PROGRAM",line);
01108 sensor = sensorMap["PROGRAM"+progName];
01109 if (sensor == 0){
01110 int interval = getInt("INTERVAL",line);
01111 interval = (interval == 0)?3600000:interval;
01112 QString encoding = getString( "ENCODING", line );
01113 sensor = (sensorMap["PROGRAM"+progName] = new ProgramSensor( progName, interval, encoding ) );
01114 sensorList->append( sensor );
01115 }
01116 SensorParams *sp = new SensorParams(meter);
01117 sp->addParam( "LINE", QString::number( getInt( "LINE", line ) ) );
01118 sp->addParam( "THEMAPATH", themePath );
01119 sensor->addMeter(sp);
01120 }
01121
01122 if (sensor != 0){
01123 QTimer::singleShot( 0, sensor, SLOT(update()) );
01124 sensor->start();
01125 }
01126 }
01127
01128 void karamba::passClick( QMouseEvent *e ){
01129 QObjectListIt it( *clickList );
01130 while ( it != 0 ){
01131 (( ClickArea* ) *it)->click( e );
01132 ++it;
01133 }
01134
01135 QObjectListIt it2( *timeList );
01136 while ( it2 != 0 ){
01137 (( DateSensor* ) *it2)->toggleCalendar( e );
01138 ++it2;
01139 }
01140
01141 QObjectListIt it3( *childList );
01142 while ( it3 != 0 ){
01143 (( Child* ) *it3)->click( e );
01144 ++it3;
01145 }
01146
01147 }
01148
01149 void karamba::mousePressEvent( QMouseEvent *e ){
01150 if( e->button() == RightButton ){
01151 QPtrListIterator<IconBoxLabel> iconBox_it( *iconBoxList);
01152 IconBoxLabel *iconBox;
01153 while ( (iconBox = iconBox_it.current()) != 0 ){
01154 iconBox->mouseOver(e);
01155 ++iconBox_it;
01156 }
01157 kpop->popup(QCursor::pos());
01158 }
01159 else{
01160 if(pr == 0){
01161 clickPos = e->pos();
01162 }
01163 else{
01164 clickPos = mapToGlobal(e->pos());
01165 }
01166 clickX = e->x();
01167 clickY = e->y();
01168 if( locked ){
01169 passClick( e );
01170 }
01171 if( !onTop ){
01172 lower();
01173 }
01174 }
01175 }
01176
01177 void karamba::mouseReleaseEvent( QMouseEvent *e ){
01178 kdDebug("Main") << "Click X=" << clickPos.x() << " Y=" << clickPos .y() <<endl;
01179 kdDebug("Main") << "Window X=" << x() << " Y=" << y() <<endl;
01180 step();
01181 }
01182
01183 void karamba::mouseDoubleClickEvent( QMouseEvent *e ){
01184 if( !locked ){
01185 passClick( e );
01186 }
01187 }
01188
01189 void karamba::mouseMoveEvent( QMouseEvent *e ){
01190 if( e->state() != 0 && e->state() < 16 && !locked ){
01191 if(hidek == "RIGHT"){
01192 themeY = e->globalY() - clickY;
01193 move( QApplication::desktop()->width() - themeW, themeY );
01194 }
01195 else if(hidek == "LEFT"){
01196 themeY = e->globalY() - clickY;
01197 move( 0 - themeW, themeY );
01198 }
01199 else if(hidek == "TOP"){
01200 themeX = e->globalX() - clickX;
01201 move( themeX, 0 );
01202 }
01203 else if(hidek == "BOTTOM"){
01204 themeX = e->globalX() - clickX;
01205 move( themeX, QApplication::desktop()->height() - themeH );
01206 }
01207 else{
01208 move( e->globalPos() - clickPos );
01209 }
01210 }
01211 else{
01212
01213 QObjectListIt it( *clickList );
01214 bool insideArea = false;
01215 while ( it != 0 && !insideArea ){
01216 insideArea = (((ClickArea*) *it)->getRectangle()).contains(e->pos());
01217 ++it;
01218 }
01219
01220
01221 QObjectListIt it2( *childList );
01222 bool insideChild = false;
01223 while ( it2 != 0 && !insideChild ){
01224 insideChild = (((Child*) *it2)->getRectangle()).contains(e->pos());
01225 if(insideChild){
01226 (( Child* ) *it2)->enter( e );
01227 }
01228 else{
01229 (( Child* ) *it2)->leave( e );
01230 }
01231 ++it2;
01232 }
01233
01234 if(insideArea || insideChild){
01235 if( cursor().shape() != PointingHandCursor ){
01236 setCursor( PointingHandCursor );
01237 }
01238 }
01239 else{
01240 if( cursor().shape() != ArrowCursor )
01241 setCursor( ArrowCursor );
01242 }
01243
01244 QObjectListIt image_it( *imageList);
01245 while ( image_it != 0 ){
01246 ((ImageLabel*) *image_it)->rolloverImage(e);
01247 ++image_it;
01248 }
01249
01250 QPtrListIterator<IconLabel> icon_it( *iconList);
01251 IconLabel *icon;
01252 while ( (icon = icon_it.current()) != 0 ){
01253 icon->rolloverImage(e);
01254 ++icon_it;
01255 }
01256
01257 }
01258 }
01259
01260 void karamba::enterEvent( QEvent * ){
01261 MouseOver = true;
01262 toggleHide();
01263 setActiveWindow();
01264 }
01265
01266 void karamba::leaveEvent( QEvent * ){
01267 MouseOver = false;
01268 toggleHide();
01269 }
01270
01271 void karamba::dragEnterEvent( QDragEnterEvent * ){
01272 MouseOver = true;
01273 toggleHide();
01274 setActiveWindow();
01275 }
01276
01277 void karamba::dragLeaveEvent( QDragLeaveEvent * ){
01278 MouseOver = false;
01279 toggleHide();
01280 }
01281
01282 void karamba::dragMoveEvent( QDragMoveEvent *e){
01283 QPtrListIterator<IconBoxLabel> iconBox_it( *iconBoxList);
01284 IconBoxLabel *iconBox;
01285 while ( (iconBox = iconBox_it.current()) != 0 ){
01286 if((iconBox->getRectangle()).contains(e->pos())){
01287 e->accept( true );
01288 break;
01289 }
01290 else{
01291 e->ignore();
01292 }
01293 ++iconBox_it;
01294 }
01295 }
01296
01297 void karamba::dropEvent( QDropEvent *e){
01298 QPtrListIterator<IconBoxLabel> iconBox_it( *iconBoxList);
01299 IconBoxLabel *iconBox;
01300 while ( (iconBox = iconBox_it.current()) != 0 ){
01301 if((iconBox->getRectangle()).contains(e->pos())){
01302 iconBox->dropEvent(e);
01303 }
01304 ++iconBox_it;
01305 }
01306 }
01307
01308 void karamba::toggleHide(){
01309 if(hidek == "TOP"){
01310 if(MouseOver == true){
01311 if( y() != 0 ){
01312 updateSensors();
01313 move(themeX, 0);
01314 hidden = false;
01315 }
01316 }
01317 else if( y() == 0 && !popupIsShown ){
01318 move(themeX, Hlimit - themeH);
01319 hidden = true;
01320 }
01321 }
01322 if(hidek == "BOTTOM"){
01323 if(MouseOver == true){
01324 if( y() != QApplication::desktop()->height() - themeH ){
01325 move(themeX, QApplication::desktop()->height() - themeH);
01326 hidden = false;
01327 }
01328 }
01329 else if( y() == QApplication::desktop()->height() - themeH && !popupIsShown ){
01330 move(themeX, QApplication::desktop()->height() - Hlimit);
01331 hidden = true;
01332 }
01333 }
01334 if(hidek == "LEFT"){
01335 if(MouseOver == true){
01336 if( x() != 0 ){
01337 move(0, themeY);
01338 hidden = false;
01339 }
01340 }
01341 else if( x() == 0 && !popupIsShown ){
01342 move(Hlimit - themeW, themeY);
01343 hidden = true;
01344 }
01345 }
01346 if(hidek == "RIGHT"){
01347 if(MouseOver == true ){
01348 if( x() != QApplication::desktop()->width() - themeW ){
01349 move(QApplication::desktop()->width() - themeW, themeY);
01350 hidden = false;
01351 }
01352 }
01353 else if( x() == QApplication::desktop()->width() - themeW && !popupIsShown ){
01354 move(QApplication::desktop()->width() - Hlimit, themeY);
01355 hidden = true;
01356 }
01357 }
01358 }
01359
01360 void karamba::windowActivationChange(bool b){
01361 if(!shadow && shadowed){
01362 kdDebug("Karamba") << "Disable shadow for WinId: " << winId() << endl;
01363 DCOPRef m_kwinKWinInterface("kwin","KWinInterface");
01364 m_kwinKWinInterface.call("setShadowed(unsigned long int,bool)", winId(),false);
01365 shadowed = false;
01366 }
01367 emit ActiveWin(!b);
01368 }
01369
01370 void karamba::closeEvent ( QCloseEvent * ){
01371 emit karambaRun( false );
01372 this->close(true);
01373 delete this;
01374 }
01375
01376 void karamba::paintEvent ( QPaintEvent *e){
01377 if( !onTop && lowerTimer.elapsed() > 100 ){
01378 this->lower();
01379 lowerTimer.restart();
01380 }
01381 QRect rect = e->rect();
01382 bitBlt(this,rect.topLeft(),&pm,rect,Qt::CopyROP);
01383 }
01384
01385 void karamba::updateSensors(){
01386 QObjectListIt it( *sensorList );
01387 while ( it != 0 ){
01388 ((Sensor*) *it)->update();
01389 ++it;
01390 }
01391 delete it;
01392 QTimer::singleShot( 500, this, SLOT(step()) );
01393 }
01394
01395 void karamba::updateBackground(KSharedPixmap* kpm){
01396 if(backgroundMode() == NoBackground){
01397 if(fade){
01398 KPixmap tbg = KPixmap(*kpm);
01399 background = KPixmapEffect::fade(tbg, fadeLevel, fadeColor);
01400 tbg.resize(0,0);
01401 }
01402 else{
01403 background = KPixmap(*kpm);
01404 }
01405 }
01406 step();
01407 }
01408
01409 void karamba::currentDesktopChanged( int ){
01410 if(backgroundMode() == NoBackground){
01411 kroot->repaint( true );
01412 }
01413 }
01414
01415 void karamba::step(){
01416 pm = KPixmap(size());
01417 if(fade && backgroundMode() != NoBackground){
01418 pm.fill(bgColor);
01419 pm = KPixmapEffect::fade(pm, fadeLevel, fadeColor);
01420 }
01421 QObjectListIt it( *meterList );
01422 p.begin(&pm);
01423 if(backgroundMode() == NoBackground){
01424 bitBlt(&pm,0,0,&background,0,Qt::CopyROP);
01425 }
01426 else if(!fade){
01427 pm.fill(bgColor);
01428 }
01429 while ( it != 0 ){
01430 ((Meter*) *it)->mUpdate(&p);
01431 ++it;
01432 }
01433 p.end();
01434 update();
01435 }
01436
01437 void karamba::slotToggleLocked(){
01438 locked = toggleLocked->isChecked();
01439 if( locked ){
01440 toggleLocked->setIconSet(SmallIconSet("encrypted"));
01441 toggleLocked->setText( tr2i18n( "Un&lock position" ) );
01442 kdDebug("Main") << "Locked" << endl;
01443 }
01444 else{
01445 toggleLocked->setIconSet(SmallIconSet("lockoverlay"));
01446 toggleLocked->setText( tr2i18n( "&Lock position" ) );
01447 kdDebug("Main") << "Unlocked" << endl;
01448 }
01449 }
01450
01451 void karamba::slotMove(int nx, int ny){
01452 move(nx, ny);
01453 themeX = nx;
01454 themeY = ny;
01455 }
01456
01457 void karamba::LaunchCreator(){
01458 kdDebug("Main") << "Starting KarthemeCreator" << endl;
01459 KRun::runCommand("KarthemeCreator");
01460 }
01461
01462 void karamba::about(){
01463 KAboutApplication* aboutdlg;
01464 aboutdlg = new KAboutApplication();
01465 aboutdlg->show();
01466 }
01467
01468 void karamba::aboutKDE(){
01469 KAboutKDE* aboutkdedlg;
01470 aboutkdedlg = new KAboutKDE();
01471 aboutkdedlg->show();
01472 }
01473
01474 void karamba::status( bool r ){
01475 if( r ){
01476 kdDebug("Main") << "Karamba is running" << endl;
01477 isRunning = true;
01478 }
01479 else{
01480 kdDebug("Main") << "Karamba is halted" << endl;
01481 isRunning = false;
01482 }
01483 }
01484
01485 QPtrList<MeterList>* karamba::getMeterList(){
01486 return m_meter_list;
01487 }
01488
01489 void karamba::popupShown(){
01490 popupIsShown = true;
01491 toggleHide();
01492 }
01493
01494 void karamba::popupHiden(){
01495 popupIsShown = false;
01496 toggleHide();
01497 }
01498
01499 void karamba::setActiveWin(){
01500 this->setActiveWindow();
01501 }
01502
01503 #include "karamba.moc"