Skip to content

Commit

Permalink
close others
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-giddins committed Jan 31, 2021
1 parent f4b53f0 commit 50e0e52
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions include/SignalSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class SignalSender : public QObject

signals:
void closeAllSignal();
void closeAllButThisSignal(SubWindow * source);
void closeOthersSignal(SubWindow * source);

public slots:
void closeAll();
void closeAllButThis(SubWindow* source);
void closeOthers(SubWindow* source);
};

#endif
6 changes: 3 additions & 3 deletions include/SubWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ class LMMS_EXPORT SubWindow : public QMdiSubWindow
bool m_hasFocus;
QMenu* m_systemMenu;
QAction* m_closeAllAction;
QAction* m_closeAllButThisAction;
QAction* m_closeOthersAction;

static void elideText( QLabel *label, QString text );
void adjustTitleBar();

private slots:
void focusChanged( QMdiSubWindow * subWindow );
void closeAllButThisEmit();
void closeAllButThisRecive( SubWindow * source);
void closeOthersEmit();
void closeOthersRecive( SubWindow * source);
};

#endif
4 changes: 2 additions & 2 deletions src/gui/SignalSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void SignalSender::closeAll()
emit closeAllSignal();
}

void SignalSender::closeAllButThis(SubWindow* source)
void SignalSender::closeOthers(SubWindow* source)
{
emit closeAllButThisSignal(source);
emit closeOthersSignal(source);
}
24 changes: 12 additions & 12 deletions src/gui/SubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
#include "embed.h"
#include "SignalSender.h"

void SubWindow::closeAllButThisEmit()
void SubWindow::closeOthersEmit()
{
// trigger signal sender to send a close event to all elements
emit SignalSender::getInstance()->closeAllButThis(this);
emit SignalSender::getInstance()->closeOthers(this);
}

void SubWindow::closeAllButThisRecive(SubWindow* source)
void SubWindow::closeOthersRecive(SubWindow* source)
{
// check if source of signal is equal to the current window
// make sure source of signal is not the current window
if (source != this) {
emit closeSignal();
}
Expand Down Expand Up @@ -124,20 +124,20 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) :
// add action to systemMenu
m_systemMenu->addAction(m_closeAllAction);

// create 'close all but this' action
m_closeAllButThisAction = new QAction();
m_closeAllButThisAction->setText("Close all but this");
m_closeAllButThisAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Q));
// create 'close others' action
m_closeOthersAction = new QAction();
m_closeOthersAction->setText("Close others");
m_closeOthersAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Q));
// connect action to signal emit
connect(m_closeAllButThisAction, SIGNAL(triggered()), this, SLOT(closeAllButThisEmit()));
connect(m_closeOthersAction, SIGNAL(triggered()), this, SLOT(closeOthersEmit()));
// connect SignalSender to signal recive
connect(SignalSender::getInstance(), SIGNAL(closeAllButThisSignal(SubWindow*)), this, SLOT(closeAllButThisRecive(SubWindow*)));
connect(SignalSender::getInstance(), SIGNAL(closeOthersSignal(SubWindow*)), this, SLOT(closeOthersRecive(SubWindow*)));
// connect signal to close action
connect(this, SIGNAL(closeSignal()), this, SLOT(close()));
// add action to subwindow to capture keypress
addAction(m_closeAllButThisAction);
addAction(m_closeOthersAction);
// add action to systemMenu
m_systemMenu->addAction(m_closeAllButThisAction);
m_systemMenu->addAction(m_closeOthersAction);

// update systemMenu
setSystemMenu(m_systemMenu);
Expand Down

0 comments on commit 50e0e52

Please sign in to comment.