Ignore:
Timestamp:
May 3, 2016, 5:25:45 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.4

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/helper.cpp

    r165 r176  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    2525#include <QTextCodec>
    2626#include <QWidget>
    27 //#include <QDebug>
     27#include <QDebug>
    2828#include "config.h"
    2929#include "extensions.h"
     
    6161
    6262QString Helper::formatTime(int secs) {
     63        bool negative = (secs < 0);
     64        secs = abs(secs);
     65
    6366        int t = secs;
    64     int hours = (int) t / 3600;
    65     t -= hours*3600;
    66     int minutes = (int) t / 60;
    67     t -= minutes*60;
    68     int seconds = t;
    69 
    70     QString tf;
    71     return tf.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
     67        int hours = (int) t / 3600;
     68        t -= hours*3600;
     69        int minutes = (int) t / 60;
     70        t -= minutes*60;
     71        int seconds = t;
     72
     73        //qDebug() << "Helper::formatTime:" << hours << ":" << minutes << ":" << seconds;
     74
     75        return QString("%1%2:%3:%4").arg(negative ? "-" : "").arg(hours, 2, 10, QChar('0')).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'));
    7276}
    7377
     
    243247                while ( !matching_files.isEmpty() ) {
    244248                        qDebug("Helper::searchForConsecutiveFiles: '%s' exists, added to the list", matching_files[0].toUtf8().constData());
    245                         files_to_add << path  + "/" + matching_files[0];
     249                        QString filename = path  + "/" + matching_files[0];
     250                        #ifdef Q_OS_WIN
     251                        filename = QDir::toNativeSeparators(filename);
     252                        #endif
     253                        files_to_add << filename;
    246254                        current_number++;
    247255                        next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0'));
     
    269277        QStringList r;
    270278        for (int n = 0; n < all_files.count(); n++) {
    271                 if (all_files[n] != current_file) {
     279                //if (all_files[n] != current_file) {
    272280                        QString s = path +"/" + all_files[n];
     281                        #ifdef Q_OS_WIN
     282                        s = QDir::toNativeSeparators(s);
     283                        #endif
    273284                        r << s;
    274                 }
     285                //}
    275286        }
    276287
     
    313324}
    314325#endif
     326
     327#ifndef Q_OS_WIN
     328QString Helper::findExecutable(const QString & name) {
     329        QByteArray env = qgetenv("PATH");
     330#ifdef Q_OS_OS2
     331        QString newName = name;
     332        if (!newName.endsWith(".exe", Qt::CaseInsensitive))
     333                newName.append(".exe");
     334#endif
     335        QStringList search_paths = QString::fromLocal8Bit(env.constData()).split(':', QString::SkipEmptyParts);
     336        for (int n = 0; n < search_paths.count(); n++) {
     337#ifdef Q_OS_OS2
     338                QString candidate = search_paths[n] + "/" + newName;
     339#else
     340                QString candidate = search_paths[n] + "/" + name;
     341#endif
     342                qDebug("Helper::findExecutable: candidate: %s", candidate.toUtf8().constData());
     343                QFileInfo info(candidate);
     344                if (info.isFile() && info.isExecutable()) {
     345                        qDebug("Helper::findExecutable: executable found: %s", candidate.toUtf8().constData());
     346                        return candidate;
     347                }
     348        }
     349        return QString::null;
     350}
     351#endif
Note: See TracChangeset for help on using the changeset viewer.