本文整理汇总了C++中QMdiSubWindow::setWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QMdiSubWindow::setWidget方法的具体用法?C++ QMdiSubWindow::setWidget怎么用?C++ QMdiSubWindow::setWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMdiSubWindow
的用法示例。
在下文中一共展示了QMdiSubWindow::setWidget方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFixtureDefinition
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);
}
}
示例2: addSubWindow
/**
\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ño de la ventana que esta diseñada con Designer:
/// Sólo si la ventana es más grande que el espacio de representación
/// se ajusta para caber dentro.
/// Captura el tamaño disponible. Restamos el margen que dejamos a cada lado (x2).
tamdispW = this->width() - ( margen * 2 );
tamdispH = this->height() - ( margen * 2 );
/// Captura el tamaño con decoración de la ventana a insertar.
tamventanadecoW = w->parentWidget() ->frameGeometry().width();
tamventanadecoH = w->parentWidget() ->frameGeometry().height();
/// Captura el tamaño sin decoración de la ventana a insertar.
tamventanaW = w->geometry().width();
tamventanaH = w->geometry().height();
/// Comprobamos si es necesario cambiar el tamañ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 );
}
示例3: createAndShow
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();
}
示例4: slotFileNew
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();
}
示例5: insertPlot
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;
}
示例6: slotMainActionForMenuTriggered
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 {
示例7: slotMainActionForMenuTriggered
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 {
示例8: openPage
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 );
}
示例9: on_actionReload_triggered
//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();
//.........这里部分代码省略.........
示例10: QVBoxLayout
/* 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 );
//.........这里部分代码省略.........
示例11: QWidget
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, ×tep);
setData(Workspace::STATE, 3, &maxTimestep);
setData(Workspace::STATE, 4, &jitter);
setActive(true);
saveStats = false;
}
示例12: on_actionReload_triggered
//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;
//.........这里部分代码省略.........