diff --git a/src/Resources/application.qrc b/src/Resources/application.qrc index 124e0d814..76cb23423 100644 --- a/src/Resources/application.qrc +++ b/src/Resources/application.qrc @@ -121,19 +121,34 @@ xml/home-perspectives.xml ini/measures.ini html/ltm-summary.html - images/oxygen/power-off.png - images/oxygen/power-on.png - images/oxygen/play.png - images/oxygen/pause.png - images/oxygen/stop.png - images/oxygen/ffwd.png - images/oxygen/rewind.png - images/oxygen/lap.png - images/oxygen/fwd.png - images/oxygen/back.png - images/oxygen/save.png - images/oxygen/open.png - images/oxygen/cal.png + images/breeze/light/unknown.svg + images/breeze/light/offline.svg + images/breeze/light/online.svg + images/breeze/light/play.svg + images/breeze/light/pause.svg + images/breeze/light/ffwd.svg + images/breeze/light/rewind.svg + images/breeze/light/stop.svg + images/breeze/light/lap.svg + images/breeze/light/fwd.svg + images/breeze/light/back.svg + images/breeze/light/up.svg + images/breeze/light/down.svg + images/breeze/light/cal.svg + images/breeze/dark/unknown.svg + images/breeze/dark/offline.svg + images/breeze/dark/online.svg + images/breeze/dark/play.svg + images/breeze/dark/pause.svg + images/breeze/dark/ffwd.svg + images/breeze/dark/rewind.svg + images/breeze/dark/stop.svg + images/breeze/dark/lap.svg + images/breeze/dark/fwd.svg + images/breeze/dark/back.svg + images/breeze/dark/up.svg + images/breeze/dark/down.svg + images/breeze/dark/cal.svg images/toolbar/close-icon.png images/toolbar/save.png images/toolbar/saveas.png @@ -183,8 +198,6 @@ images/sidebar/movie.png images/sidebar/power.png images/sidebar/sync.png - images/oxygen/up.png - images/oxygen/down.png audio/lap.wav images/configure.png images/toolbar/cloud.png diff --git a/src/Resources/images/breeze/dark/back.svg b/src/Resources/images/breeze/dark/back.svg new file mode 100644 index 000000000..00af3f123 --- /dev/null +++ b/src/Resources/images/breeze/dark/back.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/cal.svg b/src/Resources/images/breeze/dark/cal.svg new file mode 100644 index 000000000..34cd5704d --- /dev/null +++ b/src/Resources/images/breeze/dark/cal.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/down.svg b/src/Resources/images/breeze/dark/down.svg new file mode 100644 index 000000000..0ab5ffdf5 --- /dev/null +++ b/src/Resources/images/breeze/dark/down.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/src/Resources/images/breeze/dark/ffwd.svg b/src/Resources/images/breeze/dark/ffwd.svg new file mode 100644 index 000000000..4a5270cdc --- /dev/null +++ b/src/Resources/images/breeze/dark/ffwd.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/fwd.svg b/src/Resources/images/breeze/dark/fwd.svg new file mode 100644 index 000000000..c507ec927 --- /dev/null +++ b/src/Resources/images/breeze/dark/fwd.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/lap.svg b/src/Resources/images/breeze/dark/lap.svg new file mode 100644 index 000000000..83321c597 --- /dev/null +++ b/src/Resources/images/breeze/dark/lap.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/offline.svg b/src/Resources/images/breeze/dark/offline.svg new file mode 100644 index 000000000..24d396e5d --- /dev/null +++ b/src/Resources/images/breeze/dark/offline.svg @@ -0,0 +1,21 @@ + + + + + + + diff --git a/src/Resources/images/breeze/dark/online.svg b/src/Resources/images/breeze/dark/online.svg new file mode 100644 index 000000000..b32a31be3 --- /dev/null +++ b/src/Resources/images/breeze/dark/online.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/pause.svg b/src/Resources/images/breeze/dark/pause.svg new file mode 100644 index 000000000..be4004c2e --- /dev/null +++ b/src/Resources/images/breeze/dark/pause.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/play.svg b/src/Resources/images/breeze/dark/play.svg new file mode 100644 index 000000000..18b861b29 --- /dev/null +++ b/src/Resources/images/breeze/dark/play.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/rewind.svg b/src/Resources/images/breeze/dark/rewind.svg new file mode 100644 index 000000000..3054cdbd6 --- /dev/null +++ b/src/Resources/images/breeze/dark/rewind.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/stop.svg b/src/Resources/images/breeze/dark/stop.svg new file mode 100644 index 000000000..6a8743d88 --- /dev/null +++ b/src/Resources/images/breeze/dark/stop.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/unknown.svg b/src/Resources/images/breeze/dark/unknown.svg new file mode 100644 index 000000000..02358a643 --- /dev/null +++ b/src/Resources/images/breeze/dark/unknown.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/Resources/images/breeze/dark/up.svg b/src/Resources/images/breeze/dark/up.svg new file mode 100644 index 000000000..80a221318 --- /dev/null +++ b/src/Resources/images/breeze/dark/up.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/src/Resources/images/breeze/light/back.svg b/src/Resources/images/breeze/light/back.svg new file mode 100644 index 000000000..66b3be400 --- /dev/null +++ b/src/Resources/images/breeze/light/back.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/cal.svg b/src/Resources/images/breeze/light/cal.svg new file mode 100644 index 000000000..8b9f85d10 --- /dev/null +++ b/src/Resources/images/breeze/light/cal.svg @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/down.svg b/src/Resources/images/breeze/light/down.svg new file mode 100644 index 000000000..6a5e82bff --- /dev/null +++ b/src/Resources/images/breeze/light/down.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/src/Resources/images/breeze/light/ffwd.svg b/src/Resources/images/breeze/light/ffwd.svg new file mode 100644 index 000000000..bab90f17c --- /dev/null +++ b/src/Resources/images/breeze/light/ffwd.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/fwd.svg b/src/Resources/images/breeze/light/fwd.svg new file mode 100644 index 000000000..2b4f9dfc9 --- /dev/null +++ b/src/Resources/images/breeze/light/fwd.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/lap.svg b/src/Resources/images/breeze/light/lap.svg new file mode 100644 index 000000000..3ca1eed2b --- /dev/null +++ b/src/Resources/images/breeze/light/lap.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/offline.svg b/src/Resources/images/breeze/light/offline.svg new file mode 100644 index 000000000..bb87f596d --- /dev/null +++ b/src/Resources/images/breeze/light/offline.svg @@ -0,0 +1,22 @@ + + + + + + + diff --git a/src/Resources/images/breeze/light/online.svg b/src/Resources/images/breeze/light/online.svg new file mode 100644 index 000000000..e7d2b626d --- /dev/null +++ b/src/Resources/images/breeze/light/online.svg @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/pause.svg b/src/Resources/images/breeze/light/pause.svg new file mode 100644 index 000000000..4ec8ec4de --- /dev/null +++ b/src/Resources/images/breeze/light/pause.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/play.svg b/src/Resources/images/breeze/light/play.svg new file mode 100644 index 000000000..0321c55f2 --- /dev/null +++ b/src/Resources/images/breeze/light/play.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/rewind.svg b/src/Resources/images/breeze/light/rewind.svg new file mode 100644 index 000000000..1f168902b --- /dev/null +++ b/src/Resources/images/breeze/light/rewind.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/stop.svg b/src/Resources/images/breeze/light/stop.svg new file mode 100644 index 000000000..81705d07e --- /dev/null +++ b/src/Resources/images/breeze/light/stop.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/unknown.svg b/src/Resources/images/breeze/light/unknown.svg new file mode 100644 index 000000000..780a23ff6 --- /dev/null +++ b/src/Resources/images/breeze/light/unknown.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/Resources/images/breeze/light/up.svg b/src/Resources/images/breeze/light/up.svg new file mode 100644 index 000000000..f43c800fd --- /dev/null +++ b/src/Resources/images/breeze/light/up.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/src/Resources/images/oxygen/back.png b/src/Resources/images/oxygen/back.png deleted file mode 100644 index 64cff200f..000000000 Binary files a/src/Resources/images/oxygen/back.png and /dev/null differ diff --git a/src/Resources/images/oxygen/cal.png b/src/Resources/images/oxygen/cal.png deleted file mode 100644 index 930359757..000000000 Binary files a/src/Resources/images/oxygen/cal.png and /dev/null differ diff --git a/src/Resources/images/oxygen/down.png b/src/Resources/images/oxygen/down.png deleted file mode 100644 index 373469310..000000000 Binary files a/src/Resources/images/oxygen/down.png and /dev/null differ diff --git a/src/Resources/images/oxygen/equalizer.png b/src/Resources/images/oxygen/equalizer.png deleted file mode 100644 index 6f0670174..000000000 Binary files a/src/Resources/images/oxygen/equalizer.png and /dev/null differ diff --git a/src/Resources/images/oxygen/ffwd.png b/src/Resources/images/oxygen/ffwd.png deleted file mode 100644 index fd976956d..000000000 Binary files a/src/Resources/images/oxygen/ffwd.png and /dev/null differ diff --git a/src/Resources/images/oxygen/fwd.png b/src/Resources/images/oxygen/fwd.png deleted file mode 100644 index 33a99e134..000000000 Binary files a/src/Resources/images/oxygen/fwd.png and /dev/null differ diff --git a/src/Resources/images/oxygen/lap.png b/src/Resources/images/oxygen/lap.png deleted file mode 100644 index 24478199a..000000000 Binary files a/src/Resources/images/oxygen/lap.png and /dev/null differ diff --git a/src/Resources/images/oxygen/open.png b/src/Resources/images/oxygen/open.png deleted file mode 100644 index 2ba1ca10f..000000000 Binary files a/src/Resources/images/oxygen/open.png and /dev/null differ diff --git a/src/Resources/images/oxygen/pause.png b/src/Resources/images/oxygen/pause.png deleted file mode 100644 index d5b9c83cf..000000000 Binary files a/src/Resources/images/oxygen/pause.png and /dev/null differ diff --git a/src/Resources/images/oxygen/play.png b/src/Resources/images/oxygen/play.png deleted file mode 100644 index 8b8a32b81..000000000 Binary files a/src/Resources/images/oxygen/play.png and /dev/null differ diff --git a/src/Resources/images/oxygen/power-off.png b/src/Resources/images/oxygen/power-off.png deleted file mode 100644 index a333237e3..000000000 Binary files a/src/Resources/images/oxygen/power-off.png and /dev/null differ diff --git a/src/Resources/images/oxygen/power-on.png b/src/Resources/images/oxygen/power-on.png deleted file mode 100644 index 1356dafc1..000000000 Binary files a/src/Resources/images/oxygen/power-on.png and /dev/null differ diff --git a/src/Resources/images/oxygen/rewind.png b/src/Resources/images/oxygen/rewind.png deleted file mode 100644 index 95cc10fd5..000000000 Binary files a/src/Resources/images/oxygen/rewind.png and /dev/null differ diff --git a/src/Resources/images/oxygen/save.png b/src/Resources/images/oxygen/save.png deleted file mode 100644 index 29610ea76..000000000 Binary files a/src/Resources/images/oxygen/save.png and /dev/null differ diff --git a/src/Resources/images/oxygen/stop.png b/src/Resources/images/oxygen/stop.png deleted file mode 100644 index b5829bc06..000000000 Binary files a/src/Resources/images/oxygen/stop.png and /dev/null differ diff --git a/src/Resources/images/oxygen/up.png b/src/Resources/images/oxygen/up.png deleted file mode 100644 index eeea7903f..000000000 Binary files a/src/Resources/images/oxygen/up.png and /dev/null differ diff --git a/src/Train/TrainBottom.cpp b/src/Train/TrainBottom.cpp index 201a9f5e8..fda3ee2ee 100644 --- a/src/Train/TrainBottom.cpp +++ b/src/Train/TrainBottom.cpp @@ -34,145 +34,129 @@ TrainBottom::TrainBottom(TrainSidebar *trainSidebar, QWidget *parent) : HelpWhatsThis *help = new HelpWhatsThis(this); this->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::WorkoutControl)); + setAttribute(Qt::WA_StyledBackground, true); // otherwise the background-color of the widget is not shown + // Control buttons QHBoxLayout *toolbuttons = new QHBoxLayout; toolbuttons->setSpacing(0); toolbuttons->setContentsMargins(0,0,0,0); - QIcon connectButtonIcon(":images/oxygen/power-off.png"); - m_connectButton = new QPushButton(connectButtonIcon, "", this); + m_connectButton = new QPushButton(this); + applyIcon(m_connectButton, "offline"); m_connectButton->setFocusPolicy(Qt::NoFocus); - m_connectButton->setIconSize(QSize(64,64)); - m_connectButton->setAutoFillBackground(false); m_connectButton->setAutoDefault(false); m_connectButton->setFlat(true); - m_connectButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_connectButton->setShortcut(Qt::Key_MediaPrevious); toolbuttons->addWidget(m_connectButton); - QIcon rewIcon(":images/oxygen/rewind.png"); - m_rewindButton = new QPushButton(rewIcon, "", this); + toolbuttons->addSpacing(5); + toolbuttons->addWidget(newSep()); + toolbuttons->addSpacing(5); + + m_rewindButton = new QPushButton(this); + applyIcon(m_rewindButton, "rewind"); m_rewindButton->setFocusPolicy(Qt::NoFocus); - m_rewindButton->setIconSize(QSize(64,64)); - m_rewindButton->setAutoFillBackground(false); m_rewindButton->setAutoDefault(false); m_rewindButton->setFlat(true); - m_rewindButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_rewindButton->setAutoRepeat(true); m_rewindButton->setAutoRepeatDelay(400); m_rewindButton->setShortcut(Qt::Key_MediaPrevious); toolbuttons->addWidget(m_rewindButton); - QIcon stopIcon(":images/oxygen/stop.png"); - m_stopButton = new QPushButton(stopIcon, "", this); + m_stopButton = new QPushButton(this); + applyIcon(m_stopButton, "stop"); m_stopButton->setFocusPolicy(Qt::NoFocus); - m_stopButton->setIconSize(QSize(64,64)); - m_stopButton->setAutoFillBackground(false); m_stopButton->setAutoDefault(false); m_stopButton->setFlat(true); - m_stopButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_stopButton->setShortcut(Qt::Key_MediaStop); toolbuttons->addWidget(m_stopButton); - QIcon playIcon(":images/oxygen/play.png"); - m_playButton = new QPushButton(playIcon, "", this); + m_playButton = new QPushButton(this); + applyIcon(m_playButton, "play"); m_playButton->setFocusPolicy(Qt::NoFocus); - m_playButton->setIconSize(QSize(64,64)); - m_playButton->setAutoFillBackground(false); m_playButton->setAutoDefault(false); m_playButton->setFlat(true); - m_playButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_playButton->setShortcut(Qt::Key_MediaTogglePlayPause); toolbuttons->addWidget(m_playButton); - QIcon fwdIcon(":images/oxygen/ffwd.png"); - m_forwardButton = new QPushButton(fwdIcon, "", this); + m_forwardButton = new QPushButton(this); + applyIcon(m_forwardButton, "ffwd"); m_forwardButton->setFocusPolicy(Qt::NoFocus); - m_forwardButton->setIconSize(QSize(64,64)); - m_forwardButton->setAutoFillBackground(false); m_forwardButton->setAutoDefault(false); m_forwardButton->setFlat(true); - m_forwardButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_forwardButton->setAutoRepeat(true); m_forwardButton->setAutoRepeatDelay(400); m_forwardButton->setShortcut(Qt::Key_MediaNext); toolbuttons->addWidget(m_forwardButton); - QIcon backLapIcon(":images/oxygen/back.png"); - backLap = new QPushButton(backLapIcon, "", this); + toolbuttons->addSpacing(5); + toolbuttons->addWidget(newSep()); + toolbuttons->addSpacing(5); + + backLap = new QPushButton(this); + applyIcon(backLap, "back"); backLap->setFocusPolicy(Qt::NoFocus); - backLap->setIconSize(QSize(64,64)); - backLap->setAutoFillBackground(false); backLap->setAutoDefault(false); backLap->setFlat(true); - backLap->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); backLap->setAutoRepeat(true); backLap->setAutoRepeatDelay(400); toolbuttons->addWidget(backLap); - QIcon lapIcon(":images/oxygen/lap.png"); - m_lapButton = new QPushButton(lapIcon, "", this); + m_lapButton = new QPushButton(this); + applyIcon(m_lapButton, "lap"); m_lapButton->setFocusPolicy(Qt::NoFocus); - m_lapButton->setIconSize(QSize(64,64)); - m_lapButton->setAutoFillBackground(false); m_lapButton->setAutoDefault(false); m_lapButton->setFlat(true); - m_lapButton->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); m_lapButton->setShortcut(Qt::Key_0); toolbuttons->addWidget(m_lapButton); - QIcon fwdLapIcon(":images/oxygen/fwd.png"); - fwdLap = new QPushButton(fwdLapIcon, "", this); + fwdLap = new QPushButton(this); + applyIcon(fwdLap, "fwd"); fwdLap->setFocusPolicy(Qt::NoFocus); - fwdLap->setIconSize(QSize(64,64)); - fwdLap->setAutoFillBackground(false); fwdLap->setAutoDefault(false); fwdLap->setFlat(true); - fwdLap->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); fwdLap->setAutoRepeat(true); fwdLap->setAutoRepeatDelay(400); fwdLap->setShortcut(Qt::Key_MediaLast); toolbuttons->addWidget(fwdLap); - QIcon calIcon(":images/oxygen/cal.png"); - cal = new QPushButton(calIcon, "", this); + toolbuttons->addSpacing(5); + toolbuttons->addWidget(newSep()); + toolbuttons->addSpacing(5); + + cal = new QPushButton(this); + applyIcon(cal, "cal"); cal->setFocusPolicy(Qt::NoFocus); - cal->setIconSize(QSize(64,64)); - cal->setAutoFillBackground(false); cal->setAutoDefault(false); cal->setFlat(true); - cal->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); cal->setShortcut(Qt::Key_C); toolbuttons->addWidget(cal); - QIcon upIcon(":images/oxygen/up.png"); - loadUp = new QPushButton(upIcon, "", this); - loadUp->setFocusPolicy(Qt::NoFocus); - loadUp->setIconSize(QSize(64,64)); - loadUp->setAutoFillBackground(false); - loadUp->setAutoDefault(false); - loadUp->setFlat(true); - loadUp->setAutoRepeat(true); - loadUp->setAutoRepeatInterval(50); - loadUp->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); - loadUp->setShortcut(Qt::Key_Plus); - toolbuttons->addWidget(loadUp); + toolbuttons->addSpacing(5); + toolbuttons->addWidget(newSep()); + toolbuttons->addSpacing(5); - QIcon downIcon(":images/oxygen/down.png"); - loadDown = new QPushButton(downIcon, "", this); + loadDown = new QPushButton(this); + applyIcon(loadDown, "down"); loadDown->setFocusPolicy(Qt::NoFocus); - loadDown->setIconSize(QSize(64,64)); - loadDown->setAutoFillBackground(false); loadDown->setAutoDefault(false); loadDown->setFlat(true); loadDown->setAutoRepeat(true); loadDown->setAutoRepeatInterval(50); - loadDown->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); loadDown->setShortcut(Qt::Key_Minus); toolbuttons->addWidget(loadDown); + loadUp = new QPushButton(this); + applyIcon(loadUp, "up"); + loadUp->setFocusPolicy(Qt::NoFocus); + loadUp->setAutoDefault(false); + loadUp->setFlat(true); + loadUp->setAutoRepeat(true); + loadUp->setAutoRepeatInterval(50); + loadUp->setShortcut(Qt::Key_Plus); + toolbuttons->addWidget(loadUp); + intensitySlider = new QSlider(Qt::Vertical, this); - intensitySlider->setAutoFillBackground(false); intensitySlider->setFocusPolicy(Qt::NoFocus); intensitySlider->setMinimum(75); intensitySlider->setMaximum(125); @@ -230,10 +214,10 @@ TrainBottom::TrainBottom(TrainSidebar *trainSidebar, QWidget *parent) : connect(m_trainSidebar, SIGNAL(setNotification(QString, int)), this, SLOT(setNotification(QString, int))); connect(m_trainSidebar, SIGNAL(clearNotification(void)), this, SLOT(clearNotification(void))); + connect(m_trainSidebar->context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); + this->setContentsMargins(0,0,0,0); this->setFocusPolicy(Qt::NoFocus); - this->setAutoFillBackground(false); - this->setStyleSheet("background-color: rgba( 255, 255, 255, 0% ); border: 0px;"); this->setLayout(allControlsLayout); this->installEventFilter(trainSidebar); @@ -263,24 +247,23 @@ TrainBottom::TrainBottom(TrainSidebar *trainSidebar, QWidget *parent) : // Create a timer for notifications, but don't start yet notificationTimer = new QTimer(this); connect(notificationTimer, SIGNAL(timeout()), SLOT(clearNotification())); + + updateStyles(); } void TrainBottom::updatePlayButtonIcon() { - static QIcon playIcon(":images/oxygen/play.png"); - static QIcon pauseIcon(":images/oxygen/pause.png"); - if (m_trainSidebar->currentStatus() & RT_PAUSED) { - m_playButton->setIcon(playIcon); + applyIcon(m_playButton, "play"); } else if (m_trainSidebar->currentStatus() & RT_RUNNING) { - m_playButton->setIcon(pauseIcon); + applyIcon(m_playButton, "pause"); } else // Not running or paused means stopped { - m_playButton->setIcon(playIcon); + applyIcon(m_playButton, "play"); } } @@ -292,12 +275,9 @@ void TrainBottom::autoHideCheckboxChanged(int state) void TrainBottom::statusChanged(int status) { - static QIcon connectedIcon(":images/oxygen/power-on.png"); - static QIcon disconnectedIcon(":images/oxygen/power-off.png"); - // not yet connected if ((status&RT_CONNECTED) == 0) { - m_connectButton->setIcon(disconnectedIcon); + applyIcon(m_connectButton, "offline"); m_connectButton->setEnabled(true); m_playButton->setEnabled(false); m_stopButton->setEnabled(false); @@ -315,7 +295,7 @@ void TrainBottom::statusChanged(int status) // connected, but not running if ((status&RT_CONNECTED) && ((status&RT_RUNNING) == 0)) { - m_connectButton->setIcon(connectedIcon); + applyIcon(m_connectButton, "online"); m_connectButton->setEnabled(true); m_playButton->setEnabled(true); m_stopButton->setEnabled(false); @@ -333,7 +313,7 @@ void TrainBottom::statusChanged(int status) // paused - important to check for paused before running if (status&RT_PAUSED) { - m_connectButton->setIcon(connectedIcon); + applyIcon(m_connectButton, "online"); m_connectButton->setEnabled(false); m_playButton->setEnabled(true); m_stopButton->setEnabled(true); @@ -351,7 +331,7 @@ void TrainBottom::statusChanged(int status) // running & calibrating if ((status&RT_CALIBRATING) && (status&RT_RUNNING)) { - m_connectButton->setIcon(connectedIcon); + applyIcon(m_connectButton, "online"); m_connectButton->setEnabled(false); m_playButton->setEnabled(false); m_stopButton->setEnabled(true); @@ -369,7 +349,7 @@ void TrainBottom::statusChanged(int status) // running if (status&RT_RUNNING) { - m_connectButton->setIcon(connectedIcon); + applyIcon(m_connectButton, "online"); m_connectButton->setEnabled(false); m_playButton->setEnabled(true); m_stopButton->setEnabled(true); @@ -406,3 +386,94 @@ void TrainBottom::clearNotification(void) { notificationText->clear(); } + + +void TrainBottom::updateStyles() +{ + QColor bg = GColor(CCHROME); + QColor frame = GCColor::invertColor(bg); + QColor hover = GColor(CHOVER); + QString bss = QString( + "QWidget { background-color: %2; }" + "QPushButton { border: 0px; } " + "QPushButton:hover { background-color: %1; } " + "QFrame { color: %3; } " + ).arg(hover.name(QColor::HexArgb)) + .arg(bg.name(QColor::HexArgb)) + .arg(frame.name(QColor::HexArgb)); + bool dark = isDark(); + + reapplyIcon(m_connectButton, dark); + reapplyIcon(m_playButton, dark); + reapplyIcon(m_rewindButton, dark); + reapplyIcon(m_stopButton, dark); + reapplyIcon(m_forwardButton, dark); + reapplyIcon(m_lapButton, dark); + reapplyIcon(m_connectButton, dark); + reapplyIcon(loadDown, dark); + reapplyIcon(loadUp, dark); + reapplyIcon(cal, dark); + reapplyIcon(fwdLap, dark); + reapplyIcon(backLap, dark); + + setStyleSheet(bss); +} + + +QFrame* TrainBottom::newSep() +{ + QFrame *sep = new QFrame(this); + sep->setFrameShape(QFrame::VLine); + sep->setFrameShadow(QFrame::Plain); + sep->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + return sep; +} + + +void TrainBottom::configChanged(qint32) +{ + updateStyles(); +} + + +void +TrainBottom::applyIcon +(QPushButton *button, QString iconName, bool dark) +{ + iconNames[button] = iconName; + button->setIcon(QIcon(QString(":images/breeze/%1/%2.svg").arg(dark ? "dark" : "light").arg(iconName))); + button->setIconSize(QSize(64, 64)); + button->setFixedSize(64, 64); +} + + +void +TrainBottom::applyIcon +(QPushButton *button, QString iconName) +{ + applyIcon(button, iconName, isDark()); +} + + +void +TrainBottom::reapplyIcon +(QPushButton *button, bool dark) +{ + applyIcon(button, iconNames.value(button, "unknown"), dark); +} + + +void +TrainBottom::reapplyIcon +(QPushButton *button) +{ + applyIcon(button, iconNames.value(button, "unknown")); +} + + +bool +TrainBottom::isDark +() const +{ + return GColor(CCHROME).lightness() < 127; +} diff --git a/src/Train/TrainBottom.h b/src/Train/TrainBottom.h index 0d574147d..9bd52d396 100644 --- a/src/Train/TrainBottom.h +++ b/src/Train/TrainBottom.h @@ -20,6 +20,9 @@ #define _GC_TrainBottom_h #include +#include +#include +#include class TrainSidebar; class QPushButton; @@ -32,6 +35,10 @@ class TrainBottom : public QWidget public: TrainBottom(TrainSidebar * trainSidebar, QWidget *parent = 0); + +public slots: + void configChanged(qint32); + private: TrainSidebar *m_trainSidebar; QPushButton *m_playButton, *m_rewindButton, *m_stopButton, *m_forwardButton; @@ -39,6 +46,15 @@ private: QSlider *intensitySlider; QPlainTextEdit *notificationText; QTimer *notificationTimer; + QMap iconNames; + + void updateStyles(); + QFrame *newSep(); + void applyIcon(QPushButton *button, QString iconName, bool dark); + void applyIcon(QPushButton *button, QString iconName); + void reapplyIcon(QPushButton *button, bool dark); + void reapplyIcon(QPushButton *button); + bool isDark() const; private slots: void updatePlayButtonIcon(); diff --git a/src/Train/TrainSidebar.cpp b/src/Train/TrainSidebar.cpp index 0d5a17c50..eb804c0c6 100644 --- a/src/Train/TrainSidebar.cpp +++ b/src/Train/TrainSidebar.cpp @@ -1631,9 +1631,6 @@ void TrainSidebar::Disconnect() // don't try to disconnect if running or not connected if ((status&RT_RUNNING) || ((status&RT_CONNECTED) == 0)) return; - static QIcon connectedIcon(":images/oxygen/power-on.png"); - static QIcon disconnectedIcon(":images/oxygen/power-off.png"); - qDebug() << "disconnecting.."; foreach(int dev, activeDevices) {