Ignore:
Timestamp:
Aug 31, 2016, 5:31:04 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.8.0

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/widgetactions.cpp

    r176 r181  
    1919#include "widgetactions.h"
    2020#include "colorutils.h"
     21#include "helper.h"
    2122#include <QLabel>
    2223#include <QDebug>
     
    4748        QList<QWidget *> l = createdWidgets();
    4849        for (int n=0; n < l.count(); n++) {
    49                 TimeSlider *s = (TimeSlider*) l[n];
    50                 s->setEnabled(b);;
     50                l[n]->setEnabled(b);
    5151        }
    5252        setEnabled(b);
     
    204204
    205205
    206 TimeLabelAction::TimeLabelAction( QWidget * parent )
     206TimeLabelAction::TimeLabelAction(TimeLabelType type, QWidget * parent )
    207207        : MyWidgetAction(parent)
    208208{
     209        label_type = type;
     210        current_time = 0;
     211        total_time = 0;
     212        updateText();
    209213}
    210214
     
    212216}
    213217
     218void TimeLabelAction::setCurrentTime(double t) {
     219        current_time = t;
     220        updateText();
     221}
     222
     223void TimeLabelAction::setTotalTime(double t) {
     224        total_time = t;
     225        updateText();
     226}
     227
     228void TimeLabelAction::updateText() {
     229        QString ct = Helper::formatTime(current_time);
     230        QString tt = Helper::formatTime(total_time);
     231        QString rt;
     232        if (total_time < 1) rt = "00:00:00"; else rt = "-" + Helper::formatTime(total_time - current_time);
     233
     234        switch (label_type) {
     235                case CurrentTime: setText(ct); break;
     236                case TotalTime: setText(tt); break;
     237                case CurrentAndTotalTime: setText(ct + " / " + tt); break;
     238                case RemainingTime: setText(rt); break;
     239        }
     240}
     241
    214242void TimeLabelAction::setText(QString s) {
    215         _text = s;
     243        current_text = s;
    216244        emit newText(s);
    217245}
     
    220248        QLabel * time_label = new QLabel(parent);
    221249        time_label->setObjectName("time_label");
    222     time_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
    223     time_label->setAutoFillBackground(true);
    224 
    225     ColorUtils::setBackgroundColor( time_label, QColor(0,0,0) );
    226     ColorUtils::setForegroundColor( time_label, QColor(255,255,255) );
    227     time_label->setText( "00:00:00 / 00:00:00" );
    228     time_label->setFrameShape( QFrame::Panel );
    229     time_label->setFrameShadow( QFrame::Sunken );
     250        time_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
     251        //time_label->setAutoFillBackground(true);
     252
     253        //ColorUtils::setBackgroundColor( time_label, QColor(0,0,0) );
     254        //ColorUtils::setForegroundColor( time_label, QColor(255,255,255) );
     255
     256        if (current_text.isEmpty()) current_text = "00:00:00 / 00:00:00";
     257        time_label->setText(current_text);
     258
     259        //time_label->setFrameShape( QFrame::Panel );
     260        //time_label->setFrameShadow( QFrame::Sunken );
    230261
    231262        connect( this, SIGNAL(newText(QString)),
Note: See TracChangeset for help on using the changeset viewer.