~ubuntu-branches/ubuntu/wily/smplayer/wily

« back to all changes in this revision

Viewing changes to src/smplayer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
3
3
 
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
19
19
#include "smplayer.h"
20
20
#include "defaultgui.h"
21
21
#include "minigui.h"
 
22
#include "mpcgui.h"
22
23
#include "global.h"
23
 
#include "helper.h"
 
24
#include "paths.h"
24
25
#include "translator.h"
25
26
#include "version.h"
26
27
#include "constants.h"
33
34
#include <stdio.h>
34
35
 
35
36
#ifdef Q_OS_WIN
 
37
#if USE_ASSOCIATIONS
36
38
#include "extensions.h"
37
39
#include "winfileassoc.h"       //required for Uninstall
38
40
#endif
 
41
#endif
39
42
 
40
43
 
41
44
using namespace Global;
42
45
 
43
 
SMPlayer::SMPlayer(const QString & ini_path, QObject * parent )
 
46
SMPlayer::SMPlayer(const QString & config_path, QObject * parent )
44
47
        : QObject(parent) 
45
48
{
46
49
        main_window = 0;
47
50
        gui_to_use = "DefaultGui";
48
51
 
49
 
    Helper::setAppPath( qApp->applicationDirPath() );
 
52
    Paths::setAppPath( qApp->applicationDirPath() );
50
53
 
51
 
        if (ini_path.isEmpty()) createHomeDirectory();
52
 
        global_init(ini_path);
 
54
#ifndef PORTABLE_APP
 
55
        if (config_path.isEmpty()) createConfigDirectory();
 
56
#endif
 
57
        global_init(config_path);
53
58
 
54
59
        // Application translations
55
60
        translator->load( pref->language );
63
68
 
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());
 
75
                
66
76
                if (gui_to_use.toLower() == "minigui") 
67
77
                        main_window = new MiniGui(0);
 
78
                else 
 
79
                if (gui_to_use.toLower() == "mpcgui")
 
80
                        main_window = new MpcGui(0);
68
81
                else
69
82
                        main_window = new DefaultGui(0);
70
 
 
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());
75
83
        }
76
84
        return main_window;
77
85
}
95
103
 
96
104
#ifdef Q_OS_WIN
97
105
        if (args.contains("-uninstall")){
 
106
#if USE_ASSOCIATIONS
98
107
                //Called by uninstaller. Will restore old associations.
99
108
                WinFileAssoc RegAssoc; 
100
109
                Extensions exts; 
102
111
                RegAssoc.GetRegisteredExtensions(exts.multimedia(), regExts); 
103
112
                RegAssoc.RestoreFileAssociations(regExts); 
104
113
                printf("Restored associations\n");
 
114
#endif
105
115
                return NoError; 
106
116
        }
107
117
#endif
129
139
                        }
130
140
                }
131
141
                else
 
142
                if (argument == "-sub") {
 
143
                        if (n+1 < args.count()) {
 
144
                                n++;
 
145
                                QString file = args[n];
 
146
                                if (QFile::exists(file)) {
 
147
                                        subtitle_file = QFileInfo(file).absoluteFilePath();
 
148
                                } else {
 
149
                                        printf("Error: file '%s' doesn't exists\r\n", file.toUtf8().constData());
 
150
                                }
 
151
                        } else {
 
152
                                printf("Error: expected parameter for -sub\r\n");
 
153
                                return ErrorArgument;
 
154
                        }
 
155
                }
 
156
                else
132
157
                if (argument == "-playlist") {
133
158
                        is_playlist = true;
134
159
                }
163
188
                        gui_to_use = "MiniGui";
164
189
                }
165
190
                else
 
191
                if (argument == "-mpcgui") {
 
192
                        gui_to_use = "MpcGui";
 
193
                }
 
194
                else
166
195
                if (argument == "-defaultgui") {
167
196
                        gui_to_use = "DefaultGui";
168
197
                }
192
221
 
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;
 
226
 
 
227
                MyClient *c = new MyClient(port);
196
228
                //c->setTimeOut(1000);
 
229
                qDebug("SMPlayer::processArgs: trying to connect to port %d", port);
 
230
 
197
231
                if (c->openConnection()) {
198
232
                        qDebug("SMPlayer::processArgs: found another instance");
199
233
 
244
278
 
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);
 
284
        }
248
285
 
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);
 
289
                } else {
 
290
                        gui()->runActionsLater(actions_list);
 
291
                }
 
292
        }
250
293
}
251
294
 
252
 
void SMPlayer::createHomeDirectory() {
253
 
        // Create smplayer home directories
254
 
        if (!QFile::exists(Helper::appHomePath())) {
 
295
#ifndef PORTABLE_APP
 
296
void SMPlayer::createConfigDirectory() {
 
297
        // Create smplayer config directory
 
298
        if (!QFile::exists(Paths::configPath())) {
255
299
                QDir d;
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());
258
302
                }
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());
262
306
                }
263
307
        }
264
308
}
 
309
#endif
265
310
 
266
311
void SMPlayer::showInfo() {
267
312
        QString s = QObject::tr("This is SMPlayer v. %1 running on %2")
279
324
 
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());
283
328
 
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());
293
339
}