mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
BlankState fixup for MainWindow refactor
.. reintroduced it whilst moving the logic to TabView and BlankStatePage.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
//
|
||||
// Replace home window when no ride
|
||||
//
|
||||
BlankStatePage::BlankStatePage(Context *context) : context(context)
|
||||
BlankStatePage::BlankStatePage(Context *context) : context(context), canShow_(true)
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->addStretch();
|
||||
@@ -81,9 +81,18 @@ BlankStatePage::BlankStatePage(Context *context) : context(context)
|
||||
bottomRow->addStretch();
|
||||
bottomRow->addWidget(closeButton);
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(setCanShow()));
|
||||
connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closeClicked()));
|
||||
}
|
||||
|
||||
void
|
||||
BlankStatePage::setCanShow()
|
||||
{
|
||||
// the view was closed, so set canShow_ off
|
||||
canShow_ = false;
|
||||
saveState();
|
||||
}
|
||||
|
||||
QPushButton*
|
||||
BlankStatePage::addToShortCuts(ShortCut shortCut)
|
||||
{
|
||||
@@ -150,6 +159,7 @@ BlankStateAnalysisPage::BlankStateAnalysisPage(Context *context) : BlankStatePag
|
||||
QPushButton *downloadButton = addToShortCuts(scDownload);
|
||||
connect(downloadButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadRide()));
|
||||
|
||||
canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_ANALYSIS).toBool();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -177,6 +187,8 @@ BlankStateHomePage::BlankStateHomePage(Context *context) : BlankStatePage(contex
|
||||
scDownload.buttonIconPath = ":images/mac/download.png";
|
||||
QPushButton *downloadButton = addToShortCuts(scDownload);
|
||||
connect(downloadButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadRide()));
|
||||
|
||||
canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_HOME).toBool();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -204,6 +216,8 @@ BlankStateDiaryPage::BlankStateDiaryPage(Context *context) : BlankStatePage(cont
|
||||
scDownload.buttonIconPath = ":images/mac/download.png";
|
||||
QPushButton *downloadButton = addToShortCuts(scDownload);
|
||||
connect(downloadButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadRide()));
|
||||
|
||||
canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_DIARY).toBool();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -241,4 +255,29 @@ BlankStateTrainPage::BlankStateTrainPage(Context *context) : BlankStatePage(cont
|
||||
scDownloadWorkout.buttonIconPath = ":images/mac/download.png";
|
||||
QPushButton *downloadWorkoutButton = addToShortCuts(scDownloadWorkout);
|
||||
connect(downloadWorkoutButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadErgDB()));
|
||||
|
||||
canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_TRAIN).toBool();
|
||||
}
|
||||
|
||||
// save away the don't show stuff
|
||||
void
|
||||
BlankStateAnalysisPage::saveState()
|
||||
{
|
||||
appsettings->setCValue(context->athlete->cyclist, GC_BLANK_ANALYSIS, dontShow->isChecked());
|
||||
}
|
||||
void
|
||||
BlankStateDiaryPage::saveState()
|
||||
{
|
||||
appsettings->setCValue(context->athlete->cyclist, GC_BLANK_DIARY, dontShow->isChecked());
|
||||
}
|
||||
void
|
||||
BlankStateHomePage::saveState()
|
||||
{
|
||||
appsettings->setCValue(context->athlete->cyclist, GC_BLANK_HOME, dontShow->isChecked());
|
||||
}
|
||||
void
|
||||
BlankStateTrainPage::saveState()
|
||||
{
|
||||
appsettings->setCValue(context->athlete->cyclist, GC_BLANK_TRAIN, dontShow->isChecked());
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,18 @@ class BlankStatePage : public GcWindow
|
||||
QPushButton *addToShortCuts(ShortCut shortCut);
|
||||
QCheckBox *dontShow;
|
||||
|
||||
bool canShow() { return canShow_; }
|
||||
virtual void saveState() = 0; // save settings
|
||||
|
||||
signals:
|
||||
void closeClicked();
|
||||
|
||||
public slots:
|
||||
void setCanShow();
|
||||
|
||||
protected:
|
||||
Context *context;
|
||||
bool canShow_;
|
||||
|
||||
QVBoxLayout *leftLayout;
|
||||
QLabel *welcomeTitle;
|
||||
@@ -69,6 +76,7 @@ class BlankStateAnalysisPage : public BlankStatePage
|
||||
|
||||
public:
|
||||
BlankStateAnalysisPage(Context *context);
|
||||
void saveState();
|
||||
|
||||
};
|
||||
|
||||
@@ -79,6 +87,7 @@ class BlankStateHomePage : public BlankStatePage
|
||||
|
||||
public:
|
||||
BlankStateHomePage(Context *context);
|
||||
void saveState();
|
||||
|
||||
};
|
||||
|
||||
@@ -89,6 +98,7 @@ class BlankStateDiaryPage : public BlankStatePage
|
||||
|
||||
public:
|
||||
BlankStateDiaryPage(Context *context);
|
||||
void saveState();
|
||||
|
||||
};
|
||||
|
||||
@@ -99,6 +109,7 @@ class BlankStateTrainPage : public BlankStatePage
|
||||
|
||||
public:
|
||||
BlankStateTrainPage(Context *context);
|
||||
void saveState();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "BlankState.h"
|
||||
#include "HomeWindow.h"
|
||||
#include "GcWindowRegistry.h"
|
||||
#include "TrainDB.h"
|
||||
#include "MetricAggregator.h"
|
||||
|
||||
#include "Settings.h"
|
||||
#include "MainWindow.h" // temp - will become Tab when its ready
|
||||
@@ -39,6 +41,10 @@ TabView::TabView(Context *context, int type) :
|
||||
|
||||
stack = new QStackedWidget(this);
|
||||
stack->setContentsMargins(0,0,0,0);
|
||||
stack->setFrameStyle(QFrame::Plain | QFrame::NoFrame);
|
||||
stack->setMinimumWidth(500);
|
||||
stack->setMinimumHeight(500);
|
||||
|
||||
layout->addWidget(stack);
|
||||
|
||||
// the splitter
|
||||
@@ -109,7 +115,15 @@ void
|
||||
TabView::setBlank(BlankStatePage *blank)
|
||||
{
|
||||
blank_ = blank;
|
||||
blank->hide();//stack->insertWidget(1, blank); // blank state always at index 1
|
||||
blank->hide();
|
||||
stack->insertWidget(1, blank); // blank state always at index 1
|
||||
|
||||
// and when stuff happens lets check
|
||||
connect(blank, SIGNAL(closeClicked()), this, SLOT(checkBlank()));
|
||||
connect(context->athlete->metricDB, SIGNAL(dataChanged()), this, SLOT(checkBlank()));
|
||||
connect(context, SIGNAL(configChanged()), this, SLOT(checkBlank()));
|
||||
connect(trainDB, SIGNAL(dataChanged()), this, SLOT(checkBlank()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -155,12 +169,24 @@ TabView::selectionChanged()
|
||||
// we got selected..
|
||||
if (isSelected()) {
|
||||
|
||||
emit onSelected(); // give view a change to prepare
|
||||
page()->selected(); // select the view
|
||||
|
||||
// or do we need to show blankness?
|
||||
if (isBlank() && blank_ && page_) stack->setCurrentIndex(1);
|
||||
if (!isBlank() && blank_ && page_) stack->setCurrentIndex(0);
|
||||
if (isBlank() && blank_ && page_ && blank_->canShow()) {
|
||||
|
||||
splitter->hide();
|
||||
blank()->show();
|
||||
|
||||
stack->setCurrentIndex(1);
|
||||
|
||||
} else if (blank_ && page_) {
|
||||
|
||||
blank()->hide();
|
||||
splitter->show();
|
||||
|
||||
emit onSelected(); // give view a change to prepare
|
||||
page()->selected(); // select the view
|
||||
|
||||
stack->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,3 +201,9 @@ TabView::addChart(GcWinID id)
|
||||
{
|
||||
if (page_) page_->appendChart(id);
|
||||
}
|
||||
|
||||
void
|
||||
TabView::checkBlank()
|
||||
{
|
||||
selectionChanged(); // run through the code again
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class TabView : public QWidget
|
||||
// interface used by the Tab class - must be implemented by a TabView
|
||||
virtual bool isBlank() = 0;
|
||||
virtual void setRide(RideItem*);
|
||||
virtual void checkBlank();
|
||||
|
||||
// can be overriden by the derived class but we provide a working version
|
||||
virtual void sidebarChanged();
|
||||
|
||||
@@ -22,20 +22,7 @@
|
||||
#include "TrainSidebar.h"
|
||||
#include "LTMSidebar.h"
|
||||
#include "BlankState.h"
|
||||
|
||||
// BLANK STATE NEEDS FIXING
|
||||
// blank state settings
|
||||
//appsettings->setCValue(context->athlete->cyclist, GC_BLANK_ANALYSIS, blankStateAnalysisPage->dontShow->isChecked());
|
||||
//appsettings->setCValue(context->athlete->cyclist, GC_BLANK_DIARY, blankStateDiaryPage->dontShow->isChecked());
|
||||
//appsettings->setCValue(context->athlete->cyclist, GC_BLANK_HOME, blankStateHomePage->dontShow->isChecked());
|
||||
//appsettings->setCValue(context->athlete->cyclist, GC_BLANK_TRAIN, blankStateTrainPage->dontShow->isChecked());
|
||||
// // when metricDB updates check if BlankState needs to be closed
|
||||
// connect(context->athlete->metricDB, SIGNAL(dataChanged()), this, SLOT(checkBlankState()));
|
||||
// // when config changes see if Train View BlankState needs to be closed
|
||||
// connect(context, SIGNAL(configChanged()), this, SLOT(checkBlankState()));
|
||||
// // when trainDB updates check if BlankState needs to be closed
|
||||
// connect(trainDB, SIGNAL(dataChanged()), this, SLOT(checkBlankState()));
|
||||
|
||||
#include "TrainDB.h"
|
||||
|
||||
AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView(context, VIEW_ANALYSIS)
|
||||
{
|
||||
@@ -75,7 +62,8 @@ void AnalysisView::close()
|
||||
bool
|
||||
AnalysisView::isBlank()
|
||||
{
|
||||
return false;
|
||||
if (context->athlete->allRides->childCount() > 0) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
DiaryView::DiaryView(Context *context, QStackedWidget *controls) : TabView(context, VIEW_DIARY)
|
||||
@@ -114,7 +102,8 @@ DiaryView::dateRangeChanged(DateRange dr)
|
||||
bool
|
||||
DiaryView::isBlank()
|
||||
{
|
||||
return false;
|
||||
if (context->athlete->allRides->childCount() > 0) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
HomeView::HomeView(Context *context, QStackedWidget *controls) : TabView(context, VIEW_HOME)
|
||||
@@ -146,7 +135,8 @@ HomeView::dateRangeChanged(DateRange dr)
|
||||
bool
|
||||
HomeView::isBlank()
|
||||
{
|
||||
return false;
|
||||
if (context->athlete->allRides->childCount() > 0) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -186,5 +176,6 @@ TrainView::close()
|
||||
bool
|
||||
TrainView::isBlank()
|
||||
{
|
||||
return false;
|
||||
if (appsettings->value(this, GC_DEV_COUNT).toInt() > 0 && trainDB->getCount() > 2) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user