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).
This commit is contained in:
Adrien Destugues 2017-08-26 17:20:50 +02:00
parent f1af46a2c0
commit 83776950cd
2 changed files with 15 additions and 3 deletions

View File

@ -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;

View File

@ -35,6 +35,7 @@ class SerialWindow: public BWindow
BMenu* fLineTerminatorMenu;
BMenu* fFileMenu;
BFilePanel* fLogFilePanel;
BFilePanel* fSendFilePanel;
BStatusBar* fStatusBar;
static const int kBaudrates[];