Skip to content

Commit

Permalink
start the scope automatically when ready
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Nov 29, 2019
1 parent 0b77b94 commit c365d9b
Show file tree
Hide file tree
Showing 6 changed files with 1,065 additions and 827 deletions.
2 changes: 1 addition & 1 deletion openhantek/src/OH_BUILD.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Do not edit, will be re-created at each commit!
#define OH_BUILD "20191129 build 563"
#define OH_BUILD "20191129 build 564"
25 changes: 15 additions & 10 deletions openhantek/src/selectdevice/selectsupporteddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
#include "newdevicemodelfromexisting.h"
#include "modelregistry.h"

SelectSupportedDevice::SelectSupportedDevice(QWidget *parent) :
QDialog(parent),
ui(new Ui::SelectSupportedDevice)
SelectSupportedDevice::SelectSupportedDevice( QWidget *parent ) :
QDialog( parent ), ui( new Ui::SelectSupportedDevice )
{
ui->setupUi(this);
newDeviceFromExistingDialog = new NewDeviceModelFromExisting(this);
Expand Down Expand Up @@ -47,15 +46,15 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
return;
}
if (ui->cmbDevices->currentData(Qt::UserRole+1).toBool()) {
if (ui->cmbDevices->currentData( Qt::UserRole + 1 ).toBool()) { // canConnect
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui->labelReadyState->setText(
tr("<p><br/><b>The device is ready for use.</b></p><p>Please observe the "
"<a href='https://github.com/OpenHantek/OpenHantek6022/blob/master/docs/OpenHantek6022_User_Manual.pdf'>"
"user manual</a> for safe operation.</p>"));
} else {
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
if (ui->cmbDevices->currentData(Qt::UserRole+2).toBool()) {
if (ui->cmbDevices->currentData( Qt::UserRole + 2 ).toBool()) { // needFirmware
ui->labelReadyState->setText(tr("<p>Upload in progress ...</p>"
"<p><b>If the upload takes more than 30 s, please close this window <br/>and restart the program!</b></p>"
"<p>In this case, please unplug other USB devices on the same bus!<br/>"
Expand All @@ -81,7 +80,6 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
if ( !libRules.exists() && !etcRules.exists() ) {
messageNoDevices += tr("<p>Please make sure you have copied the udev rules file to <b>%1</b> for correct USB access permissions.</p>").arg(libRules.fileName());
}
#else
#endif
messageNoDevices += tr("<p>Visit the build and run instruction "
"<a href='https://github.com/OpenHantek/OpenHantek6022/blob/master/docs/build.md'>website</a> for help.</p>");
Expand All @@ -91,12 +89,19 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
QTimer timer;
timer.setInterval(1000);
connect(&timer, &QTimer::timeout, [this, &model, &findDevices, &messageNoDevices]() {
if (findDevices->updateDeviceList())
if ( findDevices->updateDeviceList() ) { // searching...
model->updateDeviceList();
if (model->rowCount(QModelIndex()))
ui->cmbDevices->setCurrentIndex(0);
else
}
if ( model->rowCount( QModelIndex() ) ) { // device ready
ui->cmbDevices->setCurrentIndex( 0 );
// HACK: "click()" the "OK" button (if enabled) to start the scope automatically
if ( model->rowCount( QModelIndex() ) == 1 // only one device available...
&& ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled() ) { // ...and ready to run
ui->buttonBox->button(QDialogButtonBox::Ok)->click(); // start it without user activity
}
} else {
ui->labelReadyState->setText(messageNoDevices);
}
});
timer.start();
QCoreApplication::sendEvent(&timer, new QTimerEvent(timer.timerId())); // immediate timer event
Expand Down
Loading

0 comments on commit c365d9b

Please sign in to comment.