added option to view json
This commit is contained in:
parent
2df9419ce2
commit
67997aa2b1
4 changed files with 38 additions and 4 deletions
|
@ -122,8 +122,9 @@ void Conversation::MessageReceived(BMessage *message) {
|
|||
|
||||
try {
|
||||
|
||||
printf("full Reply as text:%s",body.text.value().String());
|
||||
json parsed = json::parse(body.text.value().String());
|
||||
//printf("full Reply as text:%s",body.text.value().String());
|
||||
auto fullBody =body.text.value().String();
|
||||
json parsed = json::parse(fullBody);
|
||||
printf("Parsed..\n");
|
||||
|
||||
std::string objType = parsed["object"];
|
||||
|
@ -159,6 +160,7 @@ void Conversation::MessageReceived(BMessage *message) {
|
|||
// printf("we got content:%s",content.c_str());
|
||||
BMessage message(kSendReply);
|
||||
message.AddString("text", BString(content.c_str()));
|
||||
message.AddString("json", BString(fullBody));
|
||||
sendReply(message);
|
||||
}
|
||||
|
||||
|
|
BIN
DumBer
BIN
DumBer
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ static const uint32 kMsgNewFile = 'fnew';
|
|||
static const uint32 kMsgOpenFile = 'fopn';
|
||||
static const uint32 kMsgSaveFile = 'fsav';
|
||||
static const uint32 kModelSelected = 'msel';
|
||||
static const uint32 kViewJSON = 'vjso';
|
||||
|
||||
|
||||
|
||||
static const uint32 kPulse = 'plse';
|
||||
|
||||
|
@ -51,6 +54,9 @@ public:
|
|||
void updateHistoryInfo();
|
||||
|
||||
private:
|
||||
|
||||
std::string lastJSON;
|
||||
|
||||
void ShowMissingKeyAlertAndQuit();
|
||||
void SelectModelByName(const char *targetLabel);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue