Changeset 66 in projects for punch-card-project/trunk/punch-card-editor/src/driver/documation-m200-client/controller.cc
- Timestamp:
- Jan 15, 2013, 3:48:24 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
punch-card-project/trunk/punch-card-editor/src/driver/documation-m200-client/controller.cc
r59 r66 4 4 #include <QHBoxLayout> 5 5 #include <QVBoxLayout> 6 #include <QGridLayout> 6 7 #include <QPushButton> 7 8 … … 27 28 // now going to fire up working thread 28 29 connect(worker, SIGNAL(recievedResponse(QString, QString)), this, SLOT(logResponse(QString,QString)), Qt::QueuedConnection); 30 connect(worker, SIGNAL(finished()), this, SLOT(setButtonsDisabled())); 31 connect(worker, SIGNAL(started()), this, SLOT(setButtonsEnabled())); 29 32 30 33 qDebug("Starting worker thread"); … … 35 38 QWidget* Controller::createButtonBar() { 36 39 QWidget* box = new QWidget(this); 37 QHBoxLayout* layout = new QHBoxLayout(box);40 QGridLayout* layout = new QGridLayout(box); 38 41 39 42 start_button = new QPushButton(tr("Start"), box); 40 43 connect(start_button, SIGNAL(clicked()), worker, SLOT(fire_start())); 44 start_button->setStatusTip(tr("Start the punch card reader cycle (read in cards)")); 45 layout->addWidget(start_button, 0, 0); 41 46 42 47 stop_button = new QPushButton(tr("Stop"), box); 43 48 connect(stop_button, SIGNAL(clicked()), worker, SLOT(fire_stop())); 49 stop_button->setStatusTip(tr("Immediately stop the punch card reader cycle")); 50 layout->addWidget(stop_button, 0, 1); 44 51 45 52 ping_button = new QPushButton(tr("Ping"), box); 46 53 connect(ping_button, SIGNAL(clicked()), worker, SLOT(fire_ping())); 54 ping_button->setStatusTip(tr("Ping the microcontroller (should output data in the message window if connected)")); 55 ping_button->setAutoRepeat(true); 56 layout->addWidget(ping_button, 1, 0); 47 57 48 58 reset_button = new QPushButton(tr("Reset"), box); 49 59 connect(reset_button, SIGNAL(clicked()), worker, SLOT(fire_reset())); 60 reset_button->setStatusTip(tr("Completely reset the microcontroller. Only for bad errors, use with care")); 61 layout->addWidget(reset_button, 1, 1); 50 62 51 63 QWidget* clear_log = new QPushButton(tr("Clear log"), box); 52 64 connect(clear_log, SIGNAL(clicked()), log, SLOT(clear())); 65 clear_log->setStatusTip(tr("Clear the Log window (the white pane on the right)")); 66 layout->addWidget(clear_log, 2, 0); 53 67 54 68 quit_button = new QPushButton(tr("Quit Client"), box); 55 69 quit_button->setToolTip("Suspend or restart Client Thread"); 56 connect(reset_button, SIGNAL(clicked()), this, SLOT(client_toggle_run())); 70 connect(quit_button, SIGNAL(clicked()), this, SLOT(client_toggle_run())); 71 quit_button->setStatusTip(tr("Disconnect from microcontroller and quit client")); 72 layout->addWidget(quit_button, 2, 1); 57 73 58 74 box->setLayout(layout); … … 62 78 void Controller::client_toggle_run() { 63 79 // when user clicks quit_button 64 bool on = worker->isRunning(); 80 bool on = worker->isRunning(); 81 qDebug() << "Client toggle run, isRunning= " << on; 65 82 66 83 if(on) { … … 71 88 } 72 89 73 start_button->setEnabled(on); 74 stop_button->setEnabled(on); 75 ping_button->setEnabled(on); 76 reset_button->setEnabled(on); 77 quit_button->setText(on ? tr("Quit Client") : tr("Restart Client")); 90 // um Button-Status kuemmern sich signals/slots 91 } 92 93 void Controller::setButtonsDisabled() { 94 start_button->setEnabled(false); 95 stop_button->setEnabled(false); 96 ping_button->setEnabled(false); 97 reset_button->setEnabled(false); 98 quit_button->setText(tr("Restart Client")); 99 } 100 101 void Controller::setButtonsEnabled() { 102 start_button->setEnabled(true); 103 stop_button->setEnabled(true); 104 ping_button->setEnabled(true); 105 reset_button->setEnabled(true); 106 quit_button->setText(tr("Quit Client")); 78 107 } 79 108
Note: See TracChangeset
for help on using the changeset viewer.