diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 27fda0a1a76..9480d1dc6e1 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -39,18 +39,18 @@ void SubWindow::closeAllButThisEmit() { + // trigger signal sender to send a close event to all elements emit SignalSender::getInstance()->closeAllButThis(this); } - void SubWindow::closeAllButThisRecive(SubWindow* source) { + // check if source of signal is equal to the current window if (source != this) { emit closeSignal(); } } - SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : QMdiSubWindow( parent, windowFlags ), m_buttonSize( 17, 17 ), @@ -115,8 +115,9 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_closeAllAction = new QAction(); m_closeAllAction->setText("Close all"); m_closeAllAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_W)); - // connect action to signal + // connect action to SignalSender connect(m_closeAllAction, SIGNAL(triggered()), SignalSender::getInstance(), SLOT(closeAll())); + // connect SignalSender to close action connect(SignalSender::getInstance(), SIGNAL(closeAllSignal()), this, SLOT(close())); // add action to subwindow to capture keypress addAction(m_closeAllAction); @@ -127,10 +128,11 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_closeAllButThisAction = new QAction(); m_closeAllButThisAction->setText("Close all but this"); m_closeAllButThisAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Q)); - // connect action to signal + // connect action to signal emit connect(m_closeAllButThisAction, SIGNAL(triggered()), this, SLOT(closeAllButThisEmit())); - //connect(m_closeAllButThisAction, SIGNAL(triggered()), SignalSender::getInstance(), SLOT(closeAllButThis(this))); + // connect SignalSender to signal recive connect(SignalSender::getInstance(), SIGNAL(closeAllButThisSignal(SubWindow*)), this, SLOT(closeAllButThisRecive(SubWindow*))); + // connect signal to close action connect(this, SIGNAL(closeSignal()), this, SLOT(close())); // add action to subwindow to capture keypress addAction(m_closeAllButThisAction);