mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
Add tool tips to trainer controls (#4517)
Add a preferences option to enable/disable these tooltips. Default is enabled. If enabled tooltips will also be shown for disabled controls in TrainBottom so users can preview what they do once the session start.
This commit is contained in:
@@ -238,6 +238,7 @@
|
||||
#define TRAIN_USESIMULATEDSPEED "<global-trainmode>train/usesimulatedspeed"
|
||||
#define TRAIN_USESIMULATEDHYPOXIA "<global-trainmode>train/usesimulatedhypoxia"
|
||||
#define TRAIN_COALESCE_SECTIONS "<global-trainmode>train/coalesceSections"
|
||||
#define TRAIN_TOOLTIPS "<global-trainmode>train/tooltips"
|
||||
#define TRAIN_TELEMETRY_FONT_SCALING "<global-trainmode>train/telemetryFontScaling"
|
||||
#define GC_REMOTE_START "<global-trainmode>remote/start"
|
||||
#define GC_REMOTE_STOP "<global-trainmode>remote/stop"
|
||||
|
||||
@@ -757,6 +757,9 @@ TrainOptionsPage::TrainOptionsPage(QWidget *parent, Context *context) : QWidget(
|
||||
coalesce = new QCheckBox(tr("Coalesce contiguous sections of same wattage"), this);
|
||||
coalesce->setChecked(appsettings->value(this, TRAIN_COALESCE_SECTIONS, false).toBool());
|
||||
|
||||
tooltips = new QCheckBox(tr("Enable Tooltips"), this);
|
||||
tooltips->setChecked(appsettings->value(this, TRAIN_TOOLTIPS, true).toBool());
|
||||
|
||||
telemetryScalingLabel = new QLabel(tr("Telemetry font scaling"));
|
||||
telemetryScaling = new QComboBox();
|
||||
telemetryScaling->addItem(tr("Fit to height only"), 0);
|
||||
@@ -785,6 +788,7 @@ TrainOptionsPage::TrainOptionsPage(QWidget *parent, Context *context) : QWidget(
|
||||
all->addRow("", autoHide);
|
||||
all->addRow("", lapAlert);
|
||||
all->addRow("", coalesce);
|
||||
all->addRow("", tooltips);
|
||||
all->addRow(delayLabel, startDelay);
|
||||
all->addRow(telemetryScalingLabel, telemetryScaling);
|
||||
}
|
||||
@@ -803,6 +807,7 @@ TrainOptionsPage::saveClicked()
|
||||
appsettings->setValue(TRAIN_AUTOHIDE, autoHide->isChecked());
|
||||
appsettings->setValue(TRAIN_LAPALERT, lapAlert->isChecked());
|
||||
appsettings->setValue(TRAIN_COALESCE_SECTIONS, coalesce->isChecked());
|
||||
appsettings->setValue(TRAIN_TOOLTIPS, tooltips->isChecked());
|
||||
appsettings->setValue(TRAIN_TELEMETRY_FONT_SCALING, telemetryScaling->currentIndex());
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -240,6 +240,7 @@ class TrainOptionsPage : public QWidget
|
||||
QCheckBox *autoHide;
|
||||
QCheckBox *lapAlert;
|
||||
QCheckBox *coalesce;
|
||||
QCheckBox *tooltips;
|
||||
QLabel *telemetryScalingLabel;
|
||||
QComboBox *telemetryScaling;
|
||||
};
|
||||
|
||||
@@ -249,6 +249,8 @@ TrainBottom::TrainBottom(TrainSidebar *trainSidebar, QWidget *parent) :
|
||||
connect(notificationTimer, SIGNAL(timeout()), SLOT(clearNotification()));
|
||||
|
||||
updateStyles();
|
||||
m_tooltips = appsettings->value(this, TRAIN_TOOLTIPS, true).toBool();
|
||||
updateTooltips();
|
||||
}
|
||||
|
||||
void TrainBottom::updatePlayButtonIcon()
|
||||
@@ -256,14 +258,26 @@ void TrainBottom::updatePlayButtonIcon()
|
||||
if (m_trainSidebar->currentStatus() & RT_PAUSED)
|
||||
{
|
||||
applyIcon(m_playButton, "play");
|
||||
if (m_tooltips)
|
||||
{
|
||||
m_playButton->setToolTip(tr("Resume"));
|
||||
}
|
||||
}
|
||||
else if (m_trainSidebar->currentStatus() & RT_RUNNING)
|
||||
{
|
||||
applyIcon(m_playButton, "pause");
|
||||
if (m_tooltips)
|
||||
{
|
||||
m_playButton->setToolTip(tr("Pause"));
|
||||
}
|
||||
}
|
||||
else // Not running or paused means stopped
|
||||
{
|
||||
applyIcon(m_playButton, "play");
|
||||
if (m_tooltips)
|
||||
{
|
||||
m_playButton->setToolTip(tr("Start"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +292,9 @@ void TrainBottom::statusChanged(int status)
|
||||
// not yet connected
|
||||
if ((status&RT_CONNECTED) == 0) {
|
||||
applyIcon(m_connectButton, "offline");
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Connect"));
|
||||
}
|
||||
m_connectButton->setEnabled(true);
|
||||
m_playButton->setEnabled(false);
|
||||
m_stopButton->setEnabled(false);
|
||||
@@ -296,6 +313,9 @@ void TrainBottom::statusChanged(int status)
|
||||
// connected, but not running
|
||||
if ((status&RT_CONNECTED) && ((status&RT_RUNNING) == 0)) {
|
||||
applyIcon(m_connectButton, "online");
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Disconnect"));
|
||||
}
|
||||
m_connectButton->setEnabled(true);
|
||||
m_playButton->setEnabled(true);
|
||||
m_stopButton->setEnabled(false);
|
||||
@@ -314,6 +334,9 @@ void TrainBottom::statusChanged(int status)
|
||||
// paused - important to check for paused before running
|
||||
if (status&RT_PAUSED) {
|
||||
applyIcon(m_connectButton, "online");
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Disconnect"));
|
||||
}
|
||||
m_connectButton->setEnabled(false);
|
||||
m_playButton->setEnabled(true);
|
||||
m_stopButton->setEnabled(true);
|
||||
@@ -332,6 +355,9 @@ void TrainBottom::statusChanged(int status)
|
||||
// running & calibrating
|
||||
if ((status&RT_CALIBRATING) && (status&RT_RUNNING)) {
|
||||
applyIcon(m_connectButton, "online");
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Disconnect"));
|
||||
}
|
||||
m_connectButton->setEnabled(false);
|
||||
m_playButton->setEnabled(false);
|
||||
m_stopButton->setEnabled(true);
|
||||
@@ -350,6 +376,9 @@ void TrainBottom::statusChanged(int status)
|
||||
// running
|
||||
if (status&RT_RUNNING) {
|
||||
applyIcon(m_connectButton, "online");
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Disconnect"));
|
||||
}
|
||||
m_connectButton->setEnabled(false);
|
||||
m_playButton->setEnabled(true);
|
||||
m_stopButton->setEnabled(true);
|
||||
@@ -362,6 +391,7 @@ void TrainBottom::statusChanged(int status)
|
||||
loadUp->setEnabled(true);
|
||||
loadDown->setEnabled(true);
|
||||
intensitySlider->setEnabled(true);
|
||||
intensitySlider->setToolTip(tr("Adjust intensity"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -419,7 +449,36 @@ void TrainBottom::updateStyles()
|
||||
setStyleSheet(bss);
|
||||
}
|
||||
|
||||
|
||||
void TrainBottom::updateTooltips()
|
||||
{
|
||||
if (m_tooltips) {
|
||||
m_connectButton->setToolTip(tr("Connect"));
|
||||
m_rewindButton->setToolTip(tr("Rewind"));
|
||||
m_stopButton->setToolTip(tr("Stop"));
|
||||
m_playButton->setToolTip(tr("Start"));
|
||||
m_forwardButton->setToolTip(tr("Fast forward"));
|
||||
backLap->setToolTip(tr("Back 1 lap"));
|
||||
m_lapButton->setToolTip(tr("Lap"));
|
||||
fwdLap->setToolTip(tr("Forward 1 lap"));
|
||||
cal->setToolTip(tr("Calibrate"));
|
||||
loadDown->setToolTip(tr("Decrease intensity"));
|
||||
loadUp->setToolTip(tr("Increase intensity"));
|
||||
}
|
||||
else {
|
||||
m_connectButton->setToolTip("");
|
||||
m_playButton->setToolTip("");
|
||||
m_stopButton->setToolTip("");
|
||||
m_forwardButton->setToolTip("");
|
||||
m_rewindButton->setToolTip("");
|
||||
backLap->setToolTip("");
|
||||
m_lapButton->setToolTip("");
|
||||
fwdLap->setToolTip("");
|
||||
cal->setToolTip("");
|
||||
loadUp->setToolTip("");
|
||||
loadDown->setToolTip("");
|
||||
intensitySlider->setToolTip("");
|
||||
}
|
||||
}
|
||||
QFrame* TrainBottom::newSep()
|
||||
{
|
||||
QFrame *sep = new QFrame(this);
|
||||
@@ -433,6 +492,11 @@ QFrame* TrainBottom::newSep()
|
||||
void TrainBottom::configChanged(qint32)
|
||||
{
|
||||
updateStyles();
|
||||
const bool tooltips = appsettings->value(this, TRAIN_TOOLTIPS, true).toBool();
|
||||
if (m_tooltips != tooltips) {
|
||||
m_tooltips = tooltips;
|
||||
updateTooltips();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,10 @@ private:
|
||||
QPlainTextEdit *notificationText;
|
||||
QTimer *notificationTimer;
|
||||
QMap<void*, QString> iconNames;
|
||||
bool m_tooltips;
|
||||
|
||||
void updateStyles();
|
||||
void updateTooltips();
|
||||
QFrame *newSep();
|
||||
void applyIcon(QPushButton *button, QString iconName, bool dark);
|
||||
void applyIcon(QPushButton *button, QString iconName);
|
||||
|
||||
Reference in New Issue
Block a user