Ignore:
Timestamp:
10/21/13 08:12:00 (10 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:
4bf853e
Parents:
dca28eb
Message:

Remove the old life-preserver from the src-qt4/life-preserver dir, and replace it with src-qt4/life-preserver/lp-tray and src-qt4/life-preserver/lp-gui.

File:
1 moved

Legend:

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

    re0c368d r6a2483b  
    99  //Setup the context menu 
    1010  menu = new QMenu; 
     11        menu->addAction(QIcon(":/images/tray-icon-idle.png"),tr("Start Application UI"),this,SLOT(startGUI()) ); 
     12        menu->addSeparator(); 
    1113        menu->addAction(QIcon(":/images/backup-failed.png"),tr("View Messages"),this,SLOT(startMessageDialog()) ); 
    12         menu->addAction(QIcon(":/images/tray-icon-idle.png"),tr("Start Application UI"),this,SLOT(startGUI()) ); 
     14        menu->addAction(QIcon(":/images/refresh.png"),tr("Refresh Tray"),this,SLOT(refreshStatus()) ); 
    1315        menu->addSeparator(); 
    1416        menu->addAction(QIcon(":/images/application-exit.png"),tr("Close Life Preserver Tray"),this,SLOT(slotClose()) ); 
     
    1618  //Setup initial icon for the tray 
    1719  this->setIcon( QIcon(":/images/tray-icon-idle.png") ); 
    18   //Create the configuration GUI 
    19   GUI = new mainUI(); 
     20  //Create the messages GUI 
    2021  msgdlg = new LPMessages(); 
    2122  //connect other signals/slots 
     
    3031  watcher->stop(); 
    3132  delete watcher; 
    32   delete GUI; 
    3333  delete msgdlg; 
    3434} 
     
    115115 
    116116void LPTray::slotTrayClicked(QSystemTrayIcon::ActivationReason reason){ 
    117   if(reason == QSystemTrayIcon::Trigger){  
    118     if(GUI->isVisible()){ GUI->hide(); } 
    119     else{ startGUI(); } 
    120   }else if( reason == QSystemTrayIcon::Context){ 
     117  if(reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::Context){ 
    121118    this->contextMenu()->popup(QCursor::pos()); 
    122119  } 
     
    129126void LPTray::slotSingleInstance(){ 
    130127  this->show(); 
    131   if(!GUI->isVisible()){ startGUI(); } 
    132   else{  
    133     GUI->raise();  
    134     GUI->show(); 
     128  if(msgdlg->isVisible()){  
     129    msgdlg->raise();  
     130    msgdlg->show(); 
    135131  } 
    136132} 
     
    138134void LPTray::startGUI(){ 
    139135  //Start up the GUI 
    140     GUI->setupUI(); 
    141     GUI->raise(); 
    142     GUI->show(); 
     136  system("pc-su life-preserver"); 
    143137} 
    144138 
     
    152146    QStringList info = watcher->getMessages(types[i], infoL); 
    153147    if(info.isEmpty()){continue;} 
    154     if(info[0] == "ERROR"){ 
    155       errs << info[1] + " (" + info[2] + "): " + info[3]; 
    156     }else if(!info[0].isEmpty()){ 
    157       msgs << info[1] + " (" + info[2] + "): " + info[3]; 
     148    //Take into account multiple devices/messages per type 
     149    QStringList devs=info[2].split(":::"); QStringList msgs=info[3].split(":::"); 
     150    for(int j=0; j<devs.length(); j++){ 
     151      if(info[0] == "ERROR"){ 
     152        errs << info[1] + " (" + devs[j] + "): " + msgs[j]; 
     153      }else if(!info[0].isEmpty()){ 
     154        msgs << info[1] + " (" + devs[j] + "): " + msgs[j]; 
     155      } 
    158156    } 
    159157    if(!info[4].isEmpty()){ 
    160       logs << info[4]; // In format:  "example logfile </var/logs/example.log>" 
     158      //allow for multiple log files 
     159      logs << info[4].split(":::"); // In format:  "example logfile </var/logs/example.log>" 
    161160    } 
    162161  } 
    163162  //Now start up the dialog 
    164   msgdlg->setMessages( msgs.join("\n") ); 
    165   msgdlg->setErrors( errs.join("\n") ); 
     163  msgdlg->setMessages( msgs.join("\n"), errs.join("\n") ); 
    166164  msgdlg->setLogFiles(logs); 
    167165  msgdlg->raise(); 
    168166  msgdlg->show(); 
    169167} 
     168 
     169void LPTray::refreshStatus(){ 
     170  //Manually trigger the watcher to update status notifications 
     171  watcher->refresh(); 
     172} 
Note: See TracChangeset for help on using the changeset viewer.