Qt4: Put yn queries in message history

When using OPTIONS=popup_dialog, or compiling with USE_POPUPS,
the yes/no -questions weren't put into the message history.
This commit is contained in:
Pasi Kallinen
2017-10-11 09:50:22 +03:00
parent 5d1f77301a
commit 46217bbda2
+24 -22
View File
@@ -497,10 +497,6 @@ int NetHackQtBind::qt_doprev_message()
char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, CHAR_P def) char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, CHAR_P def)
{ {
QString question(QString::fromLatin1(question_)); QString question(QString::fromLatin1(question_));
if (qt_settings->ynInMessages() && WIN_MESSAGE!=WIN_ERR) {
// Similar to X11 windowport `slow' feature.
QString message; QString message;
char yn_esc_map='\033'; char yn_esc_map='\033';
@@ -518,30 +514,31 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C
message = question; message = question;
} }
#ifdef USE_POPUPS if (qt_settings->ynInMessages() && WIN_MESSAGE!=WIN_ERR) {
// Improve some special-cases (DIRKS 08/02/23) // Similar to X11 windowport `slow' feature.
if (strcmp (choices,"ynq") == 0) {
switch (QMessageBox::information (NetHackQtBind::mainWidget(),"NetHack",question,"&Yes","&No","&Quit",0,2))
{
case 0: return 'y';
case 1: return 'n';
case 2: return 'q';
}
}
if (strcmp (choices,"yn") == 0) { int result = -1;
switch (QMessageBox::information(NetHackQtBind::mainWidget(),"NetHack",question,"&Yes", "&No",0,1))
{ #ifdef USE_POPUPS
case 0: return 'y'; if (choices) {
case 1: return 'n'; if (!strcmp(choices,"ynq"))
result = QMessageBox::information (NetHackQtBind::mainWidget(),"NetHack",question,"&Yes","&No","&Quit",0,2);
else if (!strcmp(choices,"yn"))
result = QMessageBox::information(NetHackQtBind::mainWidget(),"NetHack",question,"&Yes", "&No",0,1);
else if (!strcmp(choices, "rl"))
result = QMessageBox::information(NetHackQtBind::mainWidget(),"NetHack",question,"&Right", "&Left",0,1);
if (result >= 0 && result < strlen(choices)) {
char yn_resp = choices[result];
message += QString(" %1").arg(yn_resp);
result = yn_resp;
} }
} }
#endif #endif
NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, message); NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, message);
int result=-1; while (result < 0) {
while (result<0) {
char ch=NetHackQtBind::qt_nhgetch(); char ch=NetHackQtBind::qt_nhgetch();
if (ch=='\033') { if (ch=='\033') {
result=yn_esc_map; result=yn_esc_map;
@@ -562,7 +559,12 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C
return result; return result;
} else { } else {
NetHackQtYnDialog dialog(mainWidget(),question,choices,def); NetHackQtYnDialog dialog(mainWidget(),question,choices,def);
return dialog.Exec(); char ret = dialog.Exec();
if (!(ret == '\0' || ret == '\033') && choices)
message += QString(" %1").arg(ret);
else if (def)
message += QString(" %1").arg(def);
NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, message);
} }
} }