mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
add Erase Ride(s) button to download dialog
This is a workaround for the SRM erase bug. It gives the user a way to try erasing the device's memory without re-downloading a ride.
This commit is contained in:
@@ -49,15 +49,18 @@ DownloadRideDialog::DownloadRideDialog(MainWindow *mainWindow,
|
||||
}
|
||||
|
||||
downloadButton = new QPushButton(tr("&Download"), this);
|
||||
eraseRideButton = new QPushButton(tr("&Erase Ride(s)"), this);
|
||||
rescanButton = new QPushButton(tr("&Rescan"), this);
|
||||
cancelButton = new QPushButton(tr("&Cancel"), this);
|
||||
|
||||
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadClicked()));
|
||||
connect(eraseRideButton, SIGNAL(clicked()), this, SLOT(eraseClicked()));
|
||||
connect(rescanButton, SIGNAL(clicked()), this, SLOT(scanCommPorts()));
|
||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
buttonLayout->addWidget(downloadButton);
|
||||
buttonLayout->addWidget(eraseRideButton);
|
||||
buttonLayout->addWidget(rescanButton);
|
||||
buttonLayout->addWidget(cancelButton);
|
||||
|
||||
@@ -81,6 +84,7 @@ DownloadRideDialog::setReadyInstruct()
|
||||
"unit is plugged into the computer,\n"
|
||||
"then click \"Rescan\" to check again."));
|
||||
downloadButton->setEnabled(false);
|
||||
eraseRideButton->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
Device &device = Device::device(deviceCombo->currentText());
|
||||
@@ -90,6 +94,8 @@ DownloadRideDialog::setReadyInstruct()
|
||||
else
|
||||
label->setText(inst + ", \nthen click Download.");
|
||||
downloadButton->setEnabled(true);
|
||||
if (deviceCombo->currentText() == "SRM") // only SRM supports erase ride for now
|
||||
eraseRideButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +139,7 @@ void
|
||||
DownloadRideDialog::downloadClicked()
|
||||
{
|
||||
downloadButton->setEnabled(false);
|
||||
eraseRideButton->setEnabled(false);
|
||||
rescanButton->setEnabled(false);
|
||||
downloadInProgress = true;
|
||||
CommPortPtr dev;
|
||||
@@ -211,6 +218,27 @@ DownloadRideDialog::downloadClicked()
|
||||
accept();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadRideDialog::eraseClicked()
|
||||
{
|
||||
downloadButton->setEnabled(false);
|
||||
eraseRideButton->setEnabled(false);
|
||||
rescanButton->setEnabled(false);
|
||||
downloadInProgress = true;
|
||||
CommPortPtr dev;
|
||||
for (int i = 0; i < devList.size(); ++i) {
|
||||
if (devList[i]->name() == portCombo->currentText()) {
|
||||
dev = devList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(dev);
|
||||
Device &device = Device::device(deviceCombo->currentText());
|
||||
device.cleanup(dev);
|
||||
downloadInProgress = false;
|
||||
accept();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadRideDialog::cancelClicked()
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ class DownloadRideDialog : public QDialog
|
||||
|
||||
private slots:
|
||||
void downloadClicked();
|
||||
void eraseClicked();
|
||||
void cancelClicked();
|
||||
void setReadyInstruct();
|
||||
void scanCommPorts();
|
||||
@@ -44,7 +45,7 @@ class DownloadRideDialog : public QDialog
|
||||
|
||||
MainWindow *mainWindow;
|
||||
QDir home;
|
||||
QPushButton *downloadButton, *rescanButton, *cancelButton;
|
||||
QPushButton *downloadButton, *eraseRideButton, *rescanButton, *cancelButton;
|
||||
QComboBox *portCombo, *deviceCombo;
|
||||
QLabel *label;
|
||||
|
||||
|
||||
@@ -135,8 +135,8 @@ SrmDevice::cleanup(CommPortPtr dev)
|
||||
if (!dev2path(dev, path, err))
|
||||
assert(false);
|
||||
if (QMessageBox::question(0, "Powercontrol",
|
||||
"Erase downloaded ride from device memory?",
|
||||
"&Erase", "&Save Only", "", 1, 1) == 0) {
|
||||
"Erase ride from device memory?",
|
||||
"&Erase", "&Cancel", "", 1, 1) == 0) {
|
||||
SrmpcConn srm(path);
|
||||
if(!srm.d || (srmpc_clear_chunks(srm.d) < 0)) {
|
||||
QMessageBox::warning(0, "Error",
|
||||
|
||||
Reference in New Issue
Block a user