From df6a44ca8347a20cdee2339fc6377226ce5fbf2e Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 1 Sep 2011 20:59:03 +0100 Subject: [PATCH] Workout Controls for Train View Fixes broken controls on train view, so we can now start stop with the sidebar hidden and also adjust the settings for the realtime dials on the layout. Will need to think about saving the properties of the controls to use last used settings. Fixes #439. --- src/GcWindowRegistry.cpp | 2 + src/GcWindowRegistry.h | 3 +- src/MainWindow.cpp | 2 +- src/TrainTool.cpp | 28 ++++++++------ src/TrainTool.h | 2 +- src/xml/train-layout.xml | 81 ++++++++++++++++++---------------------- 6 files changed, 60 insertions(+), 58 deletions(-) diff --git a/src/GcWindowRegistry.cpp b/src/GcWindowRegistry.cpp index 0e97af4a3..6cc877e74 100644 --- a/src/GcWindowRegistry.cpp +++ b/src/GcWindowRegistry.cpp @@ -73,6 +73,7 @@ GcWindowRegistry GcWindows[] = { { "Ride Collection TreeMap",GcWindowTypes::TreeMap }, { "Weekly Summary",GcWindowTypes::WeeklySummary }, { "Video Player",GcWindowTypes::VideoPlayer }, + { "Realtime Controls", GcWindowTypes::RealtimeControls }, { "Realtime Dial",GcWindowTypes::DialWindow }, { "Realtime Plot",GcWindowTypes::RealtimePlot }, { "Workout Plot",GcWindowTypes::WorkoutPlot }, @@ -117,6 +118,7 @@ GcWindowRegistry::newGcWindow(GcWinID id, MainWindow *main) //XXX mainWindow wil #endif case GcWindowTypes::DialWindow: returning = new DialWindow(main); break; case GcWindowTypes::MetadataWindow: returning = new MetadataWindow(main); break; + case GcWindowTypes::RealtimeControls: returning = new TrainTool(main, main->home); break; case GcWindowTypes::RealtimePlot: returning = new RealtimePlotWindow(main); break; case GcWindowTypes::WorkoutPlot: returning = new WorkoutPlotWindow(main); break; case GcWindowTypes::BingMap: returning = new BingMap(main); break; diff --git a/src/GcWindowRegistry.h b/src/GcWindowRegistry.h index 5913d085e..32305b6b8 100644 --- a/src/GcWindowRegistry.h +++ b/src/GcWindowRegistry.h @@ -51,7 +51,8 @@ enum gcwinid { MetadataWindow = 23, RealtimePlot = 24, WorkoutPlot = 25, - BingMap = 26 + BingMap = 26, + RealtimeControls = 27 }; }; typedef enum GcWindowTypes::gcwinid GcWinID; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d79cd9bca..3e441e123 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -394,7 +394,7 @@ MainWindow::MainWindow(const QDir &home) : // TRAIN WINDOW & CONTROLS trainWindow = new HomeWindow(this, "train", "Training"); trainWindow->controls()->hide(); - trainControls->addWidget(new TrainTool(this, this->home)); + trainControls->addWidget(trainWindow->controls()); // ANALYSIS WINDOW & CONTRAOLS analWindow = new HomeWindow(this, "analysis", "Analysis"); diff --git a/src/TrainTool.cpp b/src/TrainTool.cpp index 786af9c87..2f2160928 100644 --- a/src/TrainTool.cpp +++ b/src/TrainTool.cpp @@ -35,16 +35,24 @@ #include "NullController.h" -TrainTool::TrainTool(MainWindow *parent, const QDir &home) : QWidget(parent), home(home), main(parent) +TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), home(home), main(parent) { - QVBoxLayout *mainLayout = new QVBoxLayout(this); + setInstanceName("Train Controls"); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(0,0,0,0); + QWidget *c = new QWidget; + QVBoxLayout *cl = new QVBoxLayout(c); + setControls(c); + + QVBoxLayout *mainLayout = new QVBoxLayout(this); + setLayout(mainLayout); + + cl->setSpacing(0); + cl->setContentsMargins(0,0,0,0); //setLineWidth(1); //setMidLineWidth(0); //setFrameStyle(QFrame::Plain | QFrame::Sunken); + mainLayout->setSpacing(0); setContentsMargins(0,0,0,0); @@ -81,10 +89,12 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : QWidget(parent), ho buttonPanel = new QFrame; buttonPanel->setLineWidth(1); - buttonPanel->setFrameStyle(QFrame::Box | QFrame::Raised); + buttonPanel->setFrameStyle(QFrame::NoFrame); buttonPanel->setContentsMargins(0,0,0,0); QVBoxLayout *panel = new QVBoxLayout; + panel->setSpacing(0); QHBoxLayout *buttons = new QHBoxLayout; + buttons->setSpacing(0); startButton = new QPushButton(tr("Start"), this); startButton->setMaximumHeight(100); pauseButton = new QPushButton(tr("Pause"), this); @@ -101,6 +111,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : QWidget(parent), ho panel->addWidget(recordSelector); buttonPanel->setLayout(panel); buttonPanel->setFixedHeight(90); + mainLayout->addWidget(buttonPanel); trainSplitter = new QSplitter; trainSplitter->setOrientation(Qt::Vertical); @@ -108,15 +119,10 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : QWidget(parent), ho trainSplitter->setLineWidth(0); trainSplitter->setMidLineWidth(0); - mainLayout->addWidget(trainSplitter); - trainSplitter->addWidget(buttonPanel); - trainSplitter->setCollapsible(0, false); + cl->addWidget(trainSplitter); trainSplitter->addWidget(deviceTree); - trainSplitter->setCollapsible(1, true); trainSplitter->addWidget(serverTree); - trainSplitter->setCollapsible(2, true); trainSplitter->addWidget(workoutTree); - trainSplitter->setCollapsible(3, true); // handle config changes connect(serverTree,SIGNAL(itemSelectionChanged()), this, SLOT(serverTreeWidgetSelectionChanged())); diff --git a/src/TrainTool.h b/src/TrainTool.h index 9181be10c..8bc5fdb02 100644 --- a/src/TrainTool.h +++ b/src/TrainTool.h @@ -66,7 +66,7 @@ class NullController; class RealtimePlot; class RealtimeData; -class TrainTool : public QWidget +class TrainTool : public GcWindow { Q_OBJECT G_OBJECT diff --git a/src/xml/train-layout.xml b/src/xml/train-layout.xml index 55dba17dc..471fffa03 100644 --- a/src/xml/train-layout.xml +++ b/src/xml/train-layout.xml @@ -1,34 +1,46 @@ - - + + + + + + + + + + - - - + + + + + + + + + + + + - - + + + - - + + - - - - - - - - + - - + + + @@ -38,8 +50,9 @@ + - + @@ -49,8 +62,9 @@ + - + @@ -60,34 +74,13 @@ + - + - - - - - - - - - - - - - - - - - - - - - -