Changeset 176 for smplayer/trunk/src/helper.cpp
- Timestamp:
- May 3, 2016, 5:25:45 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/helper.cpp
r165 r176 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 25 25 #include <QTextCodec> 26 26 #include <QWidget> 27 //#include <QDebug>27 #include <QDebug> 28 28 #include "config.h" 29 29 #include "extensions.h" … … 61 61 62 62 QString Helper::formatTime(int secs) { 63 bool negative = (secs < 0); 64 secs = abs(secs); 65 63 66 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')); 72 76 } 73 77 … … 243 247 while ( !matching_files.isEmpty() ) { 244 248 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; 246 254 current_number++; 247 255 next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0')); … … 269 277 QStringList r; 270 278 for (int n = 0; n < all_files.count(); n++) { 271 if (all_files[n] != current_file) {279 //if (all_files[n] != current_file) { 272 280 QString s = path +"/" + all_files[n]; 281 #ifdef Q_OS_WIN 282 s = QDir::toNativeSeparators(s); 283 #endif 273 284 r << s; 274 }285 //} 275 286 } 276 287 … … 313 324 } 314 325 #endif 326 327 #ifndef Q_OS_WIN 328 QString 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.