Ignore:
Timestamp:
Aug 26, 2013 11:44:54 AM (8 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
2ac57ce
Parents:
da39501
Message:

Clean up the tooltip for the life preserver tray: will now list the latest snapshot for each managed dataset/zpool.
Also clean up the ordering of the available snapshots - they should always list in the proper chronological order for snapshots that life-preserver created, with an additional section at the end for any other snapshots that are available for that data subset.

File:
1 edited

Legend:

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

    r96c5e841 r539d8eb  
    33//PUBLIC 
    44LPTray::LPTray() : QSystemTrayIcon(){ 
     5  initPhase = true; //flag that we are in the startup process 
    56  //Start up the log file watcher 
    67  QString logfile = "/var/log/lpreserver/lpreserver.log"; 
     
    4748//  PRIVATE FUNCTIONS 
    4849// =============== 
    49 void LPTray::parseLogMessage(QString log){ 
     50void LPTray::parseLogMessage(QString log, bool quiet){ 
    5051  //Divide up the log into it's sections 
    5152  QString timestamp = log.section(":",0,2).simplified(); 
     
    5758  if(message.contains("creating snapshot")){ 
    5859    dev = message.section(" ",-1).simplified(); 
    59     this->showMessage( time, QString(tr("Creating snapshot for %1")).arg(dev), QSystemTrayIcon::Information, 5000); 
     60    if(!quiet){ this->showMessage( time, QString(tr("Creating snapshot for %1")).arg(dev), QSystemTrayIcon::Information, 5000); } 
    6061    //Just set the standard idle icon 
    6162    this->setIcon( QIcon(":/images/tray-icon-idle.png") );    
    62 //  }else if(message.contains("pruning snapshot")){ 
     63    setIdleToolTip(); 
    6364  }else if(message.contains("starting replication")){ 
    6465    startWorkingIcon(); 
     
    8283    //Clean up and show messages 
    8384    repTotK.clear(); 
    84     this->setToolTip(""); 
     85    setIdleToolTip(); 
    8586    dev = message.section(" ",-1).simplified(); 
    86     this->showMessage( time, QString(tr("Finished replication for %1")).arg(dev), QSystemTrayIcon::Information, 5000); 
     87    if(!quiet){ this->showMessage( time, QString(tr("Finished replication for %1")).arg(dev), QSystemTrayIcon::Information, 5000); } 
    8788  }else if( message.contains("FAILED replication") ){ 
    8889    stopWorkingIcon(); 
     
    99100    QString tt = QString(tr("%1: Replication Failed on %2")).arg(time,dev) +"\n"+ QString(tr("Logfile available at: %1")).arg(file); 
    100101    this->setToolTip(tt);    
    101     this->showMessage( time, QString(tr("Replication Error for %1")).arg(dev), QSystemTrayIcon::Information, 5000); 
     102    if(!quiet){ this->showMessage( time, QString(tr("Replication Error for %1")).arg(dev), QSystemTrayIcon::Information, 5000); } 
    102103    this->setIcon(QIcon(":/images/tray-icon-failed.png")); 
    103104  }else{ 
     
    139140} 
    140141 
     142void LPTray::setIdleToolTip(){ 
     143  //Get the last snapshot created 
     144  QStringList dsList = LPBackend::listDatasets(); 
     145  if(dsList.isEmpty()){ 
     146    this->setToolTip(tr("Automatic Backups Disabled")); 
     147  }else{ 
     148    //Grab the newest snapshot from each dataset 
     149    QString tt; //tooltip 
     150    for(int i=0; i<dsList.length(); i++){ 
     151      QStringList snaps = LPBackend::listLPSnapshots(dsList[0]); 
     152      if(!tt.isEmpty()){ tt.append("\n"); } //put each dataset on a new line 
     153      if(snaps.isEmpty()){ 
     154        tt.append( QString(tr("%1: No snapshots available")).arg(dsList[0]) ); 
     155      }else{ 
     156        tt.append( QString(tr("%1: %2 available")).arg(dsList[0],snaps[0]) ); 
     157      } 
     158    } 
     159    this->setToolTip(tt); 
     160  } 
     161         
     162} 
     163 
    141164void LPTray::startWorkingIcon(){ 
    142165  this->setIcon( QIcon(":/images/tray-icon-active7.png")); 
     
    171194void LPTray::firstCheck(){ 
    172195  slotNewLogMessage("/var/log/lpreserver/lpreserver.log"); 
     196  initPhase = false; //done with initializations 
    173197} 
    174198 
     
    181205    while( !LFStream->atEnd() ){ log = LFStream->readLine(); } 
    182206    //Now parse the log line and do stuff with it 
    183     parseLogMessage(log); 
     207    parseLogMessage(log,initPhase); 
    184208  }else{ 
    185209    //Replication status update 
Note: See TracChangeset for help on using the changeset viewer.