2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2010 University of Szeged
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "MiniBrowserApplication.h"
34 MiniBrowserApplication::MiniBrowserApplication(int& argc, char** argv)
35 : QApplication(argc, argv, QApplication::GuiServer)
37 , m_isRobotized(false)
38 , m_robotTimeoutSeconds(0)
39 , m_robotExtraTimeSeconds(0)
41 setOrganizationName("Nokia");
42 setApplicationName("QtMiniBrowser");
43 setApplicationVersion("0.1");
48 void MiniBrowserApplication::handleUserOptions()
50 QStringList args = arguments();
51 QFileInfo program(args.at(0));
52 QString programName("MiniBrowser");
54 programName = program.baseName();
56 if (args.contains("-help")) {
57 qDebug() << "Usage:" << programName.toLatin1().data()
59 << "[-robot-timeout seconds]"
60 << "[-robot-extra-time seconds]"
61 << "[-tiled-backing-store]"
62 << "[-separate-web-process-per-window]"
67 int robotIndex = args.indexOf("-r");
68 if (robotIndex != -1) {
69 QString listFile = takeOptionValue(&args, robotIndex);
70 if (listFile.isEmpty())
71 appQuit(1, "-r needs a list file to start in robotized mode");
72 if (!QFile::exists(listFile))
73 appQuit(1, "The list file supplied to -r does not exist.");
76 m_urls = QStringList(listFile);
78 int lastArg = args.lastIndexOf(QRegExp("^-.*"));
79 m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1);
82 int robotTimeoutIndex = args.indexOf("-robot-timeout");
83 if (robotTimeoutIndex != -1)
84 m_robotTimeoutSeconds = takeOptionValue(&args, robotTimeoutIndex).toInt();
86 int robotExtraTimeIndex = args.indexOf("-robot-extra-time");
87 if (robotExtraTimeIndex != -1)
88 m_robotExtraTimeSeconds = takeOptionValue(&args, robotExtraTimeIndex).toInt();
90 if (args.contains("-tiled-backing-store"))
91 m_windowOptions.useTiledBackingStore = true;
93 if (args.contains("-separate-web-process-per-window"))
94 m_windowOptions.useSeparateWebProcessPerWindow = true;