Added possibility to save and load initial values.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# Form implementation generated from reading ui file 'QmuSRSim.ui'
|
||||
#
|
||||
# Created: Thu Apr 7 17:22:13 2011
|
||||
# Created: Fri Apr 8 15:45:19 2011
|
||||
# by: The PerlQt User Interface Compiler (puic)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@ -18368,17 +18368,73 @@ sub fileNew
|
||||
|
||||
sub fileOpen
|
||||
{
|
||||
print "QmuSRSim->fileOpen(): Not implemented yet.\n";
|
||||
|
||||
my $file=Qt::FileDialog::getOpenFileName(
|
||||
".",
|
||||
"Initialization file (.* *.*)",
|
||||
this,
|
||||
"open file dialog",
|
||||
"Choose an initialization file");
|
||||
|
||||
# If the user gave a valid filename try to read it
|
||||
if ($file ne "") {
|
||||
open (INF,q{<},"$file" );
|
||||
my @lines = <INF>;
|
||||
close(INF);
|
||||
my $Attrib="";
|
||||
foreach my $line (@lines) {
|
||||
# Remove white spaces
|
||||
$line =~ s/\s+//g;
|
||||
my @InitPar = split (/=/,$line);
|
||||
# Check it is not empty or title line
|
||||
if ($InitPar[0] ne "" && $InitPar[1] ne "") {
|
||||
$Attrib = child($InitPar[0]);
|
||||
$Attrib->setText($InitPar[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub fileSave
|
||||
{
|
||||
print "QmuSRSim->fileSave(): Not implemented yet.\n";
|
||||
|
||||
my %All=CreateAllInput();
|
||||
my $InitFile="";
|
||||
for my $key (keys %All) {
|
||||
$InitFile=$InitFile.$key."=".$All{$key}."\n";
|
||||
}
|
||||
|
||||
# Save to default file name "TriumSP.cfg"
|
||||
my $file = "musrSim.cfg";
|
||||
open (OUTF,q{>},"$file" );
|
||||
print OUTF (" $InitFile");
|
||||
close(OUTF);
|
||||
|
||||
}
|
||||
|
||||
sub fileSaveAs
|
||||
{
|
||||
print "QmuSRSim->fileSaveAs(): Not implemented yet.\n";
|
||||
|
||||
my %All=CreateAllInput();
|
||||
my $InitFile="";
|
||||
for my $key (keys %All) {
|
||||
$InitFile=$InitFile.$key."=".$All{$key}."\n";
|
||||
}
|
||||
|
||||
my $file=Qt::FileDialog::getSaveFileName(
|
||||
"musrSim cfg",
|
||||
"musrSim GUI Initialization file (*.cfg)",
|
||||
this,
|
||||
"save file dialog",
|
||||
"Choose a filename to save under");
|
||||
# if the user gave a filename then sanesave copy to it
|
||||
if ($file ne "") {
|
||||
open (OUTF,q{>},"$file" );
|
||||
print OUTF (" $InitFile");
|
||||
close(OUTF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub filePrint
|
||||
@ -18388,7 +18444,14 @@ sub filePrint
|
||||
|
||||
sub fileExit
|
||||
{
|
||||
print "QmuSRSim->fileExit(): Not implemented yet.\n";
|
||||
|
||||
my $Ans = Qt::MessageBox::question( this, "Quit?","Are you sure you want to quit?","&Yes","&No","",0,1);
|
||||
if ($Ans==0) {
|
||||
# Then quit
|
||||
Qt::Application::exit( 0 );
|
||||
}
|
||||
# Otherwize go back
|
||||
|
||||
}
|
||||
|
||||
sub editUndo
|
||||
@ -18528,7 +18591,7 @@ sub StartCalc
|
||||
}
|
||||
|
||||
open(NEWMACF,">1000.mac");
|
||||
print (NEWMACF "@lines");
|
||||
print NEWMACF @lines;
|
||||
close(NEWMACF);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user