[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 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 |
|
---|
[128] | 19 | #include "myapplication.h"
|
---|
[112] | 20 | #include "smplayer.h"
|
---|
| 21 |
|
---|
[176] | 22 | #include <QDir>
|
---|
| 23 |
|
---|
[181] | 24 | #ifdef HDPI_SUPPORT
|
---|
| 25 | #include "paths.h"
|
---|
| 26 | #include "hdpisupport.h"
|
---|
| 27 | #endif
|
---|
| 28 |
|
---|
| 29 | int main( int argc, char ** argv )
|
---|
[112] | 30 | {
|
---|
[181] | 31 | #ifdef HDPI_SUPPORT
|
---|
| 32 | HDPISupport * hdpi = new HDPISupport(Paths::configPath());
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[128] | 35 | MyApplication a( "smplayer", argc, argv );
|
---|
| 36 | /*
|
---|
| 37 | if (a.isRunning()) {
|
---|
| 38 | qDebug("Another instance is running. Exiting.");
|
---|
| 39 | return 0;
|
---|
[112] | 40 | }
|
---|
[128] | 41 | */
|
---|
[112] | 42 |
|
---|
| 43 | a.setQuitOnLastWindowClosed(false);
|
---|
[176] | 44 |
|
---|
| 45 | #ifdef Q_OS_WIN
|
---|
| 46 | // Change the working directory to the application path
|
---|
| 47 | QDir::setCurrent(a.applicationDirPath());
|
---|
| 48 | #endif
|
---|
[112] | 49 |
|
---|
[119] | 50 | #if QT_VERSION >= 0x040400
|
---|
| 51 | // Enable icons in menus
|
---|
| 52 | QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
[112] | 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 |
|
---|
[181] | 95 | #ifdef HDPI_SUPPORT
|
---|
| 96 | delete hdpi;
|
---|
| 97 | #endif
|
---|
| 98 |
|
---|
[112] | 99 | return r;
|
---|
| 100 | }
|
---|
| 101 |
|
---|