Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 55 additions and 21 deletions.
  1. +35 −8 lp-gui/LPMain.cpp
  2. +2 −1 lp-gui/LPMain.h
  3. +18 −12 lp-gui/LPMain.ui
View
43 lp-gui/LPMain.cpp
@@ -43,7 +43,7 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
connect(ui->actionSet_Disk_Offline, SIGNAL(triggered()), this, SLOT(menuOfflineDisk()) );
connect(ui->action_startScrub, SIGNAL(triggered()), this, SLOT(menuStartScrub()) );
connect(ui->action_newSnapshot, SIGNAL(triggered()), this, SLOT(menuNewSnapshot()) );
- connect(ui->action_rmSnapshot, SIGNAL(triggered()), this, SLOT(menuRemoveSnapshot()) );
+ connect(ui->menuDelete_Snapshot, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveSnapshot(QAction*)) );
//Update the interface
updatePoolList();
//Make sure the status tab is shown initially
@@ -170,11 +170,17 @@ void LPMain::updateTabs(){
if(dsin >= 0){ ui->combo_datasets->setCurrentIndex(dsin); }
else if( !dslist.isEmpty() ){ ui->combo_datasets->setCurrentIndex(0); }
else{ ui->combo_datasets->addItem(tr("No datasets available")); }
- //Automatically calls the "updateDataset()" function
+ //NOTE: this automatically calls the "updateDataset()" function
+
+ //Now update the snapshot removal menu list
+ QStringList snaps = LPBackend::listLPSnapshots(ui->combo_pools->currentText());
+ ui->menuDelete_Snapshot->clear();
+ for(int i=0; i<snaps.length(); i++){
+ ui->menuDelete_Snapshot->addAction(snaps[i]);
+ }
+ ui->menuDelete_Snapshot->setEnabled( !ui->menuDelete_Snapshot->isEmpty() );
}else{
//No Pool selected
- ui->menuDisks->setEnabled(false); //make sure this is always disabled if nothing selected
- ui->menuSnapshots->setEnabled(false); //make sure this is always disabled if nothing selected
ui->label_numdisks->clear();
ui->label_latestsnapshot->clear();
ui->label_status->clear();
@@ -396,10 +402,31 @@ void LPMain::menuStartScrub(){
// ==== Snapshots Menu ====
void LPMain::menuNewSnapshot(){
qDebug() << "New Snapshot";
-
+ QString ds = ui->combo_pools->currentText();
+ if(ds.isEmpty()){return; }
+ //Get the new snapshot name from the user
+ bool ok;
+ QString name = QInputDialog::getText(this,tr("New Snapshot Name"), tr("Snapshot Name:"), QLineEdit::Normal, tr("Name"), &ok, 0, Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly | Qt::ImhDigitsOnly );
+ if(!ok || name.isEmpty()){ return; } //cancelled
+ qDebug() << "Creating a new snapshot:" << ds << name;
+ //Now create the new snapshot
+ LPBackend::newSnapshot(ds,name);
+ QMessageBox::information(this,tr("Snapshot Pending"), tr("The new snapshot creation has been added to the queue"));
+ updateTabs();
}
-void LPMain::menuRemoveSnapshot(){
- qDebug() << "Remove Snapshot";
-
+void LPMain::menuRemoveSnapshot(QAction *act){
+ QString snapshot = act->text();
+ QString pool = ui->combo_pools->currentText();
+ qDebug() << "Remove Snapshot:" << snapshot;
+ //verify snapshot removal
+ if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Snapshot Deletion"),QString(tr("Do you wish to delete this snapshot? %1")).arg(pool+"/"+snapshot)+"\n"+tr("WARNING: This is a permanant change that cannot be reversed"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ bool ok = LPBackend::removeSnapshot(ui->combo_pools->currentText(), snapshot);
+ if(ok){
+ QMessageBox::information(this,tr("Snapshot Removed"),tr("The snapshot was successfully deleted"));
+ }else{
+ QMessageBox::information(this,tr("Snapshot Removal Failure"),tr("The snapshot removal experienced an error and it not be completed at this time."));
+ }
+ updateTabs();
+ }
}
View
3 lp-gui/LPMain.h
@@ -10,6 +10,7 @@
#include <QRadioButton>
#include <QWidgetAction>
#include <QFileSystemModel>
+#include <QInputDialog>
#include "LPBackend.h"
#include "LPContainers.h"
@@ -66,7 +67,7 @@ private slots:
void menuStartScrub();
//Snapshots Menu
void menuNewSnapshot();
- void menuRemoveSnapshot();
+ void menuRemoveSnapshot(QAction*);
protected:
View
30 lp-gui/LPMain.ui
@@ -421,8 +421,18 @@
<property name="title">
<string>Snapshots</string>
</property>
+ <widget class="QMenu" name="menuDelete_Snapshot">
+ <property name="title">
+ <string>Delete Snapshot</string>
+ </property>
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/list-remove.png</normaloff>:/images/list-remove.png</iconset>
+ </property>
+ <addaction name="actionSnapshots"/>
+ </widget>
<addaction name="action_newSnapshot"/>
- <addaction name="action_rmSnapshot"/>
+ <addaction name="menuDelete_Snapshot"/>
</widget>
<widget class="QMenu" name="menuClassic_Backups">
<property name="title">
@@ -513,15 +523,6 @@
<string>New Snapshot</string>
</property>
</action>
- <action name="action_rmSnapshot">
- <property name="icon">
- <iconset resource="lPreserve.qrc">
- <normaloff>:/images/list-remove.png</normaloff>:/images/list-remove.png</iconset>
- </property>
- <property name="text">
- <string>Delete Snapshot</string>
- </property>
- </action>
<action name="action_SaveKeyToUSB">
<property name="icon">
<iconset resource="lPreserve.qrc">
@@ -572,12 +573,17 @@
</action>
<action name="actionPools">
<property name="text">
- <string>pools</string>
+ <string notr="true">pools</string>
</property>
</action>
<action name="actionPools_2">
<property name="text">
- <string>pools</string>
+ <string notr="true">pools</string>
+ </property>
+ </action>
+ <action name="actionSnapshots">
+ <property name="text">
+ <string notr="true">snapshots</string>
</property>
</action>
</widget>

No commit comments for this range

Something went wrong with that request. Please try again.