diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-15 23:12:16 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-02-15 23:12:16 +0200 |
commit | 8350c401327c8f3766acf7ee9615442ea3211640 (patch) | |
tree | e6cb85a477c2aa6f6190c24bd59a604adc330c25 /client/mainwindow.cpp | |
parent | 4a2dd17aa0601fffd42f2ec1c92c6a1b79f648d3 (diff) |
shell exec service fixes
some work with client
Diffstat (limited to 'client/mainwindow.cpp')
-rw-r--r-- | client/mainwindow.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 943e04d..d7070a6 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -29,7 +29,7 @@ MainWindow::MainWindow(QWidget *parent) : this->setWindowTitle(tr("Client")); this->setFixedSize(this->size()); show(); - ui->state_lbl->setVisible(true); + ui->state_lbl->show(); ui->state_lbl->setText(" "); ui->state_lbl->setText(tr("Preparing..")); get_socket(); @@ -121,15 +121,19 @@ void MainWindow::handle_data() { service_ui *u = new service_ui; u->group = new QGroupBox(i->service.c_str(), this); - u->group->show(); + u->group->resize(this->size().width() - 10, 25); + u->layout = new QHBoxLayout(u->group); for(std::list<service_s::cmd>::iterator ii = i->cmds.begin(), eend = i->cmds.end(); ii != eend; ++ii) { u->commands.push_back(new QPushButton(QString::fromUtf8(ii->command.c_str()), u->group)); connect(u->commands.back(), SIGNAL(clicked()), SLOT(handle_button_click())); u->commands.back()->setToolTip(QString::fromUtf8(ii->description.c_str())); - u->commands.back()->show(); + u->layout->addWidget(u->commands.back()); + //u->commands.back()->show(); + svc_ui_list.push_back(u); } - svc_ui_list.push_back(u); + u->group->setLayout(u->layout); + u->group->show(); } } break; @@ -153,8 +157,19 @@ void MainWindow::handle_data() void MainWindow::handle_button_click() { - //TODO - + QPushButton *btn = qobject_cast<QPushButton*>(sender()); + if(btn) + { + QGroupBox *svc = qobject_cast<QGroupBox*>(btn->parent()); + if(svc) + { + packet *p = packet::cli_make_command_packet(svc->title().toUtf8(), btn->text().toUtf8()); + unsigned char *b = p->buf(); + sock->write((char*)b, p->raw().size()); + delete [] b; + delete p; + } + } } void MainWindow::ssl_verify_error_handler(const QSslError error) @@ -177,15 +192,14 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::enable_buttons(bool enable) -{ -} void MainWindow::disconnected() { - enable_buttons(true); ui->state_lbl->setText(QString::fromUtf8(" ")); + for(std::list<service_ui*>::iterator i = svc_ui_list.begin(), end = svc_ui_list.end(); i != end; ++i) + delete *i; + svc_ui_list.clear(); sock->deleteLater(); } |