From 204dbe3f48bc2b7516e8922e403cb189d9d037fe Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 28 Jan 2013 22:46:53 +0100 Subject: [PATCH] UI Nits: GcChartWindow for CriticalPowerWindow and ModelWindow --- src/CriticalPowerWindow.cpp | 37 +++---------------------------------- src/CriticalPowerWindow.h | 6 +----- src/ModelWindow.cpp | 22 ++++++++++++++++++++-- src/ModelWindow.h | 11 ++++++++--- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index 11e039f65..de5d9f67c 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -34,36 +34,14 @@ #include CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, bool rangemode) : - GcWindow(parent), _dateRange("{00000000-0000-0000-0000-000000000001}"), home(home), mainWindow(parent), currentRide(NULL), rangemode(rangemode), stale(true), useCustom(false), useToToday(false) + GcChartWindow(parent), _dateRange("{00000000-0000-0000-0000-000000000001}"), home(home), mainWindow(parent), currentRide(NULL), rangemode(rangemode), stale(true), useCustom(false), useToToday(false) { setInstanceName("Critical Power Window"); - // Main layout - QGridLayout *mainLayout = new QGridLayout(this); - mainLayout->setContentsMargins(2,2,2,2); - // // reveal controls widget // - // reveal widget - revealControls = new QWidget(this); - revealControls->setFixedHeight(50); - revealControls->setStyleSheet("QWidget { background-color: rgba(100%, 100%, 100%, 100%); }"); - revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - - revealAnim = new QPropertyAnimation(revealControls, "pos"); - revealAnim->setDuration(500); - revealAnim->setKeyValueAt(0,QPoint(2,-50)); - revealAnim->setKeyValueAt(0.5,QPoint(2,15)); - revealAnim->setKeyValueAt(1,QPoint(2,20)); - - unrevealAnim = new QPropertyAnimation(revealControls, "pos"); - unrevealAnim->setDuration(500); - unrevealAnim->setKeyValueAt(0,QPoint(2,20)); - unrevealAnim->setKeyValueAt(0.5,QPoint(2,15)); - unrevealAnim->setKeyValueAt(1,QPoint(2,-50)); - // layout reveal controls QHBoxLayout *revealLayout = new QHBoxLayout; revealLayout->setContentsMargins(0,0,0,0); @@ -76,11 +54,7 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b revealLayout->addWidget(rCpintSetCPButton); revealLayout->addStretch(); - revealControls->setLayout(revealLayout); - - // hide them initially - revealControls->hide(); - + setRevealLayout(revealLayout); // main plot area QVBoxLayout *vlayout = new QVBoxLayout; @@ -196,12 +170,7 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b picker->setStateMachine(new QwtPickerDragPointMachine); picker->setRubberBandPen(GColor(CPLOTTRACKER)); - mainLayout->addLayout(vlayout, 0, 0); - mainLayout->addWidget(pickerControls, 0, 0, Qt::AlignTop | Qt::AlignRight); - mainLayout->addWidget(revealControls,0,0, Qt::AlignTop); - pickerControls->raise(); - revealControls->raise(); - setLayout(mainLayout); + setChartLayout(vlayout); connect(picker, SIGNAL(moved(const QPoint &)), SLOT(pickerMoved(const QPoint &))); //connect(cpintTimeValue, SIGNAL(editingFinished()), this, SLOT(cpintTimeValueEntered())); diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index dffb5687c..0db81f669 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -31,7 +31,7 @@ class MainWindow; class RideItem; class QwtPlotPicker; -class CriticalPowerWindow : public GcWindow +class CriticalPowerWindow : public GcChartWindow { Q_OBJECT G_OBJECT @@ -60,8 +60,6 @@ class CriticalPowerWindow : public GcWindow // reveal bool hasReveal() { return true; } - void reveal() { revealControls->show(); revealAnim->start(); } - void unreveal() { unrevealAnim->start(); revealControls->hide(); } void deleteCpiFile(QString filename); @@ -127,8 +125,6 @@ class CriticalPowerWindow : public GcWindow private: // reveal controls - QWidget *revealControls; - QPropertyAnimation *revealAnim, *unrevealAnim; QPushButton *rCpintSetCPButton; void updateCpint(double minutes); diff --git a/src/ModelWindow.cpp b/src/ModelWindow.cpp index 25f44335b..d1efcfd99 100644 --- a/src/ModelWindow.cpp +++ b/src/ModelWindow.cpp @@ -45,7 +45,7 @@ ModelWindow::addStandardChannels(QComboBox *box) } ModelWindow::ModelWindow(MainWindow *parent, const QDir &home) : - GcWindow(parent), home(home), main(parent), ride(NULL), current(NULL) + GcChartWindow(parent), home(home), main(parent), ride(NULL), current(NULL) { setInstanceName("3D Window"); @@ -57,6 +57,24 @@ ModelWindow::ModelWindow(MainWindow *parent, const QDir &home) : nodata = new QLabel(tr("No data or bin size too large."), this); nodata->hide(); + // + // reveal controls + // + rpresetLabel = new QLabel(tr("Analyse"), this); + rpresetValues = new QComboBox; + fillPresets(rpresetValues); + rpresetValues->setCurrentIndex(1); + + // layout reveal controls + QHBoxLayout *r = new QHBoxLayout; + r->setSpacing(4); + r->setContentsMargins(0,0,0,0); + r->addStretch(); + r->addWidget(rpresetLabel); + r->addWidget(rpresetValues); + r->addStretch(); + setRevealLayout(r); + // the plot widget QHBoxLayout *mainLayout = new QHBoxLayout; modelPlot= new ModelPlot(main, NULL); @@ -68,7 +86,7 @@ ModelWindow::ModelWindow(MainWindow *parent, const QDir &home) : mainLayout->addWidget(zpane); mainLayout->addWidget(modelPlot); mainLayout->addWidget(nodata); - setLayout(mainLayout); + setChartLayout(mainLayout); // preset Values presetLabel = new QLabel(tr("Analyse"), this); diff --git a/src/ModelWindow.h b/src/ModelWindow.h index 23807e117..04cc492a5 100644 --- a/src/ModelWindow.h +++ b/src/ModelWindow.h @@ -46,7 +46,7 @@ class ModelSettings }; -class ModelWindow : public GcWindow +class ModelWindow : public GcChartWindow { Q_OBJECT G_OBJECT @@ -67,6 +67,9 @@ class ModelWindow : public GcWindow ModelWindow(MainWindow *, const QDir &); + // reveal + bool hasReveal() { return true; } + // set/get properties int preset() const { return presetValues->currentIndex(); } void setPreset(int x) { presetValues->setCurrentIndex(x); } @@ -132,10 +135,12 @@ class ModelWindow : public GcWindow *yLabel, *zLabel, *colorLabel, - *binLabel; + *binLabel, + *rpresetLabel; // top of screen selectors - QComboBox *presetValues; + QComboBox *presetValues, + *rpresetValues; // bottom selectors QComboBox *xSelector,