1 | // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*- |
---|
2 | // vi:set ts=4 sts=4 sw=4 noet : |
---|
3 | // |
---|
4 | // Copyright 2010, 2011 wkhtmltopdf authors |
---|
5 | // |
---|
6 | // This file is part of wkhtmltopdf. |
---|
7 | // |
---|
8 | // wkhtmltopdf is free software: you can redistribute it and/or modify |
---|
9 | // it under the terms of the GNU Lesser General Public License as published by |
---|
10 | // the Free Software Foundation, either version 3 of the License, or |
---|
11 | // (at your option) any later version. |
---|
12 | // |
---|
13 | // wkhtmltopdf is distributed in the hope that it will be useful, |
---|
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | // GNU General Public License for more details. |
---|
17 | // |
---|
18 | // You should have received a copy of the GNU Lesser General Public License |
---|
19 | // along with wkhtmltopdf. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | |
---|
21 | #include "imagecommandlineparser.hh" |
---|
22 | #include "progressfeedback.hh" |
---|
23 | #include <QApplication> |
---|
24 | #include <QWebFrame> |
---|
25 | #include <wkhtmltox/imageconverter.hh> |
---|
26 | #include <wkhtmltox/imagesettings.hh> |
---|
27 | #include <wkhtmltox/utilities.hh> |
---|
28 | |
---|
29 | #if defined(Q_OS_UNIX) |
---|
30 | #include <locale.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | int main(int argc, char** argv) { |
---|
34 | #if defined(Q_OS_UNIX) |
---|
35 | setlocale(LC_ALL, ""); |
---|
36 | #endif |
---|
37 | //This will store all our settings |
---|
38 | wkhtmltopdf::settings::ImageGlobal settings; |
---|
39 | //Create a command line parser to parse commandline arguments |
---|
40 | ImageCommandLineParser parser(settings); |
---|
41 | //Parse the arguments |
---|
42 | parser.parseArguments(argc, (const char**)argv); |
---|
43 | |
---|
44 | |
---|
45 | bool use_graphics=true; |
---|
46 | #if defined(Q_OS_UNIX) || defined(Q_OS_MAC) |
---|
47 | #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__ |
---|
48 | use_graphics=settings.useGraphics; |
---|
49 | if (!use_graphics) QApplication::setGraphicsSystem("raster"); |
---|
50 | #endif |
---|
51 | #endif |
---|
52 | QApplication a(argc, argv, use_graphics); |
---|
53 | MyLooksStyle * style = new MyLooksStyle(); |
---|
54 | a.setStyle(style); |
---|
55 | |
---|
56 | //Create the actual page converter to convert the pages |
---|
57 | wkhtmltopdf::ImageConverter converter(settings); |
---|
58 | QObject::connect(&converter, SIGNAL(checkboxSvgChanged(const QString &)), style, SLOT(setCheckboxSvg(const QString &))); |
---|
59 | QObject::connect(&converter, SIGNAL(checkboxCheckedSvgChanged(const QString &)), style, SLOT(setCheckboxCheckedSvg(const QString &))); |
---|
60 | QObject::connect(&converter, SIGNAL(radiobuttonSvgChanged(const QString &)), style, SLOT(setRadioButtonSvg(const QString &))); |
---|
61 | QObject::connect(&converter, SIGNAL(radiobuttonCheckedSvgChanged(const QString &)), style, SLOT(setRadioButtonCheckedSvg(const QString &))); |
---|
62 | |
---|
63 | wkhtmltopdf::ProgressFeedback feedback(settings.quiet, converter); |
---|
64 | bool success = converter.convert(); |
---|
65 | return handleError(success, converter.httpErrorCode()); |
---|
66 | } |
---|