1
1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
2
Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
4
4
This program is free software; you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License as published by
36
38
#include "extensions.h"
37
39
#include "winfileassoc.h" //required for Uninstall
41
44
using namespace Global;
43
SMPlayer::SMPlayer(const QString & ini_path, QObject * parent )
46
SMPlayer::SMPlayer(const QString & config_path, QObject * parent )
47
50
gui_to_use = "DefaultGui";
49
Helper::setAppPath( qApp->applicationDirPath() );
52
Paths::setAppPath( qApp->applicationDirPath() );
51
if (ini_path.isEmpty()) createHomeDirectory();
52
global_init(ini_path);
55
if (config_path.isEmpty()) createConfigDirectory();
57
global_init(config_path);
54
59
// Application translations
55
60
translator->load( pref->language );
64
69
BaseGui * SMPlayer::gui() {
65
70
if (main_window == 0) {
71
// Changes to app path, so smplayer can find a relative mplayer path
72
QDir::setCurrent(Paths::appPath());
73
qDebug("SMPlayer::gui: changed working directory to app path");
74
qDebug("SMPlayer::gui: current directory: %s", QDir::currentPath().toUtf8().data());
66
76
if (gui_to_use.toLower() == "minigui")
67
77
main_window = new MiniGui(0);
79
if (gui_to_use.toLower() == "mpcgui")
80
main_window = new MpcGui(0);
69
82
main_window = new DefaultGui(0);
71
// Changes to app path, so smplayer can find a relative mplayer path
72
QDir::setCurrent(Helper::appPath());
73
qDebug("SMPlayer::gui: changed working directory to app path");
74
qDebug("SMPlayer::gui: current directory: %s", QDir::currentPath().toUtf8().data());
76
84
return main_window;
142
if (argument == "-sub") {
143
if (n+1 < args.count()) {
145
QString file = args[n];
146
if (QFile::exists(file)) {
147
subtitle_file = QFileInfo(file).absoluteFilePath();
149
printf("Error: file '%s' doesn't exists\r\n", file.toUtf8().constData());
152
printf("Error: expected parameter for -sub\r\n");
153
return ErrorArgument;
132
157
if (argument == "-playlist") {
133
158
is_playlist = true;
193
222
if (pref->use_single_instance) {
194
223
// Single instance
195
MyClient *c = new MyClient(pref->connection_port);
224
int port = pref->connection_port;
225
if (pref->use_autoport) port = pref->autoport;
227
MyClient *c = new MyClient(port);
196
228
//c->setTimeOut(1000);
229
qDebug("SMPlayer::processArgs: trying to connect to port %d", port);
197
231
if (c->openConnection()) {
198
232
qDebug("SMPlayer::processArgs: found another instance");
245
279
void SMPlayer::start() {
246
280
if (!gui()->startHidden() || !files_to_play.isEmpty() ) gui()->show();
247
if (!files_to_play.isEmpty()) gui()->openFiles(files_to_play);
281
if (!files_to_play.isEmpty()) {
282
if (!subtitle_file.isEmpty()) gui()->setInitialSubtitle(subtitle_file);
283
gui()->openFiles(files_to_play);
249
if (!actions_list.isEmpty()) gui()->runActions(actions_list);
286
if (!actions_list.isEmpty()) {
287
if (files_to_play.isEmpty()) {
288
gui()->runActions(actions_list);
290
gui()->runActionsLater(actions_list);
252
void SMPlayer::createHomeDirectory() {
253
// Create smplayer home directories
254
if (!QFile::exists(Helper::appHomePath())) {
296
void SMPlayer::createConfigDirectory() {
297
// Create smplayer config directory
298
if (!QFile::exists(Paths::configPath())) {
256
if (!d.mkdir(Helper::appHomePath())) {
257
qWarning("SMPlayer::createHomeDirectory: can't create %s", Helper::appHomePath().toUtf8().data());
300
if (!d.mkdir(Paths::configPath())) {
301
qWarning("SMPlayer::createConfigDirectory: can't create %s", Paths::configPath().toUtf8().data());
259
QString s = Helper::appHomePath() + "/screenshots";
303
QString s = Paths::configPath() + "/screenshots";
260
304
if (!d.mkdir(s)) {
261
305
qWarning("SMPlayer::createHomeDirectory: can't create %s", s.toUtf8().data());
266
311
void SMPlayer::showInfo() {
267
312
QString s = QObject::tr("This is SMPlayer v. %1 running on %2")
280
325
printf("%s\n", s.toLocal8Bit().data() );
281
326
qDebug("%s", s.toUtf8().data() );
282
qDebug("Qt v. " QT_VERSION_STR);
327
qDebug("Compiled with Qt v. %s, using %s", QT_VERSION_STR, qVersion());
284
qDebug(" * application path: '%s'", Helper::appPath().toUtf8().data());
285
qDebug(" * data path: '%s'", Helper::dataPath().toUtf8().data());
286
qDebug(" * translation path: '%s'", Helper::translationPath().toUtf8().data());
287
qDebug(" * doc path: '%s'", Helper::docPath().toUtf8().data());
288
qDebug(" * themes path: '%s'", Helper::themesPath().toUtf8().data());
289
qDebug(" * shortcuts path: '%s'", Helper::shortcutsPath().toUtf8().data());
290
qDebug(" * smplayer home path: '%s'", Helper::appHomePath().toUtf8().data());
291
qDebug(" * ini path: '%s'", Helper::iniPath().toUtf8().data());
329
qDebug(" * application path: '%s'", Paths::appPath().toUtf8().data());
330
qDebug(" * data path: '%s'", Paths::dataPath().toUtf8().data());
331
qDebug(" * translation path: '%s'", Paths::translationPath().toUtf8().data());
332
qDebug(" * doc path: '%s'", Paths::docPath().toUtf8().data());
333
qDebug(" * themes path: '%s'", Paths::themesPath().toUtf8().data());
334
qDebug(" * shortcuts path: '%s'", Paths::shortcutsPath().toUtf8().data());
335
qDebug(" * config path: '%s'", Paths::configPath().toUtf8().data());
336
qDebug(" * ini path: '%s'", Paths::iniPath().toUtf8().data());
337
qDebug(" * file for subtitles' styles: '%s'", Paths::subtitleStyleFile().toUtf8().data());
292
338
qDebug(" * current path: '%s'", QDir::currentPath().toUtf8().data());