int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: reconnectUdp(); break;
        case 1: sendPacket(); break;
        case 2: sendBtnClicked(); break;
        case 3: resetBtnClicked(); break;
        case 4: disconnectUdp(); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Beispiel #2
0
MainWindow::MainWindow(QWidget *parent)
    : QDialog(parent),
    udpsocket(this)
{
    QGridLayout* layout = new QGridLayout(this);
    edtIp = new QLineEdit("127.0.0.1", this);
    edtPort = new QLineEdit("20011", this);
    edtId = new QLineEdit("0", this);
    edtVx = new QLineEdit("0", this);
    edtVy = new QLineEdit("0", this);
    edtW  = new QLineEdit("0", this);
    edtV1 = new QLineEdit("0", this);
    edtV2 = new QLineEdit("0", this);
    edtV3 = new QLineEdit("0", this);
    edtV4 = new QLineEdit("0", this);
    edtChip = new QLineEdit("0", this);
    edtKick = new QLineEdit("0", this);

    this->setWindowTitle(QString("grSim Sample Client - v 2.0"));

    lblIp = new QLabel("Simulator Address", this);
    lblPort = new QLabel("Simulator Port", this);
    lblId = new QLabel("Id", this);
    lblVx = new QLabel("Velocity X (m/s)", this);
    lblVy = new QLabel("Velocity Y (m/s)", this);
    lblW  = new QLabel("Velocity W (rad/s)", this);
    lblV1 = new QLabel("Wheel1 (rad/s)", this);
    lblV2 = new QLabel("Wheel2 (rad/s)", this);
    lblV3 = new QLabel("Wheel3 (rad/s)", this);
    lblV4 = new QLabel("Wheel4 (rad/s)", this);
    cmbTeam = new QComboBox(this);
    cmbTeam->addItem("Yellow");
    cmbTeam->addItem("Blue");
    lblChip = new QLabel("Chip (m/s)", this);
    lblKick = new QLabel("Kick (m/s)", this);
    txtInfo = new QTextEdit(this);
    chkVel = new QCheckBox("Send Velocity? (or wheels)", this);
    chkSpin = new QCheckBox("Spin", this);
    btnSend = new QPushButton("Send", this);
    btnReset = new QPushButton("Reset", this);
    btnConnect = new QPushButton("Connect", this);
    txtInfo->setReadOnly(true);
    txtInfo->setHtml("This program is part of <b>grSim RoboCup SSL Simulator</b> package.<br />For more information please refer to <a href=\"http://eew.aut.ac.ir/~parsian/grsim/\">http://eew.aut.ac.ir/~parsian/grsim</a><br /><font color=\"gray\">This program is free software under the terms of GNU General Public License Version 3.</font>");
    txtInfo->setFixedHeight(70);
    layout->addWidget(lblIp, 1, 1, 1, 1);layout->addWidget(edtIp, 1, 2, 1, 1);
    layout->addWidget(lblPort, 1, 3, 1, 1);layout->addWidget(edtPort, 1, 4, 1, 1);
    layout->addWidget(lblId, 2, 1, 1, 1);layout->addWidget(edtId, 2, 2, 1, 1);layout->addWidget(cmbTeam, 2, 3, 1, 2);
    layout->addWidget(lblVx, 3, 1, 1, 1);layout->addWidget(edtVx, 3, 2, 1, 1);
    layout->addWidget(lblVy, 4, 1, 1, 1);layout->addWidget(edtVy, 4, 2, 1, 1);
    layout->addWidget(lblW, 5, 1, 1, 1);layout->addWidget(edtW, 5, 2, 1, 1);
    layout->addWidget(chkVel, 6, 1, 1, 1);layout->addWidget(edtKick, 6, 2, 1, 1);
    layout->addWidget(lblV1, 3, 3, 1, 1);layout->addWidget(edtV1, 3, 4, 1, 1);
    layout->addWidget(lblV2, 4, 3, 1, 1);layout->addWidget(edtV2, 4, 4, 1, 1);
    layout->addWidget(lblV3, 5, 3, 1, 1);layout->addWidget(edtV3, 5, 4, 1, 1);
    layout->addWidget(lblV4, 6, 3, 1, 1);layout->addWidget(edtV4, 6, 4, 1, 1);
    layout->addWidget(lblChip, 7, 1, 1, 1);layout->addWidget(edtChip, 7, 2, 1, 1);
    layout->addWidget(lblKick, 7, 3, 1, 1);layout->addWidget(edtKick, 7, 4, 1, 1);
    layout->addWidget(chkSpin, 8, 1, 1, 4);
    layout->addWidget(btnConnect, 9, 1, 1, 2);layout->addWidget(btnSend, 9, 3, 1, 1);layout->addWidget(btnReset, 9, 4, 1, 1);
    layout->addWidget(txtInfo, 10, 1, 1, 4);
    timer = new QTimer (this);
    timer->setInterval(20);
    connect(edtIp, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp()));
    connect(edtPort, SIGNAL(textChanged(QString)), this, SLOT(disconnectUdp()));
    connect(timer, SIGNAL(timeout()), this, SLOT(sendPacket()));
    connect(btnConnect, SIGNAL(clicked()), this, SLOT(reconnectUdp()));
    connect(btnSend, SIGNAL(clicked()), this, SLOT(sendBtnClicked()));
    connect(btnReset, SIGNAL(clicked()), this, SLOT(resetBtnClicked()));
    btnSend->setDisabled(true);
    chkVel->setChecked(true);
    sending = false;
    reseting = false;
}
Beispiel #3
0
FQTermShortcutDialog::FQTermShortcutDialog(FQTermShortcutHelper* helper, QWidget *parent_, Qt::WindowFlags fl)
  : QDialog(parent_, fl),
    helper_(helper),
    table_(NULL) {
  setWindowTitle(tr("Shortcut Setting"));
  //grabKeyboard();
  if (helper_)
  {
    QSignalMapper* signalMapper = new QSignalMapper(this);
    int row = FQTermShortcutHelper::FQTERM_APPLICATION_SHORTCUT_END - FQTermShortcutHelper::FQTERM_APPLICATION_SHORTCUT_START - 1;
    int column = 3;
    table_ = new QTableWidget(row, column, this);
    table_->clear();
    QStringList header;
    header << tr("Description") << tr("Shortcut") << "";
    table_->setHorizontalHeaderLabels(header);
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        if (j == 0) {
          QTableWidgetItem* item = new QTableWidgetItem;
          table_->setItem(i, j, item);
          item->setFlags(item->flags() & ~Qt::ItemIsEditable);
          item->setText(helper_->getShortcutDescription(i + 1));
        } else if (j == 1) {
          FQTermShortcutTableWidget* stw = new FQTermShortcutTableWidget(table_);
          stw->setReadOnly(true);
          stw->setText(helper_->getShortcutText(i + 1));
          table_->setCellWidget(i, j, stw);
        }else {
          QPushButton* btn = new QPushButton(tr("default"), table_);
          table_->setCellWidget(i, j, btn);
          FQ_VERIFY(connect(btn, SIGNAL(clicked()), signalMapper, SLOT(map())));
         signalMapper->setMapping(btn, i);
        }
      }
    }
    table_->resizeColumnsToContents();
    int tableWidth = table_->horizontalHeader()->length();
    if (table_->horizontalScrollBar() && table_->horizontalScrollBar()->isVisible()) {
      tableWidth += table_->horizontalScrollBar()->width();
    }
    QPushButton* okBtn = new QPushButton(tr("OK"), this);
    FQ_VERIFY(connect(okBtn, SIGNAL(clicked()), this, SLOT(okBtnClicked())));
    QPushButton* applyBtn = new QPushButton(tr("Apply"), this);
    FQ_VERIFY(connect(applyBtn, SIGNAL(clicked()), this, SLOT(applyBtnClicked())));
    QPushButton* cancelBtn = new QPushButton(tr("Cancel"), this);
    FQ_VERIFY(connect(cancelBtn, SIGNAL(clicked()), this, SLOT(cancelBtnClicked())));
    QPushButton* resetBtn = new QPushButton(tr("Reset All"), this);
    FQ_VERIFY(connect(resetBtn, SIGNAL(clicked()), this, SLOT(resetBtnClicked())));
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    QGridLayout* layout = new QGridLayout(this);
    QLabel* label = new QLabel(tr("Press key/combines on Shortcut column.\nNote Del is reserved for clear shortcut setting."));
    layout->addWidget(label, 0, 0, 1, -1);
    layout->addWidget(table_, 1, 0, 1, -1);
    layout->addWidget(okBtn, 2, 0);
    layout->addWidget(applyBtn, 2, 1);
    layout->addWidget(cancelBtn, 2, 2);
    layout->addWidget(resetBtn, 2, 3);
    setLayout(layout);
    int left = 0;
    int right = 0;
    layout->getContentsMargins(&left, NULL, &right, NULL);
    table_->horizontalHeader()->setStretchLastSection(true);
    tableWidth *= 1.1;
    resize(tableWidth + left + right, height());
    FQ_VERIFY(connect(signalMapper, SIGNAL(mapped(int)),this, SLOT(defaultClicked(int))));
  }
}