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

Last change on this file since 176 was 176, checked in by Silvan Scherrer, 9 years ago

smplayer: update trunk to version 16.4

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