Qt: Disable "New multiplayer window" when MAX_GBAS is reached. Fixes #107.
waddlesplash waddlesplash@gmail.com
Tue, 16 May 2017 14:54:57 -0400
3 files changed,
12 insertions(+),
3 deletions(-)
M
src/platform/qt/GBAApp.cpp
→
src/platform/qt/GBAApp.cpp
@@ -127,6 +127,9 @@ Window* w = new Window(&m_configController, m_multiplayer.attached());
int windowId = m_multiplayer.attached(); connect(w, &Window::destroyed, [this, w]() { m_windows.removeAll(w); + for (Window* w : m_windows) { + w->updateMultiplayerStatus(m_windows.count() < MAX_GBAS); + } }); m_windows.append(w); w->setAttribute(Qt::WA_DeleteOnClose);@@ -134,6 +137,9 @@ w->loadConfig();
w->show(); w->controller()->setMultiplayerController(&m_multiplayer); w->multiplayerChanged(); + for (Window* w : m_windows) { + w->updateMultiplayerStatus(m_windows.count() < MAX_GBAS); + } return w; }
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -1088,11 +1088,11 @@ addControlledAction(fileMenu, exportShark, "exportShark");
#endif fileMenu->addSeparator(); - QAction* multiWindow = new QAction(tr("New multiplayer window"), fileMenu); - connect(multiWindow, &QAction::triggered, [this]() { + m_multiWindow = new QAction(tr("New multiplayer window"), fileMenu); + connect(m_multiWindow, &QAction::triggered, [this]() { GBAApp::app()->newWindow(); }); - addControlledAction(fileMenu, multiWindow, "multiWindow"); + addControlledAction(fileMenu, m_multiWindow, "multiWindow"); #ifndef Q_OS_MAC fileMenu->addSeparator();
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -49,6 +49,8 @@ void argumentsPassed(mArguments*);
void resizeFrame(const QSize& size); + void updateMultiplayerStatus(bool canOpenAnother) { m_multiWindow->setEnabled(canOpenAnother); } + signals: void startDrawing(mCoreThread*); void shutdown();@@ -160,6 +162,7 @@ QList<QAction*> m_nonMpActions;
#ifdef M_CORE_GBA QList<QAction*> m_gbaActions; #endif + QAction* m_multiWindow; QMap<int, QAction*> m_frameSizes; LogController m_log; LogView* m_logView;