source: smplayer/trunk/src/smplayer.cpp

Last change on this file was 188, checked in by Silvan Scherrer, 8 years ago

SMPlayer: update trunk to version 17.1.0

  • Property svn:eol-style set to LF
File size: 18.8 KB
RevLine 
[112]1/* smplayer, GUI front-end for mplayer.
[188]2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
[112]3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "smplayer.h"
20#include "global.h"
21#include "paths.h"
22#include "translator.h"
23#include "version.h"
[124]24#include "config.h"
[112]25#include "clhelp.h"
[156]26#include "cleanconfig.h"
[128]27#include "myapplication.h"
[176]28#include "baseguiplus.h"
[112]29
[176]30#ifdef DEFAULTGUI
31#include "defaultgui.h"
32#endif
33
34#ifdef MINIGUI
35#include "minigui.h"
36#endif
37
[165]38#ifdef MPCGUI
39#include "mpcgui.h"
40#endif
41
[139]42#ifdef SKINS
43#include "skingui.h"
44#endif
45
[112]46#include <QDir>
[124]47#include <QUrl>
[128]48#include <QTime>
[112]49#include <stdio.h>
50
51#ifdef Q_OS_WIN
52#if USE_ASSOCIATIONS
53#include "extensions.h"
54#include "winfileassoc.h" //required for Uninstall
55#endif
56#endif
57
[139]58#ifdef FONTCACHE_DIALOG
59#include "fontcache.h"
60#include "version.h"
61#endif
62
[112]63using namespace Global;
64
[128]65BaseGui * SMPlayer::main_window = 0;
66
[112]67SMPlayer::SMPlayer(const QString & config_path, QObject * parent )
68 : QObject(parent)
69{
[128]70#ifdef LOG_SMPLAYER
[165]71 #if QT_VERSION >= 0x050000
72 qInstallMessageHandler( SMPlayer::myMessageOutput );
73 #else
[128]74 qInstallMsgHandler( SMPlayer::myMessageOutput );
[165]75 #endif
[128]76 allow_to_send_log_to_gui = true;
77#endif
78
[142]79 gui_to_use = "DefaultGUI";
[112]80
81 close_at_end = -1; // Not set
82 start_in_fullscreen = -1; // Not set
83
84 move_gui = false;
85 resize_gui = false;
86
[128]87 Paths::setAppPath( qApp->applicationDirPath() );
[112]88
89#ifndef PORTABLE_APP
90 if (config_path.isEmpty()) createConfigDirectory();
91#endif
92 global_init(config_path);
93
94 // Application translations
95 translator->load( pref->language );
96 showInfo();
[165]97
[176]98#ifdef FONTS_HACK
[165]99 createFontFile();
100#endif
[112]101}
102
103SMPlayer::~SMPlayer() {
[128]104 if (main_window != 0) {
105 deleteGUI();
106 }
[112]107 global_end();
[128]108
109#ifdef LOG_SMPLAYER
110 if (output_log.isOpen()) output_log.close();
111#endif
[112]112}
113
114BaseGui * SMPlayer::gui() {
115 if (main_window == 0) {
116 // Changes to app path, so smplayer can find a relative mplayer path
117 QDir::setCurrent(Paths::appPath());
118 qDebug("SMPlayer::gui: changed working directory to app path");
119 qDebug("SMPlayer::gui: current directory: %s", QDir::currentPath().toUtf8().data());
120
[142]121#ifdef SKINS
122 if (gui_to_use == "SkinGUI") {
123 QString theme = pref->iconset;
124 if (theme.isEmpty()) theme = "Gonzo";
[156]125 QString user_theme_dir = Paths::configPath() + "/themes/" + theme;
[142]126 QString theme_dir = Paths::themesPath() + "/" + theme;
[156]127 qDebug("SMPlayer::gui: user_theme_dir: %s", user_theme_dir.toUtf8().constData());
[142]128 qDebug("SMPlayer::gui: theme_dir: %s", theme_dir.toUtf8().constData());
[156]129 if ((QDir(theme_dir).exists()) || (QDir(user_theme_dir).exists())) {
[142]130 if (pref->iconset.isEmpty()) pref->iconset = theme;
131 } else {
132 qDebug("SMPlayer::gui: skin folder doesn't exist. Falling back to default gui.");
133 gui_to_use = "DefaultGUI";
134 pref->iconset = "";
135 pref->gui = gui_to_use;
136 }
137 }
138#endif
139
[128]140 main_window = createGUI(gui_to_use);
141
[112]142 if (move_gui) {
143 qDebug("SMPlayer::gui: moving main window to %d %d", gui_position.x(), gui_position.y());
144 main_window->move(gui_position);
145 }
146 if (resize_gui) {
147 qDebug("SMPlayer::gui: resizing main window to %dx%d", gui_size.width(), gui_size.height());
148 main_window->resize(gui_size);
149 }
150 }
151
152 return main_window;
153}
154
[128]155BaseGui * SMPlayer::createGUI(QString gui_name) {
156 BaseGui * gui = 0;
157
[139]158#ifdef SKINS
159 if (gui_name.toLower() == "skingui")
160 gui = new SkinGui(0);
161 else
162#endif
[176]163#ifdef MINIGUI
[128]164 if (gui_name.toLower() == "minigui")
165 gui = new MiniGui(0);
[165]166 else
[176]167#endif
[165]168#ifdef MPCGUI
[128]169 if (gui_name.toLower() == "mpcgui")
170 gui = new MpcGui(0);
171 else
[165]172#endif
[176]173#ifdef DEFAULTGUI
174 if (gui_name.toLower() == "defaultgui")
[128]175 gui = new DefaultGui(0);
[176]176 else
177#endif
178 {
179 // No GUI
180 qWarning() << "SMPlayer::createGUI: there's no GUI available!";
181 gui = new BaseGuiPlus(0);
182 }
[128]183
184 gui->setForceCloseOnFinish(close_at_end);
185 gui->setForceStartInFullscreen(start_in_fullscreen);
186 connect(gui, SIGNAL(quitSolicited()), qApp, SLOT(quit()));
187
188#ifdef GUI_CHANGE_ON_RUNTIME
189 connect(gui, SIGNAL(guiChanged(QString)), this, SLOT(changeGUI(QString)));
190#endif
191
192#if SINGLE_INSTANCE
193 MyApplication * app = MyApplication::instance();
194 connect(app, SIGNAL(messageReceived(const QString&)),
195 gui, SLOT(handleMessageFromOtherInstances(const QString&)));
196 app->setActivationWindow(gui);
197#endif
198
199 return gui;
200}
201
202void SMPlayer::deleteGUI() {
203#ifdef LOG_SMPLAYER
204 allow_to_send_log_to_gui = false;
205#endif
206
207 delete main_window;
208 main_window = 0;
209
210#ifdef LOG_SMPLAYER
211 allow_to_send_log_to_gui = true;
212#endif
213}
214
215#ifdef GUI_CHANGE_ON_RUNTIME
216void SMPlayer::changeGUI(QString new_gui) {
217 qDebug("SMPlayer::changeGUI: '%s'", new_gui.toLatin1().constData());
218
219 deleteGUI();
220
221 main_window = createGUI(new_gui);
222
223 main_window->show();
224}
225#endif
226
[112]227SMPlayer::ExitCode SMPlayer::processArgs(QStringList args) {
228 qDebug("SMPlayer::processArgs: arguments: %d", args.count());
229 for (int n = 0; n < args.count(); n++) {
230 qDebug("SMPlayer::processArgs: %d = %s", n, args[n].toUtf8().data());
231 }
232
233
[176]234 QString action; // Action to be passed to running instance
[112]235 bool show_help = false;
236
237 if (!pref->gui.isEmpty()) gui_to_use = pref->gui;
238 bool add_to_playlist = false;
239
240#ifdef Q_OS_WIN
[156]241 if (args.contains("-uninstall")) {
242 #if USE_ASSOCIATIONS
[112]243 //Called by uninstaller. Will restore old associations.
244 WinFileAssoc RegAssoc;
245 Extensions exts;
246 QStringList regExts;
247 RegAssoc.GetRegisteredExtensions(exts.multimedia(), regExts);
248 RegAssoc.RestoreFileAssociations(regExts);
249 printf("Restored associations\n");
[156]250 #endif
251 return NoError;
[112]252 }
253#endif
254
[156]255 if (args.contains("-delete-config")) {
256 CleanConfig::clean(Paths::configPath());
257 return NoError;
258 }
259
[112]260 for (int n = 1; n < args.count(); n++) {
261 QString argument = args[n];
262
263 if (argument == "-send-action") {
264 if (n+1 < args.count()) {
265 n++;
266 action = args[n];
267 } else {
268 printf("Error: expected parameter for -send-action\r\n");
269 return ErrorArgument;
270 }
271 }
272 else
273 if (argument == "-actions") {
274 if (n+1 < args.count()) {
275 n++;
276 actions_list = args[n];
277 } else {
278 printf("Error: expected parameter for -actions\r\n");
279 return ErrorArgument;
280 }
281 }
282 else
283 if (argument == "-sub") {
284 if (n+1 < args.count()) {
285 n++;
286 QString file = args[n];
287 if (QFile::exists(file)) {
288 subtitle_file = QFileInfo(file).absoluteFilePath();
289 } else {
290 printf("Error: file '%s' doesn't exists\r\n", file.toUtf8().constData());
291 }
292 } else {
293 printf("Error: expected parameter for -sub\r\n");
294 return ErrorArgument;
295 }
296 }
297 else
[176]298 if (argument == "-media-title") {
299 if (n+1 < args.count()) {
300 n++;
301 if (media_title.isEmpty()) media_title = args[n];
302 }
303 }
304 else
[112]305 if (argument == "-pos") {
306 if (n+2 < args.count()) {
307 bool ok_x, ok_y;
308 n++;
309 gui_position.setX( args[n].toInt(&ok_x) );
310 n++;
311 gui_position.setY( args[n].toInt(&ok_y) );
312 if (ok_x && ok_y) move_gui = true;
313 } else {
314 printf("Error: expected parameter for -pos\r\n");
315 return ErrorArgument;
316 }
317 }
318 else
319 if (argument == "-size") {
320 if (n+2 < args.count()) {
321 bool ok_width, ok_height;
322 n++;
323 gui_size.setWidth( args[n].toInt(&ok_width) );
324 n++;
325 gui_size.setHeight( args[n].toInt(&ok_height) );
326 if (ok_width && ok_height) resize_gui = true;
327 } else {
328 printf("Error: expected parameter for -resize\r\n");
329 return ErrorArgument;
330 }
331 }
332 else
333 if ((argument == "--help") || (argument == "-help") ||
334 (argument == "-h") || (argument == "-?") )
335 {
336 show_help = true;
337 }
338 else
339 if (argument == "-close-at-end") {
340 close_at_end = 1;
341 }
342 else
343 if (argument == "-no-close-at-end") {
344 close_at_end = 0;
345 }
346 else
347 if (argument == "-fullscreen") {
348 start_in_fullscreen = 1;
349 }
350 else
351 if (argument == "-no-fullscreen") {
352 start_in_fullscreen = 0;
353 }
354 else
355 if (argument == "-add-to-playlist") {
356 add_to_playlist = true;
357 }
358 else
359 if (argument == "-mini" || argument == "-minigui") {
[142]360 gui_to_use = "MiniGUI";
[112]361 }
362 else
363 if (argument == "-mpcgui") {
[142]364 gui_to_use = "MpcGUI";
[112]365 }
366 else
367 if (argument == "-defaultgui") {
[142]368 gui_to_use = "DefaultGUI";
[112]369 }
[176]370 else
371 if (argument == "-ontop") {
372 pref->stay_on_top = Preferences::AlwaysOnTop;
373 }
374 else
375 if (argument == "-no-ontop") {
376 pref->stay_on_top = Preferences::NeverOnTop;
377 }
[142]378#ifdef SKINS
379 else
380 if (argument == "-skingui") {
381 gui_to_use = "SkinGUI";
382 }
383#endif
[112]384 else {
385 // File
[124]386 #if QT_VERSION >= 0x040600
387 QUrl fUrl = QUrl::fromUserInput(argument);
388 if (fUrl.isValid() && fUrl.scheme().toLower() == "file") {
[188]389 argument = fUrl.toLocalFile();
[124]390 }
391 #endif
[112]392 if (QFile::exists( argument )) {
393 argument = QFileInfo(argument).absoluteFilePath();
394 }
395 files_to_play.append( argument );
396 }
397 }
398
399 if (show_help) {
400 printf("%s\n", CLHelp::help().toLocal8Bit().data());
401 return NoError;
402 }
403
404 qDebug("SMPlayer::processArgs: files_to_play: count: %d", files_to_play.count() );
405 for (int n=0; n < files_to_play.count(); n++) {
406 qDebug("SMPlayer::processArgs: files_to_play[%d]: '%s'", n, files_to_play[n].toUtf8().data());
407 }
408
[128]409#ifdef SINGLE_INSTANCE
[112]410 if (pref->use_single_instance) {
411 // Single instance
[128]412 MyApplication * a = MyApplication::instance();
413 if (a->isRunning()) {
414 a->sendMessage("Hello");
[112]415
416 if (!action.isEmpty()) {
[128]417 a->sendMessage("action " + action);
[112]418 }
419 else {
420 if (!subtitle_file.isEmpty()) {
[128]421 a->sendMessage("load_sub " + subtitle_file);
[112]422 }
423
[176]424 if (!media_title.isEmpty()) {
425 a->sendMessage("media_title " + files_to_play[0] + " <<sep>> " + media_title);
426 }
427
[112]428 if (!files_to_play.isEmpty()) {
[128]429 /* a->sendMessage("open_file " + files_to_play[0]); */
430 QString command = "open_files";
431 if (add_to_playlist) command = "add_to_playlist";
432 a->sendMessage(command +" "+ files_to_play.join(" <<sep>> "));
[112]433 }
434 }
[128]435
[112]436 return NoError;
437 }
438 }
[128]439#endif
[112]440
[188]441 /*
[112]442 if (!pref->default_font.isEmpty()) {
443 QFont f;
444 f.fromString(pref->default_font);
445 qApp->setFont(f);
446 }
[188]447 */
[112]448
449 return SMPlayer::NoExit;
450}
451
452void SMPlayer::start() {
[139]453#ifdef FONTCACHE_DIALOG
454#ifndef PORTABLE_APP
[156]455 if (Version::with_revision() != pref->smplayer_version) {
[139]456 FontCacheDialog d(0);
457 d.run(pref->mplayer_bin, "sample.avi");
[156]458 pref->smplayer_version = Version::with_revision();
[139]459 }
460#endif
461#endif
462
[112]463 if (!gui()->startHidden() || !files_to_play.isEmpty() ) gui()->show();
464 if (!files_to_play.isEmpty()) {
465 if (!subtitle_file.isEmpty()) gui()->setInitialSubtitle(subtitle_file);
[176]466 if (!media_title.isEmpty()) gui()->getCore()->addForcedTitle(files_to_play[0], media_title);
[112]467 gui()->openFiles(files_to_play);
468 }
469
470 if (!actions_list.isEmpty()) {
471 if (files_to_play.isEmpty()) {
472 gui()->runActions(actions_list);
473 } else {
474 gui()->runActionsLater(actions_list);
475 }
476 }
477}
478
479#ifndef PORTABLE_APP
480void SMPlayer::createConfigDirectory() {
481 // Create smplayer config directory
482 if (!QFile::exists(Paths::configPath())) {
483 QDir d;
484 if (!d.mkdir(Paths::configPath())) {
485 qWarning("SMPlayer::createConfigDirectory: can't create %s", Paths::configPath().toUtf8().data());
486 }
[124]487 // Screenshot folder already created in preferences.cpp if Qt >= 4.4
488 #if QT_VERSION < 0x040400
[112]489 QString s = Paths::configPath() + "/screenshots";
490 if (!d.mkdir(s)) {
491 qWarning("SMPlayer::createHomeDirectory: can't create %s", s.toUtf8().data());
492 }
[124]493 #endif
[112]494 }
495}
496#endif
497
[176]498#ifdef FONTS_HACK
[165]499void SMPlayer::createFontFile() {
500 qDebug("SMPlayer::createFontFile");
501 QString output = Paths::configPath() + "/fonts.conf";
502
503 // Check if the file already exists with the modified path
504 if (QFile::exists(output)) {
505 QFile i(output);
506 if (i.open(QIODevice::ReadOnly | QIODevice::Text)) {
507 QString text = i.readAll();
508 if (text.contains("<dir>" + Paths::fontPath() + "</dir>")) {
509 qDebug("SMPlayer::createFontFile: file %s already exists with font path. Doing nothing.", output.toUtf8().constData());
510 return;
511 }
512 }
513 }
514
515 QString input = Paths::appPath() + "/mplayer/fonts/fonts.conf";
[176]516 if (!QFile::exists(input)) {
517 qDebug("SMPlayer::createFontFile: %s doesn't exist", input.toUtf8().constData());
518 input = Paths::appPath() + "/mplayer/mpv/fonts.conf";
519 if (!QFile::exists(input)) {
520 qDebug("SMPlayer::createFontFile: %s doesn't exist", input.toUtf8().constData());
521 qWarning("SMPlayer::createFontFile: failed to create fonts.conf");
522 return;
523 }
524 }
525 qDebug("SMPlayer::createFontFile: input: %s", input.toUtf8().constData());
[165]526 QFile infile(input);
527 if (infile.open(QIODevice::ReadOnly | QIODevice::Text)) {
528 QString text = infile.readAll();
[176]529 text = text.replace("<!-- <dir>WINDOWSFONTDIR</dir> -->", "<dir>WINDOWSFONTDIR</dir>");
[165]530 text = text.replace("<dir>WINDOWSFONTDIR</dir>", "<dir>" + Paths::fontPath() + "</dir>");
531 //qDebug("SMPlayer::createFontFile: %s", text.toUtf8().constData());
532
533 qDebug("SMPlayer::createFontFile: saving %s", output.toUtf8().constData());
534 QFile outfile(output);
535 if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
536 outfile.write(text.toUtf8());
537 outfile.close();
538 }
539 }
540}
541#endif
542
[112]543void SMPlayer::showInfo() {
544#ifdef Q_OS_WIN
545 QString win_ver;
546 switch (QSysInfo::WindowsVersion) {
547 case QSysInfo::WV_2000: win_ver = "Windows 2000"; break;
548 case QSysInfo::WV_XP: win_ver = "Windows XP"; break;
[139]549 case QSysInfo::WV_2003: win_ver = "Windows XP Professional x64/Server 2003"; break;
550 case QSysInfo::WV_VISTA: win_ver = "Windows Vista/Server 2008"; break;
[112]551 #if QT_VERSION >= 0x040501
[139]552 case QSysInfo::WV_WINDOWS7: win_ver = "Windows 7/Server 2008 R2"; break;
[112]553 #endif
[135]554 #if QT_VERSION >= 0x040803
[139]555 case QSysInfo::WV_WINDOWS8: win_ver = "Windows 8/Server 2012"; break;
[135]556 #endif
[176]557 #if ((QT_VERSION >= 0x040806 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050200))
558 case QSysInfo::WV_WINDOWS8_1: win_ver = "Windows 8.1/Server 2012 R2"; break;
559 #endif
560 #if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
561 case QSysInfo::WV_WINDOWS10: win_ver = "Windows 10"; break;
562 #endif
[139]563 case QSysInfo::WV_NT_based: win_ver = "NT-based Windows"; break;
564 default: win_ver = QString("Unknown/Unsupported Windows OS"); break;
[112]565 }
566#endif
567 QString s = QObject::tr("This is SMPlayer v. %1 running on %2")
[156]568 .arg(Version::printable())
[112]569#ifdef Q_OS_LINUX
570 .arg("Linux")
571#else
572#ifdef Q_OS_WIN
573 .arg("Windows ("+win_ver+")")
574#else
575#ifdef Q_OS_OS2
[182]576 .arg("OS/2 and OS/2-based systems")
[112]577#else
578 .arg("Other OS")
579#endif
580#endif
581#endif
582 ;
583
584 printf("%s\n", s.toLocal8Bit().data() );
585 qDebug("%s", s.toUtf8().data() );
586 qDebug("Compiled with Qt v. %s, using %s", QT_VERSION_STR, qVersion());
587
[181]588 qDebug() << " * application path:" << Paths::appPath();
589 qDebug() << " * data path:" << Paths::dataPath();
590 qDebug() << " * translation path:" << Paths::translationPath();
591 qDebug() << " * doc path:" << Paths::docPath();
592 qDebug() << " * themes path:" << Paths::themesPath();
593 qDebug() << " * shortcuts path:" << Paths::shortcutsPath();
594 qDebug() << " * config path:" << Paths::configPath();
595 qDebug() << " * ini path:" << Paths::iniPath();
596 qDebug() << " * file for subtitles' styles:" << Paths::subtitleStyleFile();
597 qDebug() << " * current path:" << QDir::currentPath();
[176]598#ifdef FONTS_HACK
[181]599 qDebug() << " * font path:" << Paths::fontPath();
[165]600#endif
[112]601}
[128]602
603#ifdef LOG_SMPLAYER
604QFile SMPlayer::output_log;
605bool SMPlayer::allow_to_send_log_to_gui = false;
606
[165]607#if QT_VERSION >= 0x050000
608void SMPlayer::myMessageOutput( QtMsgType type, const QMessageLogContext &, const QString & msg ) {
609#else
[128]610void SMPlayer::myMessageOutput( QtMsgType type, const char *msg ) {
[165]611#endif
[128]612 static QStringList saved_lines;
613 static QString orig_line;
614 static QString line2;
615 static QRegExp rx_log;
616
617 if (pref) {
618 if (!pref->log_smplayer) return;
619 rx_log.setPattern(pref->log_filter);
620 } else {
621 rx_log.setPattern(".*");
622 }
623
624 line2.clear();
625
[165]626#if QT_VERSION >= 0x050000
627 orig_line = msg;
628#else
[176]629 #ifdef Q_OS_WIN
630 orig_line = QString::fromLocal8Bit(msg);
631 #else
[128]632 orig_line = QString::fromUtf8(msg);
[176]633 #endif
[165]634#endif
[128]635
636 switch ( type ) {
637 case QtDebugMsg:
638 if (rx_log.indexIn(orig_line) > -1) {
639 #ifndef NO_DEBUG_ON_CONSOLE
640 fprintf( stderr, "Debug: %s\n", orig_line.toLocal8Bit().data() );
641 #endif
642 line2 = orig_line;
643 }
644 break;
645 case QtWarningMsg:
646 #ifndef NO_DEBUG_ON_CONSOLE
647 fprintf( stderr, "Warning: %s\n", orig_line.toLocal8Bit().data() );
648 #endif
649 line2 = "WARNING: " + orig_line;
650 break;
651 case QtFatalMsg:
652 #ifndef NO_DEBUG_ON_CONSOLE
653 fprintf( stderr, "Fatal: %s\n", orig_line.toLocal8Bit().data() );
654 #endif
655 line2 = "FATAL: " + orig_line;
656 abort(); // deliberately core dump
657 case QtCriticalMsg:
658 #ifndef NO_DEBUG_ON_CONSOLE
659 fprintf( stderr, "Critical: %s\n", orig_line.toLocal8Bit().data() );
660 #endif
661 line2 = "CRITICAL: " + orig_line;
662 break;
[181]663 #if QT_VERSION >= 0x050500
664 case QtInfoMsg:
665 break;
666 #endif
[128]667 }
668
669 if (line2.isEmpty()) return;
670
671 line2 = "["+ QTime::currentTime().toString("hh:mm:ss:zzz") +"] "+ line2;
672
673 if (allow_to_send_log_to_gui && main_window) {
674 if (!saved_lines.isEmpty()) {
675 // Send saved lines first
676 for (int n=0; n < saved_lines.count(); n++) {
677 main_window->recordSmplayerLog(saved_lines[n]);
678 }
679 saved_lines.clear();
680 }
681 main_window->recordSmplayerLog(line2);
682 } else {
683 // GUI is not created yet, save lines for later
684 saved_lines.append(line2);
685 /* printf("SMPlayer::myMessageOutput: no gui\n"); */
686 }
687
688 if (pref) {
689 if (pref->save_smplayer_log) {
690 // Save log to file
691 if (!output_log.isOpen()) {
692 // FIXME: the config path may not be initialized if USE_LOCKS is not defined
693 output_log.setFileName( Paths::configPath() + "/smplayer_log.txt" );
694 output_log.open(QIODevice::WriteOnly);
695 }
696 if (output_log.isOpen()) {
697 QString l = line2 + "\r\n";
698 output_log.write(l.toUtf8().constData());
699 output_log.flush();
700 }
701 }
702 }
703}
704#endif
705
706/*
707void myMessageOutput( QtMsgType type, const char *msg ) {
708 static QString orig_line;
709 orig_line = QString::fromUtf8(msg);
710
711 switch ( type ) {
712 case QtDebugMsg:
713 #ifndef NO_DEBUG_ON_CONSOLE
714 fprintf( stderr, "Debug: %s\n", orig_line.toLocal8Bit().data() );
715 #endif
716 break;
717
718 case QtWarningMsg:
719 #ifndef NO_DEBUG_ON_CONSOLE
720 fprintf( stderr, "Warning: %s\n", orig_line.toLocal8Bit().data() );
721 #endif
722 break;
723
724 case QtCriticalMsg:
725 #ifndef NO_DEBUG_ON_CONSOLE
726 fprintf( stderr, "Critical: %s\n", orig_line.toLocal8Bit().data() );
727 #endif
728 break;
729
730 case QtFatalMsg:
731 #ifndef NO_DEBUG_ON_CONSOLE
732 fprintf( stderr, "Fatal: %s\n", orig_line.toLocal8Bit().data() );
733 #endif
734 abort(); // deliberately core dump
735 }
736}
737*/
738
739#include "moc_smplayer.cpp"
Note: See TracBrowser for help on using the repository browser.