1.1 --- a/simplescripteditor.cpp Tue Mar 06 19:37:39 2007 +0000
1.2 +++ b/simplescripteditor.cpp Wed May 02 15:31:20 2007 +0000
1.3 @@ -12,16 +12,17 @@
1.4 {
1.5 ui.setupUi (this);
1.6
1.7 - connect ( ui.loadButton, SIGNAL (clicked() ), this, SLOT (loadScriptClicked() ));
1.8 - connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveScriptClicked() ));
1.9 - connect ( ui.runButton, SIGNAL (clicked() ), this, SLOT (runScriptClicked() ));
1.10 + connect ( ui.openButton, SIGNAL (clicked() ), this, SLOT (openClicked() ));
1.11 + connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveClicked() ));
1.12 + connect ( ui.saveAsButton, SIGNAL (clicked() ), this, SLOT (saveAsClicked() ));
1.13 + connect ( ui.runButton, SIGNAL (clicked() ), this, SLOT (runClicked() ));
1.14
1.15
1.16 // Initialize Editor
1.17 QFont font;
1.18 font.setFamily("Courier");
1.19 font.setFixedPitch(true);
1.20 - font.setPointSize(10);
1.21 + font.setPointSize(12);
1.22 ui.editor->setFont(font);
1.23
1.24 highlighter = new Highlighter(ui.editor->document());
1.25 @@ -45,7 +46,15 @@
1.26 ui.editor->setText(s);
1.27 }
1.28
1.29 -void SimpleScriptEditor::saveScriptClicked()
1.30 +void SimpleScriptEditor::saveClicked()
1.31 +{
1.32 + if (filename.isEmpty() )
1.33 + saveAsClicked();
1.34 + else
1.35 + saveScript();
1.36 +}
1.37 +
1.38 +void SimpleScriptEditor::saveAsClicked()
1.39 {
1.40 QString fn = QFileDialog::getSaveFileName(
1.41 this,
1.42 @@ -85,7 +94,7 @@
1.43 }
1.44 }
1.45
1.46 -void SimpleScriptEditor::loadScriptClicked()
1.47 +void SimpleScriptEditor::openClicked()
1.48 {
1.49 QFileDialog *fd=new QFileDialog( this);
1.50 QStringList types;
1.51 @@ -95,18 +104,17 @@
1.52 fd->setDirectory (QDir().current());
1.53 fd->setCaption (vymName + " - " + tr("Load script"));
1.54 fd->show();
1.55 - QString fn;
1.56 if ( fd->exec() == QDialog::Accepted )
1.57 - fn = fd->selectedFile();
1.58 + filename = fd->selectedFile();
1.59
1.60 - if ( !fn.isEmpty() )
1.61 + if ( !filename.isEmpty() )
1.62 {
1.63 - QFile f( fn );
1.64 + QFile f( filename );
1.65 if ( !f.open( QIODevice::ReadOnly ) )
1.66 {
1.67 QMessageBox::warning(0,
1.68 tr("Error"),
1.69 - tr("Couldn't open %1.\n").arg(fn));
1.70 + tr("Couldn't open %1.\n").arg(filename));
1.71 return;
1.72 }
1.73
1.74 @@ -116,7 +124,7 @@
1.75 }
1.76 }
1.77
1.78 -void SimpleScriptEditor::runScriptClicked()
1.79 +void SimpleScriptEditor::runClicked()
1.80 {
1.81 emit runScript (ui.editor->text() );
1.82 }