From 1e5806a5200db66e07b59863c5fbc4113d50fc59 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Tue, 5 Feb 2013 16:29:36 +0000 Subject: [PATCH] Fix warning message when TrimSP binary is not found. --- trimsp/src/TrimSPGUI/TrimSPGUI.pl | 20 +++++++-------- trimsp/src/TrimSPGUI/TrimSPGUI.ui.h | 38 ++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/trimsp/src/TrimSPGUI/TrimSPGUI.pl b/trimsp/src/TrimSPGUI/TrimSPGUI.pl index b1a2585..175e1c5 100644 --- a/trimsp/src/TrimSPGUI/TrimSPGUI.pl +++ b/trimsp/src/TrimSPGUI/TrimSPGUI.pl @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'TrimSPGUI.ui' # -# Created: Tue Feb 5 15:22:18 2013 +# Created: Tue Feb 5 15:53:55 2013 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -2466,8 +2466,6 @@ sub CollectValues sub CreateInpFile { -# use lib '$ENV{HOME}/Projects/TrimSPGUI/Chem'; -# push @INC, "$ENV{HOME}/Projects/TrimSPGUI"; use Chem; # The proper way I think is not to have scan sequences implimented here # but rather call this multiple times to generate the scan @@ -2669,7 +2667,7 @@ sub StartSequenceOne if (!$ENV{'TRIMBIN'}) { # If trim.sp binary is not defined give warning and return my $Warning = Qt::MessageBox::information( this, "Warning", - "Warning:\n TrimSP binary is not found.\n Define using environment variable, e.g.\n export TRIMBIN=/usr/local/bin/trimsp7l\n or use the Configuration tab."); + "Warning:\n TrimSP binary is not found.\n Define using the Configuration tab."); return(0); } @@ -3126,15 +3124,16 @@ sub GUIPath # If nothing is returned keep as is if ($FileBrowser eq "") { - $FileBrowser="$ENV{'PERLLIB'}"; + $FileBrowser=$ENV{'PERLLIB'}; } else { - TrimGUIPath->setText($FileBrowser); - $ENV{'PERLLIB'}=$FileBrowser; + $ENV{'PERLLIB'}=$FileBrowser; } + TrimGUIPath->setText($FileBrowser); # Return a string with the directory name return $FileBrowser ; + } sub TrimBin @@ -3148,11 +3147,12 @@ sub TrimBin "Select the Trim.SP binary file"); # If the user gave a valid filename try to read it - if ($file ne "") { + if ($file eq "") { + $file=$ENV{'TRIMBIN'}; + } else { $ENV{'TRIMBIN'}=$file; - TRIMBIN->setText($file); } - + TRIMBIN->setText($file); return $file; } diff --git a/trimsp/src/TrimSPGUI/TrimSPGUI.ui.h b/trimsp/src/TrimSPGUI/TrimSPGUI.ui.h index a4c0489..1eae1cb 100644 --- a/trimsp/src/TrimSPGUI/TrimSPGUI.ui.h +++ b/trimsp/src/TrimSPGUI/TrimSPGUI.ui.h @@ -311,8 +311,6 @@ void TrimSPGUI::CollectValues() void TrimSPGUI::CreateInpFile() { -# use lib '$ENV{HOME}/Projects/TrimSPGUI/Chem'; -# push @INC, "$ENV{HOME}/Projects/TrimSPGUI"; use Chem; # The proper way I think is not to have scan sequences implimented here # but rather call this multiple times to generate the scan @@ -513,7 +511,7 @@ void TrimSPGUI::StartSequenceOne() if (!$ENV{'TRIMBIN'}) { # If trim.sp binary is not defined give warning and return my $Warning = Qt::MessageBox::information( this, "Warning", - "Warning:\n TrimSP binary is not found.\n Define using environment variable, e.g.\n export TRIMBIN=/usr/local/bin/trimsp7l\n or use the Configuration tab."); + "Warning:\n TrimSP binary is not found.\n Define using the Configuration tab."); return(0); } @@ -961,14 +959,35 @@ void TrimSPGUI::GUIPath() # If nothing is returned keep as is if ($FileBrowser eq "") { - $FileBrowser="$ENV{'PERLLIB'}"; + $FileBrowser=$ENV{'PERLLIB'}; } else { - TrimGUIPath->setText($FileBrowser); - $ENV{'PERLLIB'}=$FileBrowser; + $ENV{'PERLLIB'}=$FileBrowser; } + TrimGUIPath->setText($FileBrowser); # Return a string with the directory name return $FileBrowser ; + +} + +sub TrimBin +{ + + my $file=Qt::FileDialog::getOpenFileName( + "$ENV{'TRIMBIN'}", + "Trim.SP binary (.* *.* *)", + this, + "open file dialog", + "Select the Trim.SP binary file"); + +# If the user gave a valid filename try to read it + if ($file eq "") { + $file=$ENV{'TRIMBIN'}; + } else { + $ENV{'TRIMBIN'}=$file; + } + TRIMBIN->setText($file); + return $file; } @@ -982,10 +1001,11 @@ void TrimSPGUI::TrimBin() "Select the Trim.SP binary file"); # If the user gave a valid filename try to read it - if ($file ne "") { + if ($file eq "") { + $file=$ENV{'TRIMBIN'}; + } else { $ENV{'TRIMBIN'}=$file; - TRIMBIN->setText($file); } - + TRIMBIN->setText($file); return $file; }