| 5039 | } |
| 5040 | |
| 5041 | NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(NetHackQtKeyBuffer& ks) : |
| 5042 | QDialog(qApp->mainWidget(), "ext-cmd", FALSE), |
| 5043 | keysource(ks) |
| 5044 | { |
| 5045 | int marg=4; |
| 5046 | QVBoxLayout *l = new QVBoxLayout(this,marg,marg); |
| 5047 | |
| 5048 | QPushButton* can = new QPushButton("Cancel", this); |
| 5049 | can->setDefault(TRUE); |
| 5050 | can->setMinimumSize(can->sizeHint()); |
| 5051 | l->addWidget(can); |
| 5052 | |
| 5053 | QButtonGroup *group=new QButtonGroup("",0); |
| 5054 | QGroupBox *grid=new QGroupBox("Extended commands",this); |
| 5055 | l->addWidget(grid); |
| 5056 | |
| 5057 | int i; |
| 5058 | int butw=50; |
| 5059 | QFontMetrics fm = fontMetrics(); |
| 5060 | for (i=0; extcmdlist[i].ef_txt; i++) { |
| 5061 | butw = QMAX(butw,30+fm.width(extcmdlist[i].ef_txt)); |
| 5062 | } |
| 5063 | int ncols=4; |
| 5064 | int nrows=(i+ncols-1)/ncols; |
| 5065 | |
| 5066 | QVBoxLayout* bl = new QVBoxLayout(grid,marg); |
| 5067 | bl->addSpacing(fm.height()); |
| 5068 | QGridLayout* gl = new QGridLayout(nrows,ncols,marg); |
| 5069 | bl->addLayout(gl); |
| 5070 | for (i=0; extcmdlist[i].ef_txt; i++) { |
| 5071 | QPushButton* pb=new QPushButton(extcmdlist[i].ef_txt, grid); |
| 5072 | pb->setMinimumSize(butw,pb->sizeHint().height()); |
| 5073 | group->insert(pb); |
| 5074 | gl->addWidget(pb,i/ncols,i%ncols); |
| 5075 | } |
| 5076 | connect(group,SIGNAL(clicked(int)),this,SLOT(done(int))); |
| 5077 | |
| 5078 | bl->activate(); |
| 5079 | l->activate(); |
| 5080 | resize(1,1); |
| 5081 | |
| 5082 | connect(can,SIGNAL(clicked()),this,SLOT(cancel())); |
| 5083 | } |
| 5084 | |
| 5085 | void NetHackQtExtCmdRequestor::cancel() |
| 5086 | { |
nothing calls this directly
no test coverage detected