~ubuntu-branches/debian/squeeze/smplayer/squeeze

« back to all changes in this revision

Viewing changes to src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Breuil Cyril
  • Date: 2007-06-24 16:35:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070624163529-hhckbmd24uicada7
Tags: 0.5.20-0ubuntu1
* New upstream release
* Change Maintainer Email

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <qmime.h>
46
46
#include <qurl.h>
47
47
 
48
 
QRegExp rx_log;
 
48
 
 
49
static QRegExp rx_log;
49
50
 
50
51
void myMessageOutput( QtMsgType type, const char *msg ) {
51
 
        if (!pref->log_smplayer) return;
 
52
        if ( (!pref) || (!pref->log_smplayer) ) return;
52
53
 
53
54
        rx_log.setPattern(pref->log_filter);
54
55
 
122
123
                QT_TR_NOOP("Developer"),"rvm@escomposlinux.org");
123
124
 
124
125
        static const KCmdLineOptions options[] =
125
 
        { {"+[file]", QT_TR_NOOP("File to open"), 0 }, KCmdLineLastOption };
 
126
        { 
 
127
     //{ "ini-path <dir>", "path for ini file", 0 },
 
128
     {"+[file]", QT_TR_NOOP("File to open"), 0 }, KCmdLineLastOption };
126
129
 
127
130
        KCmdLineArgs::init(argc, argv, aboutdata);
128
131
        KCmdLineArgs::addCmdLineOptions( options );
137
140
        QApplication a( argc, argv );
138
141
#endif
139
142
 
140
 
        global_init();
141
 
 
142
 
        qInstallMsgHandler( myMessageOutput );
143
 
 
144
 
 
145
 
        // Get argument with full path
146
 
 
147
 
        QString file_to_play="";
148
 
 
149
 
#if KDE_SUPPORT
150
 
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
151
 
        if (args->count() > 0) {
152
 
                file_to_play = QString::fromLocal8Bit( args->arg(0) );
153
 
        }
154
 
#else
155
 
        if (a.argc() > 1) {
156
 
                file_to_play = QString::fromLocal8Bit( a.argv()[1] );
157
 
        }
158
 
#endif
159
143
 
160
144
        QString app_path = a.applicationDirPath();
161
145
        Helper::setAppPath(app_path);
162
146
        //qDebug( "main: application path: '%s'", app_path.utf8().data());
163
147
 
 
148
 
 
149
        QString ini_path="";
 
150
        QStringList files_to_play;
 
151
 
 
152
#if KDE_SUPPORT
 
153
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
154
        int arg_init = 0;
 
155
        int arg_count = args->count();
 
156
 
 
157
        if ( arg_count > arg_init ) {
 
158
                for (int n=arg_init; n < arg_count; n++) {
 
159
                        QString argument = QString::fromLocal8Bit( args->arg(n) );
 
160
                        if (QFile::exists( argument )) {
 
161
                                argument = QFileInfo(argument).absFilePath();
 
162
                        }
 
163
                        files_to_play.append( argument );
 
164
                }
 
165
        }
 
166
 
 
167
#else
 
168
        // Qt code
 
169
        int arg_init = 1;
 
170
        #if QT_VERSION >= 0x040100
 
171
        int arg_count = a.arguments().count();
 
172
        #else
 
173
        int arg_count = a.argc();
 
174
        #endif
 
175
 
 
176
        if ( arg_count > arg_init ) {
 
177
                for (int n=arg_init; n < arg_count; n++) {
 
178
                        #if QT_VERSION >= 0x040100
 
179
                        QString argument = a.arguments()[n];
 
180
                        #else
 
181
                        QString argument = QString::fromLocal8Bit( a.argv()[n] );
 
182
                        #endif
 
183
                        if (argument == "-ini-path") {
 
184
                                //qDebug( "ini_path: %d %d", n+1, arg_count );
 
185
                                ini_path = Helper::appPath();
 
186
                                if (n+1 < arg_count) {
 
187
                                        n++;
 
188
                                        #if QT_VERSION >= 0x040100
 
189
                                        ini_path = a.arguments()[n];
 
190
                                        #else
 
191
                                        ini_path = QString::fromLocal8Bit( a.argv()[n] );
 
192
                                        #endif
 
193
                                }
 
194
                        }
 
195
                        else {
 
196
                                if (QFile::exists( argument )) {
 
197
                                        argument = QFileInfo(argument).absFilePath();
 
198
                                }
 
199
                                files_to_play.append( argument );
 
200
                        }
 
201
                }
 
202
        }
 
203
#endif
 
204
 
 
205
        global_init(ini_path);
 
206
 
 
207
        qInstallMsgHandler( myMessageOutput );
 
208
 
164
209
        showInfo();
 
210
#if QT_VERSION >= 0x040000
 
211
        qDebug(" * ini path: '%s'", ini_path.utf8().data());
 
212
#endif
165
213
 
166
214
        // Translator
167
215
        translator->load( pref->language );
168
216
        a.installTranslator(translator->qtranslator());
169
217
 
170
 
        qDebug("main: file_to_play: '%s'", file_to_play.utf8().data());
 
218
        qDebug("main: files_to_play: count: %d", files_to_play.count() );
 
219
        for (int n=0; n < files_to_play.count(); n++) {
 
220
                qDebug("main: files_to_play[%d]: '%s'", n, files_to_play[n].utf8().data());
 
221
        }
171
222
 
172
 
        DefaultGui * w = new DefaultGui(file_to_play, 0, "gui");
 
223
        DefaultGui * w = new DefaultGui(files_to_play, 0, "gui");
173
224
        a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
174
225
 
175
226
        int r = a.exec();