added option to view json

This commit is contained in:
Santiago Lema 2025-05-10 01:47:05 -03:00
parent 2df9419ce2
commit 67997aa2b1
4 changed files with 38 additions and 4 deletions

View file

@ -374,6 +374,13 @@ void MainWindow::MessageReceived(BMessage *message) {
} break;
case kViewJSON: {
_infoView->SetText("Showing JSON");
_answerView->SetText(lastJSON.c_str());
progressAnim=0;
} break;
case kSendReply: {
_sendButton->SetEnabled(true);
@ -381,12 +388,22 @@ void MainWindow::MessageReceived(BMessage *message) {
waitMode = false;
progressColor = 255;
printf("Conversation returned!\n");
printf("kSendReply - Conversation returned!\n");
_infoView->SetText("Answer Received");
progressAnim = 100;
const char *text;
const char *fullJSON;
if (message->FindString("json", &fullJSON) == B_OK) {
lastJSON = std::string(fullJSON);
}
if (message->FindString("text", &text) == B_OK) {
// printf("Received text: %s\n", text);
// Do something with text (e.g., set it to a BTextView)
@ -458,15 +475,24 @@ BMenuBar *MainWindow::_BuildMenu() {
item->SetTarget(this);
menu->AddItem(item);
menu->AddSeparatorItem();
item = new BMenuItem(B_TRANSLATE("Clear History" B_UTF8_ELLIPSIS),
new BMessage(kClearHistory));
item->SetTarget(this);
item->SetShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY);
menu->AddItem(item);
menuBar->AddItem(menu);
menu->AddSeparatorItem();
item = new BMenuItem(B_TRANSLATE("View full json" B_UTF8_ELLIPSIS),
new BMessage(kViewJSON));
item->SetTarget(this);
item->SetShortcut('J', B_COMMAND_KEY | B_SHIFT_KEY);
menu->AddItem(item);
return menuBar;
}