Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-giddins committed Jan 31, 2021
1 parent 15b445d commit f4b53f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/gui/SubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit f4b53f0

Please sign in to comment.