ProgramWidget::ProgramWidget(Program *program, Device *device, QWidget *parent) : StandardWidget(device, parent), ui(new Ui::ProgramWidget), m_program(program) { ui->setupUi(this); performStandardSetup(tr("Program")); // QAction *lock = menuBar()->addAction(UiStandards::lockString()); // connect(lock, SIGNAL(triggered()), SLOT(lock())); ui->extra->setVisible(false); connect(m_program, SIGNAL(started()), SLOT(started())); connect(m_program, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(finished(int, QProcess::ExitStatus))); ButtonProvider *buttonProvider = device->buttonProvider(); ui->normal->setEnabled(buttonProvider); ui->extra->setEnabled(buttonProvider); ui->console->setProcess(m_program->process()); if(!buttonProvider) return; ui->extra->setVisible(buttonProvider->isExtraShown()); ui->a->setText(buttonProvider->text(ButtonProvider::A)); ui->b->setText(buttonProvider->text(ButtonProvider::B)); ui->c->setText(buttonProvider->text(ButtonProvider::C)); ui->x->setText(buttonProvider->text(ButtonProvider::X)); ui->y->setText(buttonProvider->text(ButtonProvider::Y)); ui->z->setText(buttonProvider->text(ButtonProvider::Z)); connect(ui->a, SIGNAL(pressed()), SLOT(aPressed())); connect(ui->b, SIGNAL(pressed()), SLOT(bPressed())); connect(ui->c, SIGNAL(pressed()), SLOT(cPressed())); connect(ui->x, SIGNAL(pressed()), SLOT(xPressed())); connect(ui->y, SIGNAL(pressed()), SLOT(yPressed())); connect(ui->z, SIGNAL(pressed()), SLOT(zPressed())); connect(ui->a, SIGNAL(released()), SLOT(aReleased())); connect(ui->b, SIGNAL(released()), SLOT(bReleased())); connect(ui->c, SIGNAL(released()), SLOT(cReleased())); connect(ui->x, SIGNAL(released()), SLOT(xReleased())); connect(ui->y, SIGNAL(released()), SLOT(yReleased())); connect(ui->z, SIGNAL(released()), SLOT(zReleased())); connect(buttonProvider, SIGNAL(buttonTextChanged(ButtonProvider::ButtonId, QString)), SLOT(buttonTextChanged(ButtonProvider::ButtonId, QString))); connect(buttonProvider, SIGNAL(extraShownChanged(bool)), SLOT(extraShownChanged(bool))); QTimer *timer = new QTimer(this); timer->start(100); buttonProvider->connect(timer, SIGNAL(timeout()), SLOT(refresh())); buttonProvider->reset(); }
void ProgramWidget::started() { ButtonProvider *buttonProvider = device()->buttonProvider(); if(buttonProvider) buttonProvider->reset(); ui->console->setProcess(m_program->process()); }