mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
added reset window layout to all the HomeWindows.
This commit is contained in:
@@ -575,22 +575,24 @@ HomeWindow::addChart(GcWindow* newone)
|
||||
}
|
||||
|
||||
bool
|
||||
HomeWindow::removeChart(int num)
|
||||
HomeWindow::removeChart(int num, bool confirm)
|
||||
{
|
||||
if (num >= charts.count()) return false; // out of bounds (!)
|
||||
|
||||
// better let the user confirm since this
|
||||
// is undoable etc - code swiped from delete
|
||||
// ride in MainWindow, seems to work ok ;)
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Are you sure you want to remove the chart?"));
|
||||
QPushButton *deleteButton = msgBox.addButton(tr("Remove"),QMessageBox::YesRole);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.exec();
|
||||
if(msgBox.clickedButton() != deleteButton) return false;
|
||||
|
||||
if(confirm == true)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Are you sure you want to remove the chart?"));
|
||||
QPushButton *deleteButton = msgBox.addButton(tr("Remove"),QMessageBox::YesRole);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.exec();
|
||||
if(msgBox.clickedButton() != deleteButton) return false;
|
||||
}
|
||||
charts[num]->hide();
|
||||
|
||||
// just in case its currently selected
|
||||
@@ -627,6 +629,24 @@ HomeWindow::removeChart(int num)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HomeWindow::resetLayout()
|
||||
{
|
||||
setUpdatesEnabled(false);
|
||||
int numCharts = charts.count();
|
||||
for(int i = numCharts - 1; i >= 0; i--) // need to remove the charts from the end to the front
|
||||
{
|
||||
removeChart(i,false);
|
||||
}
|
||||
restoreState(true);
|
||||
for(int i = 0; i < charts.count(); i++)
|
||||
{
|
||||
charts[i]->show();
|
||||
}
|
||||
setUpdatesEnabled(true);
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
HomeWindow::showEvent(QShowEvent *)
|
||||
{
|
||||
@@ -1278,12 +1298,17 @@ HomeWindow::saveState()
|
||||
}
|
||||
|
||||
void
|
||||
HomeWindow::restoreState()
|
||||
HomeWindow::restoreState(bool useDefault)
|
||||
{
|
||||
// restore window state
|
||||
QString filename = mainWindow->home.absolutePath() + "/" + name + "-layout.xml";
|
||||
QFileInfo finfo(filename);
|
||||
|
||||
if(useDefault)
|
||||
{
|
||||
QFile::remove(filename);
|
||||
}
|
||||
|
||||
// use a default if not there
|
||||
if (!finfo.exists()) filename = QString(":xml/%1-layout.xml").arg(name);
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ class HomeWindow : public GcWindow
|
||||
//int view() const { return viewMode->currentIndex(); }
|
||||
//void setView(int x) { viewMode->setCurrentIndex(x); }
|
||||
|
||||
void resetLayout();
|
||||
|
||||
public slots:
|
||||
|
||||
// GC signals
|
||||
@@ -63,12 +65,12 @@ class HomeWindow : public GcWindow
|
||||
// My widget signals and events
|
||||
void styleChanged(int);
|
||||
void addChart(GcWindow* newone);
|
||||
bool removeChart(int);
|
||||
bool removeChart(int, bool confirm = true);
|
||||
void titleChanged();
|
||||
|
||||
// save / restore window state
|
||||
void saveState();
|
||||
void restoreState();
|
||||
void restoreState(bool useDefault = false);
|
||||
|
||||
//notifiction that been made visible
|
||||
void selected();
|
||||
|
||||
@@ -475,6 +475,7 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions()), tr("Ctrl+O"));
|
||||
optionsMenu->addAction(tr("Critical Power Calculator..."), this, SLOT(showTools()));
|
||||
optionsMenu->addAction(tr("Workout Wizard"), this, SLOT(showWorkoutWizard()));
|
||||
optionsMenu->addAction(tr("Reset Window Layout"), this, SLOT(resetWindowLayout()));
|
||||
|
||||
#ifdef GC_HAVE_ICAL
|
||||
optionsMenu->addSeparator();
|
||||
@@ -816,6 +817,11 @@ void MainWindow::showWorkoutWizard()
|
||||
ww->show();
|
||||
}
|
||||
|
||||
void MainWindow::resetWindowLayout()
|
||||
{
|
||||
currentWindow->resetLayout();
|
||||
}
|
||||
|
||||
void MainWindow::dateChanged(const QDate &date)
|
||||
{
|
||||
for (int i = 0; i < allRides->childCount(); i++)
|
||||
@@ -877,6 +883,7 @@ MainWindow::selectAnalysis()
|
||||
masterControls->setCurrentIndex(0);
|
||||
views->setCurrentIndex(0);
|
||||
analWindow->selected(); // tell it!
|
||||
currentWindow = analWindow;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -885,6 +892,7 @@ MainWindow::selectTrain()
|
||||
masterControls->setCurrentIndex(1);
|
||||
views->setCurrentIndex(1);
|
||||
trainWindow->selected(); // tell it!
|
||||
currentWindow = trainWindow;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -893,6 +901,7 @@ MainWindow::selectDiary()
|
||||
masterControls->setCurrentIndex(2);
|
||||
views->setCurrentIndex(2);
|
||||
diaryWindow->selected(); // tell it!
|
||||
currentWindow = diaryWindow;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -901,6 +910,7 @@ MainWindow::selectHome()
|
||||
masterControls->setCurrentIndex(3);
|
||||
views->setCurrentIndex(3);
|
||||
homeWindow->selected(); // tell it!
|
||||
currentWindow = homeWindow;
|
||||
}
|
||||
void
|
||||
MainWindow::selectAthlete()
|
||||
|
||||
@@ -209,6 +209,7 @@ class MainWindow : public QMainWindow
|
||||
void showSidebar(bool want);
|
||||
void showToolbar(bool want);
|
||||
void showWorkoutWizard();
|
||||
void resetWindowLayout();
|
||||
void dateChanged(const QDate &);
|
||||
void showTreeContextMenuPopup(const QPoint &);
|
||||
void showContextMenuPopup(const QPoint &);
|
||||
@@ -279,6 +280,7 @@ class MainWindow : public QMainWindow
|
||||
HomeWindow *diaryWindow;
|
||||
HomeWindow *trainWindow;
|
||||
HomeWindow *analWindow;
|
||||
HomeWindow *currentWindow; // tracks the curerntly showing window
|
||||
|
||||
// sidebar
|
||||
QTreeWidgetItem *allRides;
|
||||
|
||||
Reference in New Issue
Block a user