Changeset cbe0295


Ignore:
Timestamp:
02/28/14 07:34:45 (6 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
28f8495
Parents:
082a859
Message:

Add a popup-message ppolicy setting to the life preserver tray so that you can select to show popups for all messages, errors only, or none. This will not touch "critical" messages, which will cause an actual window to appear that requires attention.

Location:
src-qt4/life-preserver/lp-tray
Files:
2 edited

Legend:

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

    r9537cb2 rcbe0295  
    33//PUBLIC 
    44LPTray::LPTray() : QSystemTrayIcon(){ 
     5  qDebug() << "Starting up Life-preserver Tray..."; 
    56  //Start up the log file watcher and connect the signals/slots 
    67  watcher = new LPWatcher(); 
    78        connect(watcher,SIGNAL(MessageAvailable(QString)),this,SLOT(watcherMessage(QString)) ); 
    89        connect(watcher,SIGNAL(StatusUpdated()),this,SLOT(watcherMessage()) ); 
     10  //Load the tray settings file 
     11  settings = new QSettings(QSettings::UserScope,"PCBSD", "life-preserver-tray"); 
     12  //Create the notification option widgets 
     13  nShowAll = new QRadioButton(tr("Show all")); 
     14        naAll = new QWidgetAction(this); 
     15        naAll->setDefaultWidget(nShowAll); 
     16  nShowError = new QRadioButton(tr("Warnings Only")); 
     17        naErr = new QWidgetAction(this); 
     18        naErr->setDefaultWidget(nShowError); 
     19  nShowNone = new QRadioButton(tr("None")); 
     20        naNone = new QWidgetAction(this); 
     21        naNone->setDefaultWidget(nShowNone); 
     22  //Create notification menu 
     23  notificationMenu = new QMenu(tr("Popup Settings")); 
     24        notificationMenu->setIcon( QIcon(":/images/configure.png") ); 
     25        notificationMenu->addAction(naAll); 
     26        notificationMenu->addAction(naErr); 
     27        notificationMenu->addAction(naNone); 
     28  //Activate the proper notification setting widget 
     29  QString popset = settings->value("popup-policy", "").toString(); 
     30  qDebug() << "Current Popup Policy:" << popset; 
     31  if(popset=="all"){ nShowAll->setChecked(true); popupPolicy = 2; } 
     32  else if(popset=="errors"){ nShowError->setChecked(true); popupPolicy = 1; } 
     33  else if(popset=="none"){ nShowNone->setChecked(true); popupPolicy = 0; } 
     34  else{  
     35    nShowError->setChecked(true); 
     36    settings->setValue("popup-policy","errors"); //save the proper setting 
     37    popupPolicy = 1; 
     38  } 
     39  //Now connect the popup settings signals/slots 
     40  connect(nShowAll, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) ); 
     41  connect(nShowError, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) ); 
     42  connect(nShowNone, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) ); 
    943  //Setup the context menu 
    1044  menu = new QMenu; 
     
    1246        menu->addSeparator(); 
    1347        menu->addAction(QIcon(":/images/backup-failed.png"),tr("View Messages"),this,SLOT(startMessageDialog()) ); 
     48        menu->addMenu(notificationMenu); 
    1449        menu->addAction(QIcon(":/images/refresh.png"),tr("Refresh Tray"),this,SLOT(refreshStatus()) ); 
    1550        menu->addSeparator(); 
     
    6297  qDebug() << "New Watcher Message:" << type; 
    6398  QStringList info; 
    64   if(type=="message"){ 
     99  if(type=="message" &&  popupPolicy > 1){ 
    65100    //Show the message pop-up 
    66101    info << "time" << "message"; 
     
    73108    info = watcher->getMessages(type,info); 
    74109    if(info.isEmpty()){ return; } 
    75     if(info[0] == "STARTED"){ 
     110    if(info[0] == "STARTED" && popupPolicy > 1 ){ 
    76111      this->showMessage( info[1], info[2], QSystemTrayIcon::Information, 5000); 
    77     }else if(info[0] == "FINISHED"){ 
     112    }else if(info[0] == "FINISHED" && popupPolicy > 1){ 
    78113      this->showMessage( info[1], info[2], QSystemTrayIcon::Information, 5000); 
    79     }else if(info[0] == "ERROR"){ 
     114    }else if(info[0] == "ERROR" && popupPolicy > 0){ 
    80115      this->showMessage( info[1], info[2], QSystemTrayIcon::Warning, 10000); 
    81116    } 
     
    101136    info = watcher->getMessages(type, info); 
    102137    if(!info.isEmpty()){ 
    103       if(info[0]=="ERROR"){  
     138      if(info[0]=="ERROR" && popupPolicy > 0 ){  
    104139        this->showMessage(info[1], info[2], QSystemTrayIcon::Warning, 5000); 
    105       }else{  
     140      }else if(popupPolicy > 1){  
    106141        this->showMessage(info[1], info[2], QSystemTrayIcon::Information, 5000);  
    107142      } 
     
    173208  watcher->refresh(); 
    174209} 
     210 
     211void LPTray::changePopupPolicy(){ 
     212  QString policy; 
     213  if(nShowAll->isChecked()){ 
     214    policy = "all"; 
     215    popupPolicy = 2; 
     216  }else if(nShowError->isChecked()){ 
     217    policy = "errors"; 
     218    popupPolicy = 1; 
     219  }else if(nShowNone->isChecked()){ 
     220    policy = "none"; 
     221    popupPolicy = 0; 
     222  }else{ 
     223    policy = "errors"; 
     224    popupPolicy = 1; 
     225  } 
     226  qDebug() << "Change Popup Policy:" << policy; 
     227  settings->setValue("popup-policy", policy); 
     228} 
  • src-qt4/life-preserver/lp-tray/LPTray.h

    r6a2483b rcbe0295  
    66#include <QString> 
    77#include <QMessageBox> 
     8#include <QRadioButton> 
     9#include <QWidgetAction> 
     10#include <QSettings> 
    811 
    912#include "LPWatcher.h" 
     
    1922        LPWatcher *watcher; 
    2023        LPMessages *msgdlg; 
    21         QMenu *menu; 
     24        QMenu *menu, *notificationMenu; 
     25        QRadioButton *nShowAll, *nShowError, *nShowNone; //notification popup messages 
     26        QWidgetAction *naAll, *naErr, *naNone; //widget-action containers for the readio buttons 
     27        QSettings *settings; 
     28        int popupPolicy; 
    2229 
    2330        void updateTrayIcon(); 
     
    3340        void startMessageDialog(); 
    3441        void refreshStatus(); 
     42        void changePopupPolicy(); 
    3543 
    3644}; 
Note: See TracChangeset for help on using the changeset viewer.