From 29b0786d377cfae0f0e37c0cff314dda249026bc Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 21:21:00 +0200 Subject: [PATCH 1/8] Move tempo spin box next to time display --- src/gui/editors/SongEditor.cpp | 7 ++++--- src/gui/widgets/TimeDisplayWidget.cpp | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 6e23fcdbef7..729b126f934 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -113,12 +113,15 @@ SongEditor::SongEditor( Song * song ) : gui->mainWindow()->addSpacingToToolBar( 40 ); + gui->mainWindow()->addWidgetToToolBar( new TimeDisplayWidget ); + gui->mainWindow()->addSpacingToToolBar( 40 ); + m_tempoSpinBox = new LcdSpinBox( 3, tb, tr( "Tempo" ) ); m_tempoSpinBox->setModel( &m_song->m_tempoModel ); m_tempoSpinBox->setLabel( tr( "TEMPO" ) ); ToolTip::add( m_tempoSpinBox, tr( "Tempo in BPM" ) ); - int tempoSpinBoxCol = gui->mainWindow()->addWidgetToToolBar( m_tempoSpinBox, 0 ); + gui->mainWindow()->addWidgetToToolBar( m_tempoSpinBox); #if 0 toolButton * hq_btn = new toolButton( embed::getIconPixmap( "hq_mode" ), @@ -131,8 +134,6 @@ SongEditor::SongEditor( Song * song ) : gui->mainWindow()->addWidgetToToolBar( hq_btn, 1, col ); #endif - gui->mainWindow()->addWidgetToToolBar( new TimeDisplayWidget, 1, tempoSpinBoxCol ); - gui->mainWindow()->addSpacingToToolBar( 10 ); m_timeSigDisplay = new MeterDialog( this, true ); diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index e9a831193d7..ce419587726 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -47,8 +47,6 @@ TimeDisplayWidget::TimeDisplayWidget() : m_spinBoxesLayout.addWidget( &m_minorLCD ); m_spinBoxesLayout.addWidget( &m_milliSecondsLCD ); - setMaximumHeight( 32 ); - ToolTip::add( this, tr( "Time units" ) ); // update labels of LCD spinboxes From 6eb774c2c871c3ea8359bd8f3001e49d5171bbbf Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 21:34:26 +0200 Subject: [PATCH 2/8] Replace QHBoxLayout with QGridLayout in TimeDisplayWidget --- include/TimeDisplayWidget.h | 4 ++-- src/gui/widgets/TimeDisplayWidget.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 175f159c943..a1fc46690e8 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -27,7 +27,7 @@ #define _TIME_DISPLAY_WIDGET #include -#include +#include #include "LcdWidget.h" @@ -60,7 +60,7 @@ private slots: void setDisplayMode( DisplayMode displayMode ); DisplayMode m_displayMode; - QHBoxLayout m_spinBoxesLayout; + QGridLayout m_spinBoxesLayout; LcdWidget m_majorLCD; LcdWidget m_minorLCD; LcdWidget m_milliSecondsLCD; diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index ce419587726..d65cdd66077 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -43,9 +43,9 @@ TimeDisplayWidget::TimeDisplayWidget() : { m_spinBoxesLayout.setSpacing( 0 ); m_spinBoxesLayout.setMargin( 0 ); - m_spinBoxesLayout.addWidget( &m_majorLCD ); - m_spinBoxesLayout.addWidget( &m_minorLCD ); - m_spinBoxesLayout.addWidget( &m_milliSecondsLCD ); + m_spinBoxesLayout.addWidget( &m_majorLCD, 0, 0 ); + m_spinBoxesLayout.addWidget( &m_minorLCD, 0, 1 ); + m_spinBoxesLayout.addWidget( &m_milliSecondsLCD, 0, 2 ); ToolTip::add( this, tr( "Time units" ) ); From ede9765a5d7b2f34348f48defecff57ba478515b Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 22:19:55 +0200 Subject: [PATCH 3/8] Replace major LCD in TimeDisplayWidget with QLabels --- include/TimeDisplayWidget.h | 4 +++- src/gui/widgets/TimeDisplayWidget.cpp | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index a1fc46690e8..61aa322024c 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -28,6 +28,7 @@ #include #include +#include #include "LcdWidget.h" @@ -61,7 +62,8 @@ private slots: DisplayMode m_displayMode; QGridLayout m_spinBoxesLayout; - LcdWidget m_majorLCD; + QLabel m_majorLabel; + QLabel m_majorValue; LcdWidget m_minorLCD; LcdWidget m_milliSecondsLCD; diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index d65cdd66077..3765f14aeb9 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -37,16 +37,21 @@ TimeDisplayWidget::TimeDisplayWidget() : QWidget(), m_displayMode( MinutesSeconds ), m_spinBoxesLayout( this ), - m_majorLCD( 4, this ), + m_majorLabel( this ), + m_majorValue( this ), m_minorLCD( 2, this ), m_milliSecondsLCD( 3, this ) { m_spinBoxesLayout.setSpacing( 0 ); m_spinBoxesLayout.setMargin( 0 ); - m_spinBoxesLayout.addWidget( &m_majorLCD, 0, 0 ); + m_spinBoxesLayout.addWidget( &m_majorLabel, 0, 0 ); + m_spinBoxesLayout.addWidget( &m_majorValue, 1, 0 ); m_spinBoxesLayout.addWidget( &m_minorLCD, 0, 1 ); m_spinBoxesLayout.addWidget( &m_milliSecondsLCD, 0, 2 ); + m_majorLabel.setAlignment(Qt::AlignRight); + m_majorValue.setAlignment(Qt::AlignRight); + ToolTip::add( this, tr( "Time units" ) ); // update labels of LCD spinboxes @@ -63,13 +68,13 @@ void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) switch( m_displayMode ) { case MinutesSeconds: - m_majorLCD.setLabel( tr( "MIN" ) ); + m_majorLabel.setText( tr( "MIN" ) ); m_minorLCD.setLabel( tr( "SEC" ) ); m_milliSecondsLCD.setLabel( tr( "MSEC" ) ); break; case BarsTicks: - m_majorLCD.setLabel( tr( "BAR" ) ); + m_majorLabel.setText( tr( "BAR" ) ); m_minorLCD.setLabel( tr( "BEAT" ) ); m_milliSecondsLCD.setLabel( tr( "TICK" ) ); break; @@ -90,7 +95,7 @@ void TimeDisplayWidget::updateTime() case MinutesSeconds: int msec; msec = s->getMilliseconds(); - m_majorLCD.setValue(msec / 60000); + m_majorValue.setNum(msec / 60000); m_minorLCD.setValue((msec / 1000) % 60); m_milliSecondsLCD.setValue(msec % 1000); break; @@ -98,7 +103,7 @@ void TimeDisplayWidget::updateTime() case BarsTicks: int tick; tick = s->getPlayPos().getTicks(); - m_majorLCD.setValue((int)(tick / s->ticksPerTact()) + 1); + m_majorValue.setNum((int)(tick / s->ticksPerTact() ) + 1); m_minorLCD.setValue((tick % s->ticksPerTact()) / (s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1); m_milliSecondsLCD.setValue((tick % s->ticksPerTact()) % From 9e40b2c05693289108ab6e936586cab213bee5f8 Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 22:24:57 +0200 Subject: [PATCH 4/8] Replace minor LCD in TimeDisplayWidget with QLabels --- include/TimeDisplayWidget.h | 3 ++- src/gui/widgets/TimeDisplayWidget.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 61aa322024c..723935bda67 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -64,7 +64,8 @@ private slots: QGridLayout m_spinBoxesLayout; QLabel m_majorLabel; QLabel m_majorValue; - LcdWidget m_minorLCD; + QLabel m_minorLabel; + QLabel m_minorValue; LcdWidget m_milliSecondsLCD; } ; diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index 3765f14aeb9..64ff237a810 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -39,18 +39,22 @@ TimeDisplayWidget::TimeDisplayWidget() : m_spinBoxesLayout( this ), m_majorLabel( this ), m_majorValue( this ), - m_minorLCD( 2, this ), + m_minorLabel( this ), + m_minorValue( this ), m_milliSecondsLCD( 3, this ) { m_spinBoxesLayout.setSpacing( 0 ); m_spinBoxesLayout.setMargin( 0 ); m_spinBoxesLayout.addWidget( &m_majorLabel, 0, 0 ); m_spinBoxesLayout.addWidget( &m_majorValue, 1, 0 ); - m_spinBoxesLayout.addWidget( &m_minorLCD, 0, 1 ); + m_spinBoxesLayout.addWidget( &m_minorLabel, 0, 1 ); + m_spinBoxesLayout.addWidget( &m_minorValue, 1, 1 ); m_spinBoxesLayout.addWidget( &m_milliSecondsLCD, 0, 2 ); m_majorLabel.setAlignment(Qt::AlignRight); m_majorValue.setAlignment(Qt::AlignRight); + m_minorLabel.setAlignment(Qt::AlignRight); + m_minorValue.setAlignment(Qt::AlignRight); ToolTip::add( this, tr( "Time units" ) ); @@ -69,13 +73,13 @@ void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) { case MinutesSeconds: m_majorLabel.setText( tr( "MIN" ) ); - m_minorLCD.setLabel( tr( "SEC" ) ); + m_minorLabel.setText( tr( "SEC" ) ); m_milliSecondsLCD.setLabel( tr( "MSEC" ) ); break; case BarsTicks: m_majorLabel.setText( tr( "BAR" ) ); - m_minorLCD.setLabel( tr( "BEAT" ) ); + m_minorLabel.setText( tr( "BEAT" ) ); m_milliSecondsLCD.setLabel( tr( "TICK" ) ); break; @@ -96,7 +100,7 @@ void TimeDisplayWidget::updateTime() int msec; msec = s->getMilliseconds(); m_majorValue.setNum(msec / 60000); - m_minorLCD.setValue((msec / 1000) % 60); + m_minorValue.setNum((msec / 1000 ) % 60); m_milliSecondsLCD.setValue(msec % 1000); break; @@ -104,8 +108,8 @@ void TimeDisplayWidget::updateTime() int tick; tick = s->getPlayPos().getTicks(); m_majorValue.setNum((int)(tick / s->ticksPerTact() ) + 1); - m_minorLCD.setValue((tick % s->ticksPerTact()) / - (s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1); + m_minorValue.setNum( ( tick % s->ticksPerTact() ) / + ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); m_milliSecondsLCD.setValue((tick % s->ticksPerTact()) % (s->ticksPerTact() / s->getTimeSigModel().getNumerator())); break; From 52faff6721e17d438b4eb2f7bebc429df0874f70 Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 22:34:22 +0200 Subject: [PATCH 5/8] Replace milliseconds LCD in TimeDisplayWidget with QLabels --- include/TimeDisplayWidget.h | 3 ++- src/gui/widgets/TimeDisplayWidget.cpp | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 723935bda67..54265fa9b9a 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -66,7 +66,8 @@ private slots: QLabel m_majorValue; QLabel m_minorLabel; QLabel m_minorValue; - LcdWidget m_milliSecondsLCD; + QLabel m_milliSecondsLabel; + QLabel m_milliSecondsValue; } ; diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index 64ff237a810..bd72e421b17 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -41,7 +41,8 @@ TimeDisplayWidget::TimeDisplayWidget() : m_majorValue( this ), m_minorLabel( this ), m_minorValue( this ), - m_milliSecondsLCD( 3, this ) + m_milliSecondsLabel( this ), + m_milliSecondsValue( this ) { m_spinBoxesLayout.setSpacing( 0 ); m_spinBoxesLayout.setMargin( 0 ); @@ -49,12 +50,15 @@ TimeDisplayWidget::TimeDisplayWidget() : m_spinBoxesLayout.addWidget( &m_majorValue, 1, 0 ); m_spinBoxesLayout.addWidget( &m_minorLabel, 0, 1 ); m_spinBoxesLayout.addWidget( &m_minorValue, 1, 1 ); - m_spinBoxesLayout.addWidget( &m_milliSecondsLCD, 0, 2 ); + m_spinBoxesLayout.addWidget( &m_milliSecondsLabel, 0, 2 ); + m_spinBoxesLayout.addWidget( &m_milliSecondsValue, 1, 2 ); m_majorLabel.setAlignment(Qt::AlignRight); m_majorValue.setAlignment(Qt::AlignRight); m_minorLabel.setAlignment(Qt::AlignRight); m_minorValue.setAlignment(Qt::AlignRight); + m_milliSecondsLabel.setAlignment(Qt::AlignRight); + m_milliSecondsValue.setAlignment(Qt::AlignRight); ToolTip::add( this, tr( "Time units" ) ); @@ -74,13 +78,13 @@ void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) case MinutesSeconds: m_majorLabel.setText( tr( "MIN" ) ); m_minorLabel.setText( tr( "SEC" ) ); - m_milliSecondsLCD.setLabel( tr( "MSEC" ) ); + m_milliSecondsLabel.setText( tr( "MSEC" ) ); break; case BarsTicks: m_majorLabel.setText( tr( "BAR" ) ); m_minorLabel.setText( tr( "BEAT" ) ); - m_milliSecondsLCD.setLabel( tr( "TICK" ) ); + m_milliSecondsLabel.setText( tr( "TICK" ) ); break; default: break; @@ -101,7 +105,7 @@ void TimeDisplayWidget::updateTime() msec = s->getMilliseconds(); m_majorValue.setNum(msec / 60000); m_minorValue.setNum((msec / 1000 ) % 60); - m_milliSecondsLCD.setValue(msec % 1000); + m_milliSecondsValue.setNum(msec % 1000); break; case BarsTicks: @@ -110,7 +114,7 @@ void TimeDisplayWidget::updateTime() m_majorValue.setNum((int)(tick / s->ticksPerTact() ) + 1); m_minorValue.setNum( ( tick % s->ticksPerTact() ) / ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); - m_milliSecondsLCD.setValue((tick % s->ticksPerTact()) % + m_milliSecondsValue.setNum((tick % s->ticksPerTact()) % (s->ticksPerTact() / s->getTimeSigModel().getNumerator())); break; From de37efaf2fea0f47db37ecede6bb0889a2c6c2fb Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 22:59:37 +0200 Subject: [PATCH 6/8] Set colors and font sizes for TimeDisplayWidget --- src/gui/widgets/TimeDisplayWidget.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index bd72e421b17..eb508e4ea73 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -53,12 +53,23 @@ TimeDisplayWidget::TimeDisplayWidget() : m_spinBoxesLayout.addWidget( &m_milliSecondsLabel, 0, 2 ); m_spinBoxesLayout.addWidget( &m_milliSecondsValue, 1, 2 ); + this->setStyleSheet( "background-color: rgba(0,0,0,70);" ); + + QString labelStyle = "font-size: 12px;"; + QString valueStyle = "color: #0bd556; font-size: 32px;"; + m_majorLabel.setAlignment(Qt::AlignRight); + m_majorLabel.setStyleSheet(labelStyle); m_majorValue.setAlignment(Qt::AlignRight); + m_majorValue.setStyleSheet(valueStyle); m_minorLabel.setAlignment(Qt::AlignRight); + m_minorLabel.setStyleSheet(labelStyle); m_minorValue.setAlignment(Qt::AlignRight); + m_minorValue.setStyleSheet(valueStyle); m_milliSecondsLabel.setAlignment(Qt::AlignRight); + m_milliSecondsLabel.setStyleSheet(labelStyle); m_milliSecondsValue.setAlignment(Qt::AlignRight); + m_milliSecondsValue.setStyleSheet(valueStyle); ToolTip::add( this, tr( "Time units" ) ); From 1cbb7ae13f66c4f7dce6a9e9d0a962baa4b00554 Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 23:09:18 +0200 Subject: [PATCH 7/8] Add margin and padding to TimeDisplayWidget --- include/TimeDisplayWidget.h | 4 ++-- src/gui/widgets/TimeDisplayWidget.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 54265fa9b9a..206ee0d4184 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -26,14 +26,14 @@ #ifndef _TIME_DISPLAY_WIDGET #define _TIME_DISPLAY_WIDGET -#include +#include #include #include #include "LcdWidget.h" -class TimeDisplayWidget : public QWidget +class TimeDisplayWidget : public QFrame { Q_OBJECT public: diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index eb508e4ea73..c1450b5e2b7 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -34,7 +34,7 @@ TimeDisplayWidget::TimeDisplayWidget() : - QWidget(), + QFrame(), m_displayMode( MinutesSeconds ), m_spinBoxesLayout( this ), m_majorLabel( this ), @@ -53,10 +53,10 @@ TimeDisplayWidget::TimeDisplayWidget() : m_spinBoxesLayout.addWidget( &m_milliSecondsLabel, 0, 2 ); m_spinBoxesLayout.addWidget( &m_milliSecondsValue, 1, 2 ); - this->setStyleSheet( "background-color: rgba(0,0,0,70);" ); + this->setStyleSheet( "TimeDisplayWidget { border-radius: 4px; background-color: rgba(0,0,0,70); margin: 8px; padding: 4px; }" ); - QString labelStyle = "font-size: 12px;"; - QString valueStyle = "color: #0bd556; font-size: 32px;"; + QString labelStyle = "font-size: 10px;"; + QString valueStyle = "color: #0bd556; font-size: 24px;"; m_majorLabel.setAlignment(Qt::AlignRight); m_majorLabel.setStyleSheet(labelStyle); From 6857333c42b17eb82c17f14b6c62d712b60a6786 Mon Sep 17 00:00:00 2001 From: winniehell Date: Sat, 10 Aug 2019 23:52:50 +0200 Subject: [PATCH 8/8] Add leading zeros and separators to TimeDisplayWidget --- src/gui/widgets/TimeDisplayWidget.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index c1450b5e2b7..c0fc254bf16 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -109,28 +109,36 @@ void TimeDisplayWidget::updateTime() { Song* s = Engine::getSong(); + int major = 0; + int minor = 0; + int milliSeconds = 0; + switch( m_displayMode ) { case MinutesSeconds: int msec; msec = s->getMilliseconds(); - m_majorValue.setNum(msec / 60000); - m_minorValue.setNum((msec / 1000 ) % 60); - m_milliSecondsValue.setNum(msec % 1000); + major = msec / 60000; + minor = (msec / 1000) % 60; + milliSeconds = msec % 1000; break; case BarsTicks: int tick; tick = s->getPlayPos().getTicks(); - m_majorValue.setNum((int)(tick / s->ticksPerTact() ) + 1); - m_minorValue.setNum( ( tick % s->ticksPerTact() ) / - ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 ); - m_milliSecondsValue.setNum((tick % s->ticksPerTact()) % - (s->ticksPerTact() / s->getTimeSigModel().getNumerator())); + major = (int)(tick / s->ticksPerTact()) + 1; + minor = (tick % s->ticksPerTact()) / + (s->ticksPerTact() / s->getTimeSigModel().getNumerator()) +1; + milliSeconds = (tick % s->ticksPerTact()) % + (s->ticksPerTact() / s->getTimeSigModel().getNumerator()); break; default: break; } + + m_majorValue.setText( QString::number( major ).rightJustified( 4, '0' ) ); + m_minorValue.setText( QString::number( minor ).rightJustified( 2, '0' ).prepend( ':' ) ); + m_milliSecondsValue.setText( QString::number( milliSeconds ).rightJustified( 3, '0' ).prepend( '.' ) ); }