# HG changeset patch # User insilmaril # Date 1174477898 0 # Node ID eae9abe70d7c06e7494cccc25342a396141c3bf0 # Parent 918417b015e01a7c7ecf43f5dd2daa0fa0560a37 Slightly improved scripting abilities diff -r 918417b015e0 -r eae9abe70d7c simplescripteditor.cpp --- a/simplescripteditor.cpp Wed Mar 21 11:51:38 2007 +0000 +++ b/simplescripteditor.cpp Wed Mar 21 11:51:38 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() ); } diff -r 918417b015e0 -r eae9abe70d7c simplescripteditor.h --- a/simplescripteditor.h Wed Mar 21 11:51:38 2007 +0000 +++ b/simplescripteditor.h Wed Mar 21 11:51:38 2007 +0000 @@ -15,9 +15,10 @@ void setScript(const QString &); public slots: - void saveScriptClicked(); - void loadScriptClicked(); - void runScriptClicked(); + void saveClicked(); + void saveAsClicked(); + void openClicked(); + void runClicked(); signals: void runScript (QString); diff -r 918417b015e0 -r eae9abe70d7c simplescripteditor.ui --- a/simplescripteditor.ui Wed Mar 21 11:51:38 2007 +0000 +++ b/simplescripteditor.ui Wed Mar 21 11:51:38 2007 +0000 @@ -12,67 +12,76 @@ <property name="windowTitle" > <string>Simple Script Editor</string> </property> - <layout class="QHBoxLayout" > + <layout class="QGridLayout" > <property name="margin" > <number>9</number> </property> <property name="spacing" > <number>6</number> </property> - <item> + <item row="4" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>75</width> + <height>211</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="1" > + <widget class="QPushButton" name="saveAsButton" > + <property name="text" > + <string>Save as</string> + </property> + <property name="shortcut" > + <string/> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QPushButton" name="saveButton" > + <property name="text" > + <string>Save</string> + </property> + <property name="shortcut" > + <string>Qt::CTRL + Qt::Key_S</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QPushButton" name="openButton" > + <property name="text" > + <string>Open</string> + </property> + <property name="shortcut" > + <string>Qt::CTRL +Qt::Key_O</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QPushButton" name="runButton" > + <property name="text" > + <string>Run</string> + </property> + <property name="shortcut" > + <string>Qt::CTRL + Qt::Key_R</string> + </property> + </widget> + </item> + <item row="5" column="1" > + <widget class="QPushButton" name="closeButton" > + <property name="text" > + <string>Close</string> + </property> + </widget> + </item> + <item rowspan="6" row="0" column="0" > <widget class="QTextEdit" name="editor" /> </item> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="runButton" > - <property name="text" > - <string>Run</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="loadButton" > - <property name="text" > - <string>Load</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="saveButton" > - <property name="text" > - <string>Save</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="closeButton" > - <property name="text" > - <string>Close</string> - </property> - </widget> - </item> - </layout> - </item> </layout> </widget> <resources/>