1.11.2 split up of xml helper functions. started to work on attributes
1 #include "simplescripteditor.h"
9 extern QString vymName;
11 SimpleScriptEditor::SimpleScriptEditor (QWidget *parent):QDialog(parent)
15 connect ( ui.openButton, SIGNAL (clicked() ), this, SLOT (openClicked() ));
16 connect ( ui.saveButton, SIGNAL (clicked() ), this, SLOT (saveClicked() ));
17 connect ( ui.saveAsButton, SIGNAL (clicked() ), this, SLOT (saveAsClicked() ));
18 connect ( ui.runButton, SIGNAL (clicked() ), this, SLOT (runClicked() ));
23 font.setFamily("Courier");
24 font.setFixedPitch(true);
25 font.setPointSize(12);
26 ui.editor->setFont(font);
28 highlighter = new Highlighter(ui.editor->document());
31 void SimpleScriptEditor::saveScript()
34 if ( !f.open( QIODevice::WriteOnly ) )
40 t << ui.editor->text();
44 void SimpleScriptEditor::setScript(const QString &s)
46 ui.editor->setText(s);
49 void SimpleScriptEditor::saveClicked()
51 if (filename.isEmpty() )
57 void SimpleScriptEditor::saveAsClicked()
59 QString fn = QFileDialog::getSaveFileName(
61 QString (vymName + " - " +tr("Save script")),
63 "VYM script (HTML) (*.vys);;All files (*)",
65 QFileDialog::DontConfirmOverwrite);
72 QMessageBox mb( vymName,
73 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save as'").arg(fn),
75 QMessageBox::Yes | QMessageBox::Default,
76 QMessageBox::Cancel | QMessageBox::Escape,
78 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
79 mb.setButtonText( QMessageBox::No, tr("Cancel"));
82 case QMessageBox::Yes:
87 case QMessageBox::Cancel:
97 void SimpleScriptEditor::openClicked()
99 QFileDialog *fd=new QFileDialog( this);
101 types<< "VYM scripts (*.vys)" <<
103 fd->setFilters (types);
104 fd->setDirectory (QDir().current());
105 fd->setCaption (vymName + " - " + tr("Load script"));
107 if ( fd->exec() == QDialog::Accepted )
108 filename = fd->selectedFile();
110 if ( !filename.isEmpty() )
113 if ( !f.open( QIODevice::ReadOnly ) )
115 QMessageBox::warning(0,
117 tr("Couldn't open %1.\n").arg(filename));
121 QTextStream ts( &f );
122 ui.editor->setText( ts.read() );
127 void SimpleScriptEditor::runClicked()
129 emit runScript (ui.editor->text() );