Changeset 539d8eb


Ignore:
Timestamp:
08/26/13 11:44:54 (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:
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.

Location:
src-qt4/life-preserver
Files:
3 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 
  • src-qt4/life-preserver/LPTray.h

    r2a5e337 r539d8eb  
    2929        QString repTotK, lastSize; 
    3030        int wNum; //internal tracking of which frame of the icon animation we are on 
     31        bool initPhase; 
    3132 
    32         void parseLogMessage(QString); 
     33        void parseLogMessage(QString, bool quiet = false); 
    3334        void parseStatusMessage(QString); 
     35        void setIdleToolTip(); 
    3436        void startWorkingIcon(); 
    3537        void stopWorkingIcon(); 
  • src-qt4/life-preserver/mainUI.cpp

    r33a568a r539d8eb  
    5151  //List all the mountpoints in this dataset 
    5252  QStringList subsets = LPBackend::listDatasetSubsets(ds); 
     53  QStringList lpsnaps = LPBackend::listLPSnapshots(ds); 
    5354  //populate the list of snapshots available for each mountpoint 
    5455  for(int i=0; i<subsets.length(); i++){ 
     
    6162      i--; 
    6263    }else{ 
    63       DSC.subsetHash.insert(subsets[i],snaps); //add it to the internal container hash 
     64      QStringList subsnaps; 
     65      //only list the valid snapshots that life preserver created 
     66      for(int s=0; s<lpsnaps.length(); s++){ 
     67        int index = snaps.indexOf(lpsnaps[s]); 
     68        if(index > -1){ subsnaps << lpsnaps[s]; snaps.removeAt(index); } 
     69      } 
     70      //Now list all the other available snapshots (no certain ordering) 
     71      if(!snaps.isEmpty()){ 
     72        subsnaps << "--"; //so we know that this is a divider between the sections 
     73        subsnaps << snaps; 
     74      } 
     75      DSC.subsetHash.insert(subsets[i],subsnaps); //add it to the internal container hash 
    6476    } 
    6577  } 
     
    7688    DSC.latestSnapshot= ""; 
    7789  }else{ 
    78     QStringList fSnap = DSC.subsetHash[subsets[0]].filter("auto-"); //filtered snapshot list (just life preserver snapshots) 
    79     DSC.numberOfSnapshots = QString::number(fSnap.length()); 
    80     if(fSnap.isEmpty()){ DSC.latestSnapshot=""; } 
     90    DSC.numberOfSnapshots = QString::number(lpsnaps.length()); 
     91    if(lpsnaps.isEmpty()){ DSC.latestSnapshot=""; } 
    8192    else if(ci > -1 && ci < CLIST.length()){  
    8293      QString sna = CLIST[ci].section(":::",1,1); 
    8394      if(sna != "-"){ DSC.latestSnapshot= sna; } 
    8495      else{ DSC.latestSnapshot = ""; }       
    85     }else{ DSC.latestSnapshot=fSnap[0]; } 
     96    }else{ DSC.latestSnapshot=lpsnaps[0]; } 
    8697  } 
    8798  //List the replication status 
     
    186197        QMenu *menu = new QMenu(subsets[i],this); 
    187198        for(int s =0; s<snaps.length(); s++){ 
    188           QAction *act = new QAction(snaps[s],this); 
     199          if(snaps[s] == "--"){ menu->addSeparator(); } 
     200          else{ 
     201            QAction *act = new QAction(snaps[s],this); 
    189202                act->setWhatsThis(ds+":::"+subsets[i]+":::"+snaps[s]); 
    190           menu->addAction(act); 
     203            menu->addAction(act); 
     204          } 
    191205        } 
    192206        revMenu->addMenu(menu); 
Note: See TracChangeset for help on using the changeset viewer.