120
121
AHCommandDlg::AHCommandDlg(PsiAccount* pa, const Jid& receiver)
121
122
: QDialog(0), pa_(pa), receiver_(receiver)
123
125
setAttribute(Qt::WA_DeleteOnClose);
124
QVBoxLayout *vb = new QVBoxLayout(this, 11, 6);
126
// Command list + Buttons
127
QLabel* lb_commands = new QLabel(tr("Command:"),this);
128
vb->addWidget(lb_commands);
129
cb_commands = new QComboBox(this);
130
vb->addWidget(cb_commands);
131
/*pb_info = new QPushButton(tr("Info"), this);
132
hb1->addWidget(pb_info);*/
135
//pb_refresh = new QPushButton(tr("Refresh"), this);
136
//hb2->addWidget(pb_refresh);
137
//connect(pb_refresh, SIGNAL(clicked()), SLOT(refreshCommands()));
142
QHBoxLayout *hb2 = new QHBoxLayout(vb);
143
busy_ = new BusyWidget(this);
144
hb2->addWidget(busy_);
145
hb2->addItem(new QSpacerItem(20,0,QSizePolicy::Expanding));
146
pb_execute = new QPushButton(tr("Execute"), this);
147
hb2->addWidget(pb_execute);
127
pb_close = ui_.buttonBox->button(QDialogButtonBox::Cancel);
128
pb_execute = ui_.buttonBox->addButton(tr("Execute"), QDialogButtonBox::AcceptRole);
148
129
connect(pb_execute, SIGNAL(clicked()), SLOT(executeCommand()));
149
pb_close = new QPushButton(tr("Close"), this);
150
hb2->addWidget(pb_close);
151
130
connect(pb_close, SIGNAL(clicked()), SLOT(close()));
152
pb_close->setDefault(true);
153
pb_close->setFocus();
155
setCaption(QString("Execute Command (%1)").arg(receiver.full()));
131
pb_execute->setDefault(true);
133
setWindowTitle(QString("Execute Command (%1)").arg(receiver.full()));
158
135
refreshCommands();
162
139
void AHCommandDlg::refreshCommands()
164
cb_commands->clear();
141
ui_.cb_commands->clear();
165
142
pb_execute->setEnabled(false);
166
//pb_info->setEnabled(false);
169
145
JT_AHCGetList* t= new JT_AHCGetList(pa_->client()->rootTask(),receiver_);
170
146
connect(t,SIGNAL(finished()),SLOT(listReceived()));
176
152
JT_AHCGetList* task_list = (JT_AHCGetList*) sender();
177
153
foreach(AHCommandItem i, task_list->commands()) {
178
cb_commands->insertItem(i.name);
154
ui_.cb_commands->addItem(i.name);
179
155
commands_.append(i);
181
pb_execute->setEnabled(cb_commands->count()>0);
157
pb_execute->setEnabled(ui_.cb_commands->count()>0);
185
161
void AHCommandDlg::executeCommand()
187
if (cb_commands->count() > 0) {
189
Jid to(commands_[cb_commands->currentItem()].jid);
190
QString node = commands_[cb_commands->currentItem()].node;
163
if (ui_.cb_commands->count() > 0) {
165
Jid to(commands_[ui_.cb_commands->currentIndex()].jid);
166
QString node = commands_[ui_.cb_commands->currentIndex()].node;
191
167
AHCExecuteTask* t = new AHCExecuteTask(to,AHCommand(node),pa_->client()->rootTask());
192
168
connect(t,SIGNAL(finished()),SLOT(commandExecuted()));