]> git.sesse.net Git - mlt/blob - src/modules/qt/common.cpp
A little debugging.
[mlt] / src / modules / qt / common.cpp
1 /*
2  * Copyright (C) 2014 Dan Dennedy <dan@dennedy.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "common.h"
20 #include <QApplication>
21 #include <QLocale>
22
23 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
24 #include <X11/Xlib.h>
25 #endif
26
27 bool createQApplicationIfNeeded(mlt_service service)
28 {
29         if (!qApp) {
30 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
31                 XInitThreads();
32                 if (getenv("DISPLAY") == 0) {
33                         mlt_log_error(service,
34                                 "The MLT Qt module requires a X11 environment.\n"
35                                 "Please either run melt from an X session or use a fake X server like xvfb:\n"
36                                 "xvfb-run -a melt (...)\n" );
37                         return false;
38                 }
39 #endif
40                 if (!mlt_properties_get(mlt_global_properties(), "qt_argv"))
41                         mlt_properties_set(mlt_global_properties(), "qt_argv", "MLT");
42                 static int argc = 1;
43                 static char* argv[] = { mlt_properties_get(mlt_global_properties(), "Qt argv") };
44                 new QApplication(argc, argv);
45                 const char *localename = mlt_properties_get_lcnumeric(MLT_SERVICE_PROPERTIES(service));
46                 QLocale::setDefault(QLocale(localename));
47         }
48         return true;
49 }