From 260d0965e8cf1068041e2dc64e1e1f863a4ae822 Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 28 Jan 2013 21:38:28 +0100 Subject: [PATCH] UI Nits: GcChartWindow for PfPvWindow and HrPwWindow --- src/GoldenCheetah.cpp | 2 ++ src/HrPwWindow.cpp | 47 +++++++++---------------------------------- src/HrPwWindow.h | 6 +----- src/PfPvWindow.cpp | 37 ++++------------------------------ src/PfPvWindow.h | 6 +----- 5 files changed, 17 insertions(+), 81 deletions(-) diff --git a/src/GoldenCheetah.cpp b/src/GoldenCheetah.cpp index fda95fad9..b4e51f158 100644 --- a/src/GoldenCheetah.cpp +++ b/src/GoldenCheetah.cpp @@ -724,6 +724,8 @@ GcChartWindow::GcChartWindow(QWidget *parent) : GcWindow(parent) { _unrevealTimer = new QTimer(); connect(_unrevealTimer, SIGNAL(timeout()), this, SLOT(hideRevealControls())); + _revealControls->hide(); + _mainLayout->addWidget(_revealControls,0,0, Qt::AlignTop); _mainWidget->setLayout(_mainLayout); } diff --git a/src/HrPwWindow.cpp b/src/HrPwWindow.cpp index 41fe90fda..b189a9c86 100644 --- a/src/HrPwWindow.cpp +++ b/src/HrPwWindow.cpp @@ -31,43 +31,20 @@ // tooltip HrPwWindow::HrPwWindow(MainWindow *mainWindow) : - GcWindow(mainWindow), mainWindow(mainWindow), current(NULL) + GcChartWindow(mainWindow), mainWindow(mainWindow), current(NULL) { setControls(NULL); setInstanceName("HrPw"); - // 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("background-color: rgba(100%, 100%, 100%, 100%)"); - revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - - revealAnim = new QPropertyAnimation(revealControls, "pos"); - revealAnim->setDuration(500); - revealAnim->setEasingCurve(QEasingCurve(QEasingCurve::InSine)); - 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)); - // reveal controls - rDelay = new QLabel(tr("HR Delay"), revealControls); - rDelayEdit = new QLineEdit(revealControls); + rDelay = new QLabel(tr("HR Delay")); + rDelayEdit = new QLineEdit(); rDelayEdit->setFixedWidth(30); - rDelaySlider = new QSlider(Qt::Horizontal, revealControls); + rDelaySlider = new QSlider(Qt::Horizontal); rDelaySlider->setTickPosition(QSlider::TicksBelow); rDelaySlider->setTickInterval(10); rDelaySlider->setMinimum(1); @@ -75,10 +52,10 @@ HrPwWindow::HrPwWindow(MainWindow *mainWindow) : rDelayEdit->setValidator(new QIntValidator(rDelaySlider->minimum(), rDelaySlider->maximum(), rDelayEdit)); - rSmooth = new QLabel(tr("Smooth"), revealControls); - rSmoothEdit = new QLineEdit(revealControls); + rSmooth = new QLabel(tr("Smooth")); + rSmoothEdit = new QLineEdit(); rSmoothEdit->setFixedWidth(30); - rSmoothSlider = new QSlider(Qt::Horizontal, revealControls); + rSmoothSlider = new QSlider(Qt::Horizontal); rSmoothSlider->setTickPosition(QSlider::TicksBelow); rSmoothSlider->setTickInterval(50); rSmoothSlider->setMinimum(1); @@ -100,10 +77,7 @@ HrPwWindow::HrPwWindow(MainWindow *mainWindow) : r->addWidget(rSmoothEdit); r->addWidget(rSmoothSlider); r->addStretch(); - revealControls->setLayout(r); - - // hide them initially - revealControls->hide(); + setRevealLayout(r); // // Chart layout @@ -143,10 +117,7 @@ HrPwWindow::HrPwWindow(MainWindow *mainWindow) : vlayout->addWidget(smallPlot); vlayout->setStretch(1, 20); - mainLayout->addLayout(vlayout,0,0); - mainLayout->addWidget(revealControls,0,0, Qt::AlignTop); - revealControls->raise(); - setLayout(mainLayout); + setChartLayout(vlayout); // // the controls diff --git a/src/HrPwWindow.h b/src/HrPwWindow.h index 450ea7bf9..853444da6 100644 --- a/src/HrPwWindow.h +++ b/src/HrPwWindow.h @@ -34,7 +34,7 @@ class QSlider; #include "LTMWindow.h" // for tooltip/canvaspicker -class HrPwWindow : public GcWindow +class HrPwWindow : public GcChartWindow { Q_OBJECT G_OBJECT @@ -61,8 +61,6 @@ class HrPwWindow : public GcWindow // reveal bool hasReveal() { return true; } - void reveal() { revealControls->show(); revealAnim->start(); } - void unreveal() { unrevealAnim->start(); revealControls->hide(); } int smooth; @@ -101,8 +99,6 @@ class HrPwWindow : public GcWindow private: // reveal controls - QWidget *revealControls; - QPropertyAnimation *revealAnim, *unrevealAnim; QLabel *rSmooth; QSlider *rSmoothSlider; QLineEdit *rSmoothEdit; diff --git a/src/PfPvWindow.cpp b/src/PfPvWindow.cpp index cad36ae9a..88c5da917 100644 --- a/src/PfPvWindow.cpp +++ b/src/PfPvWindow.cpp @@ -25,7 +25,7 @@ #include PfPvWindow::PfPvWindow(MainWindow *mainWindow) : - GcWindow(mainWindow), mainWindow(mainWindow), current(NULL) + GcChartWindow(mainWindow), mainWindow(mainWindow), current(NULL) { setInstanceName("Pf/Pv Window"); @@ -33,38 +33,15 @@ PfPvWindow::PfPvWindow(MainWindow *mainWindow) : QVBoxLayout *cl = new QVBoxLayout(c); setControls(c); - // 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("background-color: rgba(100%, 100%, 100%, 100%)"); - revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - - revealAnim = new QPropertyAnimation(revealControls, "pos"); - revealAnim->setDuration(500); - revealAnim->setEasingCurve(QEasingCurve(QEasingCurve::InSine)); - 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); - rShade = new QCheckBox(tr("Shade zones"), revealControls); + rShade = new QCheckBox(tr("Shade zones")); if (appsettings->value(this, GC_SHADEZONES, true).toBool() == true) rShade->setCheckState(Qt::Checked); else @@ -88,20 +65,14 @@ PfPvWindow::PfPvWindow(MainWindow *mainWindow) : revealLayout->addLayout(checks); revealLayout->addStretch(); - revealControls->setLayout(revealLayout); - - // hide them initially - revealControls->hide(); + setRevealLayout(revealLayout); // the plot QVBoxLayout *vlayout = new QVBoxLayout; pfPvPlot = new PfPvPlot(mainWindow); vlayout->addWidget(pfPvPlot); - mainLayout->addLayout(vlayout,0,0); - mainLayout->addWidget(revealControls,0,0, Qt::AlignTop); - revealControls->raise(); - setLayout(mainLayout); + setChartLayout(vlayout); // allow zooming pfpvZoomer = new QwtPlotZoomer(pfPvPlot->canvas()); diff --git a/src/PfPvWindow.h b/src/PfPvWindow.h index 61b25188f..9524112a1 100644 --- a/src/PfPvWindow.h +++ b/src/PfPvWindow.h @@ -27,7 +27,7 @@ class MainWindow; class PfPvPlot; class RideItem; -class PfPvWindow : public GcWindow +class PfPvWindow : public GcChartWindow { Q_OBJECT G_OBJECT @@ -45,8 +45,6 @@ class PfPvWindow : public GcWindow // reveal bool hasReveal() { return true; } - void reveal() { revealControls->show(); revealAnim->start(); } - void unreveal() { unrevealAnim->start(); revealControls->hide(); } // get/set properties QString watts() const { return qaCPValue->text(); } @@ -84,7 +82,6 @@ class PfPvWindow : public GcWindow MainWindow *mainWindow; PfPvPlot *pfPvPlot; - QPropertyAnimation *revealAnim, *unrevealAnim; QwtPlotZoomer *pfpvZoomer; QCheckBox *shadeZonesPfPvCheckBox; QCheckBox *mergeIntervalPfPvCheckBox; @@ -96,7 +93,6 @@ class PfPvWindow : public GcWindow private: // reveal controls - QWidget *revealControls; QCheckBox *rShade, *rMergeInterval, *rFrameInterval; };