mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
WorkoutWizard - Don't save and close on Cancel
When the user Cancel the file save dialog it is better to do nothing since we have no filename for save and it is likely what the user expects. Fixes #4476
This commit is contained in:
@@ -355,12 +355,14 @@ void AbsWattagePage::updateMetrics()
|
||||
#endif
|
||||
}
|
||||
|
||||
void AbsWattagePage::SaveWorkout()
|
||||
bool AbsWattagePage::SaveWorkout()
|
||||
{
|
||||
QString workoutDir = appsettings->value(this,GC_WORKOUTDIR).toString();
|
||||
|
||||
QString filename = QFileDialog::getSaveFileName(this,QString(tr("Save Workout")),
|
||||
workoutDir,tr("Computrainer Format *.erg"));
|
||||
if (filename.isEmpty()) return false;
|
||||
|
||||
if(!filename.endsWith(".erg"))
|
||||
{
|
||||
filename.append(".erg");
|
||||
@@ -396,6 +398,7 @@ void AbsWattagePage::SaveWorkout()
|
||||
QStringList files;
|
||||
files << filename;
|
||||
Library::importFiles(hackContext, files);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// RelativeWattagePage
|
||||
@@ -494,12 +497,14 @@ void RelWattagePage::updateMetrics()
|
||||
#endif
|
||||
}
|
||||
|
||||
void RelWattagePage::SaveWorkout()
|
||||
bool RelWattagePage::SaveWorkout()
|
||||
{
|
||||
QString workoutDir = appsettings->value(this,GC_WORKOUTDIR).toString();
|
||||
|
||||
QString filename = QFileDialog::getSaveFileName(this,QString(tr("Save Workout")),
|
||||
workoutDir,tr("Computrainer Format *.mrc"));
|
||||
if (filename.isEmpty()) return false;
|
||||
|
||||
if(!filename.endsWith(".mrc"))
|
||||
{
|
||||
filename.append(".mrc");
|
||||
@@ -535,6 +540,7 @@ void RelWattagePage::SaveWorkout()
|
||||
QStringList files;
|
||||
files << filename;
|
||||
Library::importFiles(hackContext, files);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// GradientPage
|
||||
@@ -594,12 +600,14 @@ void GradientPage::updateMetrics()
|
||||
metricsSummary->updateMetrics(metricSummaryMap);
|
||||
}
|
||||
|
||||
void GradientPage::SaveWorkout()
|
||||
bool GradientPage::SaveWorkout()
|
||||
{
|
||||
QString workoutDir = appsettings->value(this,GC_WORKOUTDIR).toString();
|
||||
|
||||
QString filename = QFileDialog::getSaveFileName(this,QString(tr("Save Workout")),
|
||||
workoutDir,tr("Computrainer Format *.crs"));
|
||||
if (filename.isEmpty()) return false;
|
||||
|
||||
if(!filename.endsWith(".crs"))
|
||||
{
|
||||
filename.append(".crs");
|
||||
@@ -634,6 +642,7 @@ void GradientPage::SaveWorkout()
|
||||
QStringList files;
|
||||
files << filename;
|
||||
Library::importFiles(hackContext, files);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -752,11 +761,13 @@ void ImportPage::updatePlot()
|
||||
update();
|
||||
}
|
||||
|
||||
void ImportPage::SaveWorkout()
|
||||
bool ImportPage::SaveWorkout()
|
||||
{
|
||||
QString workoutDir = appsettings->value(this,GC_WORKOUTDIR).toString();
|
||||
QString filename = QFileDialog::getSaveFileName(this,QString(tr("Save Workout")),
|
||||
workoutDir,tr("Computrainer Format *.crs"));
|
||||
if (filename.isEmpty()) return false;
|
||||
|
||||
if(!filename.endsWith(".crs"))
|
||||
{
|
||||
filename.append(".crs");
|
||||
@@ -784,6 +795,7 @@ void ImportPage::SaveWorkout()
|
||||
QStringList files;
|
||||
files << filename;
|
||||
Library::importFiles(hackContext, files);
|
||||
return true;
|
||||
}
|
||||
|
||||
WorkoutWizard::WorkoutWizard(Context *context) :QWizard(context->mainWindow)
|
||||
@@ -805,6 +817,5 @@ WorkoutWizard::WorkoutWizard(Context *context) :QWizard(context->mainWindow)
|
||||
void WorkoutWizard::accept()
|
||||
{
|
||||
WorkoutPage *page = (WorkoutPage *)this->currentPage();
|
||||
page->SaveWorkout();
|
||||
done(0);
|
||||
if (page->SaveWorkout()) done(0);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ class WorkoutPage : public QWizardPage
|
||||
{
|
||||
public:
|
||||
WorkoutPage(QWidget *parent) : QWizardPage(parent) {}
|
||||
virtual void SaveWorkout() = 0;
|
||||
virtual bool SaveWorkout() = 0;
|
||||
void SaveWorkoutHeader(QTextStream &stream, QString fileName, QString description, QString units)
|
||||
{
|
||||
stream << "[COURSE HEADER]" << Qt::endl;
|
||||
@@ -257,7 +257,7 @@ private slots:
|
||||
public:
|
||||
AbsWattagePage(QWidget *parent=0);
|
||||
void initializePage();
|
||||
void SaveWorkout();
|
||||
bool SaveWorkout();
|
||||
bool isFinalPage() const { return true; }
|
||||
int nextId() const { return -1; }
|
||||
};
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
bool isFinalPage() const { return true; }
|
||||
int nextId() const { return -1; }
|
||||
|
||||
void SaveWorkout();
|
||||
bool SaveWorkout();
|
||||
};
|
||||
|
||||
class GradientPage : public WorkoutPage
|
||||
@@ -295,7 +295,7 @@ private slots:
|
||||
public:
|
||||
GradientPage(QWidget *parent=0);
|
||||
void initializePage();
|
||||
void SaveWorkout();
|
||||
bool SaveWorkout();
|
||||
bool isFinalPage() const { return true; }
|
||||
int nextId() const { return -1; }
|
||||
};
|
||||
@@ -314,8 +314,8 @@ public slots:
|
||||
void updatePlot();
|
||||
public:
|
||||
ImportPage(QWidget * parent=0);
|
||||
void initializePage();
|
||||
void SaveWorkout();
|
||||
void initializePage();
|
||||
bool SaveWorkout();
|
||||
bool isFinalPage() const { return true; }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user