diff --git a/Core/Core.cc b/Core/Core.cc
index 28a370a434d809a872a8500eb0aaa081b41fcf37..362d595d29f3708002181107ba63c7e31e548792 100644
--- a/Core/Core.cc
+++ b/Core/Core.cc
@@ -667,16 +667,16 @@ void Core::fullscreen( bool _state ) {
//-----------------------------------------------------------------------------
-void Core::logger() {
+void Core::showLogger(bool _state) {
if ( OpenFlipper::Options::gui() )
- coreWidget_->toggleLogger();
+ coreWidget_->showLogger( _state );
}
//-----------------------------------------------------------------------------
-void Core::toolbox() {
+void Core::showToolbox( bool _state ) {
if ( OpenFlipper::Options::gui() )
- coreWidget_->toggleToolbox();
+ coreWidget_->showToolbox(_state);
}
@@ -965,8 +965,8 @@ void Core::setDescriptions(){
emit setSlotDescription("fullscreen(bool)", "Enable or disable fullscreen mode",
QStringList("enabled") ,
QStringList("Enable or disable fullscreen mode"));
- emit setSlotDescription("logger()", "Toggle logging window visibility", QStringList(), QStringList());
- emit setSlotDescription("toolbox()", "Toggle toolbox visibility", QStringList(), QStringList());
+ emit setSlotDescription("showLogger(bool)", "Show or hide logger window", QStringList("Show or hide logger window"), QStringList());
+ emit setSlotDescription("showToolbox(bool)", "Show or hide toolbox", QStringList("Show or hide the toolbox"), QStringList());
emit setSlotDescription("setDrawMode(QString)", "Set the drawMode",
QStringList("DrawMode"), QStringList("the drawMode ( ; separated list )"));
emit setSlotDescription("restrictFrameRate(bool)", "Restrict FrameRate to MaxFrameRate",
@@ -1002,6 +1002,10 @@ void Core::setDescriptions(){
emit setSlotDescription("loadObject()", "Show the dialog to load an object. (only works if GUI is available)",QStringList(), QStringList());
emit setSlotDescription("loadSettings()", "Show the dialog to load settings. (only works if GUI is available)",QStringList(), QStringList());
emit setSlotDescription("loadSettings(QString)", "load settings from file.",QStringList(), QStringList());
+ emit setSlotDescription("createWidget(QString,QString);", "Create a widget from an ui file",
+ QString("Object name,ui file").split(","),
+ QString("Name of the new widget in script,ui file to load").split(","));
+
}
// //-----------------------------------------------------------------------------
diff --git a/Core/Core.hh b/Core/Core.hh
index 292b4ce13cf59723fa7a38e88a1888432ca74448..47f927fae0bf20f4a3d2d128b801aaca8b7fa7a0 100644
--- a/Core/Core.hh
+++ b/Core/Core.hh
@@ -283,10 +283,10 @@ public slots:
void fullscreen( bool _state );
/// Hide or show logging window
- void logger();
+ void showLogger(bool _state);
- /// Hide or show toolbox window
- void toolbox();
+ /// Show or hide toolbox
+ void showToolbox( bool _state );
/// Set the drawMode ( ; separated list )
void setDrawMode(QString _mode);
@@ -584,6 +584,17 @@ private:
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
+
+ public slots:
+ /** \brief Create an script object from a ui file
+ *
+ * This function will load an ui file, set up a qwidget from that and makes it available
+ * under _objectName for scripting.
+ * @param _objectName The name in scripting environment used for the new object
+ * @param _uiFilename ui file to load
+ */
+ void createWidget(QString _objectName, QString _uiFilename);
+
private :
/// Core scripting engine
QScriptEngine scriptEngine_;
diff --git a/Core/optionHandling.cc b/Core/optionHandling.cc
index cbc869646be8498814a2767ac9a79f5e5e757867..419dce69ca39e7e1a7a41bb2a1af9791826cb62c 100644
--- a/Core/optionHandling.cc
+++ b/Core/optionHandling.cc
@@ -69,7 +69,7 @@ void Core::applyOptions(){
coreWidget_->setWindowState( (coreWidget_->windowState() | Qt::WindowFullScreen) ^ Qt::WindowFullScreen);
// Logger
- coreWidget_->hideLogger( OpenFlipper::Options::hideLogger() );
+ coreWidget_->showLogger( !OpenFlipper::Options::hideLogger() );
//animation
coreWidget_->examiner_widget_->animation(OpenFlipper::Options::animation());
diff --git a/Core/scripting.cc b/Core/scripting.cc
index 567de428fa0f18b4c3775ce55e99c67596ffb513..681ff123246742be0864dbfbe80454769b94bd13 100644
--- a/Core/scripting.cc
+++ b/Core/scripting.cc
@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see .
//
@@ -43,8 +43,10 @@
// -------------------- mview
#include "Core.hh"
+#include
-//== IMPLEMENTATION ==========================================================
+
+//== IMPLEMENTATION ==========================================================
@@ -57,7 +59,7 @@ void Core::slotExecuteScript( QString _script ) {
}
void Core::slotGetScriptingEngine( QScriptEngine*& _engine ) {
- _engine = &scriptEngine_;
+ _engine = &scriptEngine_;
}
void Core::slotGetAllAvailableFunctions( QStringList& _functions ) {
@@ -65,11 +67,29 @@ void Core::slotGetAllAvailableFunctions( QStringList& _functions ) {
}
void Core::scriptLogFunction( QString _output) {
- emit scriptLog(_output);
+ emit scriptLog(_output);
+}
+
+void Core::createWidget(QString _objectName, QString _uiFilename) {
+ QUiLoader loader;
+
+ QFile uiFile(_uiFilename);
+ uiFile.open(QIODevice::ReadOnly);
+ QWidget *ui = loader.load(&uiFile);
+ uiFile.close();
+
+ QScriptValue scriptUi = scriptEngine_.newQObject(ui, QScriptEngine::ScriptOwnership);
+ scriptEngine_.globalObject().setProperty(_objectName, scriptUi);
+
+
+ ui->show();
+
+// core.createWidget("calc1","/data/home1/moebius/Calculator.ui");
+
}
//=============================================================================
-//== Script Special Functions =================================================
+//== Script Special Functions =================================================
//=============================================================================
QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine)
@@ -80,13 +100,13 @@ QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine)
result.append(" ");
result.append(context->argument(i).toString());
}
-
+
// Get the textedit for Output ( Set in Core.cc )
QScriptValue calleeData = context->callee().property("textedit");
Core *widget = qobject_cast(calleeData.toQObject());
-
- widget->scriptLogFunction(result);
-
+
+ widget->scriptLogFunction(result);
+
return engine->undefinedValue();
}
diff --git a/CoreApp/CoreApp.pro b/CoreApp/CoreApp.pro
index bcb0e45b9ea206779bacfdda901f549ee5732074..ffbe9be73a2104ea662febc2cee5701e08d4beab 100644
--- a/CoreApp/CoreApp.pro
+++ b/CoreApp/CoreApp.pro
@@ -11,6 +11,7 @@ openmesh()
glut()
glew()
openmp()
+qt()
DIRECTORIES = ../ ../Core ../Logging \
../Scripting ../Scripting/scriptPrototypes ../Scripting/scriptWrappers ../SimpleOpt \
diff --git a/widgets/coreWidget/CoreWidget.cc b/widgets/coreWidget/CoreWidget.cc
index f29e0ad937e7a67debf22a60e801e05f68245589..909d37ac3bea3c6243d170b2eb9726ca87351905 100644
--- a/widgets/coreWidget/CoreWidget.cc
+++ b/widgets/coreWidget/CoreWidget.cc
@@ -320,15 +320,15 @@ CoreWidget::toggleLogger() {
OpenFlipper::Options::hideLogger( !OpenFlipper::Options::hideLogger() );
// Hide/Show Logger
- hideLogger( OpenFlipper::Options::hideLogger() );
+ showLogger( !OpenFlipper::Options::hideLogger() );
}
/** Hide or show logger
*/
void
-CoreWidget::hideLogger(bool _hide) {
+CoreWidget::showLogger(bool _state) {
//Hide Logger
- if ( _hide ) {
+ if ( !_state ) {
QList wsizes( splitter_->sizes() );
// Remember old size
@@ -361,7 +361,18 @@ void
CoreWidget::toggleToolbox() {
//toggle
- OpenFlipper::Options::hideToolbox(!OpenFlipper::Options::hideToolbox());
+ showToolbox( OpenFlipper::Options::hideToolbox() );
+}
+
+//-----------------------------------------------------------------------------
+
+/** Hide or show toolbox
+ */
+void
+CoreWidget::showToolbox( bool _state ) {
+
+ //toggle
+ OpenFlipper::Options::hideToolbox( !_state );
if ( OpenFlipper::Options::hideToolbox() ){
//hide all toolWidgets
diff --git a/widgets/coreWidget/CoreWidget.hh b/widgets/coreWidget/CoreWidget.hh
index 6eaf2870167ad5d8c502b42d848738d542421b78..b4f6ece67290f63a308b38e9c4350cada69f58b7 100644
--- a/widgets/coreWidget/CoreWidget.hh
+++ b/widgets/coreWidget/CoreWidget.hh
@@ -212,11 +212,14 @@ public:
void toggleLogger();
/// Change visibility of the logger
- void hideLogger(bool _hide);
+ void showLogger(bool _state);
/// Hide or show toolbox area
void toggleToolbox();
+ /// Show or hide toolbox
+ void showToolbox( bool _state );
+
/** @} */
//===========================================================================