# 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 @@
Simple Script Editor
-
+
9
6
- -
+
-
+
+
+ Qt::Vertical
+
+
+
+ 75
+ 211
+
+
+
+
+ -
+
+
+ Save as
+
+
+
+
+
+
+ -
+
+
+ Save
+
+
+ Qt::CTRL + Qt::Key_S
+
+
+
+ -
+
+
+ Open
+
+
+ Qt::CTRL +Qt::Key_O
+
+
+
+ -
+
+
+ Run
+
+
+ Qt::CTRL + Qt::Key_R
+
+
+
+ -
+
+
+ Close
+
+
+
+ -
- -
-
-
- 0
-
-
- 6
-
-
-
-
-
- Run
-
-
-
- -
-
-
- Load
-
-
-
- -
-
-
- Save
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Close
-
-
-
-
-