Ejemplo n.º 1
0
QWidget * ScriptToolbox::loadUi(const QString & screenName, QWidget * parent)
{
    if(screenName.isEmpty())
        return 0;

    q.prepare("SELECT *"
              "  FROM uiform"
              " WHERE((uiform_name=:uiform_name)"
              "   AND (uiform_enabled))"
              " ORDER BY uiform_order"
              " LIMIT 1;");
    q.bindValue(":uiform_name", screenName);
    q.exec();
    if(!q.first())
    {
        QMessageBox::critical(0, tr("Could Not Create Form"),
                              tr("Could not create the required form. Either an error occurred or the specified form does not exist.") );
        return 0;
    }

    XUiLoader loader;
    QByteArray ba = q.value("uiform_source").toByteArray();
    QBuffer uiFile(&ba);
    if(!uiFile.open(QIODevice::ReadOnly))
    {
        QMessageBox::critical(0, tr("Could not load file"),
                              tr("There was an error loading the UI Form from the database."));
        return 0;
    }
    QWidget *ui = loader.load(&uiFile, parent);
    uiFile.close();

    return ui;
}
Ejemplo n.º 2
0
        QWidget *ActionProxyWidget::CreateNewOpenSimWorld()
        {
            QWidget *new_os_world_widget;
            current_grid_info_map_.clear();

            QUiLoader loader;
            QFile uiFile("./data/ui/ether/world-edit-opensim.ui");
            new_os_world_widget = loader.load(&uiFile, 0);
            uiFile.close();

            QPushButton *button;
            button = new_os_world_widget->findChild<QPushButton*>("pushButtonGetGridInfo");
            connect(button, SIGNAL( clicked() ), SLOT( GridInfoRequested() ));

            button = new_os_world_widget->findChild<QPushButton*>("pushButtonSave");
            connect(button, SIGNAL( clicked() ), SLOT( SaveInformation() ));

            QPixmap pic = CretatePicture(QSize(150,150), "./data/ui/images/ether/world.png");
            QLabel *pic_label = new_os_world_widget->findChild<QLabel*>("pictureLabel");
            pic_label->setPixmap(pic);

            current_type_ = "new-world-opensim";
            current_os_world_data_ = 0;

            return new_os_world_widget;
        }
Ejemplo n.º 3
0
hotkey_parser::hotkey_parser(const wxString& uikeys_filename) : m_filename( uikeys_filename )
{
	//we will read the uikeys.txt now to get the key profile
	//1. Fill the profile with spring's default bindings
	KeynameConverter::initialize();

	this->m_bindings = SpringDefaultProfile::getBindings();

	//2. now read uikeys.txt and modify the default profile
	wxTextFile uiFile( this->m_filename );

	if ( !uiFile.Open() )
	{
		wxLogWarning( _( "can't open " ) + uikeys_filename );
		return;
	}

	wxString line;
	for ( line = uiFile.GetFirstLine(); !uiFile.Eof(); line = uiFile.GetNextLine() )
	{
		if ( line.Trim().StartsWith( wxT("//") ) )
		{
			continue;
		}

		if ( line.size() == 0 )
		{
			continue;
		}

		this->processLine( line );
	}
}
Ejemplo n.º 4
0
void QgsSaveStyleToDbDialog::mFilePickButton_clicked()
{
  QgsSettings myQSettings;  // where we keep last used filter in persistent state
  QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();

  QString myFileName = QFileDialog::getOpenFileName( this, tr( "Attach Qt Designer UI File" ), myLastUsedDir, tr( "Qt Designer UI file .ui" ) + " (*.ui)" );
  if ( myFileName.isNull() )
  {
    return;
  }
  QFileInfo myFI( myFileName );
  QFile uiFile( myFI.filePath() );

  QString myPath = myFI.path();
  myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath );

  if ( uiFile.open( QIODevice::ReadOnly ) )
  {
    QString content( uiFile.readAll() );
    QDomDocument doc;

    if ( !doc.setContent( content ) || doc.documentElement().tagName().compare( QLatin1String( "ui" ) ) )
    {
      QMessageBox::warning( this, tr( "Attach UI File" ),
                            tr( "The selected file does not appear to be a valid Qt Designer UI file." ) );
      return;
    }
    mUIFileContent = content;
    mFileNameLabel->setText( myFI.fileName() );
  }
}
Ejemplo n.º 5
0
        QWidget *ActionProxyWidget::OpenSimAvatarEditWidget(Data::OpenSimAvatar *data)
        {
            QWidget *os_edit_widget;

            QUiLoader loader;
            QFile uiFile("./data/ui/ether/avatar-edit-opensim.ui");
            os_edit_widget = loader.load(&uiFile, 0);
            uiFile.close();

            QLineEdit *line_edit;
            line_edit = os_edit_widget->findChild<QLineEdit*>("firstNameLineEdit");
            line_edit->setText(data->firstName());
            line_edit = os_edit_widget->findChild<QLineEdit*>("lastNameLineEdit");
            line_edit->setText(data->lastName());
            line_edit = os_edit_widget->findChild<QLineEdit*>("passwordLineEdit");
            line_edit->setText(data->password());

            QPixmap pic = CretatePicture(QSize(150,150), data->pixmapPath());
            QLabel *pic_label = os_edit_widget->findChild<QLabel*>("pictureLabel");
            pic_label->setPixmap(pic);

            QPushButton *button = os_edit_widget->findChild<QPushButton*>("pushButtonSave");
            connect(button, SIGNAL( clicked() ), SLOT( SaveInformation() ));

            // Store data pointer and define types for save function
            current_type_ = "avatar-opensim";
            current_os_avatar_data_ = data;

            return os_edit_widget;
        }
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
	Q_INIT_RESOURCE(rtfedit);
	
    QApplication app(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    QScriptEngine engine;

    QFile scriptFile(":/rtfedit.js");
    scriptFile.open(QIODevice::ReadOnly);
    engine.evaluate(QObject::tr(scriptFile.readAll()));
    scriptFile.close();

    RTFUiLoader loader;
    QFile uiFile(":/rtfedit.ui");
    uiFile.open(QIODevice::ReadOnly);
    QWidget *ui = loader.load(&uiFile);
    uiFile.close();

    QScriptValue func = engine.evaluate("RTF");
    QScriptValue scriptUi = engine.newQObject(ui);
    QScriptValue table = func.construct(QScriptValueList() << scriptUi);
    if(engine.hasUncaughtException()) {
    	QScriptValue value = engine.uncaughtException();
    	QString lineNumber = QString("\nLine Number:%1\n").arg(engine.uncaughtExceptionLineNumber());
    	QStringList btList = engine.uncaughtExceptionBacktrace();
    	QString trace;
    	for(short i=0; i<btList.size(); ++i)
    		trace += btList.at(i);
    	QMessageBox::information(NULL, QObject::tr("Exception"), value.toString() + lineNumber + trace );
    }

    ui->show();
    return app.exec();
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(tetrix);

//! [1]
    QApplication app(argc, argv);
    QScriptEngine engine;

    QScriptValue Qt = engine.newQMetaObject(QtMetaObject::get());
    Qt.setProperty("App", engine.newQObject(&app));
    engine.globalObject().setProperty("Qt", Qt);
//! [1]

#ifndef QT_NO_SCRIPTTOOLS
    QScriptEngineDebugger debugger;
    debugger.attachTo(&engine);
    QMainWindow *debugWindow = debugger.standardWindow();
    debugWindow->resize(1024, 640);
#endif

//! [2]
    evaluateFile(engine, ":/tetrixpiece.js");
    evaluateFile(engine, ":/tetrixboard.js");
    evaluateFile(engine, ":/tetrixwindow.js");
//! [2]

//! [3]
    TetrixUiLoader loader;
    QFile uiFile(":/tetrixwindow.ui");
    uiFile.open(QIODevice::ReadOnly);
    QWidget *ui = loader.load(&uiFile);
    uiFile.close();

    QScriptValue ctor = engine.evaluate("TetrixWindow");
    QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
    QScriptValue tetrix = ctor.construct(QScriptValueList() << scriptUi);
//! [3]

    QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton");
#ifndef QT_NO_SCRIPTTOOLS
    QObject::connect(debugButton, SIGNAL(clicked()),
                     debugger.action(QScriptEngineDebugger::InterruptAction),
                     SIGNAL(triggered()));
    QObject::connect(debugButton, SIGNAL(clicked()),
                     debugWindow, SLOT(show()));
#else
    debugButton->hide();
#endif

//! [4]
    ui->resize(550, 370);
    ui->show();

    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
    return app.exec();
//! [4]
}
Ejemplo n.º 8
0
int main( int argc, char** argv )
{
    osg::ArgumentParser arguments( &argc, argv );
    
    std::string uiFile("Gui/Samples/CarHud.xaml");
    arguments.read( "--ui", uiFile );
    
    osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
    if ( !scene ) scene = osgDB::readNodeFile("cessna.osg");
    
    osg::ref_ptr<NoesisDrawable> noesis = new NoesisDrawable(uiFile);
    
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    geode->setCullingActive( false );
    geode->addDrawable( noesis.get() );
    geode->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
    geode->getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
    
    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
    camera->setClearMask( GL_STENCIL_BUFFER_BIT );
    camera->setClearStencil( 1 );
    camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
    camera->setRenderOrder( osg::Camera::POST_RENDER );
    camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
    camera->addChild( geode.get() );
    
    osg::ref_ptr<osg::Group> root = new osg::Group;
    root->addChild( scene.get() );
    root->addChild( camera.get() );
    
    osgViewer::Viewer viewer;
    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
    viewer.addEventHandler( new osgViewer::StatsHandler );
    viewer.addEventHandler( new osgViewer::WindowSizeHandler );
    viewer.setSceneData( root.get() );
    viewer.setUpViewInWindow( 50, 50, 800, 600 );
    //viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded );
    viewer.realize();
    
    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>( viewer.getCamera()->getGraphicsContext() );
    if ( gw )
    {
        // Send a window size event for resizing the UI
        int x, y, w, h; gw->getWindowRectangle( x, y, w, h );
        viewer.getEventQueue()->windowResize( x, y, w, h );
    }
    return viewer.run();
}
Ejemplo n.º 9
0
Archivo: main.cpp Proyecto: cedrus/qt4
int main(int argc, char **argv)
{
    Q_INIT_RESOURCE(calculator);

    QApplication app(argc, argv);
//! [0a]
    QScriptEngine engine;
//! [0a]

#if !defined(QT_NO_SCRIPTTOOLS)
    QScriptEngineDebugger debugger;
    debugger.attachTo(&engine);
    QMainWindow *debugWindow = debugger.standardWindow();
    debugWindow->resize(1024, 640);
#endif

//! [0b]
    QString scriptFileName(":/calculator.js");
    QFile scriptFile(scriptFileName);
    scriptFile.open(QIODevice::ReadOnly);
    engine.evaluate(scriptFile.readAll(), scriptFileName);
    scriptFile.close();
//! [0b]

//! [1]
    QUiLoader loader;
    QFile uiFile(":/calculator.ui");
    uiFile.open(QIODevice::ReadOnly);
    QWidget *ui = loader.load(&uiFile);
    uiFile.close();
//! [1]

//! [2]
    QScriptValue ctor = engine.evaluate("Calculator");
    QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
    QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
//! [2]

#if !defined(QT_NO_SCRIPTTOOLS)
    QLineEdit *display = qFindChild<QLineEdit*>(ui, "display");
    QObject::connect(display, SIGNAL(returnPressed()),
                     debugWindow, SLOT(show()));
#endif
//! [3]
    ui->show();
    return app.exec();
//! [3]
}
Ejemplo n.º 10
0
void uiforms::sTest()
{
  q.prepare("SELECT *"
            "  FROM uiform "
            " WHERE(uiform_id=:uiform_id);");
  q.bindValue(":uiform_id", _uiform->id());
  q.exec();
  if (q.first())
    ; // everything's OK
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
    return;
  
  XMainWindow * wnd = new XMainWindow();
  wnd->setObjectName(q.value("uiform_name").toString());

  XUiLoader loader;
  QByteArray ba = q.value("uiform_source").toString().toUtf8();
  qDebug("about to load a uiFile with %s", ba.constData());
  QBuffer uiFile(&ba);
  if(!uiFile.open(QIODevice::ReadOnly))
  {
    QMessageBox::critical(this, tr("Could not load file"),
        tr("There was an error loading the UI Form from the database."));
    return;
  }
  QWidget *ui = loader.load(&uiFile);
  if (ui)
  {
    wnd->setWindowTitle(ui->windowTitle());
    wnd->setCentralWidget(ui);
    omfgThis->handleNewWindow(wnd);
  }
  else
    QMessageBox::critical(this, tr("Could not load file"),
                          tr("<p>Could not interpret the UI Form data "
                             "as a UI definition."));
  uiFile.close();
}
Ejemplo n.º 11
0
        QWidget *ActionProxyWidget::OpenSimWorldEditWidget(Data::OpenSimWorld *data)
        {
            QWidget *os_world_edit_widget;
            current_grid_info_map_.clear();

            QUiLoader loader;
            QFile uiFile("./data/ui/ether/world-edit-opensim.ui");
            os_world_edit_widget = loader.load(&uiFile, 0);
            uiFile.close();

            QLineEdit *line_edit;
            line_edit = os_world_edit_widget->findChild<QLineEdit*>("loginURLLineEdit");
            line_edit->setText(data->loginUrl().toString());
            line_edit = os_world_edit_widget->findChild<QLineEdit*>("startLocationLineEdit");
            line_edit->setText(data->startLocation());

            QPushButton *button;
            button = os_world_edit_widget->findChild<QPushButton*>("pushButtonGetGridInfo");
            connect(button, SIGNAL( clicked() ), SLOT( GridInfoRequested() ));

            button = os_world_edit_widget->findChild<QPushButton*>("pushButtonSave");
            connect(button, SIGNAL( clicked() ), SLOT( SaveInformation() ));

            QPixmap pic = CretatePicture(QSize(150,150), data->pixmapPath());
            QLabel *pic_label = os_world_edit_widget->findChild<QLabel*>("pictureLabel");
            pic_label->setPixmap(pic);

            // Grid info from file if it is there
            if (data->gridInfo().count() > 0)
            {
                SetGridInfoToWorldWidget(os_world_edit_widget, data->gridInfo());
                QLabel *status = os_world_edit_widget->findChild<QLabel*>("gridInfoStatusLabel");
                if (status)
                    status->setText("Grid info from local storage");
            }

            // Store data pointer and define types for save function
            current_type_ = "world-opensim";
            current_os_world_data_ = data;
            current_grid_info_map_ = data->gridInfo();

            return os_world_edit_widget;
        }
Ejemplo n.º 12
0
void hotkey_parser::setUiKeys(const wxString& filename )
{
	if (filename.empty()) {
		wxLogError( _( "hotkey_parser: invalid filename" ));
		return;
	}
	//we will read the uikeys.txt now to get the key profile
	//1. Fill the profile with spring's default bindings
	KeynameConverter::initialize();

	this->m_bindings = SpringDefaultProfile::getBindings();

	//2. now read uikeys.txt and modify the default profile
	wxTextFile uiFile( this->m_filename );

	if ( !uiFile.Exists() || !uiFile.Open() ) {
		wxLogWarning( _( "hotkey_parser: can't open " ) + filename );
		return;
	}

	wxString line;
	for ( line = uiFile.GetFirstLine(); !uiFile.Eof(); line = uiFile.GetNextLine() ) {
		if ( line.Trim().StartsWith( wxT("//SPRINGSETTINGS DO NOT TOUCH") ) ) {
			this->m_dontTouch = true;
		}

		//look for comments
		int cmtPos = line.Find(wxT("//"));
		if (cmtPos != -1) {
			line.Truncate(cmtPos);	//comment found. cut it.
		}

		line = line.Trim();

		if ( line.size() == 0 )
			continue;

		this->processLine( line );
	}
	this->m_filename = filename;
}
Ejemplo n.º 13
0
        QWidget *ActionProxyWidget::CreateNewOpenSimAvatar()
        {
            QWidget *new_os_avatar;

            QUiLoader loader;
            QFile uiFile("./data/ui/ether/avatar-edit-opensim.ui");
            new_os_avatar = loader.load(&uiFile, 0);
            uiFile.close();

            QPushButton *button = new_os_avatar->findChild<QPushButton*>("pushButtonSave");
            connect(button, SIGNAL( clicked() ), SLOT( SaveInformation() ));

            QPixmap pic = CretatePicture(QSize(150,150), "./data/ui/images/ether/naali.png");
            QLabel *pic_label = new_os_avatar->findChild<QLabel*>("pictureLabel");
            pic_label->setPixmap(pic);

            // Store data pointer and define types for save function
            current_type_ = "new-avatar-opensim";
            current_os_avatar_data_ = 0;

            return new_os_avatar;
        }
Ejemplo n.º 14
0
Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{
    const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w);
    const Designer::FormClassWizardParameters params = wizardDialog->parameters();

    if (params.uiTemplate().isEmpty()) {
        *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents");
        return Core::GeneratedFiles();
    }

    // header
    const QString formFileName = buildFileName(params.path(), params.uiFile(), formSuffix());
    const QString headerFileName = buildFileName(params.path(), params.headerFile(), headerSuffix());
    const QString sourceFileName = buildFileName(params.path(), params.sourceFile(), sourceSuffix());

    Core::GeneratedFile headerFile(headerFileName);
    headerFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND));

    // Source
    Core::GeneratedFile sourceFile(sourceFileName);
    sourceFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND));

    // UI
    Core::GeneratedFile uiFile(formFileName);
    uiFile.setContents(params.uiTemplate());
    uiFile.setEditorKind(QLatin1String(Constants::C_FORMEDITOR));

    QString source, header;
    Designer::FormClassWizardGenerationParameters generationParameters;
    generationParameters.fromSettings(Core::ICore::instance()->settings());
    params.generateCpp(generationParameters, &header, &source);
    sourceFile.setContents(source);
    headerFile.setContents(header);

    if (Designer::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << '\n' << header << '\n' << source;

    return  Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
}
Ejemplo n.º 15
0
Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{
    const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w);
    const Designer::FormClassWizardParameters params = wizardDialog->parameters();

    if (params.uiTemplate.isEmpty()) {
        *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents");
        return Core::GeneratedFiles();
    }

    // header
    const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix());
    const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
    const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());

    Core::GeneratedFile headerFile(headerFileName);
    headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    // Source
    Core::GeneratedFile sourceFile(sourceFileName);
    sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    // UI
    Core::GeneratedFile uiFile(formFileName);
    uiFile.setContents(params.uiTemplate);
    uiFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    QString source, header;

    QtDesignerFormClassCodeGenerator::generateCpp(params, &header, &source);
    sourceFile.setContents(source);
    headerFile.setContents(header);

    if (Designer::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << '\n' << header << '\n' << source;

    return  Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
}
Ejemplo n.º 16
0
void InventoryWindow::InitInventoryWindow()
{
    QUiLoader loader;
    loader.setLanguageChangeEnabled(true);
    QFile uiFile("./data/ui/inventory.ui");
    mainWidget_ = loader.load(&uiFile, this);
    uiFile.close();

    setWindowTitle(QApplication::translate("Inventory::InventoryWindow", "Inventory"));

    // Layout
    layout_ = new QVBoxLayout(this);
    layout_->addWidget(mainWidget_);
    layout_->setContentsMargins(0, 0, 0, 0);
    setLayout(layout_);

///\todo Disable crappy search line edit feature for now. Maybe do better some day.
    /*
        QHBoxLayout *line_layout = new QHBoxLayout();
        line_layout->setContentsMargins(7, 0, 7, 0);
        QLineEdit *lineEditSearch_ = new QLineEdit(mainWidget_);
        QObject::connect(lineEditSearch_, SIGNAL(textChanged(const QString &)), this, SLOT(Search(const QString &)));
        lineEditSearch_->setText("Search...");
        line_layout->addWidget(lineEditSearch_);
    */
    // Create inventory tree view.
    treeView_ = new InventoryTreeView(mainWidget_);

//    layout_->addLayout(line_layout);
    layout_->addWidget(treeView_);

    // Connect signals
    ///\todo Connecting both these signals causes WebDav inventory to work incorrectly.
//    connect(treeView_, SIGNAL(expanded(const QModelIndex &)), this, SLOT(ExpandFolder(const QModelIndex &)));
    connect(treeView_, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(OpenItem()));

    CreateActions();
}
void RenderWindow::slotChangedComboFractal(int indexInComboBox)
{
	QString comboName = this->sender()->objectName();
	int index = qobject_cast<QComboBox *>(this->sender())->itemData(indexInComboBox).toInt();
	int fractalNumber = comboName.right(1).toInt() - 1;

	QString fullFormulaName = fractalList[index].nameInComboBox;
	if (fractalList[index].internalID > 0)
	{
		QString formulaName = fractalList[index].internalName;
		QString uiFilename =
			systemData.sharedDir + "qt_data" + QDir::separator() + "fractal_" + formulaName + ".ui";

		if (fractalWidgets[fractalNumber]) delete fractalWidgets[fractalNumber];
		fractalWidgets[fractalNumber] = NULL;

		MyUiLoader loader;
		QFile uiFile(uiFilename);

		if (uiFile.exists())
		{
			uiFile.open(QFile::ReadOnly);
			fractalWidgets[fractalNumber] = loader.load(&uiFile);
			QVBoxLayout *layout = ui->dockWidget_fractal->findChild<QVBoxLayout *>(
				"verticalLayout_fractal_" + QString::number(fractalNumber + 1));
			layout->addWidget(fractalWidgets[fractalNumber]);
			uiFile.close();
			fractalWidgets[fractalNumber]->show();
			automatedWidgets->ConnectSignalsForSlidersInWindow(fractalWidgets[fractalNumber]);
			SynchronizeInterfaceWindow(
				fractalWidgets[fractalNumber], &gParFractal->at(fractalNumber), qInterface::write);

			QFrame *frame = ui->tabWidget_fractals->findChild<QFrame *>(
				"frame_iterations_formula_" + QString::number(fractalNumber + 1));
			MyCheckBox *caddCheckBoxframe = frame->findChild<MyCheckBox *>(
				QString("checkBox_dont_add_c_constant_") + QString::number(fractalNumber + 1));

			switch (fractalList[index].cpixelAddition)
			{
				case fractal::cpixelEnabledByDefault:
					caddCheckBoxframe->setText(QObject::tr("Don't add global C constant"));
					caddCheckBoxframe->setEnabled(true);
					break;

				case fractal::cpixelDisabledByDefault:
				{
					caddCheckBoxframe->setText(QObject::tr("Add global C constant"));
					caddCheckBoxframe->setEnabled(true);
					break;
				}

				case fractal::cpixelAlreadyHas:
				{
					caddCheckBoxframe->setText(QObject::tr("Don't add global C constant"));
					caddCheckBoxframe->setEnabled(false);
					break;
				}
			}

			fractal::enumCPixelAddition cPixelAddition = fractalList[index].cpixelAddition;
			bool boleanState = ui->groupCheck_boolean_operators->isChecked();
			if (cPixelAddition == fractal::cpixelAlreadyHas)
				ui->tabWidget_fractals
					->findChild<QGroupBox *>(
						"groupBox_c_constant_addition_" + QString::number(fractalNumber + 1))
					->setVisible(false);
			else
				ui->tabWidget_fractals
					->findChild<QGroupBox *>(
						"groupBox_c_constant_addition_" + QString::number(fractalNumber + 1))
					->setVisible(boleanState);

			if (fractalList[index].internalID == fractal::kaleidoscopicIFS)
			{
				QWidget *pushButton_preset_dodecahedron =
					fractalWidgets[fractalNumber]->findChild<QWidget *>("pushButton_preset_dodecahedron");
				QApplication::connect(pushButton_preset_dodecahedron, SIGNAL(clicked()), this,
					SLOT(slotPressedButtonIFSDefaultsDodecahedron()));
				QWidget *pushButton_preset_icosahedron =
					fractalWidgets[fractalNumber]->findChild<QWidget *>("pushButton_preset_icosahedron");
				QApplication::connect(pushButton_preset_icosahedron, SIGNAL(clicked()), this,
					SLOT(slotPressedButtonIFSDefaultsIcosahedron()));
				QWidget *pushButton_preset_octahedron =
					fractalWidgets[fractalNumber]->findChild<QWidget *>("pushButton_preset_octahedron");
				QApplication::connect(pushButton_preset_octahedron, SIGNAL(clicked()), this,
					SLOT(slotPressedButtonIFSDefaultsOctahedron()));
				QWidget *pushButton_preset_menger_sponge =
					fractalWidgets[fractalNumber]->findChild<QWidget *>("pushButton_preset_menger_sponge");
				QApplication::connect(pushButton_preset_menger_sponge, SIGNAL(clicked()), this,
					SLOT(slotPressedButtonIFSDefaultsMengerSponge()));
				QWidget *pushButton_preset_reset =
					fractalWidgets[fractalNumber]->findChild<QWidget *>("pushButton_preset_reset");
				QApplication::connect(pushButton_preset_reset, SIGNAL(clicked()), this,
					SLOT(slotPressedButtonIFSDefaultsReset()));
			}
		}
		else
		{
			cErrorMessage::showMessage(
				QString("Can't open file ") + uiFilename + QString("\nFractal ui file can't be loaded"),
				cErrorMessage::errorMessage, gMainInterface->mainWindow);
		}
	}
	else
	{
		if (fractalWidgets[fractalNumber]) delete fractalWidgets[fractalNumber];
		fractalWidgets[fractalNumber] = NULL;
	}
	ui->tabWidget_fractals->setTabText(
		fractalNumber, QString("#%1: %2").arg(fractalNumber + 1).arg(fullFormulaName));
	// ui->tabWidget_fractals->setTabIcon(fractalNumber, QIcon(fractalList[index].getIconName()));
}
Ejemplo n.º 18
0
QWidget *ScriptToolbox::openWindow(QString name, QWidget *parent, Qt::WindowModality modality, Qt::WindowFlags flags)
{
    QWidget *returnVal = 0;

    XSqlQuery screenq;
    screenq.prepare("SELECT * "
                    "FROM uiform "
                    "WHERE (uiform_name=:uiform_name);");
    screenq.bindValue(":uiform_name", name);
    screenq.exec();
    if (screenq.first())
    {
        XUiLoader loader;
        QByteArray ba = screenq.value("uiform_source").toByteArray();
        QBuffer uiFile(&ba);
        if (!uiFile.open(QIODevice::ReadOnly))
        {
            QMessageBox::critical(0, tr("Could not load UI"),
                                  tr("<p>There was an error loading the UI Form "
                                     "from the database."));
            return 0;
        }
        QWidget *ui = loader.load(&uiFile);
        uiFile.close();

        if (ui->inherits("QDialog"))
        {
            flags |= Qt::Dialog;
            if (modality == Qt::NonModal)
                modality = Qt::WindowModal;
        }

        XMainWindow *window = new XMainWindow(parent,
                                              screenq.value("uiform_name").toString(),
                                              flags);

        window->setCentralWidget(ui);
        window->setWindowTitle(ui->windowTitle());
        window->setWindowModality(modality);

        if (ui->inherits("QDialog"))
        {
            QDialog *innerdlg = qobject_cast<QDialog*>(ui);

            connect(innerdlg, SIGNAL(finished(int)), window, SLOT(close()));
            connect(innerdlg, SIGNAL(accepted()),    window, SLOT(close()));
            connect(innerdlg, SIGNAL(rejected()),    window, SLOT(close()));

            // alternative to creating mydialog object:
            // for each property of mydialog (including functions)
            //   add a property to _engine's mywindow property
            if (engine(window))
            {
                QScriptValue mydialog = engine(window)->newQObject(innerdlg);
                engine(window)->globalObject().setProperty("mydialog", mydialog);
            }
            else
                qWarning("Could not find the script engine to embed a dialog inside "
                         "a placeholder window");

            omfgThis->handleNewWindow(window);
            returnVal = ui;
        }
        else
        {
            omfgThis->handleNewWindow(window);
            returnVal = window;
        }
        _lastWindow = window;
    }
    else if (screenq.lastError().type() != QSqlError::None)
    {
        systemError(0, screenq.lastError().databaseText(), __FILE__, __LINE__);
        return 0;
    }

    return returnVal;
}
Ejemplo n.º 19
0
void setup::setCurrentIndex(XTreeWidgetItem* item)
{
  QString uiName = item->data(0, Xt::RawRole).toString();
  QString label = "<span style=\" font-size:14pt; font-weight:600;\">%1</span></p></body></html>";

  if (_itemMap.contains(uiName) && _itemMap.value(uiName).index >= 0)
  {
    _stack->setCurrentIndex(_itemMap.value(uiName).index);
    _stackLit->setText(label.arg(item->text(0)));
    return;
  }
  else if (_itemMap.contains(uiName) && !item->isDisabled())
  {
    // First look for a class...
    QWidget *w = xtGetScreen(uiName, this);

    if (w)
      _itemMap[uiName].implementation = w;
    else
    {
      // No class, so look for an extension
      XSqlQuery screenq;
      screenq.prepare("SELECT * "
                      "  FROM uiform "
                      " WHERE((uiform_name=:uiform_name)"
                      "   AND (uiform_enabled))"
                      " ORDER BY uiform_order DESC"
                      " LIMIT 1;");
      screenq.bindValue(":uiform_name", uiName);
      screenq.exec();
      if (screenq.first())
      {     
        QUiLoader loader;
        QByteArray ba = screenq.value("uiform_source").toByteArray();
        QBuffer uiFile(&ba);
        if (!uiFile.open(QIODevice::ReadOnly))
          QMessageBox::critical(0, tr("Could not load UI"),
                                tr("<p>There was an error loading the UI Form "
                                   "from the database."));
        w = loader.load(&uiFile);
        w->setObjectName(uiName);
        uiFile.close();

        // Load scripts if applicable
        XSqlQuery scriptq;
        scriptq.prepare("SELECT script_source, script_order"
                        "  FROM script"
                        " WHERE((script_name=:script_name)"
                        "   AND (script_enabled))"
                        " ORDER BY script_order;");
        scriptq.bindValue(":script_name", uiName);
        scriptq.exec();

        QScriptEngine* engine = new QScriptEngine();
        if (_preferences->boolean("EnableScriptDebug"))
        {
          QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
          debugger->attachTo(engine);
        }
        omfgThis->loadScriptGlobals(engine);
        QScriptValue mywindow = engine->newQObject(w);
        engine->globalObject().setProperty("mywindow", mywindow);

        while(scriptq.next())
        {
          QString script = scriptHandleIncludes(scriptq.value("script_source").toString());
          QScriptValue result = engine->evaluate(script, uiName);
          if (engine->hasUncaughtException())
          {
            int line = engine->uncaughtExceptionLineNumber();
            qDebug() << "uncaught exception at line" << line << ":" << result.toString();
          }
        }
        _itemMap[uiName].implementation = engine;
      }
    }

    if (w)
    {
      // Hide buttons out of context here
      QWidget* close = w->findChild<QWidget*>("_close");
      if (close)
        close->hide();
      QWidget* buttons = w->findChild<QDialogButtonBox*>();
      if (buttons)
        buttons->hide();

      //Set mode if applicable
      int mode = _itemMap.value(uiName).mode;
      if (mode && w->inherits("XDialog"))
      {
        XWidget* x = dynamic_cast<XWidget*>(w);
        ParameterList params;
        if (mode == cEdit)
          params.append("mode", "edit");
        else if (mode == cView)
          params.append("mode", "view");
        if (x)
          x->set(params);
      }

      int idx = _stack->count();
      _itemMap[uiName].index = idx;
      _stack->addWidget(w);
      _stack->setCurrentIndex(idx);

      _stackLit->setText(label.arg(item->text(0)));
      return;
    }
  }

  // Nothing here so try the next one
  XTreeWidgetItem* next = dynamic_cast<XTreeWidgetItem*>(_tree->itemBelow(item));
  if (next)
    setCurrentIndex(next);
}