Let Qt keep track of top-level windows.
This commit is contained in:
+4
-1
@@ -204,8 +204,11 @@ void File::close( MainWindow *window )
|
|||||||
///
|
///
|
||||||
void File::exit()
|
void File::exit()
|
||||||
{
|
{
|
||||||
foreach ( MainWindow* window, MainWindow::windowList() )
|
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
||||||
|
{
|
||||||
|
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
||||||
{
|
{
|
||||||
window->close();
|
window->close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,6 @@
|
|||||||
#include "Help.h"
|
#include "Help.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Static window list
|
|
||||||
///
|
|
||||||
QList<MainWindow*> MainWindow::smWindowList;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -146,8 +140,6 @@ MainWindow::MainWindow()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
smWindowList.push_back( this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,7 +148,6 @@ MainWindow::MainWindow()
|
|||||||
///
|
///
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
smWindowList.removeOne( this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -208,14 +199,6 @@ bool MainWindow::isEmpty() const
|
|||||||
return mModel == 0;
|
return mModel == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Get window list
|
|
||||||
///
|
|
||||||
QList<MainWindow*> MainWindow::windowList()
|
|
||||||
{
|
|
||||||
return smWindowList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close Event Handler
|
/// Close Event Handler
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ public:
|
|||||||
void setModel( LabelModel* label );
|
void setModel( LabelModel* label );
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
static QList<MainWindow *> windowList();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Events
|
// Events
|
||||||
@@ -186,8 +184,6 @@ private:
|
|||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
static QList<MainWindow*> smWindowList;
|
|
||||||
|
|
||||||
QMenu* fileMenu;
|
QMenu* fileMenu;
|
||||||
QMenu* editMenu;
|
QMenu* editMenu;
|
||||||
QMenu* viewMenu;
|
QMenu* viewMenu;
|
||||||
|
|||||||
Reference in New Issue
Block a user