1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-01 11:06:39 +00:00

Fixes docked subviews becoming tabbed and application closure when

closing one of several views.
This commit is contained in:
graffy76 2013-03-11 06:38:27 -05:00
parent ce91ef36ea
commit 96b62940b3
3 changed files with 19 additions and 11 deletions

View file

@ -131,10 +131,12 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1),
mViewTotal (totalViews) mViewTotal (totalViews)
{ {
setDockOptions (QMainWindow::AllowNestedDocks); // setDockOptions (QMainWindow::AllowNestedDocks);
resize (300, 300); /// \todo get default size from settings and set reasonable minimal size resize (300, 300); /// \todo get default size from settings and set reasonable minimal size
mSubViewWindow.setDockOptions (QMainWindow::AllowNestedDocks);
setCentralWidget (&mSubViewWindow); setCentralWidget (&mSubViewWindow);
mOperations = new Operations; mOperations = new Operations;

View file

@ -14,6 +14,8 @@
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QtGui/QApplication>
#include <QDebug>
void CSVDoc::ViewManager::updateIndices() void CSVDoc::ViewManager::updateIndices()
{ {
@ -44,6 +46,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GlobalVarType, mDelegateFactories->add (CSMWorld::ColumnBase::Display_GlobalVarType,
new CSVWorld::VarTypeDelegateFactory (ESM::VT_Short, ESM::VT_Long, ESM::VT_Float)); new CSVWorld::VarTypeDelegateFactory (ESM::VT_Short, ESM::VT_Long, ESM::VT_Float));
connect (this, SIGNAL (exitApplication()), QApplication::instance(), SLOT (closeAllWindows()));
} }
CSVDoc::ViewManager::~ViewManager() CSVDoc::ViewManager::~ViewManager()
@ -143,7 +147,7 @@ bool CSVDoc::ViewManager::showModifiedDocumentMessageBox (std::vector<View *>::i
bool retVal = true; bool retVal = true;
connect (this, SIGNAL (closeMessageBox()), &messageBox, SLOT (close())); connect (this, SIGNAL (closeMessageBox()), &messageBox, SLOT (close()));
connect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); connect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
mUserWarned = true; mUserWarned = true;
int response = messageBox.exec(); int response = messageBox.exec();
@ -161,13 +165,13 @@ bool CSVDoc::ViewManager::showModifiedDocumentMessageBox (std::vector<View *>::i
case QMessageBox::Discard: case QMessageBox::Discard:
disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
break; break;
case QMessageBox::Cancel: case QMessageBox::Cancel:
//disconnect to prevent unintended view closures //disconnect to prevent unintended view closures
disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
retVal = false; retVal = false;
break; break;
@ -195,7 +199,7 @@ bool CSVDoc::ViewManager::showSaveInProgressMessageBox (std::vector<View *>::ite
bool retVal = true; bool retVal = true;
//Connections shut down message box if operation ends before user makes a decision. //Connections shut down message box if operation ends before user makes a decision.
connect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); connect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
connect (this, SIGNAL (closeMessageBox()), &messageBox, SLOT (close())); connect (this, SIGNAL (closeMessageBox()), &messageBox, SLOT (close()));
//set / clear the user warned flag to indicate whether or not the message box is currently active. //set / clear the user warned flag to indicate whether or not the message box is currently active.
@ -216,7 +220,7 @@ bool CSVDoc::ViewManager::showSaveInProgressMessageBox (std::vector<View *>::ite
else if (messageBox.clickedButton() == closeButton) else if (messageBox.clickedButton() == closeButton)
{ {
//disconnect to avoid segmentation fault //disconnect to avoid segmentation fault
disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
(*viewIter)->abortOperation(CSMDoc::State_Saving); (*viewIter)->abortOperation(CSMDoc::State_Saving);
mCloseMeOnSaveStateChange = mViews.end(); mCloseMeOnSaveStateChange = mViews.end();
} }
@ -226,7 +230,7 @@ bool CSVDoc::ViewManager::showSaveInProgressMessageBox (std::vector<View *>::ite
//abort shutdown, allow save to complete //abort shutdown, allow save to complete
//disconnection to prevent unintended view closures //disconnection to prevent unintended view closures
mCloseMeOnSaveStateChange = mViews.end(); mCloseMeOnSaveStateChange = mViews.end();
disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onCloseWarningHandler(int, CSMDoc::Document *))); disconnect ((*viewIter)->getDocument(), SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (onExitWarningHandler(int, CSMDoc::Document *)));
retVal = false; retVal = false;
} }
@ -247,7 +251,7 @@ void CSVDoc::ViewManager::progress (int current, int max, int type, int threads,
(*iter)->updateProgress (current, max, type, threads); (*iter)->updateProgress (current, max, type, threads);
} }
void CSVDoc::ViewManager::onCloseWarningHandler (int state, CSMDoc::Document *document) void CSVDoc::ViewManager::onExitWarningHandler (int state, CSMDoc::Document *document)
{ {
if ( !(state & CSMDoc::State_Saving) ) if ( !(state & CSMDoc::State_Saving) )
{ {
@ -257,10 +261,10 @@ void CSVDoc::ViewManager::onCloseWarningHandler (int state, CSMDoc::Document *do
emit closeMessageBox(); emit closeMessageBox();
//otherwise, the user has closed the message box before the save operation ended. //otherwise, the user has closed the message box before the save operation ended.
//close the view //exit the application
else if (mCloseMeOnSaveStateChange!=mViews.end()) else if (mCloseMeOnSaveStateChange!=mViews.end())
{ {
(*mCloseMeOnSaveStateChange)->close(); emit exitApplication();
mCloseMeOnSaveStateChange = mViews.end(); mCloseMeOnSaveStateChange = mViews.end();
} }
} }

View file

@ -60,13 +60,15 @@ namespace CSVDoc
void closeMessageBox(); void closeMessageBox();
void exitApplication();
private slots: private slots:
void documentStateChanged (int state, CSMDoc::Document *document); void documentStateChanged (int state, CSMDoc::Document *document);
void progress (int current, int max, int type, int threads, CSMDoc::Document *document); void progress (int current, int max, int type, int threads, CSMDoc::Document *document);
void onCloseWarningHandler(int state, CSMDoc::Document* document); void onExitWarningHandler(int state, CSMDoc::Document* document);
}; };
} }