Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

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

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 28 additions and 3 deletions.
  1. +27 −3 src-qt4/pc-bootconfig/mainUI.cpp
  2. +1 −0  src-qt4/pc-bootconfig/mainUI.h
View
30 src-qt4/pc-bootconfig/mainUI.cpp
@@ -66,6 +66,18 @@ bool mainUI::checkName(QString newname){
return ok;
}
+bool mainUI::validateInput(QString name){
+ //Check for invalid name characters (only letters/numbers)
+ bool ok = true;
+ for(int i=0; i<name.length(); i++){
+ if( !name.at(i).isLetter() && !name.at(i).isDigit() ){ ok = false; break; }
+ }
+ if(!ok){
+ QMessageBox::warning(this,tr("Invalid Name"), tr("Boot Environment names may only be comprised of letters and numbers") );
+ }
+ return ok;
+}
+
void mainUI::runLongCMD(QString cmd, QString info){
if(info.isEmpty()){ info = tr("Performing Boot Environment Changes. Please Wait."); }
@@ -310,8 +322,12 @@ void mainUI::on_tool_BEadd_clicked(){
if( ui->tree_BE->topLevelItemCount() == 1){updateGRUB=true;} //moving from 1 to 2
//Get the new name from the user
bool ok;
- QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, "", &ok);
+ QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, "", &ok,0, Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly);
if(ok && !newname.isEmpty()){
+ if( !validateInput(newname) ){
+ on_tool_BEadd_clicked(); //try again
+ return;
+ }
if( checkName(newname) ){
if(updateGRUB && !G_showMenu){
G_showMenu=true;
@@ -349,8 +365,12 @@ void mainUI::on_tool_BEcp_clicked(){
QString name = ui->tree_BE->topLevelItem(index)->text(0);
//Get the new name from the user
bool ok;
- QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, name, &ok);
+ QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhDigitsOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly);
if(ok && !newname.isEmpty()){
+ if( !validateInput(newname) ){
+ on_tool_BEcp_clicked(); //try again
+ return;
+ }
if( checkName(newname) ){
if(updateGRUB && !G_showMenu){
G_showMenu=true;
@@ -374,8 +394,12 @@ void mainUI::on_tool_BEmv_clicked(){
QString name = ui->tree_BE->topLevelItem(index)->text(0);
//Get the new name from the user
bool ok;
- QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a new name for this boot environment"), QLineEdit::Normal, name, &ok);
+ QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a new name for this boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly );
if(ok && !newname.isEmpty()){
+ if( !validateInput(newname) ){
+ on_tool_BEmv_clicked(); //try again
+ return;
+ }
if( checkName(newname) ){
beadmRename(name,newname);
updateBEList();
View
1  src-qt4/pc-bootconfig/mainUI.h
@@ -38,6 +38,7 @@ public slots:
//Random usage functions
int getSelectedBE(); //get the currently selected Boot Environment index
bool checkName(QString); //make sure the selected name is valid
+ bool validateInput(QString); //Make sure the input text is number/letter
void runLongCMD(QString cmd , QString info = "");
//Boot Environment Management Functions

No commit comments for this range

Something went wrong with that request. Please try again.