summaryrefslogtreecommitdiffstats
path: root/src/assistant/qhelpgenerator/main.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-09-13 20:57:01 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-09-13 20:57:01 +0200
commit7f9aac1d910101267c95a75985a71719682e4ad6 (patch)
treeab50a2d005bc0921f68dbce36416848a437c3c0d /src/assistant/qhelpgenerator/main.cpp
parent4b2d6747b51137fd2fbff83c0232d155552d6332 (diff)
parent650dc4fc2856339805a80e3170f4de6ce1003588 (diff)
Merge remote-tracking branch 'origin/refactor' into master
Conflicts: src/assistant/help/help.pro src/designer/src/components/formeditor/formwindow.cpp src/designer/src/components/formeditor/formwindow_dnditem.cpp src/designer/src/components/formeditor/layout_propertysheet.cpp src/designer/src/components/formeditor/qdesigner_resource.cpp src/designer/src/components/lib/lib.pro src/designer/src/components/signalsloteditor/signalsloteditor.cpp src/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp src/designer/src/components/widgetbox/widgetbox_dnditem.cpp src/designer/src/components/widgetbox/widgetboxtreewidget.cpp src/designer/src/lib/lib.pro src/designer/src/lib/shared/qdesigner_formbuilder.cpp src/designer/src/lib/shared/qdesigner_propertysheet.cpp src/designer/src/lib/shared/shared.pri src/designer/src/plugins/qdeclarativeview/qdeclarativeview.pro src/linguist/lupdate/qdeclarative.cpp src/linguist/shared/profileevaluator.cpp src/linguist/shared/qph.cpp src/linguist/shared/ts.cpp src/qtconfig/mainwindow.cpp src/shared/qtgradienteditor/qtcolorline.cpp src/shared/qtgradienteditor/qtgradientwidget.cpp sync.profile Change-Id: I53f0ce4efae4179257cbf3aab87e1af12c3aa4ff
Diffstat (limited to 'src/assistant/qhelpgenerator/main.cpp')
-rw-r--r--src/assistant/qhelpgenerator/main.cpp178
1 files changed, 178 insertions, 0 deletions
diff --git a/src/assistant/qhelpgenerator/main.cpp b/src/assistant/qhelpgenerator/main.cpp
new file mode 100644
index 000000000..d1d1cc626
--- /dev/null
+++ b/src/assistant/qhelpgenerator/main.cpp
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../shared/helpgenerator.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
+
+#include <private/qhelpprojectdata_p.h>
+
+QT_USE_NAMESPACE
+
+class QHG {
+ Q_DECLARE_TR_FUNCTIONS(QHelpGenerator)
+};
+
+int main(int argc, char *argv[])
+{
+ QString error;
+ QString arg;
+ QString compressedFile;
+ QString projectFile;
+ QString basePath;
+ bool showHelp = false;
+ bool showVersion = false;
+ bool checkLinks = false;
+
+ QCoreApplication app(argc, argv);
+#ifndef Q_OS_WIN32
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+#endif // Q_OS_WIN32
+
+ for (int i = 1; i < argc; ++i) {
+ arg = QString::fromLocal8Bit(argv[i]);
+ if (arg == QLatin1String("-o")) {
+ if (++i < argc) {
+ QFileInfo fi(QString::fromLocal8Bit(argv[i]));
+ compressedFile = fi.absoluteFilePath();
+ } else {
+ error = QHG::tr("Missing output file name.");
+ }
+ } else if (arg == QLatin1String("-v")) {
+ showVersion = true;
+ } else if (arg == QLatin1String("-h")) {
+ showHelp = true;
+ } else if (arg == QLatin1String("-c")) {
+ checkLinks = true;
+ } else {
+ QFileInfo fi(arg);
+ projectFile = fi.absoluteFilePath();
+ basePath = fi.absolutePath();
+ }
+ }
+
+ if (showVersion) {
+ fputs(qPrintable(QHG::tr("Qt Help Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
+ return 0;
+ }
+
+ if (projectFile.isEmpty() && !showHelp)
+ error = QHG::tr("Missing Qt help project file.");
+
+ QString help = QHG::tr("\nUsage:\n\n"
+ "qhelpgenerator <help-project-file> [options]\n\n"
+ " -o <compressed-file> Generates a Qt compressed help\n"
+ " file called <compressed-file>.\n"
+ " If this option is not specified\n"
+ " a default name will be used.\n"
+ " -c Checks whether all links in HTML files\n"
+ " point to files in this help project.\n"
+ " -v Displays the version of \n"
+ " qhelpgenerator.\n\n");
+
+ if (showHelp) {
+ fputs(qPrintable(help), stdout);
+ return 0;
+ }else if (!error.isEmpty()) {
+ fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
+ return -1;
+ }
+
+ QFile file(projectFile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ fputs(qPrintable(QHG::tr("Could not open %1.\n").arg(projectFile)), stderr);
+ return -1;
+ }
+
+ if (compressedFile.isEmpty()) {
+ if (!checkLinks) {
+ QFileInfo fi(projectFile);
+ compressedFile = basePath + QDir::separator()
+ + fi.baseName() + QLatin1String(".qch");
+ }
+ } else {
+ // check if the output dir exists -- create if it doesn't
+ QFileInfo fi(compressedFile);
+ QDir parentDir = fi.dir();
+ if (!parentDir.exists()) {
+ if (!parentDir.mkpath(QLatin1String("."))) {
+ fputs(qPrintable(QHG::tr("Could not create output directory: %1\n")
+ .arg(parentDir.path())), stderr);
+ }
+ }
+ }
+
+ QHelpProjectData *helpData = new QHelpProjectData();
+ if (!helpData->readData(projectFile)) {
+ fprintf(stderr, "%s\n", qPrintable(helpData->errorMessage()));
+ return -1;
+ }
+
+ HelpGenerator generator;
+ bool success = true;
+ if (checkLinks)
+ success = generator.checkLinks(*helpData);
+ if (success && !compressedFile.isEmpty())
+ success = generator.generate(helpData, compressedFile);
+ delete helpData;
+ if (!success) {
+ fprintf(stderr, "%s\n", qPrintable(generator.error()));
+ return -1;
+ }
+ return 0;
+}