Switch to unified view

a/GUI/progresswidget/progresswidget.cpp b/GUI/progresswidget/progresswidget.cpp
...
...
14
 *   Free Software Foundation, Inc.,
14
 *   Free Software Foundation, Inc.,
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#include "progresswidget.h"
17
#include "progresswidget.h"
18
18
19
#include "HelperStructs/Helper.h"
20
19
#include <QDebug>
21
#include <QDebug>
20
22
21
ProgressWidget::ProgressWidget(QWidget *parent = 0)
23
ProgressWidget::ProgressWidget(QWidget *parent)
22
    : ProgressWidgetIF(parent)
24
    : ProgressWidgetIF(parent), m_totalsecs(0), m_step_pc(2), m_step_secs(-1)
23
{
25
{
26
    setupUi(this);
27
    songProgress->setMinimum(0);
28
    songProgress->setMaximum(100);
29
    connect(songProgress, SIGNAL(valueChanged(int)),
30
            this, SLOT(onProgressSliderChanged(int)));
24
}
31
}
25
32
26
void ProgressWidget::setTotalTime(int value)
33
void ProgressWidget::setTotalTime(int secs)
27
{
34
{
35
    QString length_str = Helper::cvtMsecs2TitleLengthString(secs * 1000, true);
36
    endTime->setText(length_str);
37
    m_totalsecs = secs;
28
}
38
}
29
39
30
void ProgressWidget::seek(int value)
40
void ProgressWidget::seek(int secs)
31
{
41
{
42
    if (secs < 0) {
43
        secs = 0;
44
    } else if (secs > m_totalsecs) {
45
        secs = m_totalsecs;
46
    }
47
    setUi(secs);
48
    emit progressChanged(secs);
49
        
32
}
50
}
33
51
34
void ProgressWidget::step(int steps)
52
void ProgressWidget::step(int steps)
35
{
53
{
54
    int secs = m_step_pc > 0 ? (m_step_pc * steps * m_totalsecs) / 100 :
55
        m_step_secs * steps;
56
    setUi(secs);
57
    emit progressChanged(secs);
36
}
58
}
37
59
38
void ProgressWidget::set_step_value_pc(int percent)
60
void ProgressWidget::set_step_value_pc(int percent)
39
{
61
{
62
    if (percent > 0 && percent <= 100) {
63
        m_step_secs = -1;
64
        m_step_pc = percent;
65
    }
40
}
66
}
41
67
42
void ProgressWidget::set_step_value_secs(int secs)
68
void ProgressWidget::set_step_value_secs(int secs)
43
{
69
{
70
    m_step_secs = secs;
71
    if (secs < 0) {
72
        m_step_pc = 2;
73
    } else {
74
        m_step_pc = -1;
75
    }
44
}
76
}
45
77
46
void ProgressWidget::setUi(int value)
78
void ProgressWidget::showTimes(int secs)
47
{
79
{
80
    QString curPosString = Helper::cvtMsecs2TitleLengthString(secs*1000);
81
    curTime->setText(curPosString);
82
    if (secs > 0) {
83
        curPosString =
84
            Helper::cvtMsecs2TitleLengthString((secs - m_totalsecs)*1000);
85
        endTime->setText(curPosString);
86
    } else {
87
        curPosString = Helper::cvtMsecs2TitleLengthString(m_totalsecs*1000);
88
        endTime->setText(curPosString);
89
    }        
48
}
90
}
49
91
50
void ProgressWidget::onProgressSliderChanged(int value)
92
void ProgressWidget::setUi(int secs)
51
{
93
{
94
    int pc = (secs * 100) / m_totalsecs;
95
    songProgress->setValueNoSigs(pc);
96
    showTimes(secs);
52
}
97
}
53
98
99
void ProgressWidget::onProgressSliderChanged(int pc)
100
{
101
    //qDebug() << "GUI_Player::setProgressJump: " << percent << " %";
102
    if (pc > 100) {
103
        pc = 100;
104
    } else if (pc < 0) {
105
        pc = 0;
106
    }
107
    int secs = (pc * m_totalsecs) / 100;
108
    showTimes(secs);
109
    emit progressChanged(secs);
110
}
111