| 76 | } |
| 77 | |
| 78 | bool NetHackQtStringRequestor::Get(char *buffer, int maxchar, int minchar) |
| 79 | { |
| 80 | input.setMaxLength(maxchar - 1); |
| 81 | |
| 82 | const QString &txt = prompt.text(); |
| 83 | int pw = fontMetrics().QFM_WIDTH(txt), |
| 84 | ww = minchar * input.fontMetrics().QFM_WIDTH(QChar('X')); |
| 85 | int heightfactor = ((txt.size() > 16) ? 3 : 2) * 2; // 2 or 3 lines high |
| 86 | int widthfudge = (((txt.size() > 16) ? 1 : 2) * 5) * 2; // 5: margn, guttr |
| 87 | resize(pw + ww + widthfudge, fontMetrics().height() * heightfactor); |
| 88 | |
| 89 | #ifdef EDIT_GETLIN |
| 90 | input.setText(buffer); |
| 91 | #endif |
| 92 | centerOnMain(this); |
| 93 | show(); |
| 94 | // Make sure that setFocus() really does change keyboard focus. |
| 95 | // This allows typing to go directly to the NetHackQtLineEdit |
| 96 | // widget without clicking on or in it first. Not needed for |
| 97 | // qt_getline() but is needed for menu Search to prevent typed |
| 98 | // characters being treated as making menu selections. |
| 99 | if (!input.isActiveWindow()) |
| 100 | input.activateWindow(); |
| 101 | input.setFocus(); |
| 102 | exec(); |
| 103 | |
| 104 | if (result()) { |
| 105 | str_copy(buffer, input.text().toLatin1().constData(), maxchar); |
| 106 | return true; |
| 107 | } else { |
| 108 | return false; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | } // namespace nethack_qt_ |
nothing calls this directly
no test coverage detected