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

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