示例#1
0
文件: UiAPI.cpp 项目: A-K/naali
QWidget *UiAPI::LoadFromFile(const QString &filePath, bool addToScene, QWidget *parent)
{
    QWidget *widget = 0;

    if (AssetAPI::ParseAssetRefType(filePath) != AssetAPI::AssetRefLocalPath)
    {
        AssetPtr asset = owner->Asset()->GetAsset(filePath);
        if (!asset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not loaded to the asset system. Call RequestAsset prior to use!").toStdString());
            return 0;
        }

        QtUiAsset *uiAsset = dynamic_cast<QtUiAsset*>(asset.get());
        if (!uiAsset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not of type QtUiFile!").toStdString());
            return 0;
        }
        if (!uiAsset->IsLoaded())
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" data is not valid!").toStdString());
            return 0;
        }

        // Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
        QByteArray data = uiAsset->GetRefReplacedAssetData();
        
        QUiLoader loader;
        QDataStream dataStream(&data, QIODevice::ReadOnly);
        widget = loader.load(dataStream.device(), parent);
    }
    else // The file is from absolute source location.
    {
        QFile file(filePath);
        QUiLoader loader;
        file.open(QFile::ReadOnly);
        widget = loader.load(&file, parent);
    }

    if (!widget)
    {
        LogError(("LoadFromFile: Failed to load widget from file \"" + filePath + "\"!").toStdString());
        return 0;
    }

    if (addToScene && widget)
        AddWidgetToScene(widget);

    return widget;
}
示例#2
0
文件: main.cpp 项目: hkutangyu/QTDemo
int main(int argc, char **argv)
{
	Q_INIT_RESOURCE(table);
	
    QApplication app(argc, argv);
    QScriptEngine engine;

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

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

    QScriptValue func = engine.evaluate("Table");
    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();
}
示例#3
0
QWidget* FormModule::createWidgetFromUI(QWidget* parent, const QString& xml)
{
    QUiLoader loader;

    QDomDocument doc("mydocument");
    doc.setContent(xml.toUtf8());

    QDomNodeList strings=doc.elementsByTagName("string");
    int i=strings.size();
    while(--i>=0)
    {
        QDomElement e=strings.at(i).toElement();
        QString i18nd=e.attribute("comment").isEmpty()?QObject::tr(e.text().toUtf8()):QObject::tr(e.text().toUtf8(),e.attribute("comment").toUtf8());
        if (i18nd==e.text())
            continue;
        QDomNode n = e.firstChild();
        while (!n.isNull())
        {
            QDomNode nn=n.nextSibling();
            if (n.isCharacterData())
                e.removeChild(n);
            n = nn;
        }
        e.appendChild(e.ownerDocument().createTextNode(i18nd));
    }

    QByteArray ba = doc.toByteArray();
    QBuffer buffer(&ba);
    buffer.open(QIODevice::ReadOnly);

    QWidget* widget = loader.load(&buffer, parent);
    if( widget && parent && parent->layout() )
        parent->layout()->addWidget(widget);
    return widget;
}
示例#4
0
void OgreScriptEditor::InitEditorWindow()
{
    // Create widget from ui file
    QUiLoader loader;
    QFile file("./data/ui/ogrescripteditor.ui");
    if (!file.exists())
    {
        OgreAssetEditorModule::LogError("Cannot find OGRE Script Editor .ui file.");
        return;
    }

    mainWidget_ = loader.load(&file);
    file.close();

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

    // Get controls
    lineEditName_ = mainWidget_->findChild<QLineEdit *>("lineEditName");
    buttonSaveAs_ = mainWidget_->findChild<QPushButton *>("buttonSaveAs");
    buttonCancel_ = mainWidget_->findChild<QPushButton *>("buttonCancel");

    // Connect signals
    QObject::connect(buttonSaveAs_, SIGNAL(clicked()), this, SLOT(SaveAs()));
    QObject::connect(buttonCancel_, SIGNAL(clicked(bool)), this, SLOT(Close()));
    QObject::connect(lineEditName_, SIGNAL(textChanged(const QString &)), this, SLOT(ValidateScriptName(const QString &)));
}
示例#5
0
POCO_END_MANIFEST

//API stuff here first

//for javascript to load a .ui file and get the widget in return, to assign connections
QScriptValue RexQtScript::LoadUI(QScriptContext *context, QScriptEngine *engine)
{
	QWidget *widget;
	QScriptValue qswidget;
    
	boost::shared_ptr<QtUI::QtModule> qt_module = RexQtScript::staticframework->GetModuleManager()->GetModule<QtUI::QtModule>(Foundation::Module::MT_Gui).lock();
	boost::shared_ptr<QtUI::UICanvas> canvas_;
    
    //if ( qt_module.get() == 0)
    //    return NULL;

    canvas_ = qt_module->CreateCanvas(QtUI::UICanvas::External).lock();

    QUiLoader loader;
    QFile file("../RexQtScriptModule/proto/dialog.ui");
    widget = loader.load(&file); 

    canvas_->AddWidget(widget);

    // Set canvas size. 
    canvas_->resize(widget->size());
	canvas_->Show();

	qswidget = engine->newQObject(widget);

	return qswidget;
}
示例#6
0
UploadProgressWindow::UploadProgressWindow(InventoryModule *owner, QWidget *parent) :
    QWidget(parent), owner_(owner), mainWidget_(0), layout_(0), uploadCount_(0)
{
    QUiLoader loader;
    QFile file("./data/ui/uploadprogress.ui");
    file.open(QFile::ReadOnly);
    mainWidget_ = loader.load(&file, this);
    file.close();

    layout_ = new QVBoxLayout;
    layout_->addWidget(mainWidget_);
    setLayout(layout_);

    progressBar_ = mainWidget_->findChild<QProgressBar *>("progressBar");
    labelFileNumber_ = mainWidget_->findChild<QLabel *>("labelFileNumber");

    // Add widget to UI via ui services module
    boost::shared_ptr<UiServices::UiModule> ui_module =
        owner_->GetFramework()->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock();
    if (!ui_module.get())
        return;

    proxyWidget_ = ui_module->GetInworldSceneController()->AddWidgetToScene(
        this, UiServices::UiWidgetProperties("Upload Progress Window", UiServices::SceneWidget));
}
示例#7
0
void MainWindow::attachAllWidget()
{
	QString displayname;
	QUiLoader loader;
	//const int singletime = 1;
	QFile file;
	for(int i = 0; i < displayDocklist.size();i++)
	{
		displayname = QString("/usr/local/opi/ui/")+displayDocklist.at(i)+".ui";
		//pattach = new AttachChannelAccess(displayname.toStdString().c_str(), i, singletime );
		file.setFileName(displayname);
		file.open(QFile::ReadOnly);
		pwidget = loader.load(&file);
		vecACHAcc.push_back(pwidget);
		if (!pwidget)
		{
			 QWidget *page = new QWidget();
			 QPushButton *pbut = new QPushButton(page);
			 pbut -> setGeometry(0,0,180,40);
			 char display[30];
			 sprintf(display,"%s: %d",displayname.toStdString().c_str(), i);
			 pbut -> setText(display);
			 stackedWidget->addWidget(page);
		}
		else
		{
			pwidget->setAutoFillBackground (true);
			stackedWidget->addWidget(pwidget);
		};
	};
}
示例#8
0
QWidget *QtUiAsset::Instantiate(bool addToScene, QWidget *parent)
{
    if (!IsLoaded())
    {
        LogError("QtUiAsset::Instantiate: Cannot instantiate an unloaded UI Asset \"" + Name().toStdString() + "\"!");
        return 0;
    }

    // Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
    QByteArray data = GetRefReplacedAssetData();
        
    QUiLoader loader;
    QDataStream dataStream(&data, QIODevice::ReadOnly);
    QWidget *widget = loader.load(dataStream.device(), parent);

    if (!widget)
    {
        LogError("QtUiAsset::Instantiate: Failed to instantiate widget from UI asset \"" + Name().toStdString() + "\"!");
        return 0;
    }

    if (addToScene)
    {
        UiProxyWidget *proxy = assetAPI->GetFramework()->Ui()->AddWidgetToScene(widget);
        if (!proxy)
            LogError("QtUiAsset::Instantiate: Failed to add widget to main QGraphicsScene in UI asset \"" + Name().toStdString() + "\"!");
    }

    return widget;
}
示例#9
0
    void UICanvasTestEdit::InitEditorWindow()
    {
        boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock();

        // If this occurs, we're most probably operating in headless mode.
        if (ui_module.get() == 0)
            return;

        QUiLoader loader;
        QFile file("./data/ui/uicanvastestedit.ui");

        if (!file.exists())
        {
            QtModule::LogError("Cannot find UI canvas test editor .ui file.");
            return;
        }

        editor_widget_ = loader.load(&file);
        if (!editor_widget_)
            return;

        editor_widget_proxy_ = ui_module->GetSceneManager()->AddWidgetToScene(editor_widget_, UiServices::UiWidgetProperties(QPointF(60,60), editor_widget_->size(), Qt::Dialog, "3D GUI"));

		// Connect signals   
        QPushButton *button = editor_widget_->findChild<QPushButton *>("but_bind");
        if (button)
            QObject::connect(button, SIGNAL(clicked()), this, SLOT(BindCanvas()));
        button = editor_widget_->findChild<QPushButton *>("but_unbind");
        if (button)
            QObject::connect(button, SIGNAL(clicked()), this, SLOT(UnbindCanvas()));
        QObject::connect(editor_widget_proxy_, SIGNAL(Visible(bool)), this, SLOT(Shown(bool)));
    }
示例#10
0
Plugin::Plugin(const QVariantMap &metadata, Plugin::Type type)
    : m_metadata(metadata), m_type(type), m_enabled(true)
{

    if ( m_metadata.contains("ui") )
    {

       QStringList ui = m_metadata["ui"].toStringList();
       if ( ui.isEmpty() )
           ui << m_metadata["ui"].toString();


       foreach(QString file_name, ui)
       {
            QFile ui_file(QDir(string_data("plugin_dir"))
                          .absoluteFilePath(file_name) );
            if ( ui_file.open(QFile::ReadOnly|QFile::Text) )
            {
                QUiLoader loader;

                QWidget *widget = loader.load(&ui_file);
                if ( widget )
                {
                    if ( widget->windowIcon().isNull() )
                        widget->setWindowIcon(icon());
                    //((QObject*)widget)->setParent(this);
                    widget->hide();
                    m_widgets << widget;
                    connect(widget,SIGNAL(destroyed(QObject*)),SLOT(dialog_destroyed(QObject*)));
                }
            }
       }
示例#11
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;
        }
示例#12
0
void CAPopUp::showSingleton ()
{
#if 1
	QString uifile = p_data->m_filename;
	//qDebug("uifile-name:%s", uifile.toStdString().c_str());

	if(uifile.isEmpty() == true || bshow == 0 ) return;
	//qDebug("uifile-name-1:%s", uifile.toStdString().c_str());

	if(p_data->m_singleton != 0) return;

	QUiLoader loader;
	QString filename = QString("/usr/local/opi/ui/") + uifile;
	QFile file;
	file.setFileName(filename);
	file.open(QFile::ReadOnly);
	QDialog *pDia = (QDialog*)loader.load(&file);

	if(!pDia) return;

	connect(pDia, SIGNAL(rejected()), this, SLOT(buttonCancel()));
	QDialogButtonBox *pBBox = pDia->findChild<QDialogButtonBox *> ("buttonBox");

	if(pBBox!=0)
	{
		connect(pBBox, SIGNAL(rejected()), this, SLOT(buttonCancel()));
	}
	
	pDia -> show();
	p_data->m_singleton = 1;
#endif
}
示例#13
0
void EditorWindow::loadControlUI()
{
    QModelIndex Select = ControllerTree->selectionModel()->selectedIndexes()[0];
    QModelIndex SelectRoot = Controllers->getRootSelection(Select);
    QString Key = Controllers->data(SelectRoot, Qt::DisplayRole).toString();
    qDebug() << Key;
    if (Key == currentControl)
        return;
    QFile controllerUIFile("./Controllers/" + Key + ".ui");
    if (!controllerUIFile.exists())
    {
         QMessageBox::warning(this, tr("UI File"),
                              tr("Cannot found file %1:\n%2.")
                              .arg(controllerUIFile.fileName())
                              .arg(controllerUIFile.errorString()));
         return;
    }
    if (!controllerUIFile.open(QFile::ReadOnly | QFile::Text))
    {
         QMessageBox::warning(this, tr("UI File"),
                              tr("Cannot read file %1:\n%2.")
                              .arg(controllerUIFile.fileName())
                              .arg(controllerUIFile.errorString()));
         return;
    }
    QUiLoader UiLoader;
    clearLayout(ControllerUI->layout());
    ControllerUI->layout()->addWidget(UiLoader.load(&controllerUIFile, ControllerUI));
    controllerUIFile.close();
}
示例#14
0
//! [1]
CalculatorForm::CalculatorForm(QWidget *parent)
    : QWidget(parent)
{
    QUiLoader loader;

    QFile file(":/forms/calculatorform.ui");
    file.open(QFile::ReadOnly);
    QWidget *formWidget = loader.load(&file, this);
    file.close();
//! [1]

//! [2]
    ui_inputSpinBox1 = qFindChild<QSpinBox*>(this, "inputSpinBox1");
    ui_inputSpinBox2 = qFindChild<QSpinBox*>(this, "inputSpinBox2");
    ui_outputWidget = qFindChild<QLabel*>(this, "outputWidget");
//! [2]

//! [3]
    QMetaObject::connectSlotsByName(this);
//! [3]

//! [4]
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(formWidget);
    setLayout(layout);

    setWindowTitle(tr("Calculator Builder"));
}
示例#15
0
UploadProgressWindow::UploadProgressWindow(InventoryModule *owner, QWidget *parent) :
    QWidget(parent), owner_(owner), mainWidget_(0), layout_(0), uploadCount_(0)
{
    QUiLoader loader;
    QFile file("./data/ui/uploadprogress.ui");
    file.open(QFile::ReadOnly);
    mainWidget_ = loader.load(&file, this);
    file.close();

    layout_ = new QVBoxLayout;
    layout_->addWidget(mainWidget_);
    setLayout(layout_);

    progressBar_ = mainWidget_->findChild<QProgressBar *>("progressBar");
    labelFileNumber_ = mainWidget_->findChild<QLabel *>("labelFileNumber");

    setWindowTitle(tr("Upload Progress Window"));

#ifndef UISERVICE_TEST
    // Add widget to UI via ui services module
    UiServices::UiModule *ui_module = owner_->GetFramework()->GetModule<UiServices::UiModule>();
    if (ui_module)
        proxyWidget_ = ui_module->GetInworldSceneController()->AddWidgetToScene(this);
#endif
}
示例#16
0
void KeyBindingsConfigWindow::ShowWindow()
{
    QUiLoader loader;
    QFile file("./data/ui/KeyBindingsConfig.ui");
    file.open(QFile::ReadOnly);
    QWidget *contents_widget_ = loader.load(&file, this);
    assert(contents_widget_);
    file.close();

    if (!contents_widget_)
        return;

    QVBoxLayout *layout = new QVBoxLayout;
    assert(layout);
    layout->addWidget(contents_widget_);
    layout->setContentsMargins(0,0,0,0);
    setLayout(layout);

    configList = findChild<QTreeWidget*>("configList");

    QPushButton *apply = findChild<QPushButton*>("pushButtonApply");
    connect(apply, SIGNAL(pressed()), this, SLOT(ApplyKeyConfig()));
    QPushButton *ok = findChild<QPushButton*>("pushButtonOK");
    connect(ok, SIGNAL(pressed()), this, SLOT(ButtonOK()));
    QPushButton *cancel = findChild<QPushButton*>("pushButtonCancel");
    connect(cancel, SIGNAL(pressed()), this, SLOT(ButtonCancel()));

    connect(configList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(ConfigListAdjustEditable(QTreeWidgetItem *, int)));
    connect(configList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ConfigListAdjustEditable(QTreeWidgetItem *, int)));
    PopulateBindingsList();

    setWindowTitle(tr("Actions"));
    setAttribute(Qt::WA_DeleteOnClose);
}
示例#17
0
FilterDockWidget::FilterDockWidget(QWidget *parent, Qt::WindowFlags flags) : 
  QDockWidget("Image Filters", parent, flags),
  _currentSelection(NULL),
  _availableFilters(NULL),
  _settingsPanel(NULL),
  _layout(NULL),
  _progressBar(NULL),
  _monitor(NULL),
  _applyFilter(NULL),
  _clearFilter(NULL),
  _autoUpdateCheckBox(NULL),
  _autoUpdate(false)
{
  QUiLoader loader;
  QFile file(":/FilterWorkstationExtensionPlugin_ui/FilterDockWidget.ui");
  file.open(QFile::ReadOnly | QFile::Text);
  QWidget* contents = loader.load(&file);
  file.close();
  _layout = contents->layout();
  _layout->setAlignment(Qt::AlignTop);
  _availableFilters = contents->findChild<QListWidget*>("filterListWidget");
  connect(_availableFilters, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*)));
  _progressBar = contents->findChild<QProgressBar*>("progressBar");
  QObject::connect(_progressBar, SIGNAL(valueChanged(int)), this, SLOT(onProcessing()));
  _monitor.reset(new QtProgressMonitor());
  QObject::connect(_monitor.get(), SIGNAL(progressChanged(int)), _progressBar, SLOT(setValue(int)), Qt::QueuedConnection);
  _applyFilter = contents->findChild<QPushButton*>("applyFilterButton");
  _clearFilter = contents->findChild<QPushButton*>("clearFilterButton");
  _autoUpdateCheckBox = contents->findChild<QCheckBox*>("autoUpdateCheckBox");
  QObject::connect(_autoUpdateCheckBox, SIGNAL(toggled(bool)), _applyFilter, SLOT(setDisabled(bool)));
  QObject::connect(_autoUpdateCheckBox, SIGNAL(toggled(bool)), this, SLOT(onAutoUpdateToggled(bool)));
  QObject::connect(_applyFilter, SIGNAL(clicked()), this, SLOT(onApplyFilterClicked()));
  QObject::connect(_clearFilter, SIGNAL(clicked()), this, SLOT(onClearFilterClicked()));
  this->setWidget(contents);
}
示例#18
0
static int
qtuiloader_load(lua_State *L)
{
  // this
  QUiLoader *loader = luaQ_checkqobject<QUiLoader>(L, 1);
  // file
  QFile afile;
  QIODevice *file = qobject_cast<QIODevice*>(luaQ_toqobject(L, 2));
  if (!file && lua_isstring(L, 2))
    {
      file = &afile;
      const char *fn = lua_tostring(L, 2);
      afile.setFileName(QFile::decodeName(fn));
      if (! afile.open(QIODevice::ReadOnly))
        luaL_error(L,"cannot open file '%s' for reading (%s)", 
                   fn, afile.errorString().toLocal8Bit().constData() );
    }
  else if (!file)
    {
      file = &afile;
      void *udata = luaL_checkudata(L, 2, LUA_FILEHANDLE);
      if (! afile.open(*(FILE**)udata, QIODevice::ReadOnly))
        luaL_error(L,"cannot use stream for reading (%s)", 
                   afile.errorString().toLocal8Bit().constData() );
    }
  // parent
  QWidget *parent = luaQ_optqobject<QWidget>(L, 3);
  // load
  QWidget *w = loader->load(file, parent);
  luaQ_pushqt(L, w, !parent);
  return 1;
}
示例#19
0
bool QUiBuilder::InitializeLoader( QString strUiResName, QWidget* pkParent, QString strPluginPath )
{
    if ( !pkParent )
    {
        return false;
    }

    QUiLoader kLoader;
    if ( false == strPluginPath.isEmpty() )
    {
        kLoader.addPluginPath( strPluginPath );
    }

    QFile kFile( strUiResName );
    if( !kFile.open( QFile::ReadOnly ) )
    {
        return false;
    }

    m_pkLoadedWidget = kLoader.load( &kFile, pkParent );
    if ( !m_pkLoadedWidget )
    {
        return false;
    }
    kFile.close();

    return true;
}
示例#20
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;
        }
void ControllersControlGroupDialog::setControlUI(QString ControlPath)
{
    QFile* UiFile = new QFile("./Controllers/" + ControlPath + ".ui");
    if (!UiFile->exists())
    {
        QMessageBox::warning(this, tr("UI File"),
                             tr("Cannot found file %1:\n%2.")
                             .arg(UiFile->fileName())
                             .arg(UiFile->errorString()));
        this->rejected();
        return;
    }
    if (!UiFile->open(QFile::ReadOnly | QFile::Text))
    {
         QMessageBox::warning(this, tr("SAX Bookmarks"),
                              tr("Cannot read file %1:\n%2.")
                              .arg(UiFile->fileName())
                              .arg(UiFile->errorString()));
         this->rejected();
         return;
    }
    QUiLoader uiLoader;
    ui->ControlUI->layout()->addWidget(uiLoader.load(UiFile));
    connect(ui->ControlAdd, SIGNAL(pressed()), this, SLOT(addControl()));
    return;
}
示例#22
0
void MainWindow::on_actionStatisticalRemoval_triggered()
{
    //load RadiusOutlier Ui
    QUiLoader loader;
    QFile file(":/forms/StatisticalRemoval.ui");
    file.open(QFile::ReadOnly);

    QDialog *statisticalRemovalForm = dynamic_cast<QDialog *>(loader.load(&file, this));
    file.close();

    if(statisticalRemovalForm->exec()==QDialog::Accepted)
    {
        while(statisticalRemovalForm->isVisible());//untill it closed
        QLineEdit *std=statisticalRemovalForm->findChild<QLineEdit *>("stddev");
        QLineEdit *n=statisticalRemovalForm->findChild<QLineEdit *>("neighbor");


        QString txt ="Applying Statistical filter to the cloud ...";
        QProgressDialog *p=new QProgressDialog( txt,QString(),0, 0, this);
        p->setWindowModality(Qt::WindowModal);
        p->setVisible(true);
        connect(controller, SIGNAL(finished()), p, SLOT(reset()));

        QtConcurrent::run(controller,&CloudControl::filter,std->text().toDouble(),n->text().toInt(),1);
        //int re=controller->RadiusOutlier(r->text().toDouble(),n->text().toInt());
    }
}
void NucleiDetectionFilterPlugin::initializeSettingsPanel() {
  _mutex.lock();
  if (_settingsPanel) {
    _settingsPanel->deleteLater();
  }
  QUiLoader loader;
  QFile file(":/NucleiDetectionFilter_ui/NucleiDetectionFilter.ui");
  file.open(QFile::ReadOnly);
  _settingsPanel = loader.load(&file);
  file.close();
  QPushButton* revertStainButton = _settingsPanel->findChild<QPushButton*>("RevertStainsToDefaultButton");
  QDoubleSpinBox* stain1R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1RSpinBox");
  QDoubleSpinBox* stain1G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1GSpinBox");
  QDoubleSpinBox* stain1B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain1BSpinBox");
  QDoubleSpinBox* stain2R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2RSpinBox");
  QDoubleSpinBox* stain2G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2GSpinBox");
  QDoubleSpinBox* stain2B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain2BSpinBox");
  QDoubleSpinBox* stain3R = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3RSpinBox");
  QDoubleSpinBox* stain3G = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3GSpinBox");
  QDoubleSpinBox* stain3B = _settingsPanel->findChild<QDoubleSpinBox*>("Stain3BSpinBox");
  QDoubleSpinBox* rThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("RThreshold");
  QDoubleSpinBox* gThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("GThreshold");
  QDoubleSpinBox* bThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("BThreshold");
  QDoubleSpinBox* globalThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("GlobalThreshold");
  QDoubleSpinBox* maxRadius = _settingsPanel->findChild<QDoubleSpinBox*>("MaxRadiusSpinBox");
  QDoubleSpinBox* minRadius = _settingsPanel->findChild<QDoubleSpinBox*>("MinRadiusSpinBox");
  QDoubleSpinBox* stepRadius = _settingsPanel->findChild<QDoubleSpinBox*>("StepRadiusSpinBox");
  QDoubleSpinBox* alpha = _settingsPanel->findChild<QDoubleSpinBox*>("AlphaSpinBox");
  QDoubleSpinBox* beta = _settingsPanel->findChild<QDoubleSpinBox*>("BetaSpinBox");
  QDoubleSpinBox* hMaximaThreshold = _settingsPanel->findChild<QDoubleSpinBox*>("HMaximaThresholdSpinBox");
  connect(stain1R, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain1G, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain1B, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain2R, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain2G, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain2B, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain3R, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain3G, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stain3B, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(rThreshold, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(gThreshold, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(bThreshold, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(globalThreshold, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(maxRadius, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(minRadius, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(stepRadius, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(alpha, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(beta, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(hMaximaThreshold, SIGNAL(valueChanged(double)), this, SLOT(updateFilterFromSettingsPanel()));
  connect(revertStainButton, SIGNAL(clicked()), this, SLOT(revertStainToDefault()));
  QGroupBox* colorDeconvBox = _settingsPanel->findChild<QGroupBox*>("ColorDeconvolutionBox");
  if (_monochromeInput) {
    colorDeconvBox->setEnabled(false);
  }
  else {
    colorDeconvBox->setEnabled(true);
  }
  _mutex.unlock();
}
static void* createUI(const char* ui)
{
	QUiLoader loader;
	QBuffer buffer;
	buffer.setData(ui, strlen(ui));
	auto* widget = loader.load(&buffer);
	widget->show();
	return widget;
}
示例#25
0
NMainWindow::NMainWindow(const QString &uiFile, QWidget *parent) : QDialog(parent)
{
#ifdef Q_WS_WIN
    m_framelessShadow = false;
#endif

    setObjectName("mainWindow");

#ifndef _N_NO_SKINS_
    QUiLoader loader;
    QFile formFile(uiFile);
    formFile.open(QIODevice::ReadOnly);
    QWidget *form = loader.load(&formFile);
    formFile.close();

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(form->layout()->itemAt(0)->widget());
    layout->setContentsMargins(0, 0, 0, 0);
    setLayout(layout);
    setStyleSheet(form->styleSheet());
    form->setStyleSheet("");
#else
    Q_UNUSED(uiFile)
    ui.setupUi(this);
#endif

    m_unmaximizedSize = QSize();
    m_unmaximizedPos = QPoint();
    m_isFullScreen = false;
    m_dragActive = false;
    m_resizeActive = false;
    m_resizeSection = Qt::NoSection;

    // enabling dragging window from any point
    QList<QWidget *> widgets = findChildren<QWidget *>();
    foreach (QWidget *widget, widgets)
        widget->installEventFilter(this);

    QIcon icon;
#ifdef Q_WS_X11
    icon = QIcon::fromTheme("nulloy");
#endif
#ifndef Q_WS_MAC
    if (icon.isNull()) {
        QStringList files = QDir(":").entryList(QStringList() << "icon-*", QDir::Files);
        foreach (QString fileName, files)
            icon.addFile(":" + fileName);
    }
#else
    icon.addFile(":icon-16.png");
#endif
    setWindowIcon(icon);

    QMetaObject::connectSlotsByName(this);
}
示例#26
0
 QWidget* FrmCompras_cls::loadUiFile()
 {
     QUiLoader loader;

     QFile file(":/forms/frmcompras.ui");
     file.open(QFile::ReadOnly);

     QWidget *formWidget = loader.load(&file, this);
     file.close();
     return formWidget;
 }
示例#27
0
QScriptValue ConfigurationDialog::addPage( const QString &name, const QString &filename, const QString &icon ) {
	QDir dir = this->baseDir();

	QUiLoader loader;
	QFile file(dir.filePath(filename));
	file.open(QFile::ReadOnly);
	QWidget *widget = loader.load(&file, this);
	file.close();

	return this->addPage(name, widget, icon);
}
//! [4]
QWidget* TextFinder::loadUiFile()
{
    QUiLoader loader;

    QFile file(":/forms/textfinder.ui");
    file.open(QFile::ReadOnly);

    QWidget *formWidget = loader.load(&file, this);
    file.close();

    return formWidget;
}
示例#29
0
QWidget*
Tomahawk::ExternalResolverGui::widgetFromData( QByteArray& data, QWidget* parent )
{
    if( data.isEmpty() )
        return 0;

    QUiLoader l;
    QBuffer b( &data );
    QWidget* w = l.load( &b, parent );

    return w;
}
示例#30
-1
void TexturePreviewEditor::Initialize()
{
//    UiServiceInterface* ui= framework_->GetService<UiServiceInterface>();
//    if (!ui)
//        return;

    // Create widget from ui file
    QUiLoader loader;
    QFile file("./data/ui/texture_preview.ui");
    if (!file.exists())
    {
        OgreAssetEditorModule::LogError("Cannot find OGRE Script Editor .ui file.");
        return;
    }

    mainWidget_ = loader.load(&file);
    file.close();

    setAttribute(Qt::WA_DeleteOnClose);

    resize(cWindowMinimumWidth, cWindowMinimumHeight);

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

    // Get controls
    okButtonName_ = mainWidget_->findChild<QPushButton *>("okButton");
    connect(okButtonName_, SIGNAL(clicked()), this, SLOT(Closed()));

    headerLabel_ = mainWidget_->findChild<QLabel *>("imageNameLabel");
    scaleLabel_ = mainWidget_->findChild<QLabel *>("imageScaleLabel");
    
    QLabel *assetIdLabel = mainWidget_->findChild<QLabel *>("imageAssetIdLabel");
    if(assetIdLabel)
        assetIdLabel->setText(inventoryId_);

    imageLabel_ = new TextureLabel();
    imageLabel_->setObjectName("previewImageLabel");
    imageLabel_->setScaledContents(true);
    imageLabel_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    QObject::connect(imageLabel_, SIGNAL(MouseClicked(QMouseEvent*)), this, SLOT(TextureLabelClicked(QMouseEvent*)));

    scrollAreaWidget_ = mainWidget_->findChild<QScrollArea *>("imageScrollArea");
    scrollAreaWidget_->widget()->layout()->addWidget(imageLabel_);

    // Set black background image that will be replaced once the real image has been received.
    QImage emptyImage = QImage(QSize(256, 256), QImage::Format_ARGB32);
    emptyImage.fill(qRgba(0,0,0,0));
    imageLabel_->setPixmap(QPixmap::fromImage(emptyImage));
    headerLabel_->setText(objectName());

    // Add widget to UI via ui services module
    setWindowTitle(tr("Texture: ") + objectName());
//    UiProxyWidget *proxy = ui->AddWidgetToScene(this);
//    connect(proxy, SIGNAL(Closed()), this, SLOT(Closed()));
//    proxy->show();
//    ui->BringWidgetToFront(proxy);
}