MCPcopy Create free account
hub / github.com/NetHack/NetHack / Get

Method Get

win/Qt/qt_streq.cpp:78–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78bool 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_

Callers

nothing calls this directly

Calls 3

str_copyFunction · 0.85
centerOnMainFunction · 0.70
heightMethod · 0.45

Tested by

no test coverage detected