From 445f00371c94ad28924ac5ccadefe72e139aa602 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 1 Dec 2016 22:19:31 -0500 Subject: [PATCH] Debugger: Implement spawning connection window. TeamsWindow: - Create new connection button now sends a message to the main app, which manages the connection window as a singleton. Debugger: - Handle creating/showing connection configuration window as requested. --- src/apps/debugger/Debugger.cpp | 25 +++++++++++++++++++ .../gui/teams_window/TeamsWindow.cpp | 17 ++++++------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp index 28e6d9e416..dbda3bf2ad 100644 --- a/src/apps/debugger/Debugger.cpp +++ b/src/apps/debugger/Debugger.cpp @@ -24,6 +24,7 @@ #include "AppMessageCodes.h" #include "CommandLineUserInterface.h" +#include "ConnectionConfigWindow.h" #include "DebuggerGlobals.h" #include "DebuggerSettingsManager.h" #include "DebuggerUiSettingsFactory.h" @@ -258,6 +259,7 @@ private: private: DebuggerSettingsManager fSettingsManager; + ConnectionConfigWindow* fConnectionWindow; TeamsWindow* fTeamsWindow; StartTeamWindow* fStartTeamWindow; }; @@ -290,6 +292,7 @@ Debugger::Debugger() : BApplication(kDebuggerSignature), TargetHostInterfaceRoster::Listener(), + fConnectionWindow(NULL), fTeamsWindow(NULL), fStartTeamWindow(NULL) { @@ -377,6 +380,28 @@ Debugger::MessageReceived(BMessage* message) fStartTeamWindow = NULL; break; } + case MSG_SHOW_CONNECTION_CONFIG_WINDOW: + { + if (fConnectionWindow != NULL) { + fConnectionWindow->Activate(true); + break; + } + + try { + fConnectionWindow = ConnectionConfigWindow::Create(); + if (fConnectionWindow != NULL) + fConnectionWindow->Show(); + } catch (...) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to create Teams window\n"); + } + break; + } + case MSG_CONNECTION_CONFIG_WINDOW_CLOSED: + { + fConnectionWindow = NULL; + break; + } case MSG_DEBUG_THIS_TEAM: { team_id teamID; diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp index b0c5b6282d..613e23beaa 100644 --- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp +++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp @@ -38,8 +38,7 @@ enum { MSG_TEAM_SELECTION_CHANGED = 'tesc', MSG_CHOSE_CORE_FILE = 'chcf', - MSG_SWITCH_TARGET_CONNECTION = 'stco', - MSG_CREATE_NEW_CONNECTION = 'cnco' + MSG_SWITCH_TARGET_CONNECTION = 'stco' }; @@ -54,7 +53,8 @@ TeamsWindow::TeamsWindow(SettingsManager* settingsManager) fLoadCoreButton(NULL), fConnectionField(NULL), fCoreSelectionPanel(NULL), - fSettingsManager(settingsManager) + fSettingsManager(settingsManager), + fListeners() { team_info info; get_team_info(B_CURRENT_TEAM, &info); @@ -173,11 +173,6 @@ TeamsWindow::MessageReceived(BMessage* message) break; } - case MSG_CREATE_NEW_CONNECTION: - { - break; - } - case MSG_SWITCH_TARGET_CONNECTION: { TargetHostInterface* interface; @@ -191,6 +186,7 @@ TeamsWindow::MessageReceived(BMessage* message) fTargetHostInterface = interface; _NotifySelectedInterfaceChanged(interface); + fLoadCoreButton->SetEnabled(fTargetHostInterface->IsLocal()); break; } @@ -271,7 +267,8 @@ TeamsWindow::_Init() connectionMenu)) .AddGlue() .Add(fCreateConnectionButton = new BButton("Create new connection" - B_UTF8_ELLIPSIS, new BMessage(MSG_CREATE_NEW_CONNECTION))) + B_UTF8_ELLIPSIS, new BMessage( + MSG_SHOW_CONNECTION_CONFIG_WINDOW))) .End() .Add(fTeamsListView = new TeamsListView("TeamsList")) .SetInsets(1.0f, 1.0f, 1.0f, 5.0f) @@ -297,10 +294,10 @@ TeamsWindow::_Init() fTeamsListView->SetSelectionMessage(new BMessage( MSG_TEAM_SELECTION_CHANGED)); - fCreateConnectionButton->SetEnabled(true); fAttachTeamButton->SetEnabled(false); fCreateTeamButton->SetTarget(this); fLoadCoreButton->SetTarget(this); + fCreateConnectionButton->SetTarget(be_app); _NotifySelectedInterfaceChanged(fTargetHostInterface); }