Skip to content

Commit

Permalink
Merge pull request #38 from benis/hectoseconds2
Browse files Browse the repository at this point in the history
Additional minor fixes
  • Loading branch information
daschuer authored Jan 14, 2019
2 parents 407164a + 5ba36de commit 19cf23d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
24 changes: 12 additions & 12 deletions src/preferences/dialog/dlgprefdeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,26 @@ DlgPrefDeck::DlgPrefDeck(QWidget * parent, MixxxMainWindow * mixxx,
// If not present in the config, set the default value
if (!m_pConfig->exists(ConfigKey("[Controls]","PositionDisplay"))) {
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"),
QString::number(static_cast<int>(TrackTime::DisplayMode::Remaining)));
QString::number(static_cast<int>(TrackTime::DisplayMode::REMAINING)));
}

double positionDisplayType = m_pConfig->getValue(
ConfigKey("[Controls]", "PositionDisplay"),
static_cast<double>(TrackTime::DisplayMode::Elapsed));
static_cast<double>(TrackTime::DisplayMode::ELAPSED));
if (positionDisplayType ==
static_cast<double>(TrackTime::DisplayMode::Remaining)) {
static_cast<double>(TrackTime::DisplayMode::REMAINING)) {
radioButtonRemaining->setChecked(true);
m_pControlTrackTimeDisplay->set(
static_cast<double>(TrackTime::DisplayMode::Remaining));
static_cast<double>(TrackTime::DisplayMode::REMAINING));
} else if (positionDisplayType ==
static_cast<double>(TrackTime::DisplayMode::ElapsedAndRemaining)) {
static_cast<double>(TrackTime::DisplayMode::ELAPSED_AND_REMAINING)) {
radioButtonElapsedAndRemaining->setChecked(true);
m_pControlTrackTimeDisplay->set(
static_cast<double>(TrackTime::DisplayMode::ElapsedAndRemaining));
static_cast<double>(TrackTime::DisplayMode::ELAPSED_AND_REMAINING));
} else {
radioButtonElapsed->setChecked(true);
m_pControlTrackTimeDisplay->set(
static_cast<double>(TrackTime::DisplayMode::Elapsed));
static_cast<double>(TrackTime::DisplayMode::ELAPSED));
}
connect(buttonGroupTrackTime, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(slotSetTrackTimeDisplay(QAbstractButton *)));
Expand Down Expand Up @@ -493,20 +493,20 @@ void DlgPrefDeck::slotJumpToCueOnTrackLoadCheckbox(bool checked) {

void DlgPrefDeck::slotSetTrackTimeDisplay(QAbstractButton* b) {
if (b == radioButtonRemaining) {
m_timeDisplayMode = TrackTime::DisplayMode::Remaining;
m_timeDisplayMode = TrackTime::DisplayMode::REMAINING;
} else if (b == radioButtonElapsedAndRemaining) {
m_timeDisplayMode = TrackTime::DisplayMode::ElapsedAndRemaining;
m_timeDisplayMode = TrackTime::DisplayMode::ELAPSED_AND_REMAINING;
} else {
m_timeDisplayMode = TrackTime::DisplayMode::Elapsed;
m_timeDisplayMode = TrackTime::DisplayMode::ELAPSED;
}
}

void DlgPrefDeck::slotSetTrackTimeDisplay(double v) {
m_timeDisplayMode = static_cast<TrackTime::DisplayMode>(static_cast<int>(v));
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"), ConfigValue(v));
if (m_timeDisplayMode == TrackTime::DisplayMode::Remaining) {
if (m_timeDisplayMode == TrackTime::DisplayMode::REMAINING) {
radioButtonRemaining->setChecked(true);
} else if (m_timeDisplayMode == TrackTime::DisplayMode::ElapsedAndRemaining) {
} else if (m_timeDisplayMode == TrackTime::DisplayMode::ELAPSED_AND_REMAINING) {
radioButtonElapsedAndRemaining->setChecked(true);
} else { // Elapsed
radioButtonElapsed->setChecked(true);
Expand Down
6 changes: 3 additions & 3 deletions src/preferences/dialog/dlgprefdeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class ControlObject;

namespace TrackTime {
enum class DisplayMode {
Elapsed,
Remaining,
ElapsedAndRemaining,
ELAPSED,
REMAINING,
ELAPSED_AND_REMAINING,
};

enum class DisplayFormat {
Expand Down
9 changes: 5 additions & 4 deletions src/util/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const qint64 kSecondsPerDay = 24 * kSecondsPerHour;
} // namespace

// static
const QString DurationBase::kInvalidDurationString = "?";
// Unicode for thin space
QChar DurationBase::kKiloGroupSeparator = QChar(0x2009);
// Unicode for bottom left corner
Expand All @@ -29,7 +30,7 @@ QChar DurationBase::kDecimalSeparator = QChar(0x002E);
QString DurationBase::formatTime(double dSeconds, Precision precision) {
if (dSeconds < 0.0) {
// negative durations are not supported
return "?";
return kInvalidDurationString;
}

const qint64 days = static_cast<qint64>(std::floor(dSeconds)) / kSecondsPerDay;
Expand Down Expand Up @@ -61,7 +62,7 @@ QString DurationBase::formatTime(double dSeconds, Precision precision) {
QString DurationBase::formatSeconds(double dSeconds, Precision precision) {
if (dSeconds < 0.0) {
// negative durations are not supported
return "?";
return kInvalidDurationString;
}

QString durationString;
Expand All @@ -81,7 +82,7 @@ QString DurationBase::formatSeconds(double dSeconds, Precision precision) {
QString DurationBase::formatKiloSeconds(double dSeconds, Precision precision) {
if (dSeconds < 0.0) {
// negative durations are not supported
return "?";
return kInvalidDurationString;
}

int kilos = (int)dSeconds / 1000;
Expand All @@ -108,7 +109,7 @@ QString DurationBase::formatKiloSeconds(double dSeconds, Precision precision) {
QString DurationBase::formatHectoSeconds(double dSeconds, Precision precision) {
if (dSeconds < 0.0) {
// negative durations are not supported
return "?";
return kInvalidDurationString;
}

int hectos = (int)dSeconds / 100;
Expand Down
2 changes: 2 additions & 0 deletions src/util/duration.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace mixxx {
class DurationBase {

public:

enum Units {
SECONDS,
MILLIS,
Expand Down Expand Up @@ -89,6 +90,7 @@ class DurationBase {
static constexpr qint64 kNanosPerSecond = kMicrosPerSecond * 1000;
static constexpr qint64 kNanosPerMilli = kNanosPerSecond / 1000;
static constexpr qint64 kNanosPerMicro = kNanosPerMilli / 1000;
static const QString kInvalidDurationString;
static QChar kKiloGroupSeparator;
static QChar kHectoGroupSeparator;
static QChar kDecimalSeparator;
Expand Down
24 changes: 12 additions & 12 deletions src/widget/wnumberpos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void WNumberPos::mousePressEvent(QMouseEvent* pEvent) {

if (leftClick) {
// Cycle through display modes
if (m_displayMode == TrackTime::DisplayMode::Elapsed) {
m_displayMode = TrackTime::DisplayMode::Remaining;
} else if (m_displayMode == TrackTime::DisplayMode::Remaining) {
m_displayMode = TrackTime::DisplayMode::ElapsedAndRemaining;
} else if (m_displayMode == TrackTime::DisplayMode::ElapsedAndRemaining) {
m_displayMode = TrackTime::DisplayMode::Elapsed;
if (m_displayMode == TrackTime::DisplayMode::ELAPSED) {
m_displayMode = TrackTime::DisplayMode::REMAINING;
} else if (m_displayMode == TrackTime::DisplayMode::REMAINING) {
m_displayMode = TrackTime::DisplayMode::ELAPSED_AND_REMAINING;
} else if (m_displayMode == TrackTime::DisplayMode::ELAPSED_AND_REMAINING) {
m_displayMode = TrackTime::DisplayMode::ELAPSED;
}

m_pShowTrackTimeRemaining->set(static_cast<double>(m_displayMode));
Expand Down Expand Up @@ -77,15 +77,15 @@ void WNumberPos::slotSetTimeElapsed(double dTimeElapsed) {
precision = mixxx::Duration::Precision::SECONDS;
}

if (m_displayMode == TrackTime::DisplayMode::Elapsed) {
if (m_displayMode == TrackTime::DisplayMode::ELAPSED) {
if (dTimeElapsed >= 0.0) {
setText(timeFormat(dTimeElapsed, precision));
} else {
setText(QLatin1String("-") % timeFormat(-dTimeElapsed, precision));
}
} else if (m_displayMode == TrackTime::DisplayMode::Remaining) {
} else if (m_displayMode == TrackTime::DisplayMode::REMAINING) {
setText(QLatin1String("-") % timeFormat(dTimeRemaining, precision));
} else if (m_displayMode == TrackTime::DisplayMode::ElapsedAndRemaining) {
} else if (m_displayMode == TrackTime::DisplayMode::ELAPSED_AND_REMAINING) {
if (dTimeElapsed >= 0.0) {
setText(timeFormat(dTimeElapsed, precision)
% QLatin1String(" -") % timeFormat(dTimeRemaining, precision));
Expand All @@ -110,11 +110,11 @@ void WNumberPos::slotTimeRemainingUpdated(double dTimeRemaining) {

void WNumberPos::slotSetDisplayMode(double remain) {
if (remain == 1.0) {
m_displayMode = TrackTime::DisplayMode::Remaining;
m_displayMode = TrackTime::DisplayMode::REMAINING;
} else if (remain == 2.0) {
m_displayMode = TrackTime::DisplayMode::ElapsedAndRemaining;
m_displayMode = TrackTime::DisplayMode::ELAPSED_AND_REMAINING;
} else {
m_displayMode = TrackTime::DisplayMode::Elapsed;
m_displayMode = TrackTime::DisplayMode::ELAPSED;
}

slotSetTimeElapsed(m_dOldTimeElapsed);
Expand Down

0 comments on commit 19cf23d

Please sign in to comment.