Commit b48099ff authored by Jan Möbius's avatar Jan Möbius

Add scripting function to load gui script from file

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7658 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 620da523
......@@ -366,21 +366,36 @@ void ScriptingPlugin::slotLoadScript(){
if (filename == "")
return;
slotLoadScript(filename);
}
scriptWidget_->currentScript->clear();
QFile data(filename);
if (data.open(QFile::ReadOnly)) {
QTextStream input(&data);
do {
scriptWidget_->currentScript->append(input.readLine());
} while (!input.atEnd());
}
lastFile_ = filename;
OpenFlipper::Options::currentScriptDir( QFileInfo(filename).absolutePath() );
scriptWidget_->actionSave_Script->setEnabled( false );
void ScriptingPlugin::slotLoadScript( QString _filename ) {
if (_filename == "")
return;
// Check if we are in gui mode. Otherwise just ignore this call
if ( OpenFlipper::Options::gui() ) {
scriptWidget_->currentScript->clear();
QFile data(_filename);
if (data.open(QFile::ReadOnly)) {
QTextStream input(&data);
do {
scriptWidget_->currentScript->append(input.readLine());
} while (!input.atEnd());
lastFile_ = _filename;
OpenFlipper::Options::currentScriptDir( QFileInfo(_filename).absolutePath() );
scriptWidget_->actionSave_Script->setEnabled( false );
scriptWidget_->show();
}
}
}
void ScriptingPlugin::slotSaveScript(){
......
......@@ -124,6 +124,14 @@ public slots:
void showScriptInEditor (QString _code);
/** \brief Load Script into gui from file
*
* Loads a script from the given file and loads it into the widget.
*
* @param _filename Filename of script to load, including full path.
*/
void slotLoadScript( QString _filename );
/** @} */
//===========================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment