mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
UI Polish: Move train view controls to scope bar
Now we have a scope bar we can move the train view controls out of the sidebar.
This commit is contained in:
@@ -19,14 +19,13 @@
|
||||
#include "GcScopeBar.h"
|
||||
#include "QtMacButton.h"
|
||||
|
||||
GcScopeBar::GcScopeBar(QWidget *parent) : QWidget(parent)
|
||||
GcScopeBar::GcScopeBar(QWidget *parent, QWidget *traintool) : QWidget(parent)
|
||||
{
|
||||
setFixedHeight(25);
|
||||
setContentsMargins(10,0,10,0);
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->setSpacing(2);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
installEventFilter(this);
|
||||
|
||||
home = new QtMacButton(this, QtMacButton::Recessed);
|
||||
home->setText("Home");
|
||||
@@ -50,8 +49,11 @@ GcScopeBar::GcScopeBar(QWidget *parent) : QWidget(parent)
|
||||
train = new QtMacButton(this, QtMacButton::Recessed);
|
||||
train->setText("Train");
|
||||
layout->addWidget(train);
|
||||
layout->addStretch();
|
||||
connect(train, SIGNAL(clicked(bool)), this, SLOT(clickedTrain()));
|
||||
|
||||
layout->addStretch();
|
||||
layout->addWidget(traintool);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
GcScopeBar::~GcScopeBar()
|
||||
@@ -63,6 +65,7 @@ GcScopeBar::paintEvent (QPaintEvent *event)
|
||||
{
|
||||
// paint the darn thing!
|
||||
paintBackground(event);
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -79,12 +82,6 @@ GcScopeBar::paintBackground(QPaintEvent *)
|
||||
painter.drawTiledPixmap(all, isActiveWindow() ? active : inactive);
|
||||
}
|
||||
|
||||
bool
|
||||
GcScopeBar::eventFilter(QObject *obj, QEvent *e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
GcScopeBar::clickedHome()
|
||||
{
|
||||
|
||||
@@ -30,11 +30,10 @@ class GcScopeBar : public QWidget
|
||||
|
||||
public:
|
||||
|
||||
GcScopeBar(QWidget *parent);
|
||||
GcScopeBar(QWidget *parent, QWidget *traintool);
|
||||
~GcScopeBar();
|
||||
|
||||
public slots:
|
||||
bool eventFilter(QObject *o,QEvent *e);
|
||||
void paintEvent (QPaintEvent *event);
|
||||
|
||||
void clickedHome();
|
||||
|
||||
@@ -221,12 +221,6 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
connect(searchBox, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
|
||||
#endif
|
||||
|
||||
scopebar = new GcScopeBar(this);
|
||||
connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary()));
|
||||
connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome()));
|
||||
connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis()));
|
||||
connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain()));
|
||||
|
||||
#endif // MAC NATIVE TOOLBAR AND SCOPEBAR
|
||||
|
||||
// COMMON GUI SETUP
|
||||
@@ -382,8 +376,16 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
|
||||
trainTool = new TrainTool(this, home);
|
||||
trainTool->hide();
|
||||
trainTool->getToolbarButtons()->hide(); // no show yet
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
toolbar->addWidget(trainTool->getToolbarButtons());
|
||||
#else
|
||||
scopebar = new GcScopeBar(this, trainTool->getToolbarButtons());
|
||||
connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary()));
|
||||
connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome()));
|
||||
connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis()));
|
||||
connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain()));
|
||||
#endif
|
||||
|
||||
// Analysis view buttons too.
|
||||
@@ -1358,9 +1360,9 @@ MainWindow::selectAnalysis()
|
||||
views->setCurrentIndex(0);
|
||||
analWindow->selected(); // tell it!
|
||||
currentWindow = analWindow;
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#ifndef Q_OS_MAC
|
||||
analButtons->show();
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#else
|
||||
scopebar->selected(2);
|
||||
#endif
|
||||
@@ -1375,9 +1377,9 @@ MainWindow::selectTrain()
|
||||
views->setCurrentIndex(1);
|
||||
trainWindow->selected(); // tell it!
|
||||
currentWindow = trainWindow;
|
||||
trainTool->getToolbarButtons()->show();
|
||||
#ifndef Q_OS_MAC
|
||||
analButtons->hide();
|
||||
trainTool->getToolbarButtons()->show();
|
||||
#else
|
||||
scopebar->selected(3);
|
||||
#endif
|
||||
@@ -1392,9 +1394,9 @@ MainWindow::selectDiary()
|
||||
views->setCurrentIndex(2);
|
||||
diaryWindow->selected(); // tell it!
|
||||
currentWindow = diaryWindow;
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#ifndef Q_OS_MAC
|
||||
analButtons->hide();
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#else
|
||||
scopebar->selected(1);
|
||||
#endif
|
||||
@@ -1410,9 +1412,9 @@ MainWindow::selectHome()
|
||||
views->setCurrentIndex(3);
|
||||
homeWindow->selected(); // tell it!
|
||||
currentWindow = homeWindow;
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#ifndef Q_OS_MAC
|
||||
analButtons->hide();
|
||||
trainTool->getToolbarButtons()->hide();
|
||||
#else
|
||||
scopebar->selected(0);
|
||||
#endif
|
||||
|
||||
@@ -118,11 +118,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
workoutTree->expandItem(allWorkouts);
|
||||
|
||||
// TOOLBAR BUTTONS ETC
|
||||
#ifdef Q_OS_MAC
|
||||
QVBoxLayout *toolallbuttons=new QVBoxLayout; // in sidebar
|
||||
#else
|
||||
QHBoxLayout *toolallbuttons=new QHBoxLayout; // on toolbar
|
||||
#endif
|
||||
toolallbuttons->setSpacing(0);
|
||||
toolallbuttons->setContentsMargins(0,0,0,0);
|
||||
|
||||
@@ -135,7 +131,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
QIcon rewIcon(":images/oxygen/rewind.png");
|
||||
QPushButton *rewind = new QPushButton(rewIcon, "", this);
|
||||
rewind->setFocusPolicy(Qt::NoFocus);
|
||||
rewind->setIconSize(QSize(24,24));
|
||||
rewind->setIconSize(QSize(20,20));
|
||||
rewind->setAutoFillBackground(false);
|
||||
rewind->setAutoDefault(false);
|
||||
rewind->setFlat(true);
|
||||
@@ -147,7 +143,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
QIcon stopIcon(":images/oxygen/stop.png");
|
||||
QPushButton *stop = new QPushButton(stopIcon, "", this);
|
||||
stop->setFocusPolicy(Qt::NoFocus);
|
||||
stop->setIconSize(QSize(24,24));
|
||||
stop->setIconSize(QSize(20,20));
|
||||
stop->setAutoFillBackground(false);
|
||||
stop->setAutoDefault(false);
|
||||
stop->setFlat(true);
|
||||
@@ -157,7 +153,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
QIcon playIcon(":images/oxygen/play.png");
|
||||
play = new QPushButton(playIcon, "", this);
|
||||
play->setFocusPolicy(Qt::NoFocus);
|
||||
play->setIconSize(QSize(24,24));
|
||||
play->setIconSize(QSize(20,20));
|
||||
play->setAutoFillBackground(false);
|
||||
play->setAutoDefault(false);
|
||||
play->setFlat(true);
|
||||
@@ -167,7 +163,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
QIcon fwdIcon(":images/oxygen/ffwd.png");
|
||||
QPushButton *forward = new QPushButton(fwdIcon, "", this);
|
||||
forward->setFocusPolicy(Qt::NoFocus);
|
||||
forward->setIconSize(QSize(24,24));
|
||||
forward->setIconSize(QSize(20,20));
|
||||
forward->setAutoFillBackground(false);
|
||||
forward->setAutoDefault(false);
|
||||
forward->setFlat(true);
|
||||
@@ -215,22 +211,14 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
stress->setAutoFillBackground(false);
|
||||
stress->setFixedWidth(100);
|
||||
stress->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
||||
#ifdef Q_OS_MAC
|
||||
pal.setColor(stress->foregroundRole(), Qt::black);
|
||||
#else
|
||||
pal.setColor(stress->foregroundRole(), Qt::white);
|
||||
#endif
|
||||
stress->setPalette(pal);
|
||||
|
||||
intensity = new QLabel(this);
|
||||
intensity->setAutoFillBackground(false);
|
||||
intensity->setFixedWidth(100);
|
||||
intensity->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
||||
#ifdef Q_OS_MAC
|
||||
pal.setColor(intensity->foregroundRole(), Qt::black);
|
||||
#else
|
||||
pal.setColor(intensity->foregroundRole(), Qt::white);
|
||||
#endif
|
||||
intensity->setPalette(pal);
|
||||
|
||||
slideLayout->addWidget(stress, Qt::AlignVCenter|Qt::AlignCenter);
|
||||
@@ -267,9 +255,6 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h
|
||||
trainSplitter->setMidLineWidth(0);
|
||||
|
||||
cl->addWidget(trainSplitter);
|
||||
#ifdef Q_OS_MAC
|
||||
trainSplitter->addWidget(toolbarButtons);
|
||||
#endif
|
||||
trainSplitter->addWidget(deviceTree);
|
||||
//trainSplitter->addWidget(serverTree);
|
||||
trainSplitter->addWidget(workoutTree);
|
||||
@@ -736,12 +721,6 @@ void TrainTool::Start() // when start button is pressed
|
||||
|
||||
// Stop users from selecting different devices
|
||||
// media or workouts whilst a workout is in progress
|
||||
#if defined Q_OS_MAC || defined GC_HAVE_VLC
|
||||
mediaTree->setEnabled(false);
|
||||
#endif
|
||||
workoutTree->setEnabled(false);
|
||||
deviceTree->setEnabled(false);
|
||||
|
||||
// lets reset libusb to clear buffers
|
||||
// and reset connection to device
|
||||
// this appeara to help with ANT USB2 sticks
|
||||
@@ -756,11 +735,19 @@ void TrainTool::Start() // when start button is pressed
|
||||
if (multisetup->exec() == false) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
} else if (deviceTree->selectedItems().count() == 1) {
|
||||
bpmTelemetry = wattsTelemetry = kphTelemetry = rpmTelemetry =
|
||||
deviceTree->selectedItems().first()->type();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined Q_OS_MAC || defined GC_HAVE_VLC
|
||||
mediaTree->setEnabled(false);
|
||||
#endif
|
||||
workoutTree->setEnabled(false);
|
||||
deviceTree->setEnabled(false);
|
||||
|
||||
// START!
|
||||
play->setIcon(pauseIcon);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user