diff -r c585be63ec69 -r 54475d6f006a simplescripteditor.cpp --- a/simplescripteditor.cpp Tue Mar 06 19:37:39 2007 +0000 +++ b/simplescripteditor.cpp Tue Oct 16 09:53:22 2007 +0000 @@ -12,16 +12,17 @@ { ui.setupUi (this); - connect ( ui.loadButton, SIGNAL (clicked() ), this, SLOT (loadScriptClicked() )); - connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveScriptClicked() )); - connect ( ui.runButton, SIGNAL (clicked() ), this, SLOT (runScriptClicked() )); + connect ( ui.openButton, SIGNAL (clicked() ), this, SLOT (openClicked() )); + connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveClicked() )); + connect ( ui.saveAsButton, SIGNAL (clicked() ), this, SLOT (saveAsClicked() )); + connect ( ui.runButton, SIGNAL (clicked() ), this, SLOT (runClicked() )); // Initialize Editor QFont font; font.setFamily("Courier"); font.setFixedPitch(true); - font.setPointSize(10); + font.setPointSize(12); ui.editor->setFont(font); highlighter = new Highlighter(ui.editor->document()); @@ -45,7 +46,15 @@ ui.editor->setText(s); } -void SimpleScriptEditor::saveScriptClicked() +void SimpleScriptEditor::saveClicked() +{ + if (filename.isEmpty() ) + saveAsClicked(); + else + saveScript(); +} + +void SimpleScriptEditor::saveAsClicked() { QString fn = QFileDialog::getSaveFileName( this, @@ -85,7 +94,7 @@ } } -void SimpleScriptEditor::loadScriptClicked() +void SimpleScriptEditor::openClicked() { QFileDialog *fd=new QFileDialog( this); QStringList types; @@ -95,18 +104,17 @@ fd->setDirectory (QDir().current()); fd->setCaption (vymName + " - " + tr("Load script")); fd->show(); - QString fn; if ( fd->exec() == QDialog::Accepted ) - fn = fd->selectedFile(); + filename = fd->selectedFile(); - if ( !fn.isEmpty() ) + if ( !filename.isEmpty() ) { - QFile f( fn ); + QFile f( filename ); if ( !f.open( QIODevice::ReadOnly ) ) { QMessageBox::warning(0, tr("Error"), - tr("Couldn't open %1.\n").arg(fn)); + tr("Couldn't open %1.\n").arg(filename)); return; } @@ -116,7 +124,7 @@ } } -void SimpleScriptEditor::runScriptClicked() +void SimpleScriptEditor::runClicked() { emit runScript (ui.editor->text() ); }