source: smplayer/trunk/src/main.cpp@ 162

Last change on this file since 162 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

  • Property svn:eol-style set to LF
File size: 2.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
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 "myapplication.h"
20#include "smplayer.h"
21
22int main( int argc, char ** argv )
23{
24 MyApplication a( "smplayer", argc, argv );
25 /*
26 if (a.isRunning()) {
27 qDebug("Another instance is running. Exiting.");
28 return 0;
29 }
30 */
31
32 a.setQuitOnLastWindowClosed(false);
33
34#if QT_VERSION >= 0x040400
35 // Enable icons in menus
36 QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
37#endif
38
39 // Sets the config path
40 QString config_path;
41
42#ifdef PORTABLE_APP
43 config_path = a.applicationDirPath();
44#else
45 // If a smplayer.ini exists in the app path, will use that path
46 // for the config file by default
47 if (QFile::exists( a.applicationDirPath() + "/smplayer.ini" ) ) {
48 config_path = a.applicationDirPath();
49 qDebug("main: using existing %s", QString(config_path + "/smplayer.ini").toUtf8().data());
50 }
51#endif
52
53 QStringList args = a.arguments();
54 int pos = args.indexOf("-config-path");
55 if ( pos != -1) {
56 if (pos+1 < args.count()) {
57 pos++;
58 config_path = args[pos];
59 // Delete from list
60 args.removeAt(pos);
61 args.removeAt(pos-1);
62 } else {
63 printf("Error: expected parameter for -config-path\r\n");
64 return SMPlayer::ErrorArgument;
65 }
66 }
67
68 SMPlayer * smplayer = new SMPlayer(config_path);
69 SMPlayer::ExitCode c = smplayer->processArgs( args );
70 if (c != SMPlayer::NoExit) {
71 return c;
72 }
73 smplayer->start();
74
75 int r = a.exec();
76
77 delete smplayer;
78
79 return r;
80}
81
Note: See TracBrowser for help on using the repository browser.