Changeset bfe4e62


Ignore:
Timestamp:
08/27/13 09:32:12 (13 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:
b84dfe9, c3b1e67
Parents:
4ba9054
Message:

Disable the main GUI display buttons whenever a background process is running, with a status message at the bottom of the screen

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

Legend:

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

    r845aaf6 rbfe4e62  
    3434  //Initialize the Hash (make sure it is not run too frequently - causes kernel panics) 
    3535  if(lastUpdate.isNull() || lastUpdate.addSecs(15) < QTime::currentTime() ){ 
     36    enableButtons(false); //disable the buttons temporarily 
    3637    lastUpdate = QTime::currentTime();     
    3738    qDebug() << "Updating the database"; 
     39    ui->statusbar->showMessage(tr("Updating the database"),0); 
    3840    updateHash(); 
     41    ui->statusbar->clearMessage(); 
    3942  }else{ 
    4043    freqTimer->start(); 
     
    108111} 
    109112 
     113void mainUI::enableButtons(bool enable){ 
     114  if(enable){ 
     115    //special care must be taken here to only enable the ones that are valid 
     116    updateMenus(); 
     117  }else{ 
     118    ui->tool_add->setEnabled(false); 
     119    ui->tool_browse->setEnabled(false); 
     120    ui->tool_config->setEnabled(false); 
     121    ui->tool_keys->setEnabled(false); 
     122    ui->tool_newsnapshot->setEnabled(false); 
     123    ui->tool_remove->setEnabled(false); 
     124    ui->tool_revert->setEnabled(false); 
     125  } 
     126   
     127} 
     128 
    110129// ================= 
    111130//    PRIVATE FUNCTIONS 
     
    171190    ui->tool_newsnapshot->setVisible(false); 
    172191  }else{ 
    173     ui->tool_remove->setVisible(true); 
    174     ui->tool_config->setVisible(true);     
    175     ui->tool_newsnapshot->setVisible(true); 
     192    ui->tool_remove->setVisible(true); ui->tool_remove->setEnabled(true); 
     193    ui->tool_config->setVisible(true);  ui->tool_config->setEnabled(true); 
     194    ui->tool_newsnapshot->setVisible(true); ui->tool_newsnapshot->setEnabled(true); 
    176195  } 
    177196  //Enabled/disable the SSH key management 
     
    238257//  --- Buttons Clicked 
    239258void mainUI::on_treeWidget_itemSelectionChanged(){ 
    240   updateMenus(); 
     259  if(ui->statusbar->currentMessage().isEmpty()){ 
     260    //only update the menu's if they are not currently disabled while a process is running 
     261    updateMenus(); 
     262  } 
    241263} 
    242264 
     
    250272  bool change = false; 
    251273  if(CFG.localChanged){ 
     274    enableButtons(false); 
     275    ui->statusbar->showMessage(QString(tr("Configuring dataset: %1")).arg(ds),0); 
    252276    LPBackend::setupDataset(ds, CFG.localSchedule, CFG.localSnapshots); 
     277    ui->statusbar->clearMessage(); 
    253278    change = true; 
    254279  } 
    255280  if(CFG.remoteChanged){ 
    256281    change = true; 
     282    enableButtons(false); 
    257283    if(CFG.isReplicated){ 
     284      ui->statusbar->showMessage(QString(tr("Configuring replication: %1")).arg(ds),0); 
    258285      LPBackend::setupReplication(ds, CFG.remoteHost, CFG.remoteUser, CFG.remotePort, CFG.remoteDataset, CFG.remoteFreq); 
    259286      QMessageBox::information(this,tr("Reminder"),tr("Don't forget to save your SSH key to a USB stick so that you can restore your system from the remote host later!!")); 
    260287    }else{ 
     288      ui->statusbar->showMessage(QString(tr("Removing replication: %1")).arg(ds),0); 
    261289      LPBackend::removeReplication(ds); 
    262290    } 
     291    ui->statusbar->clearMessage(); 
    263292  } 
    264293  //Now update the UI if appropriate 
     
    273302    //Verify the removal of the dataset 
    274303    if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Dataset Backup Removal"),tr("Are you sure that you wish to cancel automated snapshots and/or replication of the following dataset?")+"\n\n"+ds,QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){             
     304      enableButtons(false); 
    275305      //verify the removal of all the snapshots for this dataset 
    276306      QStringList snaps = LPBackend::listLPSnapshots(ds); 
     
    278308        if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Snapshot Deletion"),tr("Do you wish to remove the local snapshots for this dataset?")+"\n"+tr("WARNING: This is a permanant change that cannot be reversed"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ 
    279309          //Remove all the snapshots 
     310          ui->statusbar->showMessage(QString(tr("%1: Removing snapshots")).arg(ds),0); 
    280311          for(int i=0; i<snaps.length(); i++){ 
    281312            LPBackend::removeSnapshot(ds,snaps[i]); 
    282313          } 
     314          ui->statusbar->clearMessage(); 
    283315        } 
    284316      } 
    285317      //Remove the dataset from life-preserver management 
    286       if(RLIST.contains(ds)){ LPBackend::removeReplication(ds); } 
     318      if(RLIST.contains(ds)){  
     319        ui->statusbar->showMessage(QString(tr("%1: Disabling Replication")).arg(ds),0); 
     320        LPBackend::removeReplication(ds);  
     321        ui->statusbar->clearMessage();       
     322      } 
     323      ui->statusbar->showMessage(QString(tr("%1: Disabling Life-Preserver Management")).arg(ds),0); 
    287324      LPBackend::removeDataset(ds); 
     325      ui->statusbar->clearMessage(); 
    288326    } 
    289327  } 
     
    318356             QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ 
    319357        //Perform the reversion 
     358        enableButtons(false); 
     359        ui->statusbar->showMessage(QString(tr("%1: Reverting dataset: %2")).arg(ds,subset),0); 
    320360        if( !LPBackend::revertSnapshot(ds+subset,snap) ){ 
    321361          //Error performing the reversion 
     
    327367          QMessageBox::information(this,tr("Reversion Success"), tr("The snapshot reversion was completed successfully."));      
    328368        } 
     369        ui->statusbar->clearMessage(); 
     370        enableButtons(true); 
    329371     } 
    330372  } 
     
    348390    QMessageBox::warning(this, tr("Invalid Snapshot File"), tr("Please select a file from within the chosen snapshot that you wish to revert")); 
    349391  }else{ 
     392    enableButtons(false); 
     393    ui->statusbar->showMessage(QString(tr("%1: Reverting File: %2")).arg(ds,filepath.remove(".zfs/snapshot/"+snap+"/").replace(QDir::homePath(),"~")),0); 
    350394    //Revert the file 
    351395    QString newfile = LPBackend::revertSnapshotFile(subset,snap,filepath); 
     
    359403      QMessageBox::information(this, tr("FIle Reverted"), QString(tr("The reverted file is now available at: %1")).arg(newfile) ); 
    360404    } 
     405    ui->statusbar->clearMessage(); 
     406    enableButtons(true); 
    361407  } 
    362408  return; 
     
    371417  //See if the wizard was cancelled or not 
    372418  if(!wiz.cancelled){ 
     419    enableButtons(false); 
     420    ui->statusbar->showMessage(QString(tr("Enabling dataset management: %1")).arg(dataset),0); 
    373421    //run the proper commands to get the dataset enabled 
    374422    if( LPBackend::setupDataset(dataset, wiz.localTime, wiz.totalSnapshots) ){ 
     
    378426      } 
    379427    } 
     428    ui->statusbar->clearMessage(); 
    380429  } 
    381430  //Now update the UI/Hash 
     
    389438void mainUI::on_actionKeyNew_triggered(){ 
    390439  QString ds = getSelectedDS(); 
     440  if(ds.isEmpty()){ return; } 
    391441  qDebug() << "New SSH Key triggered for DS:" << ds; 
     442  enableButtons(false); 
     443  ui->statusbar->showMessage(QString(tr("%1: Setting up SSH Key")).arg(ds),0); 
    392444  //Get the remote values for this dataset 
    393445  QString remoteHost, user, remotedataset; 
     
    403455    QMessageBox::warning(this,tr("Failure"), tr("There was an error in retrieving the remote replication information for this dataset. Please ensure that replication is enabled and try agin.") ); 
    404456  } 
     457  ui->statusbar->clearMessage(); 
     458  enableButtons(true); 
    405459} 
    406460 
    407461void mainUI::on_actionKeyCopy_triggered(){ 
    408462  QString ds = getSelectedDS();  
     463  if(ds.isEmpty()){ return; } 
    409464  qDebug() << "Copy SSH Key triggered for DS:" << ds; 
    410465  //Get the local hostname 
  • src-qt4/life-preserver/mainUI.h

    r9a67431 rbfe4e62  
    5353        LPDataset newDataset(QString); 
    5454 
     55        void enableButtons(bool); 
     56 
    5557private slots: 
    5658        void on_treeWidget_itemSelectionChanged(); 
Note: See TracChangeset for help on using the changeset viewer.