aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Ui/qsui/mainwindow.cpp6
-rw-r--r--src/qmmpui/metadataformatter.cpp4
-rw-r--r--src/qmmpui/metadataformatter.h5
3 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/Ui/qsui/mainwindow.cpp b/src/plugins/Ui/qsui/mainwindow.cpp
index 80f2202f3..b7c44e363 100644
--- a/src/plugins/Ui/qsui/mainwindow.cpp
+++ b/src/plugins/Ui/qsui/mainwindow.cpp
@@ -195,9 +195,7 @@ void MainWindow::updatePosition(qint64 pos)
if(!m_slider->isSliderDown())
m_slider->setValue(pos/1000);
- QString text = MetaDataFormatter::formatLength(pos/1000);
- if(text.isEmpty())
- text = "0:00";
+ QString text = MetaDataFormatter::formatLength(pos/1000, false);
if(m_core->totalTime() > 1000)
{
text.append("/");
@@ -382,7 +380,7 @@ void MainWindow::updateStatus()
.arg(m_core->channels())
.arg(m_core->frequency())
.arg(tracks)
- .arg(MetaDataFormatter::formatLength(length))
+ .arg(MetaDataFormatter::formatLength(length, false))
.arg(m_core->bitrate()));
}
else if(m_core->state() == Qmmp::Stopped)
diff --git a/src/qmmpui/metadataformatter.cpp b/src/qmmpui/metadataformatter.cpp
index 017c0d120..c63938560 100644
--- a/src/qmmpui/metadataformatter.cpp
+++ b/src/qmmpui/metadataformatter.cpp
@@ -105,10 +105,10 @@ QString MetaDataFormatter::format(const QMap<Qmmp::MetaData, QString> &metaData,
return evalute(&m_nodes, &metaData, length, track).trimmed();
}
-QString MetaDataFormatter::formatLength(qint64 length)
+QString MetaDataFormatter::formatLength(qint64 length, bool hideZero)
{
if(length <= 0)
- return QString();
+ return hideZero ? QString() : "0:00";
QString str;
if(length >= 3600)
str = QString("%1:%2").arg(length/3600).arg(length%3600/60, 2, 10, QChar('0'));
diff --git a/src/qmmpui/metadataformatter.h b/src/qmmpui/metadataformatter.h
index 8f841ba9f..967087e4f 100644
--- a/src/qmmpui/metadataformatter.h
+++ b/src/qmmpui/metadataformatter.h
@@ -79,8 +79,11 @@ public:
/*!
* Returns formatted length (example: 05:02:03).
* \param length Length in seconds.
+ * \param hideZero Setting for zero values output.
+ * If \b hideZero is \b true, then the function outputs empty string for zero length,
+ * otherwise outputs "0:00".
*/
- static QString formatLength(qint64 length);
+ static QString formatLength(qint64 length, bool hideZero = true);
private:
struct Node;