diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2008-12-08 01:44:03 +0100 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2008-12-08 01:44:03 +0100 |
commit | db090e65b3041b5856d9318a29ce44fb985376e7 (patch) | |
tree | 4d9cc959760fb73a8f30747a273323c6d016842e | |
parent | f56606b58d991e84a4f92942618ff5541929e5a6 (diff) | |
download | dbmodel-db090e65b3041b5856d9318a29ce44fb985376e7.tar.gz dbmodel-db090e65b3041b5856d9318a29ce44fb985376e7.tar.bz2 |
Add a Close menu item, and change the Quit item to close all windows
-rw-r--r-- | src/mainwindow.cpp | 25 | ||||
-rw-r--r-- | src/mainwindow.h | 4 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2038f5d..f714ad2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -241,6 +241,18 @@ MainWindow::setupActions() m_actionAbout = new QAction(this); m_actionAbout->setText(tr("&About...")); connect(m_actionAbout, SIGNAL(triggered(bool)), SLOT(about())); + + m_actionClose = new QAction(this); + m_actionClose->setText(tr("&Close")); + m_actionClose->setIcon(IconProvider::findIcon(16, "window-close.png")); + m_actionClose->setShortcut(QKeySequence(tr("Ctrl+W"))); + connect(m_actionClose, SIGNAL(triggered(bool)), SLOT(close())); + + m_actionQuit = new QAction(this); + m_actionQuit->setText(tr("&Quit")); + m_actionQuit->setIcon(IconProvider::findIcon(16, "application-exit.png")); + m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q"))); + connect(m_actionQuit, SIGNAL(triggered(bool)), SLOT(closeAll())); } void @@ -309,7 +321,8 @@ MainWindow::setupMenuBar() menu->addAction(m_actionRecentFile[i]); menu->addSeparator(); - menu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(tr("Ctrl+Q"))); + menu->addAction(m_actionClose); + menu->addAction(m_actionQuit); menu = menuBar()->addMenu(tr("&Edit")); menu->addAction(m_actionUndo); @@ -531,6 +544,16 @@ MainWindow::addRecentFile(const QString &fileName) } void +MainWindow::closeAll() +{ + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + MainWindow *mainWin = qobject_cast<MainWindow *>(widget); + if (mainWin) + mainWin->close(); + } +} + +void MainWindow::updateRecentFileActions() { QSettings settings; diff --git a/src/mainwindow.h b/src/mainwindow.h index a80220d..d5c3ba3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -69,6 +69,7 @@ public slots: void copy(); void paste(); void updateClipboard(QClipboard::Mode mode); + void closeAll(); protected: void setupUi(); @@ -99,6 +100,9 @@ private: QAction *m_actionSaveAs; QAction *m_actionExportPNG; + QAction *m_actionClose; + QAction *m_actionQuit; + QAction *m_actionCut; QAction *m_actionCopy; QAction *m_actionPaste; |