Ignore:
Timestamp:
09/11/13 09:59:03 (14 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
9ba89ba
Parents:
fcd9065
Message:

Setup the LPTray to use the new LPWatcher class (untested yet)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/LPTray.cpp

    r29fe4e9 r8516ff2  
    44LPTray::LPTray() : QSystemTrayIcon(){ 
    55  initPhase = true; //flag that we are in the startup process 
    6   //Start up the log file watcher 
    7   QString logfile = "/var/log/lpreserver/lpreserver.log"; 
     6  //Start up the log file watcher and connect the signals/slots 
     7  watcher = new LPWatcher(); 
     8        connect(watcher,SIGNAL(MessageAvailable(QString)),this,SLOT(watcherMessage(QString)) ); 
     9         
     10  /*QString logfile = "/var/log/lpreserver/lpreserver.log"; 
    811  watcher = new QFileSystemWatcher(); 
    912        if(!QFile::exists(logfile)){  
     
    1619  LFStream = new QTextStream(logFile); 
    1720        connect(watcher, SIGNAL(fileChanged(QString)),this,SLOT(slotNewLogMessage(QString)) ); //now connect the signal/slot 
     21        */ 
    1822  //Setup the context menu 
    1923  menu = new QMenu; 
     
    2226  this->setContextMenu(menu); 
    2327  //Setup the animated icon timer 
     28  /* 
    2429  timer = new QTimer(); 
    2530        timer->setInterval(100); 
    2631        connect(timer, SIGNAL(timeout()), this, SLOT(displayWorkingIcon()) ); 
     32  */ 
    2733  //Setup initial icon for the tray 
    2834  this->setIcon( QIcon(":/images/tray-icon-idle.png") ); 
     
    3238  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)) ); 
    3339  //Make sure we check the latest line in the logfile 
    34   QTimer::singleShot(1000, this,SLOT(firstCheck())); 
     40  //QTimer::singleShot(1000, this,SLOT(firstCheck())); 
     41  //Start up the watcher 
     42  watcher->start(); 
    3543} 
    3644 
    3745LPTray::~LPTray(){ 
    38   if(statFile != 0){ statFile->close(); } 
    39   logFile->close(); 
    40   delete statFile; 
    41   delete logFile; 
     46  //if(statFile != 0){ statFile->close(); } 
     47  //logFile->close(); 
     48  //delete statFile; 
     49  //delete logFile; 
     50  watcher->stop(); 
    4251  delete watcher; 
    43   delete menu; 
    44   delete timer; 
     52  //delete menu; 
     53  //delete timer; 
    4554} 
    4655 
     
    4857//  PRIVATE FUNCTIONS 
    4958// =============== 
     59/* 
    5060void LPTray::parseLogMessage(QString log, bool quiet){ 
    5161  //Divide up the log into it's sections 
     
    188198  return num; 
    189199} 
     200*/ 
    190201 
    191202// =============== 
    192203//     PRIVATE SLOTS 
    193204// =============== 
     205void LPTray::watcherMessage(QString type){ 
     206  qDebug() << "New Watcher Message:" << type; 
     207} 
     208/* 
    194209void LPTray::firstCheck(){ 
    195210  slotNewLogMessage("/var/log/lpreserver/lpreserver.log"); 
     
    218233  } 
    219234} 
    220  
     235*/ 
    221236void LPTray::slotTrayClicked(QSystemTrayIcon::ActivationReason reason){ 
    222237  if(reason == QSystemTrayIcon::Trigger){  
     
    248263} 
    249264 
    250 void LPTray::displayWorkingIcon(){ 
     265/*void LPTray::displayWorkingIcon(){ 
    251266  QString ico = ":/images/tray-icon-active"+QString::number(wNum)+".png"; 
    252267  this->setIcon(QIcon(ico)); 
    253268  if(wNum == 16){ wNum = 1; } //go back to the beginning of the loop 
    254269  else{ wNum++; } 
    255 } 
     270}*/ 
Note: See TracChangeset for help on using the changeset viewer.