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

Additional scipting function to jump out of loop

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16489 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ad28216c
......@@ -119,5 +119,27 @@
</code>
</element>
<element name="dialog_Continue_box">
<category>Widgets and UI</category>
<short>Continue box</short>
<long>Deliver true until the user clicks on the stop button</long>
<dataflow>true</dataflow>
<input name="message" type="String" external="false" runtime="false">
<short>Displayed message</short>
<long>Displayed message.</long>
<default>Stop?</default>
</input>
<outputs>
<output name="continue" type="Bool">
<short>continue</short>
<long>Delivers true until stop button is pressed.</long>
</output>
</outputs>
<code>
var dialog_stop_box_message = [input="message"];
[output="continue"] = visualscripting.continueBox(dialog_stop_box_message);
</code>
</element>
</OpenFlipper>
......@@ -257,4 +257,26 @@ bool VsiPlugin::questionBox (QString _message)
return false;
}
/// Non blocking box which can be used inside scripting loops to stop on clicks
bool VsiPlugin::continueBox (QString _message)
{
static QContinueBox* msgBox = NULL;
if ( !msgBox ) {
msgBox = new QContinueBox(_message);
msgBox->show();
} else {
if ( msgBox->continueBox() ) {
return true;
} else {
delete msgBox;
msgBox = NULL;
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
......@@ -109,6 +109,9 @@ class VsiPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface,
/// Scripting function, that displays a Yes/No message box
bool questionBox (QString _message);
/// Shows a non blocking stop box for use inside loops
bool continueBox(QString _message);
QString version () { return QString("1.0"); };
private slots:
......@@ -133,8 +136,41 @@ class VsiPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface,
VSI::BaseWidget *baseWidget_;
};
//=============================================================================
class QContinueBox : public QWidget {
Q_OBJECT
public:
QContinueBox(QString _message,QWidget* _parent = 0) :
QWidget(_parent),
continue_(true)
{
QPushButton* stopButton = new QPushButton("Stop",this);
QHBoxLayout* layout = new QHBoxLayout(this);
this->setWindowTitle(_message);
layout->addWidget(stopButton);
this->setLayout(layout);
connect(stopButton,SIGNAL(clicked()), this, SLOT(clicked()));
}
public slots:
void clicked( ) {
continue_ = false;
}
public:
bool continueBox() { return continue_; };
private:
bool continue_;
};
//=============================================================================
//=============================================================================
#endif
\ No newline at end of file
#endif
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