Beispiel #1
0
void App::loadFixtureDefinition(const QString& path)
{
	/* Attempt to create a fixture definition from the selected file */
	QLCFixtureDef* fixtureDef = new QLCFixtureDef();
	QFile::FileError error = fixtureDef->loadXML(path);
	if (error == QFile::NoError)
	{
		QLCFixtureEditor* editor;
		QMdiSubWindow* sub;

		/* Create a new sub window and put a fixture editor widget
		   in that sub window with the newly-created fixture def */
		sub = new QMdiSubWindow(centralWidget());
		editor = new QLCFixtureEditor(sub, fixtureDef, path);

		sub->setWidget(editor);
		sub->setAttribute(Qt::WA_DeleteOnClose);
		qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

		editor->show();
		sub->show();
	}
	else
	{
		delete fixtureDef;
		QMessageBox::warning(this, tr("Fixture loading failed"),
			tr("Unable to load fixture definition: ") +
			QLCFile::errorString(error));
	}
}
Beispiel #2
0
void App::loadFixtureDefinition(const QString& path)
{
    QLCFixtureDef* fixtureDef = NULL;

    /* Attempt to create a fixture definition from the selected file */
    QString error(tr("Unrecognized file extension: %1").arg(path));
    if (path.toLower().endsWith(KExtFixture) == true)
        fixtureDef = loadQXF(path, error);
    else if (path.toLower().endsWith(KExtAvolitesFixture) == true)
        fixtureDef = loadD4(path, error);
    else
        fixtureDef = NULL;

    if (fixtureDef != NULL)
    {
        /* Create a new sub window and put a fixture editor widget
           in that sub window with the newly-created fixture def */
        QMdiSubWindow* sub = new QMdiSubWindow(centralWidget());
        QLCFixtureEditor* editor = new QLCFixtureEditor(sub, fixtureDef, path);

        sub->setWidget(editor);
        sub->setAttribute(Qt::WA_DeleteOnClose);
        qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

        editor->show();
        sub->show();
    }
    else
    {
        QMessageBox::warning(this, tr("Fixture loading failed"),
                             tr("Unable to load fixture definition: ") + error);
    }
}
Beispiel #3
0
/**
\param w
**/
void BlWorkspace::addSubWindow ( QWidget * w )
{
    BL_FUNC_DEBUG
    int tamdispW;
    int tamdispH;
    int tamventanadecoW;
    int tamventanadecoH;
    int tamventanaW;
    int tamventanaH;
    int margen = 10;

    QMdiSubWindow *sw = new QMdiSubWindow;
    sw->setWidget(w);
    connect ( w, SIGNAL(destroyed(QObject *)), sw, SLOT(close()));
    connect ( w, SIGNAL(hided(QObject *)), sw, SLOT(hide()));
//    connect ( w, SIGNAL(hided(QObject *)), this, SIGNAL(deselectDockAll()));
    connect ( w, SIGNAL(showed(QObject *)), sw, SLOT(show()));
    
    QMdiArea::addSubWindow (sw);


    /// Se comprueba el tama&ntilde;o de la ventana que esta dise&ntilde;ada con Designer:
    /// S&oacute;lo si la ventana es m&aacute;s grande que el espacio de representaci&oacute;n
    /// se ajusta para caber dentro.

    /// Captura el tama&ntilde;o disponible. Restamos el margen que dejamos a cada lado (x2).
    tamdispW = this->width() - ( margen * 2 );
    tamdispH = this->height() - ( margen * 2 );

    /// Captura el tama&ntilde;o con decoraci&oacute;n de la ventana a insertar.
    tamventanadecoW = w->parentWidget() ->frameGeometry().width();
    tamventanadecoH = w->parentWidget() ->frameGeometry().height();
    /// Captura el tama&ntilde;o sin decoraci&oacute;n de la ventana a insertar.
    tamventanaW = w->geometry().width();
    tamventanaH = w->geometry().height();

    /// Comprobamos si es necesario cambiar el tama&ntilde;o a la ventana.
    if ( tamventanadecoW > tamdispW )
        tamventanaW = tamdispW - ( tamventanadecoW - tamventanaW );
    if ( tamventanadecoH > tamdispH )
        tamventanaH = tamdispH - ( tamventanadecoH - tamventanaH );

    w->setGeometry ( 0, 0, tamventanaW, tamventanaH );
    w->parentWidget() ->move ( margen, margen );

    /// Crea un QAction para manejar la tecla rapida ESC para cerrar la ventana.
    QAction *accionEsc = new QAction ( w );
    accionEsc->setShortcut ( _ ( "Esc" ) );
    connect ( accionEsc, SIGNAL ( triggered() ), w, SLOT ( close() ) );
    w->addAction ( accionEsc );
    
}
Beispiel #4
0
void InputManager::createAndShow(QWidget* parent, InputMap* inputMap)
{
    QWidget* window = NULL;

    /* Must not create more than one instance */
    if (s_instance == NULL)
    {
#ifdef __APPLE__
        /* Create a separate window for OSX */
        s_instance = new InputManager(parent, inputMap, Qt::Window);
        window = s_instance;
#else
        /* Create an MDI window for X11 & Win32 */
        QMdiArea* area = qobject_cast<QMdiArea*> (parent);
        Q_ASSERT(area != NULL);
        QMdiSubWindow* sub = new QMdiSubWindow;
        s_instance = new InputManager(sub, inputMap);
        sub->setWidget(s_instance);
        window = area->addSubWindow(sub);
#endif

        /* Set some common properties for the window and show it */
        window->setAttribute(Qt::WA_DeleteOnClose);
        window->setWindowIcon(QIcon(":/input.png"));
        window->setWindowTitle(tr("Input Manager"));
        window->setContextMenuPolicy(Qt::CustomContextMenu);
        window->show();

        QSettings settings;
        QVariant var = settings.value(SETTINGS_GEOMETRY);
        if (var.isValid() == true)
        {
            window->restoreGeometry(var.toByteArray());
            AppUtil::ensureWidgetIsVisible(window);
        }
    }
    else
    {
#ifdef __APPLE__
        window = s_instance;
#else
        window = s_instance->parentWidget();
#endif
    }

    window->show();
    window->raise();
}
Beispiel #5
0
void App::slotFileNew()
{
    QLCFixtureEditor* editor;
    QMdiSubWindow* sub;

    sub = new QMdiSubWindow(centralWidget());
    editor = new QLCFixtureEditor(sub, new QLCFixtureDef());

    sub->setWidget(editor);
    sub->setAttribute(Qt::WA_DeleteOnClose);
    sub->setWindowIcon(QIcon(":/fixture.png"));

    qobject_cast<QMdiArea*> (centralWidget())->addSubWindow(sub);

    editor->show();
    sub->show();
}
Beispiel #6
0
PlotWithCurves* Group::insertPlot()
{
    QMdiSubWindow* window = new QMdiSubWindow;
    {
        window->setMinimumSize(250, 150);
        window->setWindowIcon(QIcon(":/res/mainWindow/closeAllPlots.png"));
        window->setAttribute(Qt::WA_DeleteOnClose);
    }
    PlotWithCurves* plot = new PlotWithCurves(samplesManager, curvesManagerView, window);
    {
        plot->connect(plot, SIGNAL(destroyed()), this, SLOT(retitle()));
        window->setWidget(plot);
        addSubWindow(window);
        window->show();
        retitle();
    }
    return plot;
}
void DnsLookupPlugin::slotMainActionForMenuTriggered() {

    QWidget *parentWidget = qobject_cast<QWidget *> (parent());
    DnsLookupWidget *wgt = new DnsLookupWidget(parentWidget);
    //connect(wgt, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));

    QMdiArea *mdiArea = 0;
    if(parentWidget) {
        mdiArea = qobject_cast<QMdiArea *>(parentWidget);
    }
    if(mdiArea) {
        QMdiSubWindow *subWindow = new QMdiSubWindow;
        subWindow->setWidget(wgt);
        subWindow->setAttribute(Qt::WA_DeleteOnClose);
        mdiArea->addSubWindow(subWindow);
        //connect(this, SIGNAL(signalPluginToBeUnloaded()), subWindow, SLOT(close()));

        connect(subWindow, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));
        widgetList.append(subWindow);
    } else {
Beispiel #8
0
void UserManagerPlugin::slotMainActionForMenuTriggered()
{
    if(isSingle() && UserManagerMainWindow::isRunning()) {
        //TODO: Activate the widget
        qDebug() << "----UserManagerPlugin::slotRun():UserManager Is Running!";
        return;
    }

    QWidget *parentWidget = qobject_cast<QWidget *> (parent());

    HEHUI::User user;
    HEHUI::LoginBase login(&user, name(), parentWidget);
    if (!login.isVerified()) {
        return ;
    }

    bool isYDAdmin = false;
    if(user.getBusinessAddress() == "DG") {
        isYDAdmin = false;
    } else if(user.getBusinessAddress() == "YD") {
        isYDAdmin = true;
    }

    UserManagerMainWindow *wgt = new UserManagerMainWindow(isYDAdmin, parentWidget);
    //connect(userManager, SIGNAL(destroyed(QObject *)), this, SLOT(slotUserManagerWidgetDestoryed(QObject *)));

    QMdiArea *mdiArea = 0;
    if(parentWidget) {
        mdiArea = qobject_cast<QMdiArea *>(parentWidget);
    }
    if(mdiArea) {
        QMdiSubWindow *subWindow = new QMdiSubWindow;
        subWindow->setWidget(wgt);
        subWindow->setAttribute(Qt::WA_DeleteOnClose);
        mdiArea->addSubWindow(subWindow);
        //connect(this, SIGNAL(signalPluginToBeUnloaded()), subWindow, SLOT(close()));

        connect(subWindow, SIGNAL(destroyed(QObject *)), this, SLOT(slotWidgetDestoryed(QObject *)));
        widgetList.append(subWindow);
    } else {
void MainWindow::openPage( int type, quint32 accountid )
{
    if( type <= 0 )
        return;

    QUuid id;
    PageWidgetMember *tab = NULL;
    QString header;

    //usual window
    if( type != 13 )
    {
        if( !hList.contains( type, id ) )
        {
            //create page
            tab = createPage( type, accountid, header );
        }
        else
        {
            //show page
            setPageActive( id, accountid );
            return;
        }
    }
    //transactions window
    else if( type == 13 && accountid > 0 )
    {
        if( !hList.trContains( accountid, id ) )
        {
            tab = createPage( type, accountid, header );
        }
        else
        {
            setPageActive( id );
            return;
        }
    }

    // -------
    // -------

    if( tab == NULL )
        return;

    connect( tab, SIGNAL( closeRequest( const QUuid & ) ), this, SLOT( closePage( const QUuid & ) ) );
    connect( tab, SIGNAL( closed( int ) ), this, SLOT( closedPage( int ) ) );
    connect( tab, SIGNAL( headerChanged( const QString & ) ), this, SLOT( changeHeader( const QString & ) ) );

    //create an empty tab on tabwidget
    disconnect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setPageActive(int) ) );

    tabWidget->addTab( new QWidget(), header );
    tabWidget->setCurrentIndex( tabWidget->count()-1 );
    if( tab->hasIcon() )
        tabWidget->setTabIcon( tabWidget->count()-1, *tab->icon() );

    connect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setPageActive(int) ) );
    // ----

    //create and show window in MDI Area
    QMdiSubWindow *subW = new QMdiSubWindow(this);
    subW->setWidget( tab );
    subW->setWindowTitle( header );
    subW->setAttribute( Qt::WA_DeleteOnClose );
    mdiArea->addSubWindow( subW );
    subW->showMaximized();
    subW->show();
    // -----


    //creating a handler for the tab
    Handler *h = new Handler();
    h->id = QUuid::createUuid();
    h->accountid = accountid;
    h->type = type;
    h->number = tabWidget->count()-1;
    // -----

    tab->setHandler( *h );
    hList.append( h );
}
Beispiel #10
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    if(_is_reloading) return;
    _is_reloading=true;
    BoolReseter rst(&_is_reloading);
    Q_UNUSED(rst);

    QString filePath;
    QRect wnGeom;

    if (activeChildWindow()==1)
    {
        LevelData FileData;
        filePath = activeLvlEditWin()->curFile;

        if(activeLvlEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if (!QFileInfo(filePath).exists() ) {
            QMessageBox::critical(this, tr("File open error"),
            tr("Can't open the file.\nFile not exist."), QMessageBox::Ok);
                return;
        }

        if(activeLvlEditWin()->LvlData.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        //Open level file
        FileData = FileFormats::OpenLevelFile(filePath);

        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeLvlEditWin()->LvlData.modified = false;

        QFile file(filePath+".meta");
        if(QFileInfo(filePath+".meta").exists())
        {
            if (file.open(QIODevice::ReadOnly))
            {
                QString metaRaw;
                QTextStream meta(&file);
                meta.setCodec("UTF-8");
                metaRaw = meta.readAll();
                if(FileData.metaData.script)
                {
                    delete FileData.metaData.script;
                    FileData.metaData.script = NULL;
                }
                FileData.metaData = FileFormats::ReadNonSMBX64MetaData(metaRaw, filePath+".meta");
            }
            else
            {
                QMessageBox::critical(this, tr("File open error"),
                tr("Can't open the file."), QMessageBox::Ok);
            }
        }

        //Remember last section ID and positions!
        int lastSection=0;
        QMap<int, QPair<long, long> > sectionPoss;
        lastSection = activeLvlEditWin()->LvlData.CurSection;
        SetCurrentLevelSection(lastSection);//Need to remember position of current section
        for(int i=0; i<activeLvlEditWin()->LvlData.sections.size(); i++)
        {
            LevelSection sct = activeLvlEditWin()->LvlData.sections[i];
            sectionPoss[sct.id]=QPair<long, long >(sct.PositionX, sct.PositionY);
        }

        activeLvlEditWin()->close();//Close old widget without closing of sub-window

        //Get pointer to current sub-window
        QMdiSubWindow *window = ui->centralWidget->activeSubWindow();

        //Get geometry of current subwindow
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        //delete window->widget();
        LevelEdit *chLvlWin = new LevelEdit(window);
        connect(chLvlWin, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        window->setWidget(chLvlWin);
        GraphicsWorkspace* gr = static_cast<GraphicsWorkspace *>(chLvlWin->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));

        //ui->centralWidget->activeSubWindow()->close();
        LevelEdit *child = chLvlWin;//createLvlChild();
        LvlMusPlay::setNoMusic();
        setMusic(false);
        if ((bool) (child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            LvlMusPlay::musicForceReset=true; //reset musics
            updateMenus(true);

            child->setFocus();
            //Restore saved section positions
            for(int i=0; i<child->LvlData.sections.size(); i++)
            {
                if(sectionPoss.contains(child->LvlData.sections[i].id))
                {
                    child->LvlData.sections[i].PositionX=sectionPoss[child->LvlData.sections[i].id].first;
                    child->LvlData.sections[i].PositionY=sectionPoss[child->LvlData.sections[i].id].second;
                }
            }

            SetCurrentLevelSection(lastSection);

            if(GlobalSettings::autoPlayMusic) ui->actionPlayMusic->setChecked(true);
        } else {
                WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
                WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==1) activeLvlEditWin()->LvlData.modified = false;
                WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
                WriteToLog(QtDebugMsg, ">>Windows closed");
        }
    }
    else
    if (activeChildWindow()==2)
    {
        filePath = activeNpcEditWin()->curFile;
        QFile fileIn(filePath);

        if(activeNpcEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if(activeNpcEditWin()->isModyfied)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        if (!fileIn.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(this, tr("File open error"),
        tr("Can't open the file."), QMessageBox::Ok);
            return;
        }

        NPCConfigFile FileData = FileFormats::ReadNpcTXTFile(fileIn);
        if( !FileData.ReadFileValid ) return;
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        activeNpcEditWin()->isModyfied = false;
        activeNpcEditWin()->close();
        //NpcEdit *child = createNPCChild();

        QMdiSubWindow *npcWindow = ui->centralWidget->activeSubWindow();
        NpcEdit *child = new NpcEdit(&configs, npcWindow);
        npcWindow->setWidget(child);

        if (child->loadFile(filePath, FileData)) {
            statusBar()->showMessage(tr("NPC Config reloaded"), 2000);
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            updateMenus(true);
        } else {
            child->close();
            npcWindow->close();
        }
    }
    else
    if (activeChildWindow()==3)
    {
        WorldData FileData;
        filePath = activeWldEditWin()->curFile;

        if(activeWldEditWin()->isUntitled)
        {
                    QMessageBox::warning(this, tr("File not saved"),
                    tr("File doesn't saved on disk."), QMessageBox::Ok);
                        return;
        }

        if (!QFileInfo(filePath).exists() ) {
            QMessageBox::critical(this, tr("File open error"),
            tr("Can't open the file.\nFile not exist."), QMessageBox::Ok);
                return;
        }

        if(activeWldEditWin()->WldData.modified){
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
            tr("Do you want to save before reload stuff?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
            if((ret==QMessageBox::Cancel)||(ret==0))
                return;
            else
              if(ret==QMessageBox::Yes)
                save();
        }

        FileData = FileFormats::OpenWorldFile(filePath);

        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.filename = QFileInfo(filePath).baseName();
        FileData.path = QFileInfo(filePath).absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeWldEditWin()->WldData.modified = false;

        QFile file(filePath+".meta");
        if(QFileInfo(filePath+".meta").exists())
        {
            if (file.open(QIODevice::ReadOnly))
            {
                QString metaRaw;
                QTextStream meta(&file);
                meta.setCodec("UTF-8");
                metaRaw = meta.readAll();
                FileData.metaData = FileFormats::ReadNonSMBX64MetaData(metaRaw, filePath+".meta");
            }
            else
            {
                QMessageBox::critical(this, tr("File open error"),
                tr("Can't open the file."), QMessageBox::Ok);
            }
        }

        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        QMdiSubWindow *worldWindow = ui->centralWidget->activeSubWindow();
        long posX = activeWldEditWin()->scene->_viewPort->horizontalScrollBar()->value();
        long posY = activeWldEditWin()->scene->_viewPort->verticalScrollBar()->value();

        activeWldEditWin()->close();

        WorldEdit *child = new WorldEdit(worldWindow);
        connect(child, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        worldWindow->setWidget(child);
        GraphicsWorkspace* gr = static_cast<GraphicsWorkspace *>(child->getGraphicsView());

        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));
        if ( (bool)(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)) ) {
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            updateMenus(true);
            dock_WldSettingsBox->setCurrentWorldSettings();
            if(FileData.HubStyledWorld)
            {
                dock_WldSettingsBox->setVisible(true);
                dock_WldSettingsBox->raise();
            }

            child->scene->_viewPort->horizontalScrollBar()->setValue(posX);
            child->scene->_viewPort->verticalScrollBar()->setValue(posY);

            statusBar()->showMessage(tr("World map file loaded"), 2000);
        } else {
            WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
            WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==3) activeWldEditWin()->WldData.modified = false;
            WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
            WriteToLog(QtDebugMsg, ">>Windows closed");
        }

    }

    dock_LvlItemBox->clearFilter();
}
/* Build Module GUI */
void IScale_DynClamp::Module::createGUI( void ) {

	QMdiSubWindow *subWindow  = new QMdiSubWindow;
	subWindow->setAttribute(Qt::WA_DeleteOnClose);
	subWindow->setWindowIcon(QIcon("/usr/local/lib/rtxi/RTXI-widget-icon.png"));
	subWindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | 
	                          Qt::WindowMinimizeButtonHint );
	MainWindow::getInstance()->createMdi(subWindow); 
	subWindow->setWidget(this);

	mainWindow = new IScale_DynClampUI(subWindow);
	// Construct Main Layout - vertical layout
	QVBoxLayout *layout = new QVBoxLayout(this);
	setLayout(layout);
	layout->addWidget(mainWindow);

	// Model Combo Box
	mainWindow->modelComboBox->addItem("LivRudy 2009");
	mainWindow->modelComboBox->addItem("FaberRudy 2000");

	// Set GUI refresh rate
	QTimer *timer = new QTimer(this);
	timer->start(500);

	// Set validators
	mainWindow->APDRepolEdit->setValidator( new QIntValidator(mainWindow->APDRepolEdit) );
	mainWindow->minAPDEdit->setValidator( new QIntValidator(mainWindow->minAPDEdit) );
	mainWindow->stimWindowEdit->setValidator( new QIntValidator(mainWindow->stimWindowEdit) );
	mainWindow->numTrialEdit->setValidator( new QIntValidator(mainWindow->numTrialEdit) );
	mainWindow->intervalTimeEdit->setValidator( new QIntValidator(mainWindow->intervalTimeEdit) );
	mainWindow->BCLEdit->setValidator( new QDoubleValidator(mainWindow->BCLEdit) );
	mainWindow->stimMagEdit->setValidator( new QDoubleValidator(mainWindow->stimMagEdit) );
	mainWindow->stimLengthEdit->setValidator( new QDoubleValidator(mainWindow->stimLengthEdit) );
	mainWindow->CmEdit->setValidator( new QDoubleValidator(mainWindow->CmEdit) );
	mainWindow->LJPEdit->setValidator( new QDoubleValidator(mainWindow->CmEdit) );

	// Connect MainWindow elements to slot functions
	QObject::connect( mainWindow->addStepButton, SIGNAL(clicked(void)), 
	                  this, SLOT( addStep(void)) );
	QObject::connect( mainWindow->deleteStepButton, SIGNAL(clicked(void)), 
	                  this, SLOT( deleteStep(void)) );
	QObject::connect( mainWindow->saveProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( saveProtocol(void)) );
	QObject::connect( mainWindow->loadProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( loadProtocol(void)) );
	QObject::connect( mainWindow->clearProtocolButton, SIGNAL(clicked(void)), 
	                  this, SLOT( clearProtocol(void)) );
	QObject::connect( mainWindow->recordDataCheckBox, SIGNAL(clicked(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  this, SLOT( toggleProtocol(void)) );
	QObject::connect( mainWindow->thresholdButton, SIGNAL(clicked(void)), 
	                  this, SLOT( toggleThreshold(void)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(clicked(void)), 
	                  this, SLOT( togglePace(void)) );
	QObject::connect( mainWindow->resetButton, SIGNAL(clicked(void)), 
	                  this, SLOT( reset(void)) );
	QObject::connect( mainWindow->modelComboBox, SIGNAL(activated(int)), 
	                  this, SLOT( changeModel(int)) );    
	QObject::connect( mainWindow->APDRepolEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->minAPDEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimWindowEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->numTrialEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->intervalTimeEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->BCLEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimMagEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->stimLengthEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->CmEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect( mainWindow->LJPEdit, SIGNAL(returnPressed(void)), 
	                  this, SLOT( modify(void)) );
	QObject::connect(timer, SIGNAL(timeout(void)), 
	                  this, SLOT(refreshDisplay(void)));

	// Connections to allow only one button being toggled at a time
	QObject::connect( mainWindow->thresholdButton, SIGNAL(toggled(bool)), 
	                  mainWindow->staticPacingButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->thresholdButton, SIGNAL(toggled(bool)),
	                  mainWindow->startProtocolButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  mainWindow->staticPacingButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->startProtocolButton, SIGNAL(toggled(bool)), 
	                  mainWindow->thresholdButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(toggled(bool)), 
	                  mainWindow->thresholdButton, SLOT( setDisabled(bool)) );
	QObject::connect( mainWindow->staticPacingButton, SIGNAL(toggled(bool)), 
	                  mainWindow->startProtocolButton, SLOT( setDisabled(bool)) );

	// Connect states to workspace
	setData( Workspace::STATE, 0, &time );
	setData( Workspace::STATE, 1, &voltage );
	setData( Workspace::STATE, 2, &beatNum );
	setData( Workspace::STATE, 3, &APD );
	setData( Workspace::STATE, 4, &targetCurrent );
	setData( Workspace::STATE, 5, &scaledCurrent );

	subWindow->show();
	subWindow->adjustSize();
} // End createGUI()
PerformanceMeasurement::Panel::Panel(QWidget *parent) : QWidget(parent),
	Workspace::Instance("Performance Measurement", vars, num_vars), state(INIT1), duration(0),
	lastRead(0), timestep(0), maxDuration(0), maxTimestep(0), jitter(0) {

		QWidget::setAttribute(Qt::WA_DeleteOnClose);

		// Make Mdi
		QMdiSubWindow *subWindow = new QMdiSubWindow;
	   subWindow->setWindowIcon(QIcon("/usr/local/lib/rtxi/RTXI-widget-icon.png"));
		subWindow->setAttribute(Qt::WA_DeleteOnClose);
		subWindow->setFixedSize(310,200);
		MainWindow::getInstance()->createMdi(subWindow);

		// Create main layout
		QVBoxLayout *layout = new QVBoxLayout;
		QString suffix = QString("s)").prepend(QChar(0x3BC));

		// Create child widget and gridLayout
		QGridLayout *gridLayout = new QGridLayout;

		durationEdit = new QLineEdit(subWindow);
		durationEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Computation Time (").append(suffix)), 1, 0);
		gridLayout->addWidget(durationEdit, 1, 1);

		maxDurationEdit = new QLineEdit(subWindow);
		maxDurationEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Peak Computation Time (").append(suffix)), 2, 0);
		gridLayout->addWidget(maxDurationEdit, 2, 1);

		timestepEdit = new QLineEdit(subWindow);
		timestepEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Real-time Period (").append(suffix)), 3, 0);
		gridLayout->addWidget(timestepEdit, 3, 1);

		maxTimestepEdit = new QLineEdit(subWindow);
		maxTimestepEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Peak Real-time Period (").append(suffix)), 4, 0);
		gridLayout->addWidget(maxTimestepEdit, 4, 1);

		timestepJitterEdit = new QLineEdit(subWindow);
		timestepJitterEdit->setReadOnly(true);
		gridLayout->addWidget(new QLabel(tr("Real-time Jitter (").append(suffix)), 5, 0);
		gridLayout->addWidget(timestepJitterEdit, 5, 1);

		QPushButton *resetButton = new QPushButton("Reset", this);
		gridLayout->addWidget(resetButton, 6, 1);
		QObject::connect(resetButton,SIGNAL(released(void)),this,SLOT(reset(void)));

		// Attach child widget to parent widget
		layout->addLayout(gridLayout);

		// Attach gridLayout to Widget
		setLayout(layout);
		setWindowTitle(QString::number(getID()) + tr(" RT Benchmarks"));

		// Set layout to Mdi
		subWindow->setWidget(this);
		show();

		QTimer *timer = new QTimer(this);
		timer->start(1000);
		QObject::connect(timer,SIGNAL(timeout(void)),this,SLOT(update(void)));
		resetMaxTimer = new QTimer(this);
		QObject::connect(resetMaxTimer,SIGNAL(timeout(void)),this,SLOT(resetMaxTimeStep(void)));

		// Connect states to workspace
		setData(Workspace::STATE, 0, &duration);
		setData(Workspace::STATE, 1, &maxDuration);
		setData(Workspace::STATE, 2, &timestep);
		setData(Workspace::STATE, 3, &maxTimestep);
		setData(Workspace::STATE, 4, &jitter);

		setActive(true);
		saveStats = false;
}
Beispiel #13
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    if(m_isFileReloading) return;

    m_isFileReloading = true;
    BoolReseter rst(&m_isFileReloading);
    Q_UNUSED(rst);
    QString filePath;
    QRect wnGeom;
    int activeWindow = activeChildWindow(LastActiveSubWindow);

    if(activeWindow == WND_Level)
    {
        LevelEdit *lvlEdit = activeLvlEditWin(LastActiveSubWindow);
        LevelData FileData;
        filePath = lvlEdit->curFile;

        if(lvlEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(!QFileInfo(filePath).exists())
        {
            QMessageBox::critical(this, tr("File open error"),
                                  tr("Can't open the file!\nFile not exist."), QMessageBox::Ok);
            return;
        }

        if(lvlEdit->LvlData.meta.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        //Open level file
        if(!FileFormats::OpenLevelFile(filePath, FileData))
        {
            formatErrorMsgBox(filePath, FileData.meta.ERROR_info, FileData.meta.ERROR_linenum, FileData.meta.ERROR_linedata);
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;
        }

        FileData.playmusic = GlobalSettings::autoPlayMusic;
        lvlEdit->LvlData.meta.modified = false;
        //Remember last section ID and positions!
        int lastSection = 0;
        QHash<int, QPair<long, long> > sectionPoss;
        lastSection = lvlEdit->LvlData.CurSection;
        SetCurrentLevelSection(lastSection); //Need to remember position of current section

        for(int i = 0; i < lvlEdit->LvlData.sections.size(); i++)
        {
            LevelSection sct = lvlEdit->LvlData.sections[i];
            sectionPoss[sct.id] = QPair<long, long >(sct.PositionX, sct.PositionY);
        }

        long posX = lvlEdit->scene->m_viewPort->horizontalScrollBar()->value();
        long posY = lvlEdit->scene->m_viewPort->verticalScrollBar()->value();
        lvlEdit->close();//Close old widget without closing of sub-window
        //Get geometry of current subwindow
        wnGeom = LastActiveSubWindow->geometry();
        //delete window->widget();
        LevelEdit *chLvlWin = new LevelEdit(this, LastActiveSubWindow);
        connect(chLvlWin, SIGNAL(forceReload()), this, SLOT(on_actionReload_triggered()));
        LastActiveSubWindow->setWidget(chLvlWin);
        GraphicsWorkspace *gr = static_cast<GraphicsWorkspace *>(chLvlWin->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));
        //LastActiveSubWindow->close();
        LevelEdit *child = chLvlWin;//createLvlChild();
        LvlMusPlay::setNoMusic();
        setMusic();

        if(static_cast<bool>(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            LvlMusPlay::musicForceReset = true; //reset musics
            updateMenus(LastActiveSubWindow, true);
            child->setFocus();

            //Restore saved section positions
            for(int i = 0; i < child->LvlData.sections.size(); i++)
            {
                if(sectionPoss.contains(child->LvlData.sections[i].id))
                {
                    QPair<long, long> &sct = sectionPoss[child->LvlData.sections[i].id];
                    child->LvlData.sections[i].PositionX = sct.first;
                    child->LvlData.sections[i].PositionY = sct.second;
                }
            }

            SetCurrentLevelSection(lastSection);
            child->scene->m_viewPort->horizontalScrollBar()->setValue(static_cast<int>(posX));
            child->scene->m_viewPort->verticalScrollBar()->setValue(static_cast<int>(posY));

            if(GlobalSettings::autoPlayMusic)
                ui->actionPlayMusic->setChecked(true);

            child->showCustomStuffWarnings();
        }
        else
        {
            LogDebug(">>File loading aborted");
            LogDebug(">>Window showed");
            child->LvlData.meta.modified = false;
            LogDebug(">>Option set");
            LastActiveSubWindow->close();
            LogDebug(">>Windows closed");
        }
    }
    else if(activeWindow == WND_NpcTxt)
    {
        NpcEdit *npcEdit = activeNpcEditWin(LastActiveSubWindow);
        filePath = npcEdit->curFile;

        if(npcEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(npcEdit->isModyfied)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        //        if (!fileIn.open(QIODevice::ReadOnly)) {
        //        QMessageBox::critical(this, tr("File open error"),
        //        tr("Can't open the file!"), QMessageBox::Ok);
        //            return;
        //        }
        NPCConfigFile FileData;

        if(!FileFormats::ReadNpcTXTFileF(filePath, FileData))
        {
            QMessageBox::critical(this, QObject::tr("File open error"), tr("Can't read the file"), QMessageBox::Ok);
            return;
        }

        wnGeom = LastActiveSubWindow->geometry();
        npcEdit->isModyfied = false;
        npcEdit->close();
        //NpcEdit *child = createNPCChild();
        //QMdiSubWindow *npcWindow = LastActiveSubWindow;
        NpcEdit *child = new NpcEdit(&configs, LastActiveSubWindow);
        LastActiveSubWindow->setWidget(child);

        if(child->loadFile(filePath, FileData))
        {
            statusBar()->showMessage(tr("NPC Config reloaded"), 2000);
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            updateMenus(LastActiveSubWindow, true);
        }
        else
        {
            child->close();
            LastActiveSubWindow->close();
        }
    }
    else if(activeWindow == WND_World)
    {
        WorldEdit *wldEdit = activeWldEditWin(LastActiveSubWindow);
        WorldData FileData;
        filePath = wldEdit->curFile;

        if(wldEdit->isUntitled)
        {
            QMessageBox::warning(this, tr("File not saved"),
                                 tr("File doesn't saved on disk."), QMessageBox::Ok);
            return;
        }

        if(!QFileInfo(filePath).exists())
        {
            QMessageBox::critical(this, tr("File open error"),
                                  tr("Can't open the file!\nFile not exist."), QMessageBox::Ok);
            return;
        }

        if(wldEdit->WldData.meta.modified)
        {
            QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Reload file and custom stuff"),
                                              tr("Do you want to save before reload stuff?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);

            if((ret == QMessageBox::Cancel) || (ret == 0))
                return;
            else if(ret == QMessageBox::Yes)
                save();
        }

        if(!FileFormats::OpenWorldFile(filePath, FileData))
        {
            formatErrorMsgBox(filePath, FileData.meta.ERROR_info, FileData.meta.ERROR_linenum, FileData.meta.ERROR_linedata);
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;
        }

        QFileInfo finfo(filePath);
        FileData.meta.filename = util::getBaseFilename(finfo.fileName());
        FileData.meta.path = finfo.absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        wldEdit->WldData.meta.modified = false;
        wnGeom = LastActiveSubWindow->geometry();
        QMdiSubWindow *worldWindow = LastActiveSubWindow;
        long posX = wldEdit->scene->m_viewPort->horizontalScrollBar()->value();
        long posY = wldEdit->scene->m_viewPort->verticalScrollBar()->value();
        wldEdit->close();
        WorldEdit *child = new WorldEdit(this, worldWindow);
        connect(child, &WorldEdit::forceReload, this, &MainWindow::on_actionReload_triggered);
        worldWindow->setWidget(child);
        GraphicsWorkspace *gr = static_cast<GraphicsWorkspace *>(child->getGraphicsView());
        connect(gr, SIGNAL(zoomValueChanged(QString)), zoom, SLOT(setText(QString)));

        if(bool(child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts)))
        {
            child->show();
            LastActiveSubWindow->setGeometry(wnGeom);
            child->updateGeometry();
            child->ResetPosition();
            updateMenus(LastActiveSubWindow, true);
            dock_WldSettingsBox->setCurrentWorldSettings();

            if(FileData.HubStyledWorld)
            {
                dock_WldSettingsBox->setVisible(true);
                dock_WldSettingsBox->raise();
            }

            child->scene->m_viewPort->horizontalScrollBar()->setValue(static_cast<int>(posX));
            child->scene->m_viewPort->verticalScrollBar()->setValue(static_cast<int>(posY));
            statusBar()->showMessage(tr("World map file loaded"), 2000);
            child->showCustomStuffWarnings();
        }
        else
        {
            LogDebug(">>File loading aborted");
            //child->show();
            LogDebug(">>Window showed");
            child->WldData.meta.modified = false;
            LogDebug(">>Option set");
            LastActiveSubWindow->close();
            LogDebug(">>Windows closed");
        }
    }

    dock_LvlItemBox->clearFilter();
}