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

Method NetHackQtExtCmdRequestor

win/Qt/qt_xcmd.cpp:139–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
140 QDialog(parent),
141 prompt(new QLabel("#", this)),
142 cancel_btn(new QPushButton("Cancel", this)),
143 byRow(qt_settings->xcmd_by_row),
144 set(qt_settings->xcmd_set),
145 butoffset(0),
146 exactmatchindx(xcmdNoMatch)
147{
148 if (!WizardMode && set != normal_cmds)
149 set = autocomplete_cmds; // {all,wizard}_cmds are wizard mode only
150
151 QVBoxLayout *xl = new QVBoxLayout(this); // overall xcmd layout
152 int butw = 50; // initial button width; will be increased if too small
153 // should probably use the qt_settings font size as a spacing hint;
154 // tiny font, tiny internal margins; small font, small margins;
155 // medium or bigger, default margins (9 or 11?)
156 int spacing = qt_compact_mode ? 3 : -1; // 0 would abut; -1 gives default
157
158 // first, the popup's controls: a row of buttons along the top;
159 // the two padding widgets make the control buttons line up better
160 // with the grid of xcmd choice buttons (closer but not exactly)
161 QHBoxLayout *ctrls = new QHBoxLayout();
162 ctrls->setSpacing(spacing); // only seems to affect horizontal, not vert.
163 ctrls->addWidget(new QLabel(" ")); // padding
164 // Cancel, created during constructor setup (accessed in other routines)
165 DefaultActionIsCancel(true); /* cancel_btn->setDefault(true); */
166 cancel_btn->setMinimumSize(cancel_btn->sizeHint());
167 butw = std::max(butw, cancel_btn->width());
168 ctrls->addWidget(cancel_btn);
169 ctrls->addStretch(0); // Cancel will be left justified, others far right
170 // Filter: change the [sub]set of commands that get shown;
171 // presently only useful when running in wizard mode
172 QPushButton *filter_btn = new QPushButton("Filter", this);
173#if 0 /* [later] normal vs autocomplete matters regardless of wizard mode */
174 if (!WizardMode) { // nothing to filter if not in wizard mode
175 filter_btn->setEnabled(false); // gray the [Filter] button out
176#if 0 /* This works but makes [Reset] seem to be redundant. */
177 // graying out may not be adequate; conceal [Filter] so that
178 // players without access to wizard mode won't become concerned
179 // about something that seems to them to always be disabled
180 filter_btn->hide();
181#endif
182 }
183#endif
184 filter_btn->setMinimumSize(filter_btn->sizeHint());
185 butw = std::max(butw, filter_btn->width());
186 ctrls->addWidget(filter_btn);
187 // Layout: switch from by-column grid to by-row grid or vice versa
188 QPushButton *layout_btn = new QPushButton("Layout", this);
189 layout_btn->setMinimumSize(layout_btn->sizeHint());
190 butw = std::max(butw, layout_btn->width());
191 ctrls->addWidget(layout_btn);
192 // Reset: switch filter back to all commands and layout back to by-column
193 QPushButton *reset__btn = new QPushButton("Reset", this);
194 reset__btn->setMinimumSize(reset__btn->sizeHint());
195 butw = std::max(butw, reset__btn->width());
196 ctrls->addWidget(reset__btn);

Callers

nothing calls this directly

Calls 6

interesting_commandFunction · 0.85
nh_qsprintfFunction · 0.85
sizeHintMethod · 0.45
widthMethod · 0.45
setFontMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected