From 83776950cdb8c4852c3b924309d9ea0b59916f30 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 26 Aug 2017 17:20:50 +0200 Subject: [PATCH] SerialConnect: fix mixup of file panels - Use separate file panels for "load" and "save" directions - Change the message sent by the "load" panel according to the protocol to use (it just forwards the one from the BMenuItem used to invoke it, which already has the protocol information). --- src/apps/serialconnect/SerialWindow.cpp | 17 ++++++++++++++--- src/apps/serialconnect/SerialWindow.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/apps/serialconnect/SerialWindow.cpp b/src/apps/serialconnect/SerialWindow.cpp index 4524fa1793..6890c69070 100644 --- a/src/apps/serialconnect/SerialWindow.cpp +++ b/src/apps/serialconnect/SerialWindow.cpp @@ -42,6 +42,7 @@ SerialWindow::SerialWindow() : BWindow(BRect(100, 100, 400, 400), SerialWindow::kWindowTitle, B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) , fLogFilePanel(NULL) + , fSendFilePanel(NULL) { BMenuBar* menuBar = new BMenuBar(Bounds(), "menuBar"); menuBar->ResizeToPreferred(); @@ -249,6 +250,7 @@ SerialWindow::SerialWindow() SerialWindow::~SerialWindow() { delete fLogFilePanel; + delete fSendFilePanel; } @@ -325,18 +327,27 @@ void SerialWindow::MessageReceived(BMessage* message) return; } case kMsgLogfile: - case kMsgSendFile: { // Let's lazy init the file panel if (fLogFilePanel == NULL) { - fLogFilePanel = new BFilePanel( - message->what == kMsgSendFile ? B_OPEN_PANEL : B_SAVE_PANEL, + fLogFilePanel = new BFilePanel(B_SAVE_PANEL, &be_app_messenger, NULL, B_FILE_NODE, false); fLogFilePanel->SetMessage(message); } fLogFilePanel->Show(); return; } + case kMsgSendFile: + { + // Let's lazy init the file panel + if (fSendFilePanel == NULL) { + fSendFilePanel = new BFilePanel(B_OPEN_PANEL, + &be_app_messenger, NULL, B_FILE_NODE, false); + } + fSendFilePanel->SetMessage(message); + fSendFilePanel->Show(); + return; + } case kMsgSettings: { int32 baudrate; diff --git a/src/apps/serialconnect/SerialWindow.h b/src/apps/serialconnect/SerialWindow.h index 7853e77dd6..0157975b72 100644 --- a/src/apps/serialconnect/SerialWindow.h +++ b/src/apps/serialconnect/SerialWindow.h @@ -35,6 +35,7 @@ class SerialWindow: public BWindow BMenu* fLineTerminatorMenu; BMenu* fFileMenu; BFilePanel* fLogFilePanel; + BFilePanel* fSendFilePanel; BStatusBar* fStatusBar; static const int kBaudrates[];