diff options
Diffstat (limited to 'src')
42 files changed, 481 insertions, 5405 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 938087f454..642e2a0652 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -76,6 +76,7 @@ public: QPointer<ProjectExplorer::Project> project; QStringList sourceFiles; QStringList importPaths; + QString qmlDumpPath; }; class WorkingCopy diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 69f739b850..3260775ddc 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -380,13 +380,7 @@ void DebuggerRunControl::createEngine(const DebuggerStartParameters &startParams // Figure out engine according to toolchain, executable, attach or default. DebuggerEngineType engineType = NoEngineType; DebuggerLanguages activeLangs = DebuggerPlugin::instance()->activeLanguages(); - /*bool isQmlExecutable = sp.executable.endsWith(_("qmlviewer")) || sp.executable.endsWith(_("qmlobserver")); -#ifdef Q_OS_MAC - isQmlExecutable = sp.executable.endsWith(_("QMLViewer.app")) || sp.executable.endsWith(_("QMLObserver.app")); -#endif - if (isQmlExecutable && sp.startMode != AttachCore) - engineType = QmlEngineType; - else */if (sp.executable.endsWith(_(".js"))) + if (sp.executable.endsWith(_(".js"))) engineType = ScriptEngineType; else if (sp.executable.endsWith(_(".py"))) engineType = PdbEngineType; diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp index 5d65d17707..b006691cae 100644 --- a/src/plugins/projectexplorer/debugginghelper.cpp +++ b/src/plugins/projectexplorer/debugginghelper.cpp @@ -110,7 +110,8 @@ QString DebuggingHelperLibrary::copy(const QString &qtInstallData, errorMessage->clear(); return directory; } - *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") + *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", + "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); } diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index 2f3d14387b..f30357ff64 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -42,7 +42,6 @@ #include <texteditor/itexteditor.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> -#include <qt4projectmanager/qmldumptool.h> #include <QDir> #include <QFile> @@ -474,25 +473,13 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString & if (m_runningQmldumps.values().contains(canonicalLibraryPath)) return; - // TODO shouldn't be static - instead, if project changes, qmldump should probably change too. - static QString qmldumpPath; - if (qmldumpPath.isNull()) { - - ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); - qmldumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpToolForProject(activeProject); - // ### no support for .qmlproject projects or cmake projects. - - QFileInfo qmldumpFileInfo(qmldumpPath); - if (!qmldumpFileInfo.exists()) { - qWarning() << "ModelManager::loadQmlPluginTypes: qmldump executable does not exist at" << qmldumpPath; - qmldumpPath.clear(); - } else if (!qmldumpFileInfo.isFile()) { - qWarning() << "ModelManager::loadQmlPluginTypes: " << qmldumpPath << " is not a file"; - qmldumpPath.clear(); - } + ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); + if (!activeProject) + return; - } - if (qmldumpPath.isEmpty()) + ProjectInfo info = projectInfo(activeProject); + + if (info.qmlDumpPath.isEmpty()) return; QProcess *process = new QProcess(this); @@ -501,7 +488,7 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString & QStringList args; args << importPath; args << importUri; - process->start(qmldumpPath, args); + process->start(info.qmlDumpPath, args); m_runningQmldumps.insert(process, canonicalLibraryPath); } diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 3cd103a42d..34c86df699 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -32,7 +32,6 @@ #include "qmlprojectmanagerconstants.h" #include "qmlprojecttarget.h" #include "projectexplorer/projectexplorer.h" - #include <coreplugin/mimedatabase.h> #include <projectexplorer/buildconfiguration.h> #include <coreplugin/editormanager/editormanager.h> @@ -45,6 +44,7 @@ #include <utils/detailswidget.h> #include <qt4projectmanager/qtversionmanager.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> +#include <qt4projectmanager/qmlobservertool.h> #include <QFormLayout> #include <QComboBox> @@ -371,47 +371,19 @@ QString QmlProjectRunConfiguration::viewerDefaultPath() const { QString path; - // Search for QmlObserver -#ifdef Q_OS_MAC - const QString qmlObserverName = QLatin1String("QMLObserver.app"); -#else - const QString qmlObserverName = QLatin1String("qmlobserver"); -#endif - - QDir appDir(QCoreApplication::applicationDirPath()); - QString qmlObserverPath; -#ifdef Q_OS_WIN - qmlObserverPath = appDir.absoluteFilePath(qmlObserverName + QLatin1String(".exe")); -#else - qmlObserverPath = appDir.absoluteFilePath(qmlObserverName); -#endif - if (QFileInfo(qmlObserverPath).exists()) { - return qmlObserverPath; - } - - // Search for QmlViewer - - // prepend creator/bin dir to search path (only useful for special creator-qml package) - const QString searchPath = QCoreApplication::applicationDirPath() - + Utils::SynchronousProcess::pathSeparator() - + QString::fromLocal8Bit(qgetenv("PATH")); - -#ifdef Q_OS_MAC - const QString qmlViewerName = QLatin1String("QMLViewer"); -#else - const QString qmlViewerName = QLatin1String("qmlviewer"); -#endif - - path = Utils::SynchronousProcess::locateBinary(searchPath, qmlViewerName); - if (!path.isEmpty()) - return path; - // Try to locate default path in Qt Versions Qt4ProjectManager::QtVersionManager *qtVersions = Qt4ProjectManager::QtVersionManager::instance(); foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) { - if (!version->qmlviewerCommand().isEmpty() - && version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) { - return version->qmlviewerCommand(); + if (version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) { + // Search for QmlObserver + + const QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + path = Qt4ProjectManager::QmlObserverTool::toolByInstallData(qtInstallData); + + if (path.isEmpty() && !version->qmlviewerCommand().isEmpty()) { + path = version->qmlviewerCommand(); + break; + } } } diff --git a/src/plugins/qt4projectmanager/qmldumptool.cpp b/src/plugins/qt4projectmanager/qmldumptool.cpp index 51d340282e..cf60f055f0 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.cpp +++ b/src/plugins/qt4projectmanager/qmldumptool.cpp @@ -55,9 +55,8 @@ bool QmlDumpTool::canBuild(const QString &installHeadersDir) return QFile::exists(qDeclHeader); } -QString QmlDumpTool::qmlDumpToolForProject(ProjectExplorer::Project *project) +QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project) { - qDebug() << "current project:" << project; if (project->id() == Qt4ProjectManager::Constants::QT4PROJECT_ID) { Qt4Project *qt4Project = static_cast<Qt4Project*>(project); if (qt4Project && qt4Project->activeTarget() @@ -65,16 +64,15 @@ QString QmlDumpTool::qmlDumpToolForProject(ProjectExplorer::Project *project) QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); if (version->isValid()) { QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); - QString toolByInstallData = qmlDumpToolByInstallData(qtInstallData); - qDebug () << toolByInstallData; - return toolByInstallData; + QString toolPath = toolByInstallData(qtInstallData); + return toolPath; } } } return QString(); } -QString QmlDumpTool::qmlDumpToolByInstallData(const QString &qtInstallData) +QString QmlDumpTool::toolByInstallData(const QString &qtInstallData) { if (!Core::ICore::instance()) return QString(); @@ -123,8 +121,8 @@ QString QmlDumpTool::copy(const QString &qtInstallData, QString *errorMessage) errorMessage->clear(); return directory; } - *errorMessage = QCoreApplication::tr("ProjectExplorer::QmlDumpTool", - "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlDumpTool", + "qmldump could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); } diff --git a/src/plugins/qt4projectmanager/qmldumptool.h b/src/plugins/qt4projectmanager/qmldumptool.h index d8804c8b4b..5ec3355659 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.h +++ b/src/plugins/qt4projectmanager/qmldumptool.h @@ -47,8 +47,8 @@ class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrar { public: static bool canBuild(const QString &installHeadersDir); - static QString qmlDumpToolForProject(ProjectExplorer::Project *project); - static QString qmlDumpToolByInstallData(const QString &qtInstallData); + static QString toolForProject(ProjectExplorer::Project *project); + static QString toolByInstallData(const QString &qtInstallData); static QStringList locationsByInstallData(const QString &qtInstallData); // Build the helpers and return the output log/errormessage. diff --git a/src/plugins/qt4projectmanager/qmlobservertool.cpp b/src/plugins/qt4projectmanager/qmlobservertool.cpp new file mode 100644 index 0000000000..3a64da2ed7 --- /dev/null +++ b/src/plugins/qt4projectmanager/qmlobservertool.cpp @@ -0,0 +1,219 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "qmlobservertool.h" + +#include "qt4project.h" +#include "qt4projectmanagerconstants.h" +#include <coreplugin/icore.h> + +#include <projectexplorer/project.h> +#include <QDesktopServices> +#include <QCoreApplication> +#include <QDir> +#include <QDebug> + +namespace Qt4ProjectManager { + +static inline QStringList validBinaryFilenames() +{ + return QStringList() + << QLatin1String("debug/qmlobserver.exe") + << QLatin1String("qmlobserver.exe") + << QLatin1String("qmlobserver") + << QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver"); +} + +bool QmlObserverTool::canBuild(const QString &installHeadersDir) +{ + QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h"); + return QFile::exists(qDeclHeader); +} + +QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project) +{ + if (project->id() == Qt4ProjectManager::Constants::QT4PROJECT_ID) { + Qt4Project *qt4Project = static_cast<Qt4Project*>(project); + if (qt4Project && qt4Project->activeTarget() + && qt4Project->activeTarget()->activeBuildConfiguration()) { + QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); + if (version->isValid()) { + QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + QString toolPath = toolByInstallData(qtInstallData); + return toolPath; + } + } + } + return QString(); +} + +QString QmlObserverTool::toolByInstallData(const QString &qtInstallData) +{ + if (!Core::ICore::instance()) + return QString(); + + const QString mainFilename = Core::ICore::instance()->resourcePath() + + QLatin1String("/qml/qmlobserver/main.cpp"); + const QStringList directories = installDirectories(qtInstallData); + const QStringList binFilenames = validBinaryFilenames(); + + return byInstallDataHelper(mainFilename, directories, binFilenames); +} + +QStringList QmlObserverTool::locationsByInstallData(const QString &qtInstallData) +{ + QStringList result; + QFileInfo fileInfo; + const QStringList binFilenames = validBinaryFilenames(); + foreach(const QString &directory, installDirectories(qtInstallData)) { + if (getHelperFileInfoFor(binFilenames, directory, &fileInfo)) + result << fileInfo.filePath(); + } + return result; +} + +QString QmlObserverTool::build(const QString &directory, const QString &makeCommand, + const QString &qmakeCommand, const QString &mkspec, + const Utils::Environment &env, const QString &targetMode) +{ + return buildHelper(QCoreApplication::tr("QMLObserver"), QLatin1String("qmlobserver.pro"), + directory, makeCommand, qmakeCommand, mkspec, env, targetMode); +} + +static inline bool mkpath(const QString &targetDirectory, QString *errorMessage) +{ + if (!QDir().mkpath(targetDirectory)) { + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", "The target directory %1 could not be created.").arg(targetDirectory); + return false; + } + return true; +} + +QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessage) +{ + const QStringList directories = QmlObserverTool::installDirectories(qtInstallData); + + QStringList files; + files << QLatin1String("main.cpp") << QLatin1String("qmlobserver.pro") + << QLatin1String("crumblepath.cpp") << QLatin1String("crumblepath.h") + << QLatin1String("deviceorientation.cpp") << QLatin1String("deviceorientation.h") + << QLatin1String("deviceorientation_maemo5.cpp") << QLatin1String("Info_mac.plist") + << QLatin1String("loggerwidget.cpp") << QLatin1String("loggerwidget.h") + << QLatin1String("proxysettings.cpp") << QLatin1String("proxysettings.h") + << QLatin1String("proxysettings.ui") << QLatin1String("proxysettings_maemo5.ui") + << QLatin1String("qdeclarativetester.cpp") << QLatin1String("qdeclarativetester.h") + << QLatin1String("qml.icns") << QLatin1String("qml.pri") + << QLatin1String("qmlruntime.cpp") << QLatin1String("qmlruntime.h") + << QLatin1String("qmlruntime.qrc") << QLatin1String("recopts.ui") + << QLatin1String("recopts_maemo5.ui") + << QLatin1String("texteditautoresizer_maemo5.h") + << QLatin1String("content/Browser.qml") << QLatin1String("content/images/folder.png") + << QLatin1String("content/images/titlebar.png") << QLatin1String("content/images/titlebar.sci") + << QLatin1String("content/images/up.png") + << QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT"); + + QStringList debuggerLibFiles; + debuggerLibFiles << QLatin1String("jsdebuggeragent.cpp") << QLatin1String("private_headers.pri") + << QLatin1String("qdeclarativeobserverservice.cpp") << QLatin1String("qdeclarativeviewobserver.cpp") + << QLatin1String("qdeclarativeviewobserver_p.h") << QLatin1String("qmljsdebugger.pri") + << QLatin1String("qmljsdebugger.pro") << QLatin1String("qmljsdebugger-lib.pri") + << QLatin1String("include/jsdebuggeragent.h") << QLatin1String("include/qdeclarativeobserverservice.h") + << QLatin1String("include/qdeclarativeviewobserver.h") << QLatin1String("include/qmljsdebugger_global.h") + << QLatin1String("include/qmlobserverconstants.h"); + + QStringList debuggerLibEditorFiles; + debuggerLibEditorFiles << QLatin1String("abstractformeditortool.cpp") << QLatin1String("abstractformeditortool.h") + << QLatin1String("boundingrecthighlighter.cpp") << QLatin1String("boundingrecthighlighter.h") + << QLatin1String("colorpickertool.cpp") << QLatin1String("colorpickertool.h") + << QLatin1String("editor.pri") << QLatin1String("editor.qrc") + << QLatin1String("layeritem.cpp") << QLatin1String("layeritem.h") + << QLatin1String("qmltoolbar.cpp") << QLatin1String("qmltoolbar.h") + << QLatin1String("rubberbandselectionmanipulator.cpp") + << QLatin1String("rubberbandselectionmanipulator.h") << QLatin1String("selectionindicator.cpp") + << QLatin1String("selectionindicator.h") << QLatin1String("selectionrectangle.cpp") + << QLatin1String("selectionrectangle.h") << QLatin1String("selectiontool.cpp") + << QLatin1String("selectiontool.h") << QLatin1String("singleselectionmanipulator.cpp") + << QLatin1String("singleselectionmanipulator.h") << QLatin1String("subcomponenteditortool.cpp") + << QLatin1String("subcomponenteditortool.h") << QLatin1String("subcomponentmasklayeritem.cpp") + << QLatin1String("subcomponentmasklayeritem.h") << QLatin1String("toolbarcolorbox.cpp") + << QLatin1String("toolbarcolorbox.h") << QLatin1String("zoomtool.cpp") + << QLatin1String("zoomtool.h") << QLatin1String("images/color-picker.png") + << QLatin1String("images/color-picker-24.png") << QLatin1String("images/color-picker-hicontrast.png") + << QLatin1String("images/from-qml.png") << QLatin1String("images/from-qml-24.png") + << QLatin1String("images/observermode.png") << QLatin1String("images/observermode-24.png") + << QLatin1String("images/pause.png") << QLatin1String("images/pause-24.png") + << QLatin1String("images/play.png") << QLatin1String("images/play-24.png") + << QLatin1String("images/reload.png") << QLatin1String("images/resize_handle.png") + << QLatin1String("images/select.png") << QLatin1String("images/select-24.png") + << QLatin1String("images/select-marquee.png") << QLatin1String("images/select-marquee-24.png") + << QLatin1String("images/to-qml.png") << QLatin1String("images/to-qml-24.png") + << QLatin1String("images/zoom.png") << QLatin1String("images/zoom-24.png"); + + QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmlobserver/"); + QString libSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/"); + QString libEditorSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/editor/"); + + // Try to find a writeable directory. + foreach(const QString &directory, directories) { + if (!mkpath(directory + QLatin1String("/content/images"), errorMessage) + || !mkpath(directory + QLatin1String("/qmljsdebugger/editor/images"), errorMessage) + || !mkpath(directory + QLatin1String("/qmljsdebugger/include"), errorMessage)) + { + continue; + } else { + errorMessage->clear(); + } + + if (copyFiles(sourcePath, files, directory, errorMessage) + && copyFiles(libSourcePath, debuggerLibFiles, directory + QLatin1String("/qmljsdebugger/"), errorMessage) + && copyFiles(libEditorSourcePath, debuggerLibEditorFiles, directory + QLatin1String("/qmljsdebugger/editor/"), errorMessage)) + { + errorMessage->clear(); + return directory; + } + } + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", + "QMLObserver could not be built in any of the directories:\n- %1\n\nReason: %2") + .arg(directories.join(QLatin1String("\n- ")), *errorMessage); + return QString(); +} + +QStringList QmlObserverTool::installDirectories(const QString &qtInstallData) +{ + const QChar slash = QLatin1Char('/'); + const uint hash = qHash(qtInstallData); + QStringList directories; + directories + << (qtInstallData + QLatin1String("/qtc-qmlobserver/")) + << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-qmlobserver/") + QString::number(hash))) + slash + << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-qmlobserver/") + QString::number(hash)) + slash; + return directories; +} + +} // namespace diff --git a/src/plugins/qt4projectmanager/qmlobservertool.h b/src/plugins/qt4projectmanager/qmlobservertool.h new file mode 100644 index 0000000000..625e625c76 --- /dev/null +++ b/src/plugins/qt4projectmanager/qmlobservertool.h @@ -0,0 +1,69 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef QMLOBSERVERTOOL_H +#define QMLOBSERVERTOOL_H + +#include <utils/buildablehelperlibrary.h> +#include "qt4projectmanager_global.h" + +namespace Utils { + class Environment; +} + +namespace ProjectExplorer { + class Project; +} + +namespace Qt4ProjectManager { + +class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary +{ +public: + static bool canBuild(const QString &installHeadersDir); + static QString toolForProject(ProjectExplorer::Project *project); + static QString toolByInstallData(const QString &qtInstallData); + static QStringList locationsByInstallData(const QString &qtInstallData); + + // Build the helpers and return the output log/errormessage. + static QString build(const QString &directory, const QString &makeCommand, + const QString &qmakeCommand, const QString &mkspec, + const Utils::Environment &env, const QString &targetMode); + + // Copy the source files to a target location and return the chosen target location. + static QString copy(const QString &qtInstallData, QString *errorMessage); + +private: + static QStringList installDirectories(const QString &qtInstallData); + +}; + +} // namespace + +#endif // QMLOBSERVERTOOL_H diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 1385f63406..20808d95ab 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -40,6 +40,7 @@ #include "projectloadwizard.h" #include "qt4buildconfiguration.h" #include "findqt4profiles.h" +#include "qmldumptool.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -50,6 +51,7 @@ #include <qmljs/qmljsmodelmanagerinterface.h> #include <projectexplorer/buildenvironmentwidget.h> #include <projectexplorer/customexecutablerunconfiguration.h> +#include <projectexplorer/projectexplorer.h> #include <utils/qtcassert.h> #include <QtCore/QDebug> @@ -584,6 +586,36 @@ void Qt4Project::updateQmlJSCodeModel() } projectInfo.importPaths.removeDuplicates(); + + if (projectInfo.qmlDumpPath.isNull()) { + ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); + projectInfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::toolForProject(activeProject); + + // ### this is needed for qmlproject and cmake project support, but may not work in all cases. + if (projectInfo.qmlDumpPath.isEmpty()) { + // Try to locate default path in Qt Versions + QtVersionManager *qtVersions = QtVersionManager::instance(); + foreach (QtVersion *version, qtVersions->validVersions()) { + if (version->supportsTargetId(Constants::DESKTOP_TARGET_ID)) { + const QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + projectInfo.qmlDumpPath = QmlDumpTool::toolByInstallData(qtInstallData); + + if (!projectInfo.qmlDumpPath.isEmpty()) { + break; + } + } + } + } + QFileInfo qmldumpFileInfo(projectInfo.qmlDumpPath); + if (!qmldumpFileInfo.exists()) { + qWarning() << "Qt4Project::loadQmlPluginTypes: qmldump executable does not exist at" << projectInfo.qmlDumpPath; + projectInfo.qmlDumpPath.clear(); + } else if (!qmldumpFileInfo.isFile()) { + qWarning() << "Qt4Project::loadQmlPluginTypes: " << projectInfo.qmlDumpPath << " is not a file"; + projectInfo.qmlDumpPath.clear(); + } + } + modelManager->updateProjectInfo(projectInfo); } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 3b84f9653e..e456017ebe 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -62,7 +62,8 @@ HEADERS += qt4deployconfiguration.h \ librarydetailscontroller.h \ findqt4profiles.h \ qt4projectmanager_global.h \ - qmldumptool.h + qmldumptool.h \ + qmlobservertool.h SOURCES += qt4projectmanagerplugin.cpp \ qt4deployconfiguration.cpp \ qtparser.cpp \ @@ -119,7 +120,8 @@ SOURCES += qt4projectmanagerplugin.cpp \ addlibrarywizard.cpp \ librarydetailscontroller.cpp \ findqt4profiles.cpp \ - qmldumptool.cpp + qmldumptool.cpp \ + qmlobservertool.cpp FORMS += makestep.ui \ qmakestep.ui \ qt4projectconfigwidget.ui \ diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index d0e0b7d59f..0179867751 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -70,10 +70,9 @@ DebuggingHelperBuildTask::~DebuggingHelperBuildTask() void DebuggingHelperBuildTask::run(QFutureInterface<void> &future) { - future.setProgressRange(0, 4); - future.setProgressValue(1); - const QString output = m_version->buildDebuggingHelperLibrary(); + future.setProgressRange(0, 5); future.setProgressValue(1); + const QString output = m_version->buildDebuggingHelperLibrary(future); emit finished(m_version->displayName(), output); deleteLater(); } @@ -145,8 +144,10 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver : QWidget(parent) , m_debuggingHelperOkPixmap(QLatin1String(":/extensionsystem/images/ok.png")) , m_debuggingHelperErrorPixmap(QLatin1String(":/extensionsystem/images/error.png")) + , m_debuggingHelperIntermediatePixmap(QLatin1String(":/extensionsystem/images/notloaded.png")) , m_debuggingHelperOkIcon(m_debuggingHelperOkPixmap) , m_debuggingHelperErrorIcon(m_debuggingHelperErrorPixmap) + , m_debuggingHelperIntermediateIcon(m_debuggingHelperIntermediatePixmap) , m_specifyNameString(tr("<specify a name>")) , m_specifyPathString(tr("<specify a qmake location>")) , m_ui(new Internal::Ui::QtVersionManager()) @@ -190,7 +191,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver item->setData(0, Qt::UserRole, version->uniqueId()); if (version->isValid() && version->supportsBinaryDebuggingHelper()) - item->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + item->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(version)); else item->setData(2, Qt::DecorationRole, QIcon()); } @@ -235,6 +236,26 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver updateState(); } +QIcon QtOptionsPageWidget::debuggerHelperIconForQtVersion(const QtVersion *version) +{ + if (version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver()) { + return m_debuggingHelperOkIcon; + } else if (!version->hasDebuggingHelper() && !version->hasQmlDump() && !version->hasQmlObserver()) { + return m_debuggingHelperErrorIcon; + } + return m_debuggingHelperIntermediateIcon; +} + +QPixmap QtOptionsPageWidget::debuggerHelperPixmapForQtVersion(const QtVersion *version) +{ + if (version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver()) { + return m_debuggingHelperOkPixmap; + } else if (!version->hasDebuggingHelper() && !version->hasQmlDump() && !version->hasQmlObserver()) { + return m_debuggingHelperErrorPixmap; + } + return m_debuggingHelperIntermediatePixmap; +} + bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e) { // Set the items tooltip, which may cause costly initialization @@ -289,8 +310,9 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(const QString &name, cons QTreeWidgetItem *item = treeItemForIndex(index); QTC_ASSERT(item, return) item->setData(2, Qt::UserRole, output); - const bool success = m_versions.at(index)->hasDebuggingHelper(); - item->setData(2, Qt::DecorationRole, success ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + QSharedPointerQtVersion qtVersion = m_versions.at(index); + const bool success = qtVersion->hasDebuggingHelper() && qtVersion->hasQmlDump() && qtVersion->hasQmlObserver(); + item->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(qtVersion.data())); // Update bottom control if the selection is still the same if (index == currentIndex()) { @@ -373,15 +395,35 @@ void QtOptionsPageWidget::removeQtDir() } // Format html table tooltip about helpers -static inline QString msgHtmlHelperToolTip(const QFileInfo &fi) +static inline QString msgHtmlHelperToolTip(const QString &gdbHelperPath, const QString &qmlDumpPath, const QString &qmlObserverPath) { + QFileInfo gdbHelperFI(gdbHelperPath); + QFileInfo qmlDumpFI(qmlDumpPath); + QFileInfo qmlObserverFI(qmlObserverPath); + + QString notFound = QtOptionsPageWidget::tr("Binary not found"); + //: Tooltip showing the debugging helper library file. return QtOptionsPageWidget::tr("<html><body><table><tr><td>File:</td><td><pre>%1</pre></td></tr>" "<tr><td>Last modified:</td><td>%2</td></tr>" - "<tr><td>Size:</td><td>%3 Bytes</td></tr></table></body></html>"). - arg(QDir::toNativeSeparators(fi.absoluteFilePath())). - arg(fi.lastModified().toString(Qt::SystemLocaleLongDate)). - arg(fi.size()); + "<tr><td>Size:</td><td>%3 Bytes</td></tr>" + "<tr><td>File:</td><td><pre>%4</pre></td></tr>" + "<tr><td>Last modified:</td><td>%5</td></tr>" + "<tr><td>Size:</td><td>%6 Bytes</td></tr>" + "<tr><td>File:</td><td><pre>%7</pre></td></tr>" + "<tr><td>Last modified:</td><td>%8</td></tr>" + "<tr><td>Size:</td><td>%9 Bytes</td></tr>" + "</table></body></html>" + ). + arg(gdbHelperPath.isEmpty() ? notFound : QDir::toNativeSeparators(gdbHelperFI.absoluteFilePath())). + arg(gdbHelperFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(gdbHelperFI.size()). + arg(qmlDumpPath.isEmpty() ? notFound : QDir::toNativeSeparators(qmlDumpFI.absoluteFilePath())). + arg(qmlDumpFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(qmlDumpFI.size()). + arg(qmlObserverPath.isEmpty() ? notFound : QDir::toNativeSeparators(qmlObserverFI.absoluteFilePath())). + arg(qmlObserverFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(qmlObserverFI.size()); } // Update the state label with a pixmap and set a tooltip describing @@ -390,10 +432,12 @@ void QtOptionsPageWidget::updateDebuggingHelperStateLabel(const QtVersion *versi { QString tooltip; if (version && version->isValid()) { - const bool hasHelper = version->hasDebuggingHelper(); - m_ui->debuggingHelperStateLabel->setPixmap(hasHelper ? m_debuggingHelperOkPixmap : m_debuggingHelperErrorPixmap); - if (hasHelper) - tooltip = msgHtmlHelperToolTip(QFileInfo(version->debuggingHelperLibrary())); + const bool hasHelpers = version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver(); + m_ui->debuggingHelperStateLabel->setPixmap(debuggerHelperPixmapForQtVersion(version)); + if (hasHelpers) + tooltip = msgHtmlHelperToolTip(version->debuggingHelperLibrary(), + version->qmlDumpTool(), + version->qmlObserverTool()); } else { m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); } @@ -679,7 +723,7 @@ void QtOptionsPageWidget::updateCurrentQMakeLocation() if (version->isValid() && version->supportsBinaryDebuggingHelper()) { const bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty(); - currentItem->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + currentItem->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(version)); m_ui->showLogButton->setEnabled(hasLog); m_ui->rebuildButton->setEnabled(true); } else { diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h index 65a3956a3a..293dd32306 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.h +++ b/src/plugins/qt4projectmanager/qtoptionspage.h @@ -90,11 +90,15 @@ private: QtVersion *currentVersion() const; int currentIndex() const; void updateDebuggingHelperStateLabel(const QtVersion *version = 0); + QIcon debuggerHelperIconForQtVersion(const QtVersion *version); + QPixmap debuggerHelperPixmapForQtVersion(const QtVersion *version); const QPixmap m_debuggingHelperOkPixmap; const QPixmap m_debuggingHelperErrorPixmap; + const QPixmap m_debuggingHelperIntermediatePixmap; const QIcon m_debuggingHelperOkIcon; const QIcon m_debuggingHelperErrorIcon; + const QIcon m_debuggingHelperIntermediateIcon; const QString m_specifyNameString; const QString m_specifyPathString; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index e6b8aa93a3..12aeebb035 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -37,6 +37,7 @@ #include "qt-s60/s60manager.h" #include "qt-s60/s60projectchecker.h" +#include "qmlobservertool.h" #include "qmldumptool.h" #include <projectexplorer/debugginghelper.h> #include <projectexplorer/projectexplorer.h> @@ -516,6 +517,8 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id, m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -538,6 +541,8 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -556,6 +561,8 @@ QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QSt : m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -574,6 +581,8 @@ QtVersion::QtVersion() : m_id(-1), m_isAutodetected(false), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -1126,6 +1135,8 @@ void QtVersion::updateVersionInfo() const m_hasExamples = false; m_hasDocumentation = false; m_hasDebuggingHelper = false; + m_hasQmlDump = false; + m_hasQmlObserver = false; if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo)) return; @@ -1136,7 +1147,8 @@ void QtVersion::updateVersionInfo() const if (!qtInstallData.isEmpty()) { m_hasDebuggingHelper = !DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty(); - m_hasQmlDump = !QmlDumpTool::qmlDumpToolByInstallData(qtInstallData).isEmpty(); + m_hasQmlDump = !QmlDumpTool::toolByInstallData(qtInstallData).isEmpty(); + m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty(); } } @@ -1237,6 +1249,7 @@ QString QtVersion::qmlviewerCommand() const { if (!isValid()) return QString(); + if (m_qmlviewerCommand.isNull()) { #ifdef Q_OS_MAC const QString qmlViewerName = QLatin1String("QMLViewer"); @@ -1618,6 +1631,12 @@ bool QtVersion::hasQmlDump() const return m_hasQmlDump; } +bool QtVersion::hasQmlObserver() const +{ + updateVersionInfo(); + return m_hasQmlObserver; +} + QString QtVersion::debuggingHelperLibrary() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1626,6 +1645,22 @@ QString QtVersion::debuggingHelperLibrary() const return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData); } +QString QtVersion::qmlDumpTool() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlDumpTool::toolByInstallData(qtInstallData); +} + +QString QtVersion::qmlObserverTool() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlObserverTool::toolByInstallData(qtInstallData); +} + QStringList QtVersion::debuggingHelperLibraryLocations() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1711,7 +1746,7 @@ bool QtVersion::isQt64Bit() const #endif } -QString QtVersion::buildDebuggingHelperLibrary() +QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future) { QString qtInstallHeaders = versionInfo().value("QT_INSTALL_HEADERS"); QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1733,18 +1768,35 @@ QString QtVersion::buildDebuggingHelperLibrary() qmakeCommand(), mkspec(), env, (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); } + future.setProgressValue(2); + if (QmlDumpTool::canBuild(qtInstallHeaders)) { - QString qmlDumpDirectory = QmlDumpTool::copy(qtInstallData, &output); - if (!qmlDumpDirectory.isEmpty()) { - output += QmlDumpTool::build(qmlDumpDirectory, tc->makeCommand(), + QString toolDirectory = QmlDumpTool::copy(qtInstallData, &output); + if (!toolDirectory.isEmpty()) { + output += QmlDumpTool::build(toolDirectory, tc->makeCommand(), qmakeCommand(), mkspec(), env, (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); } } else { output += QCoreApplication::tr("Cannot build qmldump; Qt version must be 4.7.1 or higher."); } + future.setProgressValue(3); + + if (QmlObserverTool::canBuild(qtInstallHeaders)) { + QString toolDirectory = QmlObserverTool::copy(qtInstallData, &output); + if (!toolDirectory.isEmpty()) { + output += QmlObserverTool::build(toolDirectory, tc->makeCommand(), + qmakeCommand(), mkspec(), env, + (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); + } + } else { + output += QCoreApplication::tr("Cannot build QMLObserver; Qt version must be 4.7.1 or higher."); + } + future.setProgressValue(4); m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty(); + m_hasQmlDump = !qmlDumpTool().isEmpty(); + m_hasQmlObserver = !qmlObserverTool().isEmpty(); return output; } diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index c9bbe9d91c..4e9f0ac156 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -38,6 +38,7 @@ #include <QtCore/QHash> #include <QtCore/QSet> #include <QtCore/QSharedPointer> +#include <QtCore/QFutureInterface> namespace Qt4ProjectManager { @@ -111,14 +112,17 @@ public: bool hasDebuggingHelper() const; QString debuggingHelperLibrary() const; + QString qmlDumpTool() const; + QString qmlObserverTool() const; QStringList debuggingHelperLibraryLocations() const; bool supportsBinaryDebuggingHelper() const; bool hasQmlDump() const; + bool hasQmlObserver() const; // Builds a debugging library // returns the output of the commands - QString buildDebuggingHelperLibrary(); + QString buildDebuggingHelperLibrary(QFutureInterface<void> &future); bool hasExamples() const; QString examplesPath() const; @@ -172,6 +176,7 @@ private: QString m_autodetectionSource; mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate + mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate QString m_mwcDirectory; QString m_s60SDKDirectory; diff --git a/src/tools/qml/qmlobserver/Info_mac.plist b/src/tools/qml/qmlobserver/Info_mac.plist deleted file mode 100644 index 80ca6a3526..0000000000 --- a/src/tools/qml/qmlobserver/Info_mac.plist +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> -<plist version="0.1"> -<dict> - <key>CFBundleIconFile</key> - <string>@ICON@</string> - <key>CFBundleIdentifier</key> - <string>com.nokia.qt.qml</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleGetInfoString</key> - <string>Created by Qt/QMake</string> - <key>CFBundleSignature</key> - <string>@TYPEINFO@</string> - <key>CFBundleExecutable</key> - <string>@EXECUTABLE@</string> -</dict> -</plist> diff --git a/src/tools/qml/qmlobserver/content/Browser.qml b/src/tools/qml/qmlobserver/content/Browser.qml deleted file mode 100644 index ff2bb47647..0000000000 --- a/src/tools/qml/qmlobserver/content/Browser.qml +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import Qt.labs.folderlistmodel 1.0 - -Rectangle { - id: root - property bool keyPressed: false - property variant folders: folders1 - property variant view: view1 - width: 320 - height: 480 - color: palette.window - - FolderListModel { - id: folders1 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - FolderListModel { - id: folders2 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - - SystemPalette { id: palette } - - function down(path) { - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitLeft"; - } else { - view = view1 - folders = folders1; - view2.state = "exitLeft"; - } - view.x = root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - function up() { - var path = folders.parentFolder; - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitRight"; - } else { - view = view1 - folders = folders1; - view2.state = "exitRight"; - } - view.x = -root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - - Component { - id: folderDelegate - Rectangle { - id: wrapper - function launch() { - if (folders.isFolder(index)) { - down(filePath); - } else { - qmlViewer.launch(filePath); - } - } - width: root.width - height: 52 - color: "transparent" - Rectangle { - id: highlight; visible: false - anchors.fill: parent - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - } - Item { - width: 48; height: 48 - Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} - } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: 54 - font.pixelSize: 32 - color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText - elide: Text.ElideRight - } - MouseArea { - id: mouseRegion - anchors.fill: parent - onClicked: { if (folders == wrapper.ListView.view.model) launch() } - } - states: [ - State { - name: "pressed" - when: mouseRegion.pressed - PropertyChanges { target: highlight; visible: true } - PropertyChanges { target: nameText; color: palette.highlightedText } - } - ] - } - } - - ListView { - id: view1 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: 0 - width: parent.width - model: folders1 - delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view1.count != 0 } - highlightMoveSpeed: 1000 - pressDelay: 100 - focus: true - state: "current" - states: [ - State { - name: "current" - PropertyChanges { target: view1; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view1; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view1; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: { root.keyPressed = true; } - } - - ListView { - id: view2 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: parent.width - width: parent.width - model: folders2 - delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view2.count != 0 } - highlightMoveSpeed: 1000 - pressDelay: 100 - states: [ - State { - name: "current" - PropertyChanges { target: view2; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view2; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view2; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: { root.keyPressed = true; } - } - - Keys.onPressed: { - root.keyPressed = true; - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { - view.currentItem.launch(); - event.accepted = true; - } else if (event.key == Qt.Key_Left) { - up(); - } - } - - BorderImage { - source: "images/titlebar.sci"; - width: parent.width; - height: 52 - y: -7 - id: titleBar - - Rectangle { - id: upButton - width: 48 - height: titleBar.height - 7 - color: "transparent" - - Image { anchors.centerIn: parent; source: "images/up.png" } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: 56 - onClicked: if (folders.parentFolder != "") up() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } - } - ] - } - Rectangle { - color: "gray" - x: 48 - width: 1 - height: 44 - } - - Text { - anchors.left: upButton.right; anchors.right: parent.right; height: parent.height - anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder - color: "white" - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - font.pixelSize: 32 - } - } -} diff --git a/src/tools/qml/qmlobserver/content/images/folder.png b/src/tools/qml/qmlobserver/content/images/folder.png Binary files differdeleted file mode 100644 index e53e2ad464..0000000000 --- a/src/tools/qml/qmlobserver/content/images/folder.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/content/images/titlebar.png b/src/tools/qml/qmlobserver/content/images/titlebar.png Binary files differdeleted file mode 100644 index 51c90082d0..0000000000 --- a/src/tools/qml/qmlobserver/content/images/titlebar.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/content/images/titlebar.sci b/src/tools/qml/qmlobserver/content/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/src/tools/qml/qmlobserver/content/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/src/tools/qml/qmlobserver/content/images/up.png b/src/tools/qml/qmlobserver/content/images/up.png Binary files differdeleted file mode 100644 index b05f8025d0..0000000000 --- a/src/tools/qml/qmlobserver/content/images/up.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/deviceorientation.cpp b/src/tools/qml/qmlobserver/deviceorientation.cpp deleted file mode 100644 index e7c70d5fde..0000000000 --- a/src/tools/qml/qmlobserver/deviceorientation.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" - -QT_USE_NAMESPACE - -class DefaultDeviceOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {} - - Orientation orientation() const { - return m_orientation; - } - - void setOrientation(Orientation o) { - if (o != m_orientation) { - m_orientation = o; - emit orientationChanged(); - } - } - - Orientation m_orientation; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static DefaultDeviceOrientation *o = 0; - if (!o) - o = new DefaultDeviceOrientation; - return o; -} - -#include "deviceorientation.moc" - diff --git a/src/tools/qml/qmlobserver/deviceorientation.h b/src/tools/qml/qmlobserver/deviceorientation.h deleted file mode 100644 index 817bfc8528..0000000000 --- a/src/tools/qml/qmlobserver/deviceorientation.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ORIENTATION_H -#define ORIENTATION_H - -#include <QObject> - -QT_BEGIN_NAMESPACE - -class DeviceOrientationPrivate; -class DeviceOrientation : public QObject -{ - Q_OBJECT - Q_ENUMS(Orientation) -public: - enum Orientation { - UnknownOrientation, - Portrait, - Landscape, - PortraitInverted, - LandscapeInverted - }; - - virtual Orientation orientation() const = 0; - virtual void setOrientation(Orientation) = 0; - - static DeviceOrientation *instance(); - -signals: - void orientationChanged(); - -protected: - DeviceOrientation() {} - -private: - DeviceOrientationPrivate *d_ptr; - friend class DeviceOrientationPrivate; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp b/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp deleted file mode 100644 index e942579b70..0000000000 --- a/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" -#include <QtDBus> - -#include <mce/mode-names.h> -#include <mce/dbus-names.h> - -class MaemoOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - MaemoOrientation() - : o(UnknownOrientation) - { - // enable the orientation sensor - QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, - MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ)); - - // query the initial orientation - QDBusMessage reply = QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, - MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET)); - if (reply.type() == QDBusMessage::ErrorMessage) { - qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage())); - } else { - o = toOrientation(reply.arguments().value(0).toString()); - } - - // connect to the orientation change signal - QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF, - MCE_DEVICE_ORIENTATION_SIG, - this, - SLOT(deviceOrientationChanged(QString))); - } - - ~MaemoOrientation() - { - // disable the orientation sensor - QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, - MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ)); - } - - inline Orientation orientation() const - { - return o; - } - - void setOrientation(Orientation o) - { - } - -private Q_SLOTS: - void deviceOrientationChanged(const QString &newOrientation) - { - o = toOrientation(newOrientation); - - emit orientationChanged(); -// printf("%d\n", o); - } - -private: - static Orientation toOrientation(const QString &nativeOrientation) - { - if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE) - return Landscape; - else if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE_INVERTED) - return LandscapeInverted; - else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT) - return Portrait; - else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT_INVERTED) - return PortraitInverted; - return UnknownOrientation; - } - -private: - Orientation o; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static MaemoOrientation *o = new MaemoOrientation; - return o; -} - -#include "deviceorientation_maemo5.moc" diff --git a/src/tools/qml/qmlobserver/loggerwidget.cpp b/src/tools/qml/qmlobserver/loggerwidget.cpp deleted file mode 100644 index 8aa029f3d0..0000000000 --- a/src/tools/qml/qmlobserver/loggerwidget.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qglobal.h> -#include <QDebug> -#include <QSettings> -#include <QActionGroup> -#include <QMenu> -#include <QPlainTextEdit> -#ifdef Q_WS_MAEMO_5 -# include <QScrollArea> -# include <QVBoxLayout> -# include "texteditautoresizer_maemo5.h" -#endif - -#include "loggerwidget.h" - -QT_BEGIN_NAMESPACE - -LoggerWidget::LoggerWidget(QWidget *parent) : - QMainWindow(parent), - m_visibilityOrigin(SettingsOrigin) -{ - setAttribute(Qt::WA_QuitOnClose, false); - setWindowTitle(tr("Warnings")); - - m_plainTextEdit = new QPlainTextEdit(); - -#ifdef Q_WS_MAEMO_5 - new TextEditAutoResizer(m_plainTextEdit); - setAttribute(Qt::WA_Maemo5StackedWindow); - QScrollArea *area = new QScrollArea(); - area->setWidget(m_plainTextEdit); - area->setWidgetResizable(true); - setCentralWidget(area); -#else - setCentralWidget(m_plainTextEdit); -#endif - readSettings(); - setupPreferencesMenu(); -} - -void LoggerWidget::append(const QString &msg) -{ - m_plainTextEdit->appendPlainText(msg); - - if (!isVisible() && (defaultVisibility() == AutoShowWarnings)) - setVisible(true); -} - -LoggerWidget::Visibility LoggerWidget::defaultVisibility() const -{ - return m_visibility; -} - -void LoggerWidget::setDefaultVisibility(LoggerWidget::Visibility visibility) -{ - if (m_visibility == visibility) - return; - - m_visibility = visibility; - m_visibilityOrigin = CommandLineOrigin; - - m_preferencesMenu->setEnabled(m_visibilityOrigin == SettingsOrigin); -} - -QMenu *LoggerWidget::preferencesMenu() -{ - return m_preferencesMenu; -} - -QAction *LoggerWidget::showAction() -{ - return m_showWidgetAction; -} - -void LoggerWidget::readSettings() -{ - QSettings settings; - QString warningsPreferences = settings.value("warnings", "hide").toString(); - if (warningsPreferences == "show") { - m_visibility = ShowWarnings; - } else if (warningsPreferences == "hide") { - m_visibility = HideWarnings; - } else { - m_visibility = AutoShowWarnings; - } -} - -void LoggerWidget::saveSettings() -{ - if (m_visibilityOrigin != SettingsOrigin) - return; - - QString value = "autoShow"; - if (defaultVisibility() == ShowWarnings) { - value = "show"; - } else if (defaultVisibility() == HideWarnings) { - value = "hide"; - } - - QSettings settings; - settings.setValue("warnings", value); -} - -void LoggerWidget::warningsPreferenceChanged(QAction *action) -{ - Visibility newSetting = static_cast<Visibility>(action->data().toInt()); - m_visibility = newSetting; - saveSettings(); -} - -void LoggerWidget::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - emit opened(); -} - -void LoggerWidget::closeEvent(QCloseEvent *event) -{ - QWidget::closeEvent(event); - emit closed(); -} - -void LoggerWidget::setupPreferencesMenu() -{ - m_preferencesMenu = new QMenu(tr("Warnings")); - QActionGroup *warnings = new QActionGroup(m_preferencesMenu); - warnings->setExclusive(true); - - connect(warnings, SIGNAL(triggered(QAction*)), this, SLOT(warningsPreferenceChanged(QAction*))); - - QAction *showWarningsPreference = new QAction(tr("Show by default"), m_preferencesMenu); - showWarningsPreference->setCheckable(true); - showWarningsPreference->setData(LoggerWidget::ShowWarnings); - warnings->addAction(showWarningsPreference); - m_preferencesMenu->addAction(showWarningsPreference); - - QAction *hideWarningsPreference = new QAction(tr("Hide by default"), m_preferencesMenu); - hideWarningsPreference->setCheckable(true); - hideWarningsPreference->setData(LoggerWidget::HideWarnings); - warnings->addAction(hideWarningsPreference); - m_preferencesMenu->addAction(hideWarningsPreference); - - QAction *autoWarningsPreference = new QAction(tr("Show for first warning"), m_preferencesMenu); - autoWarningsPreference->setCheckable(true); - autoWarningsPreference->setData(LoggerWidget::AutoShowWarnings); - warnings->addAction(autoWarningsPreference); - m_preferencesMenu->addAction(autoWarningsPreference); - - switch (defaultVisibility()) { - case LoggerWidget::ShowWarnings: - showWarningsPreference->setChecked(true); - break; - case LoggerWidget::HideWarnings: - hideWarningsPreference->setChecked(true); - break; - default: - autoWarningsPreference->setChecked(true); - } -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/loggerwidget.h b/src/tools/qml/qmlobserver/loggerwidget.h deleted file mode 100644 index 13c319f91a..0000000000 --- a/src/tools/qml/qmlobserver/loggerwidget.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LOGGERWIDGET_H -#define LOGGERWIDGET_H - -#include <QMainWindow> -#include <QMetaType> - -QT_BEGIN_NAMESPACE - -class QPlainTextEdit; -class QMenu; -class QAction; - -class LoggerWidget : public QMainWindow { - Q_OBJECT -public: - LoggerWidget(QWidget *parent=0); - - enum Visibility { ShowWarnings, HideWarnings, AutoShowWarnings }; - - Visibility defaultVisibility() const; - void setDefaultVisibility(Visibility visibility); - - QMenu *preferencesMenu(); - QAction *showAction(); - -public slots: - void append(const QString &msg); - -private slots: - void warningsPreferenceChanged(QAction *action); - void readSettings(); - void saveSettings(); - -protected: - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *event); - -signals: - void opened(); - void closed(); - -private: - void setupPreferencesMenu(); - - QMenu *m_preferencesMenu; - QAction *m_showWidgetAction; - QPlainTextEdit *m_plainTextEdit; - - enum ConfigOrigin { CommandLineOrigin, SettingsOrigin }; - ConfigOrigin m_visibilityOrigin; - Visibility m_visibility; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(LoggerWidget::Visibility) - -#endif // LOGGERWIDGET_H diff --git a/src/tools/qml/qmlobserver/main.cpp b/src/tools/qml/qmlobserver/main.cpp deleted file mode 100644 index f04640d970..0000000000 --- a/src/tools/qml/qmlobserver/main.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarative.h" -#include "qmlruntime.h" -#include "qdeclarativeengine.h" -#include "loggerwidget.h" -#include <QWidget> -#include <QDir> -#include <QApplication> -#include <QTranslator> -#include <QDebug> -#include <QMessageBox> -#include "qdeclarativetester.h" - -QT_USE_NAMESPACE - -QtMsgHandler systemMsgOutput = 0; - -#if defined (Q_OS_SYMBIAN) -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -void myMessageOutput(QtMsgType type, const char *msg) -{ - static int fd = -1; - if (fd == -1) - fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT); - - ::write(fd, msg, strlen(msg)); - ::write(fd, "\n", 1); - ::fsync(fd); - - switch (type) { - case QtFatalMsg: - abort(); - } -} - -#else // !defined (Q_OS_SYMBIAN) - -QWeakPointer<LoggerWidget> logger; - -QString warnings; -void showWarnings() -{ - if (!warnings.isEmpty()) { - int argc = 0; char **argv = 0; - QApplication application(argc, argv); // QApplication() in main has been destroyed already. - Q_UNUSED(application) - QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings); - } -} - -void myMessageOutput(QtMsgType type, const char *msg) -{ - if (!logger.isNull()) { - QString strMsg = QString::fromAscii(msg); - QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); - } else { - warnings += msg; - warnings += QLatin1Char('\n'); - } - if (systemMsgOutput) { // Windows - systemMsgOutput(type, msg); - } else { // Unix - fprintf(stderr, "%s\n",msg); - fflush(stderr); - } -} - -#endif - -void usage() -{ - qWarning("Usage: qmlviewer [options] <filename>"); - qWarning(" "); - qWarning(" options:"); - qWarning(" -v, -version ............................. display version"); - qWarning(" -frameless ............................... run with no window frame"); - qWarning(" -maximized................................ run maximized"); - qWarning(" -fullscreen............................... run fullscreen"); - qWarning(" -stayontop................................ keep viewer window on top"); - qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); - qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)"); - qWarning(" -qmlbrowser .............................. use a QML-based file browser"); - qWarning(" -warnings [show|hide]..................... show warnings in a separate log window"); - qWarning(" -recordfile <output> ..................... set video recording file"); - qWarning(" - ImageMagick 'convert' for GIF)"); - qWarning(" - png file for raw frames"); - qWarning(" - 'ffmpeg' for other formats"); - qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode"); - qWarning(" -recordrate <fps> ........................ set recording frame rate"); - qWarning(" -record arg .............................. add a recording process argument"); - qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop"); - qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); - qWarning(" -netcache <size> ......................... set disk cache to size bytes"); - qWarning(" -translation <translationfile> ........... set the language to run in"); - qWarning(" -I <directory> ........................... prepend to the module import search path,"); - qWarning(" display path if <directory> is empty"); - qWarning(" -P <directory> ........................... prepend to the plugin search path"); - qWarning(" -opengl .................................. use a QGLWidget for the viewport"); - qWarning(" -script <path> ........................... set the script to use"); - qWarning(" -scriptopts <options>|help ............... set the script options to use"); - - qWarning(" "); - qWarning(" Press F1 for interactive help"); - exit(1); -} - -void scriptOptsUsage() -{ - qWarning("Usage: qmlviewer -scriptopts <option>[,<option>...] ..."); - qWarning(" options:"); - qWarning(" record ................................... record a new script"); - qWarning(" play ..................................... playback an existing script"); - qWarning(" testimages ............................... record images or compare images on playback"); - qWarning(" testerror ................................ test 'error' property of root item on playback"); - qWarning(" snapshot ................................. file being recorded is static,"); - qWarning(" only one frame will be recorded or tested"); - qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion"); - qWarning(" exitonfailure ............................ immediately exit the viewer on script failure"); - qWarning(" saveonexit ............................... save recording on viewer exit"); - qWarning(" "); - qWarning(" One of record, play or both must be specified."); - exit(1); -} - -enum WarningsConfig { ShowWarnings, HideWarnings, DefaultWarnings }; - -int main(int argc, char ** argv) -{ -#if defined (Q_OS_SYMBIAN) - qInstallMsgHandler(myMessageOutput); -#else - systemMsgOutput = qInstallMsgHandler(myMessageOutput); -#endif - -#if defined (Q_OS_WIN) - // Debugging output is not visible by default on Windows - - // therefore show modal dialog with errors instead. - atexit(showWarnings); -#endif - -#if defined (Q_WS_X11) || defined (Q_WS_MAC) - //### default to using raster graphics backend for now - bool gsSpecified = false; - for (int i = 0; i < argc; ++i) { - QString arg = argv[i]; - if (arg == "-graphicssystem") { - gsSpecified = true; - break; - } - } - - if (!gsSpecified) - QApplication::setGraphicsSystem("raster"); -#endif - - QApplication app(argc, argv); - app.setApplicationName("QtQmlViewer"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); - - QDeclarativeViewer::registerTypes(); - QDeclarativeTester::registerTypes(); - - bool frameless = false; - QString fileName; - double fps = 0; - int autorecord_from = 0; - int autorecord_to = 0; - QString dither = "none"; - QString recordfile; - QStringList recordargs; - QStringList imports; - QStringList plugins; - QString script; - QString scriptopts; - bool runScript = false; - bool devkeys = false; - int cache = 0; - QString translationFile; - bool useGL = false; - bool fullScreen = false; - bool stayOnTop = false; - bool maximized = false; - bool useNativeFileBrowser = true; - bool experimentalGestures = false; - bool designModeBehavior = false; - bool debuggerModeBehavior = false; - - WarningsConfig warningsConfig = DefaultWarnings; - bool sizeToView = true; - -#if defined(Q_OS_SYMBIAN) - maximized = true; - useNativeFileBrowser = false; -#endif - -#if defined(Q_WS_MAC) - useGL = true; -#endif - - for (int i = 1; i < argc; ++i) { - bool lastArg = (i == argc - 1); - QString arg = argv[i]; - if (arg == "-frameless") { - frameless = true; - } else if (arg == "-maximized") { - maximized = true; - } else if (arg == "-fullscreen") { - fullScreen = true; - } else if (arg == "-stayontop") { - stayOnTop = true; - } else if (arg == "-netcache") { - if (lastArg) usage(); - cache = QString(argv[++i]).toInt(); - } else if (arg == "-recordrate") { - if (lastArg) usage(); - fps = QString(argv[++i]).toDouble(); - } else if (arg == "-recordfile") { - if (lastArg) usage(); - recordfile = QString(argv[++i]); - } else if (arg == "-record") { - if (lastArg) usage(); - recordargs << QString(argv[++i]); - } else if (arg == "-recorddither") { - if (lastArg) usage(); - dither = QString(argv[++i]); - } else if (arg == "-autorecord") { - if (lastArg) usage(); - QString range = QString(argv[++i]); - int dash = range.indexOf('-'); - if (dash > 0) - autorecord_from = range.left(dash).toInt(); - autorecord_to = range.mid(dash+1).toInt(); - } else if (arg == "-devicekeys") { - devkeys = true; - } else if (arg == "-dragthreshold") { - if (lastArg) usage(); - app.setStartDragDistance(QString(argv[++i]).toInt()); - } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { - qWarning("Qt QML Viewer version %s", QT_VERSION_STR); - exit(0); - } else if (arg == "-translation") { - if (lastArg) usage(); - translationFile = argv[++i]; - } else if (arg == "-opengl") { - useGL = true; - } else if (arg == "-qmlbrowser") { - useNativeFileBrowser = false; - } else if (arg == "-warnings") { - if (lastArg) usage(); - QString warningsStr = QString(argv[++i]); - if (warningsStr == QLatin1String("show")) { - warningsConfig = ShowWarnings; - } else if (warningsStr == QLatin1String("hide")) { - warningsConfig = HideWarnings; - } else { - usage(); - } - } else if (arg == "-I" || arg == "-L") { - if (arg == "-L") - qWarning("-L option provided for compatibility only, use -I instead"); - if (lastArg) { - QDeclarativeEngine tmpEngine; - QString paths = tmpEngine.importPathList().join(QLatin1String(":")); - qWarning("Current search path: %s", paths.toLocal8Bit().constData()); - exit(0); - } - imports << QString(argv[++i]); - } else if (arg == "-P") { - if (lastArg) usage(); - plugins << QString(argv[++i]); - } else if (arg == "-script") { - if (lastArg) usage(); - script = QString(argv[++i]); - } else if (arg == "-scriptopts") { - if (lastArg) usage(); - scriptopts = QString(argv[++i]); - } else if (arg == "-savescript") { - if (lastArg) usage(); - script = QString(argv[++i]); - runScript = false; - } else if (arg == "-playscript") { - if (lastArg) usage(); - script = QString(argv[++i]); - runScript = true; - } else if (arg == "-sizeviewtorootobject") { - sizeToView = false; - } else if (arg == "-sizerootobjecttoview") { - sizeToView = true; - } else if (arg == "-experimentalgestures") { - experimentalGestures = true; - } else if (arg == "-designmode") { - designModeBehavior = true; - } else if (arg == "-debugger") { - debuggerModeBehavior = true; - } else if (arg[0] != '-') { - fileName = arg; - } else if (1 || arg == "-help") { - usage(); - } - } - - QTranslator qmlTranslator; - if (!translationFile.isEmpty()) { - qmlTranslator.load(translationFile); - app.installTranslator(&qmlTranslator); - } - - Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget); - if (stayOnTop) - wflags |= Qt::WindowStaysOnTopHint; - - QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags); - viewer->setAttribute(Qt::WA_DeleteOnClose, true); - if (!scriptopts.isEmpty()) { - QStringList options = - scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); - - QDeclarativeViewer::ScriptOptions scriptOptions = 0; - for (int i = 0; i < options.count(); ++i) { - const QString &option = options.at(i); - if (option == QLatin1String("help")) { - scriptOptsUsage(); - } else if (option == QLatin1String("play")) { - scriptOptions |= QDeclarativeViewer::Play; - } else if (option == QLatin1String("record")) { - scriptOptions |= QDeclarativeViewer::Record; - } else if (option == QLatin1String("testimages")) { - scriptOptions |= QDeclarativeViewer::TestImages; - } else if (option == QLatin1String("testerror")) { - scriptOptions |= QDeclarativeViewer::TestErrorProperty; - } else if (option == QLatin1String("exitoncomplete")) { - scriptOptions |= QDeclarativeViewer::ExitOnComplete; - } else if (option == QLatin1String("exitonfailure")) { - scriptOptions |= QDeclarativeViewer::ExitOnFailure; - } else if (option == QLatin1String("saveonexit")) { - scriptOptions |= QDeclarativeViewer::SaveOnExit; - } else if (option == QLatin1String("snapshot")) { - scriptOptions |= QDeclarativeViewer::Snapshot; - } else { - scriptOptsUsage(); - } - } - - if (script.isEmpty()) - usage(); - - if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play)) - scriptOptsUsage(); - viewer->setScriptOptions(scriptOptions); - viewer->setScript(script); - } else if (!script.isEmpty()) { - usage(); - } - -#if !defined(Q_OS_SYMBIAN) - logger = viewer->warningsWidget(); - if (warningsConfig == ShowWarnings) { - logger.data()->setDefaultVisibility(LoggerWidget::ShowWarnings); - logger.data()->show(); - } else if (warningsConfig == HideWarnings){ - logger.data()->setDefaultVisibility(LoggerWidget::HideWarnings); - } -#endif - - if (experimentalGestures) - viewer->enableExperimentalGestures(); - - viewer->setDesignModeBehavior(designModeBehavior); - - // FIXME debug mode is always on for qml observer - debuggerModeBehavior = true; - viewer->setDebugMode(debuggerModeBehavior); - - foreach (QString lib, imports) - viewer->addLibraryPath(lib); - - foreach (QString plugin, plugins) - viewer->addPluginPath(plugin); - - viewer->setNetworkCacheSize(cache); - viewer->setRecordFile(recordfile); - viewer->setSizeToView(sizeToView); - if (fps>0) - viewer->setRecordRate(fps); - if (autorecord_to) - viewer->setAutoRecord(autorecord_from,autorecord_to); - if (devkeys) - viewer->setDeviceKeys(true); - viewer->setRecordDither(dither); - if (recordargs.count()) - viewer->setRecordArgs(recordargs); - - viewer->setUseNativeFileBrowser(useNativeFileBrowser); - if (fullScreen && maximized) - qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; - - if (fileName.isEmpty()) { - QFile qmlapp(QLatin1String("qmlapp")); - if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) { - QString content = QString::fromUtf8(qmlapp.readAll()); - qmlapp.close(); - - int newline = content.indexOf(QLatin1Char('\n')); - if (newline >= 0) - fileName = content.left(newline); - else - fileName = content; - } - } - - if (!fileName.isEmpty()) { - viewer->open(fileName); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); - } else { - if (!useNativeFileBrowser) - viewer->openFile(); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); - if (useNativeFileBrowser) - viewer->openFile(); - } - viewer->setUseGL(useGL); - viewer->raise(); - - return app.exec(); -} diff --git a/src/tools/qml/qmlobserver/proxysettings.cpp b/src/tools/qml/qmlobserver/proxysettings.cpp deleted file mode 100644 index ffaa4c0a29..0000000000 --- a/src/tools/qml/qmlobserver/proxysettings.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QIntValidator> -#include <QSettings> - -#include "proxysettings.h" - -QT_BEGIN_NAMESPACE - -ProxySettings::ProxySettings (QWidget * parent) - : QDialog (parent), Ui::ProxySettings() -{ - setupUi (this); - -#if !defined Q_WS_MAEMO_5 - // the onscreen keyboard can't cope with masks - proxyServerEdit->setInputMask ("000.000.000.000;_"); -#endif - QIntValidator *validator = new QIntValidator (0, 9999, this); - proxyPortEdit->setValidator (validator); - - QSettings settings; - proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ()); - proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ()); - proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ()); - usernameEdit->insert (settings.value ("http_proxy/username", "").toString ()); - passwordEdit->insert (settings.value ("http_proxy/password", "").toString ()); -} - -ProxySettings::~ProxySettings() -{ -} - -void ProxySettings::accept () -{ - QSettings settings; - - settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ()); - settings.setValue ("http_proxy/hostname", proxyServerEdit->text ()); - settings.setValue ("http_proxy/port", proxyPortEdit->text ()); - settings.setValue ("http_proxy/username", usernameEdit->text ()); - settings.setValue ("http_proxy/password", passwordEdit->text ()); - - QDialog::accept (); -} - -QNetworkProxy ProxySettings::httpProxy () -{ - QSettings settings; - QNetworkProxy proxy; - - bool proxyInUse = settings.value ("http_proxy/use", 0).toBool (); - if (proxyInUse) { - proxy.setType (QNetworkProxy::HttpProxy); - proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5" - proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080 - proxy.setUser (settings.value ("http_proxy/username", "").toString ()); - proxy.setPassword (settings.value ("http_proxy/password", "").toString ()); - //QNetworkProxy::setApplicationProxy (proxy); - } - else { - proxy.setType (QNetworkProxy::NoProxy); - } - return proxy; -} - -bool ProxySettings::httpProxyInUse() -{ - QSettings settings; - return settings.value ("http_proxy/use", 0).toBool (); -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/proxysettings.h b/src/tools/qml/qmlobserver/proxysettings.h deleted file mode 100644 index 5d4d137a99..0000000000 --- a/src/tools/qml/qmlobserver/proxysettings.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PROXYSETTINGS_H -#define PROXYSETTINGS_H - -#include <QDialog> -#include <QNetworkProxy> -#ifdef Q_WS_MAEMO_5 -#include "ui_proxysettings_maemo5.h" -#else -#include "ui_proxysettings.h" -#endif - -QT_BEGIN_NAMESPACE -/** -*/ -class ProxySettings : public QDialog, public Ui::ProxySettings -{ - -Q_OBJECT - -public: - ProxySettings(QWidget * parent = 0); - - ~ProxySettings(); - - static QNetworkProxy httpProxy (); - static bool httpProxyInUse (); - -public slots: - virtual void accept (); -}; - -QT_END_NAMESPACE - -#endif // PROXYSETTINGS_H diff --git a/src/tools/qml/qmlobserver/proxysettings.ui b/src/tools/qml/qmlobserver/proxysettings.ui deleted file mode 100644 index 84e39fe03d..0000000000 --- a/src/tools/qml/qmlobserver/proxysettings.ui +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProxySettings</class> - <widget class="QDialog" name="ProxySettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>318</width> - <height>199</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="proxyCheckBox"> - <property name="text"> - <string>Use http proxy</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="serverAddressLabel"> - <property name="text"> - <string>Server Address:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="proxyServerEdit"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Port:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="proxyPortEdit"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="usernameLabel"> - <property name="text"> - <string>Username:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="usernameEdit"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="passwordLabel"> - <property name="text"> - <string>Password:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="passwordEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="5" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProxySettings</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProxySettings</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/tools/qml/qmlobserver/proxysettings_maemo5.ui b/src/tools/qml/qmlobserver/proxysettings_maemo5.ui deleted file mode 100644 index 83f0c2a9de..0000000000 --- a/src/tools/qml/qmlobserver/proxysettings_maemo5.ui +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProxySettings</class> - <widget class="QDialog" name="ProxySettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>449</width> - <height>164</height> - </rect> - </property> - <property name="windowTitle"> - <string>HTTP Proxy</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="leftMargin"> - <number>16</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>16</number> - </property> - <property name="bottomMargin"> - <number>8</number> - </property> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QCheckBox" name="proxyCheckBox"> - <property name="text"> - <string>Use HTTP Proxy</string> - </property> - </widget> - </item> - <item row="0" column="1" rowspan="2"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" rowspan="2"> - <widget class="QWidget" name="widget" native="true"> - <layout class="QGridLayout" name="gridLayout"> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="serverAddressLabel"> - <property name="text"> - <string>Server</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="proxyServerEdit"> - <property name="placeholderText"> - <string>Name or IP</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Port</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="proxyPortEdit"> - <property name="text"> - <string>8080</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="usernameLabel"> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="usernameEdit"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="passwordLabel"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="passwordEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="2" column="1"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>proxyCheckBox</tabstop> - <tabstop>proxyServerEdit</tabstop> - <tabstop>proxyPortEdit</tabstop> - <tabstop>usernameEdit</tabstop> - <tabstop>passwordEdit</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProxySettings</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>318</x> - <y>100</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>116</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProxySettings</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>318</x> - <y>100</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>116</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/tools/qml/qmlobserver/qdeclarativetester.cpp b/src/tools/qml/qmlobserver/qdeclarativetester.cpp deleted file mode 100644 index 9864df63ce..0000000000 --- a/src/tools/qml/qmlobserver/qdeclarativetester.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qdeclarativetester.h> -#include <QDebug> -#include <QApplication> -#include <qdeclarativeview.h> -#include <QFile> -#include <QDeclarativeComponent> -#include <QDir> -#include <QCryptographicHash> -#include <private/qabstractanimation_p.h> -#include <private/qdeclarativeitem_p.h> - -QT_BEGIN_NAMESPACE - - -QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts, - QDeclarativeView *parent) -: QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts), - testscript(0), hasCompleted(false), hasFailed(false) -{ - parent->viewport()->installEventFilter(this); - parent->installEventFilter(this); - QUnifiedTimer::instance()->setConsistentTiming(true); - if (options & QDeclarativeViewer::Play) - this->run(); - start(); -} - -QDeclarativeTester::~QDeclarativeTester() -{ - if (!hasFailed && - options & QDeclarativeViewer::Record && - options & QDeclarativeViewer::SaveOnExit) - save(); -} - -int QDeclarativeTester::duration() const -{ - return -1; -} - -void QDeclarativeTester::addMouseEvent(Destination dest, QMouseEvent *me) -{ - MouseEvent e(me); - e.destination = dest; - m_mouseEvents << e; -} - -void QDeclarativeTester::addKeyEvent(Destination dest, QKeyEvent *ke) -{ - KeyEvent e(ke); - e.destination = dest; - m_keyEvents << e; -} - -bool QDeclarativeTester::eventFilter(QObject *o, QEvent *e) -{ - if (!filterEvents) - return false; - - Destination destination; - if (o == m_view) { - destination = View; - } else if (o == m_view->viewport()) { - destination = ViewPort; - } else { - return false; - } - - switch (e->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: - addKeyEvent(destination, (QKeyEvent *)e); - return true; - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - case QEvent::MouseButtonDblClick: - addMouseEvent(destination, (QMouseEvent *)e); - return true; - default: - break; - } - return false; -} - -void QDeclarativeTester::executefailure() -{ - hasFailed = true; - - if (options & QDeclarativeViewer::ExitOnFailure) - exit(-1); -} - -void QDeclarativeTester::imagefailure() -{ - hasFailed = true; - - if (options & QDeclarativeViewer::ExitOnFailure) - exit(-1); -} - -void QDeclarativeTester::complete() -{ - if ((options & QDeclarativeViewer::TestErrorProperty) && !hasFailed) { - QString e = m_view->rootObject()->property("error").toString(); - if (!e.isEmpty()) { - qWarning() << "Test failed:" << e; - hasFailed = true; - } - } - if (options & QDeclarativeViewer::ExitOnComplete) - QApplication::exit(hasFailed?-1:0); - - if (hasCompleted) - return; - hasCompleted = true; - - if (options & QDeclarativeViewer::Play) - qWarning("Script playback complete"); -} - -void QDeclarativeTester::run() -{ - QDeclarativeComponent c(m_view->engine(), m_script + QLatin1String(".qml")); - - testscript = qobject_cast<QDeclarativeVisualTest *>(c.create()); - if (testscript) testscript->setParent(this); - else { executefailure(); exit(-1); } - testscriptidx = 0; -} - -void QDeclarativeTester::save() -{ - QString filename = m_script + QLatin1String(".qml"); - QFileInfo filenameInfo(filename); - QDir saveDir = filenameInfo.absoluteDir(); - saveDir.mkpath("."); - - QFile file(filename); - file.open(QIODevice::WriteOnly); - QTextStream ts(&file); - - ts << "import Qt.VisualTest 4.7\n\n"; - ts << "VisualTest {\n"; - - int imgCount = 0; - QList<KeyEvent> keyevents = m_savedKeyEvents; - QList<MouseEvent> mouseevents = m_savedMouseEvents; - for (int ii = 0; ii < m_savedFrameEvents.count(); ++ii) { - const FrameEvent &fe = m_savedFrameEvents.at(ii); - ts << " Frame {\n"; - ts << " msec: " << fe.msec << "\n"; - if (!fe.hash.isEmpty()) { - ts << " hash: \"" << fe.hash.toHex() << "\"\n"; - } else if (!fe.image.isNull()) { - QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png"; - fe.image.save(m_script + "." + QString::number(imgCount) + ".png"); - imgCount++; - ts << " image: \"" << filename << "\"\n"; - } - ts << " }\n"; - - while (!mouseevents.isEmpty() && - mouseevents.first().msec == fe.msec) { - MouseEvent me = mouseevents.takeFirst(); - - ts << " Mouse {\n"; - ts << " type: " << me.type << "\n"; - ts << " button: " << me.button << "\n"; - ts << " buttons: " << me.buttons << "\n"; - ts << " x: " << me.pos.x() << "; y: " << me.pos.y() << "\n"; - ts << " modifiers: " << me.modifiers << "\n"; - if (me.destination == ViewPort) - ts << " sendToViewport: true\n"; - ts << " }\n"; - } - - while (!keyevents.isEmpty() && - keyevents.first().msec == fe.msec) { - KeyEvent ke = keyevents.takeFirst(); - - ts << " Key {\n"; - ts << " type: " << ke.type << "\n"; - ts << " key: " << ke.key << "\n"; - ts << " modifiers: " << ke.modifiers << "\n"; - ts << " text: \"" << ke.text.toUtf8().toHex() << "\"\n"; - ts << " autorep: " << (ke.autorep?"true":"false") << "\n"; - ts << " count: " << ke.count << "\n"; - if (ke.destination == ViewPort) - ts << " sendToViewport: true\n"; - ts << " }\n"; - } - } - - ts << "}\n"; - file.close(); -} - -void QDeclarativeTester::updateCurrentTime(int msec) -{ - QDeclarativeItemPrivate::setConsistentTime(msec); - if (!testscript && msec > 16 && options & QDeclarativeViewer::Snapshot) - return; - - QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32); - - if (options & QDeclarativeViewer::TestImages) { - img.fill(qRgb(255,255,255)); - QPainter p(&img); - m_view->render(&p); - } - - bool snapshot = msec == 16 && (options & QDeclarativeViewer::Snapshot - || (testscript && testscript->count() == 2)); - - FrameEvent fe; - fe.msec = msec; - if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) { - // Skip first frame, skip if not doing images - } else if (0 == (m_savedFrameEvents.count() % 60) || snapshot) { - fe.image = img; - } else { - QCryptographicHash hash(QCryptographicHash::Md5); - hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height()); - fe.hash = hash.result(); - } - m_savedFrameEvents.append(fe); - - // Deliver mouse events - filterEvents = false; - - if (!testscript) { - for (int ii = 0; ii < m_mouseEvents.count(); ++ii) { - MouseEvent &me = m_mouseEvents[ii]; - me.msec = msec; - QMouseEvent event(me.type, me.pos, me.button, me.buttons, me.modifiers); - - if (me.destination == View) { - QCoreApplication::sendEvent(m_view, &event); - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - } - } - - for (int ii = 0; ii < m_keyEvents.count(); ++ii) { - KeyEvent &ke = m_keyEvents[ii]; - ke.msec = msec; - QKeyEvent event(ke.type, ke.key, ke.modifiers, ke.text, ke.autorep, ke.count); - - if (ke.destination == View) { - QCoreApplication::sendEvent(m_view, &event); - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - } - } - m_savedMouseEvents.append(m_mouseEvents); - m_savedKeyEvents.append(m_keyEvents); - } - - m_mouseEvents.clear(); - m_keyEvents.clear(); - - // Advance test script - while (testscript && testscript->count() > testscriptidx) { - - QObject *event = testscript->event(testscriptidx); - - if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) { - if (frame->msec() < msec) { - if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) { - qWarning() << "QDeclarativeTester: Extra frame. Seen:" - << msec << "Expected:" << frame->msec(); - imagefailure(); - } - } else if (frame->msec() == msec) { - if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) { - if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) { - qWarning() << "QDeclarativeTester: Mismatched frame hash at" << msec - << ". Seen:" << fe.hash.toHex() - << "Expected:" << frame->hash().toUtf8(); - imagefailure(); - } - } - } else if (frame->msec() > msec) { - break; - } - - if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) { - QImage goodImage(frame->image().toLocalFile()); - if (goodImage != img) { - QString reject(frame->image().toLocalFile() + ".reject.png"); - qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:" - << reject; - img.save(reject); - bool doDiff = (goodImage.size() == img.size()); - if (doDiff) { - QImage diffimg(m_view->width(), m_view->height(), QImage::Format_RGB32); - diffimg.fill(qRgb(255,255,255)); - QPainter p(&diffimg); - int diffCount = 0; - for (int x = 0; x < img.width(); ++x) { - for (int y = 0; y < img.height(); ++y) { - if (goodImage.pixel(x,y) != img.pixel(x,y)) { - ++diffCount; - p.drawPoint(x,y); - } - } - } - QString diff(frame->image().toLocalFile() + ".diff.png"); - diffimg.save(diff); - qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff; - } - imagefailure(); - } - } - } else if (QDeclarativeVisualTestMouse *mouse = qobject_cast<QDeclarativeVisualTestMouse *>(event)) { - QPoint pos(mouse->x(), mouse->y()); - QPoint globalPos = m_view->mapToGlobal(QPoint(0, 0)) + pos; - QMouseEvent event((QEvent::Type)mouse->type(), pos, globalPos, (Qt::MouseButton)mouse->button(), (Qt::MouseButtons)mouse->buttons(), (Qt::KeyboardModifiers)mouse->modifiers()); - - MouseEvent me(&event); - me.msec = msec; - if (!mouse->sendToViewport()) { - QCoreApplication::sendEvent(m_view, &event); - me.destination = View; - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - me.destination = ViewPort; - } - m_savedMouseEvents.append(me); - } else if (QDeclarativeVisualTestKey *key = qobject_cast<QDeclarativeVisualTestKey *>(event)) { - - QKeyEvent event((QEvent::Type)key->type(), key->key(), (Qt::KeyboardModifiers)key->modifiers(), QString::fromUtf8(QByteArray::fromHex(key->text().toUtf8())), key->autorep(), key->count()); - - KeyEvent ke(&event); - ke.msec = msec; - if (!key->sendToViewport()) { - QCoreApplication::sendEvent(m_view, &event); - ke.destination = View; - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - ke.destination = ViewPort; - } - m_savedKeyEvents.append(ke); - } - testscriptidx++; - } - - filterEvents = true; - - if (testscript && testscript->count() <= testscriptidx) { - //if (msec == 16) //for a snapshot, leave it up long enough to see - // (void)::sleep(1); - complete(); - } -} - -void QDeclarativeTester::registerTypes() -{ - qmlRegisterType<QDeclarativeVisualTest>("Qt.VisualTest", 4,7, "VisualTest"); - qmlRegisterType<QDeclarativeVisualTestFrame>("Qt.VisualTest", 4,7, "Frame"); - qmlRegisterType<QDeclarativeVisualTestMouse>("Qt.VisualTest", 4,7, "Mouse"); - qmlRegisterType<QDeclarativeVisualTestKey>("Qt.VisualTest", 4,7, "Key"); -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/qdeclarativetester.h b/src/tools/qml/qmlobserver/qdeclarativetester.h deleted file mode 100644 index 021869d93a..0000000000 --- a/src/tools/qml/qmlobserver/qdeclarativetester.h +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETESTER_H -#define QDECLARATIVETESTER_H - -#include <QEvent> -#include <QMouseEvent> -#include <QKeyEvent> -#include <QImage> -#include <QUrl> -#include <qmlruntime.h> -#include <qdeclarativelist.h> -#include <qdeclarative.h> -#include <QAbstractAnimation> - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTest : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty<QObject> events READ events CONSTANT) - Q_CLASSINFO("DefaultProperty", "events") -public: - QDeclarativeVisualTest() {} - - QDeclarativeListProperty<QObject> events() { return QDeclarativeListProperty<QObject>(this, m_events); } - - int count() const { return m_events.count(); } - QObject *event(int idx) { return m_events.at(idx); } - -private: - QList<QObject *> m_events; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTest) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestFrame : public QObject -{ - Q_OBJECT - Q_PROPERTY(int msec READ msec WRITE setMsec) - Q_PROPERTY(QString hash READ hash WRITE setHash) - Q_PROPERTY(QUrl image READ image WRITE setImage) -public: - QDeclarativeVisualTestFrame() : m_msec(-1) {} - - int msec() const { return m_msec; } - void setMsec(int m) { m_msec = m; } - - QString hash() const { return m_hash; } - void setHash(const QString &hash) { m_hash = hash; } - - QUrl image() const { return m_image; } - void setImage(const QUrl &image) { m_image = image; } - -private: - int m_msec; - QString m_hash; - QUrl m_image; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestFrame) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestMouse : public QObject -{ - Q_OBJECT - Q_PROPERTY(int type READ type WRITE setType) - Q_PROPERTY(int button READ button WRITE setButton) - Q_PROPERTY(int buttons READ buttons WRITE setButtons) - Q_PROPERTY(int x READ x WRITE setX) - Q_PROPERTY(int y READ y WRITE setY) - Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers) - Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport) -public: - QDeclarativeVisualTestMouse() : m_type(0), m_button(0), m_buttons(0), m_x(0), m_y(0), m_modifiers(0), m_viewport(false) {} - - int type() const { return m_type; } - void setType(int t) { m_type = t; } - - int button() const { return m_button; } - void setButton(int b) { m_button = b; } - - int buttons() const { return m_buttons; } - void setButtons(int b) { m_buttons = b; } - - int x() const { return m_x; } - void setX(int x) { m_x = x; } - - int y() const { return m_y; } - void setY(int y) { m_y = y; } - - int modifiers() const { return m_modifiers; } - void setModifiers(int modifiers) { m_modifiers = modifiers; } - - bool sendToViewport() const { return m_viewport; } - void setSendToViewport(bool v) { m_viewport = v; } -private: - int m_type; - int m_button; - int m_buttons; - int m_x; - int m_y; - int m_modifiers; - bool m_viewport; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestMouse) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestKey : public QObject -{ - Q_OBJECT - Q_PROPERTY(int type READ type WRITE setType) - Q_PROPERTY(int key READ key WRITE setKey) - Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers) - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(bool autorep READ autorep WRITE setAutorep) - Q_PROPERTY(int count READ count WRITE setCount) - Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport) -public: - QDeclarativeVisualTestKey() : m_type(0), m_key(0), m_modifiers(0), m_autorep(false), m_count(0), m_viewport(false) {} - - int type() const { return m_type; } - void setType(int t) { m_type = t; } - - int key() const { return m_key; } - void setKey(int k) { m_key = k; } - - int modifiers() const { return m_modifiers; } - void setModifiers(int m) { m_modifiers = m; } - - QString text() const { return m_text; } - void setText(const QString &t) { m_text = t; } - - bool autorep() const { return m_autorep; } - void setAutorep(bool a) { m_autorep = a; } - - int count() const { return m_count; } - void setCount(int c) { m_count = c; } - - bool sendToViewport() const { return m_viewport; } - void setSendToViewport(bool v) { m_viewport = v; } -private: - int m_type; - int m_key; - int m_modifiers; - QString m_text; - bool m_autorep; - int m_count; - bool m_viewport; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestKey) - -QT_BEGIN_NAMESPACE - -class QDeclarativeTester : public QAbstractAnimation -{ -public: - QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions options, QDeclarativeView *parent); - ~QDeclarativeTester(); - - static void registerTypes(); - - virtual int duration() const; - - void run(); - void save(); - - void executefailure(); -protected: - virtual void updateCurrentTime(int msecs); - virtual bool eventFilter(QObject *, QEvent *); - -private: - QString m_script; - - void imagefailure(); - void complete(); - - enum Destination { View, ViewPort }; - void addKeyEvent(Destination, QKeyEvent *); - void addMouseEvent(Destination, QMouseEvent *); - QDeclarativeView *m_view; - - struct MouseEvent { - MouseEvent(QMouseEvent *e) - : type(e->type()), button(e->button()), buttons(e->buttons()), - pos(e->pos()), modifiers(e->modifiers()), destination(View) {} - - QEvent::Type type; - Qt::MouseButton button; - Qt::MouseButtons buttons; - QPoint pos; - Qt::KeyboardModifiers modifiers; - Destination destination; - - int msec; - }; - struct KeyEvent { - KeyEvent(QKeyEvent *e) - : type(e->type()), key(e->key()), modifiers(e->modifiers()), text(e->text()), - autorep(e->isAutoRepeat()), count(e->count()), destination(View) {} - QEvent::Type type; - int key; - Qt::KeyboardModifiers modifiers; - QString text; - bool autorep; - ushort count; - Destination destination; - - int msec; - }; - struct FrameEvent { - QImage image; - QByteArray hash; - int msec; - }; - QList<MouseEvent> m_mouseEvents; - QList<KeyEvent> m_keyEvents; - - QList<MouseEvent> m_savedMouseEvents; - QList<KeyEvent> m_savedKeyEvents; - QList<FrameEvent> m_savedFrameEvents; - bool filterEvents; - - QDeclarativeViewer::ScriptOptions options; - int testscriptidx; - QDeclarativeVisualTest *testscript; - - bool hasCompleted; - bool hasFailed; -}; - - -QT_END_NAMESPACE - -#endif // QDECLARATIVETESTER_H diff --git a/src/tools/qml/qmlobserver/qml.icns b/src/tools/qml/qmlobserver/qml.icns Binary files differdeleted file mode 100644 index c76051626a..0000000000 --- a/src/tools/qml/qmlobserver/qml.icns +++ /dev/null diff --git a/src/tools/qml/qmlobserver/qml.pri b/src/tools/qml/qmlobserver/qml.pri deleted file mode 100644 index 7d9a503fb6..0000000000 --- a/src/tools/qml/qmlobserver/qml.pri +++ /dev/null @@ -1,36 +0,0 @@ -QT += declarative script network sql - -contains(QT_CONFIG, opengl) { - QT += opengl - DEFINES += GL_SUPPORTED -} - -INCLUDEPATH += $$PWD - -HEADERS += $$PWD/qmlruntime.h \ - $$PWD/proxysettings.h \ - $$PWD/qdeclarativetester.h \ - $$PWD/deviceorientation.h \ - $$PWD/loggerwidget.h - - -SOURCES += $$PWD/qmlruntime.cpp \ - $$PWD/proxysettings.cpp \ - $$PWD/qdeclarativetester.cpp \ - $$PWD/loggerwidget.cpp - -RESOURCES += $$PWD/qmlruntime.qrc - -OTHER_FILES += toolbarstyle.css - -maemo5 { - QT += dbus - HEADERS += $$PWD/texteditautoresizer_maemo5.h - SOURCES += $$PWD/deviceorientation_maemo5.cpp - FORMS += $$PWD/recopts_maemo5.ui \ - $$PWD/proxysettings_maemo5.ui -} else { - SOURCES += $$PWD/deviceorientation.cpp - FORMS += $$PWD/recopts.ui \ - $$PWD/proxysettings.ui -} diff --git a/src/tools/qml/qmlobserver/qmlobserver.pro b/src/tools/qml/qmlobserver/qmlobserver.pro deleted file mode 100644 index 765a1f839f..0000000000 --- a/src/tools/qml/qmlobserver/qmlobserver.pro +++ /dev/null @@ -1,30 +0,0 @@ -TEMPLATE = app -QT += declarative - -include(qml.pri) - -SOURCES += main.cpp -include(../../../../qtcreator.pri) - -include(../../../../share/qtcreator/qmljsdebugger/qmljsdebugger.pri) -include(../../../libs/utils/utils.pri) -mac { - qmljsLibraryTarget = $$qtLibraryName(QmlJSDebugger) - utilsLibraryTarget = $$qtLibraryName(Utils) -} - - -include(../../../private_headers.pri) -DESTDIR = $$IDE_BIN_PATH -include(../../../rpath.pri) - -mac { - QMAKE_INFO_PLIST=Info_mac.plist - TARGET=QMLObserver - ICON=qml.icns - QMAKE_POST_LINK=install_name_tool -change @executable_path/../PlugIns/lib$${qmljsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${qmljsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\' \ - && install_name_tool -change @executable_path/../PlugIns/lib$${utilsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${utilsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\' -} else { - TARGET=qmlobserver -} - diff --git a/src/tools/qml/qmlobserver/qmlruntime.cpp b/src/tools/qml/qmlobserver/qmlruntime.cpp deleted file mode 100644 index 0fbacbe364..0000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.cpp +++ /dev/null @@ -1,1581 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qdeclarativeview.h> - -#ifdef hz -#undef hz -#endif -#ifdef Q_WS_MAEMO_5 -# include <QMaemo5ValueButton> -# include <QMaemo5ListPickSelector> -# include <QWidgetAction> -# include <QStringListModel> -# include "ui_recopts_maemo5.h" -#else -# include "ui_recopts.h" -#endif - -#include <qdeclarativeviewobserver.h> -#include <qdeclarativeobserverservice.h> -#include <utils/crumblepath.h> - -#include "qmlruntime.h" -#include <qdeclarativecontext.h> -#include <qdeclarativeengine.h> -#include <qdeclarativenetworkaccessmanagerfactory.h> -#include "qdeclarative.h" -#include <QAbstractAnimation> -#include <private/qabstractanimation_p.h> - -#include <QSettings> -#include <QXmlStreamReader> -#include <QBuffer> -#include <QNetworkReply> -#include <QNetworkCookieJar> -#include <QNetworkDiskCache> -#include <QNetworkAccessManager> -#include <QSignalMapper> -#include <QDeclarativeComponent> -#include <QWidget> -#include <QApplication> -#include <QTranslator> -#include <QDir> -#include <QTextBrowser> -#include <QFile> -#include <QFileInfo> -#include <QVBoxLayout> -#include <QProgressDialog> -#include <QProcess> -#include <QMenuBar> -#include <QMenu> -#include <QAction> -#include <QFileDialog> -#include <QTimer> -#include <QGraphicsObject> -#include <QNetworkProxyFactory> -#include <QKeyEvent> -#include <QToolBar> -#include <QMutex> -#include <QMutexLocker> -#include "proxysettings.h" -#include "deviceorientation.h" -#include <QInputDialog> - -#ifdef GL_SUPPORTED -#include <QGLWidget> -#endif - -#include <qdeclarativetester.h> -#include "jsdebuggeragent.h" - -QT_BEGIN_NAMESPACE - -class Runtime : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool isActiveWindow READ isActiveWindow NOTIFY isActiveWindowChanged) - Q_PROPERTY(DeviceOrientation::Orientation orientation READ orientation NOTIFY orientationChanged) - -public: - static Runtime* instance() - { - static Runtime *instance = 0; - if (!instance) - instance = new Runtime; - return instance; - } - - bool isActiveWindow() const { return activeWindow; } - void setActiveWindow(bool active) - { - if (active == activeWindow) - return; - activeWindow = active; - emit isActiveWindowChanged(); - } - - DeviceOrientation::Orientation orientation() const { return DeviceOrientation::instance()->orientation(); } - -Q_SIGNALS: - void isActiveWindowChanged(); - void orientationChanged(); - -private: - Runtime(QObject *parent=0) : QObject(parent), activeWindow(false) - { - connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), - this, SIGNAL(orientationChanged())); - } - - bool activeWindow; -}; - - - -#if defined(Q_WS_MAEMO_5) - -class Maemo5PickerAction : public QWidgetAction { - Q_OBJECT -public: - Maemo5PickerAction(const QString &text, QActionGroup *actions, QObject *parent) - : QWidgetAction(parent), m_text(text), m_actions(actions) - { } - - QWidget *createWidget(QWidget *parent) - { - QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent); - button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered); - QMaemo5ListPickSelector *pick = new QMaemo5ListPickSelector(button); - button->setPickSelector(pick); - if (m_actions) { - QStringList sl; - int curIdx = -1, idx = 0; - foreach (QAction *a, m_actions->actions()) { - sl << a->text(); - if (a->isChecked()) - curIdx = idx; - idx++; - } - pick->setModel(new QStringListModel(sl)); - pick->setCurrentIndex(curIdx); - } else { - button->setEnabled(false); - } - connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered())); - return button; - } - -private slots: - void emitTriggered() - { - QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender()); - if (!pick) - return; - int idx = pick->currentIndex(); - - if (m_actions && idx >= 0 && idx < m_actions->actions().count()) - m_actions->actions().at(idx)->trigger(); - } - -private: - QString m_text; - QPointer<QActionGroup> m_actions; -}; - -#endif // Q_WS_MAEMO_5 - -static struct { const char *name, *args; } ffmpegprofiles[] = { - {"Maximum Quality", "-sameq"}, - {"High Quality", "-qmax 2"}, - {"Medium Quality", "-qmax 6"}, - {"Low Quality", "-qmax 16"}, - {"Custom ffmpeg arguments", ""}, - {0,0} -}; - -class RecordingDialog : public QDialog, public Ui::RecordingOptions { - Q_OBJECT - -public: - RecordingDialog(QWidget *parent) : QDialog(parent) - { - setupUi(this); -#ifndef Q_WS_MAEMO_5 - hz->setValidator(new QDoubleValidator(hz)); -#endif - for (int i=0; ffmpegprofiles[i].name; ++i) { - profile->addItem(ffmpegprofiles[i].name); - } - } - - void setArguments(QString a) - { - int i; - for (i=0; ffmpegprofiles[i].args[0]; ++i) { - if (ffmpegprofiles[i].args == a) { - profile->setCurrentIndex(i); - args->setText(QLatin1String(ffmpegprofiles[i].args)); - return; - } - } - customargs = a; - args->setText(a); - profile->setCurrentIndex(i); - } - - QString arguments() const - { - int i = profile->currentIndex(); - return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs; - } - - void setOriginalSize(const QSize &s) - { - QString str = tr("Original (%1x%2)").arg(s.width()).arg(s.height()); - -#ifdef Q_WS_MAEMO_5 - sizeCombo->setItemText(0, str); -#else - sizeOriginal->setText(str); - if (sizeWidth->value()<=1) { - sizeWidth->setValue(s.width()); - sizeHeight->setValue(s.height()); - } -#endif - } - - void showffmpegOptions(bool b) - { -#ifdef Q_WS_MAEMO_5 - profileLabel->setVisible(b); - profile->setVisible(b); - ffmpegHelp->setVisible(b); - args->setVisible(b); -#else - ffmpegOptions->setVisible(b); -#endif - } - - void showRateOptions(bool b) - { -#ifdef Q_WS_MAEMO_5 - rateLabel->setVisible(b); - rateCombo->setVisible(b); -#else - rateOptions->setVisible(b); -#endif - } - - void setVideoRate(int rate) - { -#ifdef Q_WS_MAEMO_5 - int idx; - if (rate >= 60) - idx = 0; - else if (rate >= 50) - idx = 2; - else if (rate >= 25) - idx = 3; - else if (rate >= 24) - idx = 4; - else if (rate >= 20) - idx = 5; - else if (rate >= 15) - idx = 6; - else - idx = 7; - rateCombo->setCurrentIndex(idx); -#else - if (rate == 24) - hz24->setChecked(true); - else if (rate == 25) - hz25->setChecked(true); - else if (rate == 50) - hz50->setChecked(true); - else if (rate == 60) - hz60->setChecked(true); - else { - hzCustom->setChecked(true); - hz->setText(QString::number(rate)); - } -#endif - } - - int videoRate() const - { -#ifdef Q_WS_MAEMO_5 - switch (rateCombo->currentIndex()) { - case 0: return 60; - case 1: return 50; - case 2: return 25; - case 3: return 24; - case 4: return 20; - case 5: return 15; - case 7: return 10; - default: return 60; - } -#else - if (hz24->isChecked()) - return 24; - else if (hz25->isChecked()) - return 25; - else if (hz50->isChecked()) - return 50; - else if (hz60->isChecked()) - return 60; - else { - return hz->text().toInt(); - } -#endif - } - - QSize videoSize() const - { -#ifdef Q_WS_MAEMO_5 - switch (sizeCombo->currentIndex()) { - case 0: return QSize(); - case 1: return QSize(640,480); - case 2: return QSize(320,240); - case 3: return QSize(1280,720); - default: return QSize(); - } -#else - if (sizeOriginal->isChecked()) - return QSize(); - else if (size720p->isChecked()) - return QSize(1280,720); - else if (sizeVGA->isChecked()) - return QSize(640,480); - else if (sizeQVGA->isChecked()) - return QSize(320,240); - else - return QSize(sizeWidth->value(), sizeHeight->value()); -#endif - } - - - -private slots: - void pickProfile(int i) - { - if (ffmpegprofiles[i].args[0]) { - args->setText(QLatin1String(ffmpegprofiles[i].args)); - } else { - args->setText(customargs); - } - } - - void storeCustomArgs(QString s) - { - setArguments(s); - } - -private: - QString customargs; -}; - -class PersistentCookieJar : public QNetworkCookieJar { -public: - PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); } - ~PersistentCookieJar() { save(); } - - virtual QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const - { - QMutexLocker lock(&mutex); - return QNetworkCookieJar::cookiesForUrl(url); - } - - virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) - { - QMutexLocker lock(&mutex); - return QNetworkCookieJar::setCookiesFromUrl(cookieList, url); - } - -private: - void save() - { - QMutexLocker lock(&mutex); - QList<QNetworkCookie> list = allCookies(); - QByteArray data; - foreach (QNetworkCookie cookie, list) { - if (!cookie.isSessionCookie()) { - data.append(cookie.toRawForm()); - data.append("\n"); - } - } - QSettings settings; - settings.setValue("Cookies",data); - } - - void load() - { - QMutexLocker lock(&mutex); - QSettings settings; - QByteArray data = settings.value("Cookies").toByteArray(); - setAllCookies(QNetworkCookie::parseCookies(data)); - } - - mutable QMutex mutex; -}; - -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - NetworkAccessManagerFactory() : cacheSize(0) {} - ~NetworkAccessManagerFactory() {} - - QNetworkAccessManager *create(QObject *parent); - - void setupProxy(QNetworkAccessManager *nam) - { - class SystemProxyFactory : public QNetworkProxyFactory - { - public: - virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query) - { - QString protocolTag = query.protocolTag(); - if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) { - QList<QNetworkProxy> ret; - ret << httpProxy; - return ret; - } -#ifdef Q_OS_WIN - // systemProxyForQuery can take insanely long on Windows (QTBUG-10106) - return QNetworkProxyFactory::proxyForQuery(query); -#else - return QNetworkProxyFactory::systemProxyForQuery(query); -#endif - } - void setHttpProxy (QNetworkProxy proxy) - { - httpProxy = proxy; - httpProxyInUse = true; - } - void unsetHttpProxy () - { - httpProxyInUse = false; - } - private: - bool httpProxyInUse; - QNetworkProxy httpProxy; - }; - - SystemProxyFactory *proxyFactory = new SystemProxyFactory; - if (ProxySettings::httpProxyInUse()) - proxyFactory->setHttpProxy(ProxySettings::httpProxy()); - else - proxyFactory->unsetHttpProxy(); - nam->setProxyFactory(proxyFactory); - } - - void setCacheSize(int size) { - if (size != cacheSize) { - cacheSize = size; - } - } - - static PersistentCookieJar *cookieJar; - QMutex mutex; - int cacheSize; -}; - -PersistentCookieJar *NetworkAccessManagerFactory::cookieJar = 0; - -static void cleanup_cookieJar() -{ - delete NetworkAccessManagerFactory::cookieJar; - NetworkAccessManagerFactory::cookieJar = 0; -} - -QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) -{ - QMutexLocker lock(&mutex); - QNetworkAccessManager *manager = new QNetworkAccessManager(parent); - if (!cookieJar) { - qAddPostRoutine(cleanup_cookieJar); - cookieJar = new PersistentCookieJar(0); - } - manager->setCookieJar(cookieJar); - cookieJar->setParent(0); - setupProxy(manager); - if (cacheSize > 0) { - QNetworkDiskCache *cache = new QNetworkDiskCache; - cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache")); - cache->setMaximumCacheSize(cacheSize); - manager->setCache(cache); - } else { - manager->setCache(0); - } - qDebug() << "created new network access manager for" << parent; - return manager; -} - -// -// Event filter that ensures the crumble path width is always the canvas width -// -class CrumblePathResizer : public QObject -{ - Q_OBJECT -public: - CrumblePathResizer(Utils::CrumblePath *crumblePathWidget, QObject *parent = 0) : - QObject(parent), - m_crumblePathWidget(crumblePathWidget) - { - } - - bool eventFilter(QObject *obj, QEvent *event) - { - if (event->type() == QEvent::Resize) { - QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event); - m_crumblePathWidget->resize(resizeEvent->size().width(), m_crumblePathWidget->height()); - } - return QObject::eventFilter(obj, event); - } - -private: - QWidget *m_crumblePathWidget; -}; - -QString QDeclarativeViewer::getVideoFileName() -{ - QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames"); - QStringList types; - if (ffmpegAvailable) types += tr("Common Video files")+QLatin1String(" (*.avi *.mpeg *.mov)"); - if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)"); - types += tr("Individual PNG frames")+QLatin1String(" (*.png)"); - if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)"); - return QFileDialog::getSaveFileName(this, title, "", types.join(";; ")); -} - -QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) - : QMainWindow(parent, flags) - , loggerWindow(new LoggerWidget(this)) - , frame_stream(0) - , orientation(0) - , showWarningsWindow(0) - , designModeBehaviorAction(0) - , m_scriptOptions(0) - , tester(0) - , useQmlFileBrowser(true) - , m_centralWidget(0) - , m_crumblePathWidget(0) - , translator(0) -{ - QDeclarativeViewer::registerTypes(); - setWindowTitle(tr("Qt QML Viewer")); -#ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5StackedWindow); -// setPalette(QApplication::palette("QLabel")); -#endif - - devicemode = false; - canvas = 0; - record_autotime = 0; - record_rate = 50; - record_args += QLatin1String("-sameq"); - - recdlg = new RecordingDialog(this); - connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile())); - senseFfmpeg(); - senseImageMagick(); - if (!ffmpegAvailable) - recdlg->showffmpegOptions(false); - if (!ffmpegAvailable && !convertAvailable) - recdlg->showRateOptions(false); - QString warn; - if (!ffmpegAvailable) { - if (!convertAvailable) - warn = tr("ffmpeg and ImageMagick not available - no video output"); - else - warn = tr("ffmpeg not available - GIF and PNG outputs only"); - recdlg->warning->setText(warn); - } else { - recdlg->warning->hide(); - } - - canvas = new QDeclarativeView(this); - observer = new QmlJSDebugger::QDeclarativeViewObserver(canvas, this); - if (!(flags & Qt::FramelessWindowHint)) { - m_crumblePathWidget = new Utils::CrumblePath(canvas); -#ifndef Q_WS_MAC - m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }"); -#endif - m_crumblePathWidget->setVisible(observer->designModeBehavior()); - - // CrumblePath is not in a layout, so that it overlays the central widget - // The event filter ensures that its width stays in sync nevertheless - CrumblePathResizer *resizer = new CrumblePathResizer(m_crumblePathWidget, m_crumblePathWidget); - canvas->installEventFilter(resizer); - } - - m_centralWidget = new QWidget(this); - QVBoxLayout *layout = new QVBoxLayout(m_centralWidget); - layout->setMargin(0); - layout->setSpacing(0); - - - layout->addWidget(canvas); - m_centralWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - canvas->setAttribute(Qt::WA_OpaquePaintEvent); - canvas->setAttribute(Qt::WA_NoSystemBackground); - - canvas->setFocus(); - - QObject::connect(observer, SIGNAL(reloadRequested()), this, SLOT(reload())); - QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); - QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged())); - if (m_crumblePathWidget) { - QObject::connect(observer, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear())); - QObject::connect(observer, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString))); - QObject::connect(observer, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement())); - QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), observer, SLOT(setObserverContext(int))); - QObject::connect(observer, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool))); - } - QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); - - QObject::connect(warningsWidget(), SIGNAL(opened()), this, SLOT(warningsWidgetOpened())); - QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed())); - - if (!(flags & Qt::FramelessWindowHint)) { - createMenu(); - changeOrientation(orientation->actions().value(0)); - } else { - setMenuBar(0); - } - - setCentralWidget(m_centralWidget); - - namFactory = new NetworkAccessManagerFactory; - canvas->engine()->setNetworkAccessManagerFactory(namFactory); - - connect(&autoStartTimer, SIGNAL(timeout()), this, SLOT(autoStartRecording())); - connect(&autoStopTimer, SIGNAL(timeout()), this, SLOT(autoStopRecording())); - connect(&recordTimer, SIGNAL(timeout()), this, SLOT(recordFrame())); - connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), - this, SLOT(orientationChanged()), Qt::QueuedConnection); - autoStartTimer.setSingleShot(true); - autoStopTimer.setSingleShot(true); - recordTimer.setSingleShot(false); - - QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(appAboutToQuit())); -} - -QDeclarativeViewer::~QDeclarativeViewer() -{ - delete loggerWindow; - canvas->engine()->setNetworkAccessManagerFactory(0); - delete namFactory; -} - -void QDeclarativeViewer::setDesignModeBehavior(bool value) -{ - if (designModeBehaviorAction) - designModeBehaviorAction->setChecked(value); - observer->setDesignModeBehavior(value); -} - -void QDeclarativeViewer::setDebugMode(bool on) -{ - observer->setDebugMode(on); -} - -void QDeclarativeViewer::enableExperimentalGestures() -{ - canvas->viewport()->grabGesture(Qt::TapGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); - canvas->viewport()->grabGesture(Qt::TapAndHoldGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); - canvas->viewport()->grabGesture(Qt::PanGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); - canvas->viewport()->grabGesture(Qt::PinchGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); - canvas->viewport()->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); - canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); -} - -QDeclarativeView *QDeclarativeViewer::view() const -{ - return canvas; -} - -LoggerWidget *QDeclarativeViewer::warningsWidget() const -{ - return loggerWindow; -} - -void QDeclarativeViewer::createMenu() -{ - QAction *openAction = new QAction(tr("&Open..."), this); - openAction->setShortcut(QKeySequence("Ctrl+O")); - connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - - QAction *reloadAction = new QAction(tr("&Reload"), this); - reloadAction->setShortcut(QKeySequence("Ctrl+R")); - connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); - - QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this); - snapshotAction->setShortcut(QKeySequence("F3")); - connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot())); - - recordAction = new QAction(tr("Start Recording &Video"), this); - recordAction->setShortcut(QKeySequence("F9")); - connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); - - QAction *recordOptions = new QAction(tr("Video &Options..."), this); - connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); - - QMenu *playSpeedMenu = new QMenu(tr("Animation Speed"), this); - QActionGroup *playSpeedMenuActions = new QActionGroup(this); - playSpeedMenuActions->setExclusive(true); - - QAction *speedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setChecked(true); - animationSpeed = 1.0f; - speedAction->setData(1.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(2.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(4.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(8.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(10.0f); - playSpeedMenuActions->addAction(speedAction); - - pauseAnimationsAction = playSpeedMenu->addAction(tr("Pause"), this, SLOT(setAnimationsPaused(bool))); - pauseAnimationsAction->setCheckable(true); - pauseAnimationsAction->setShortcut(QKeySequence("Ctrl+.")); - - animationStepAction = playSpeedMenu->addAction(tr("Pause and step"), this, SLOT(stepAnimations())); - animationStepAction->setShortcut(QKeySequence("Ctrl+,")); - - animationSetStepAction = playSpeedMenu->addAction(tr("Set step"), this, SLOT(setAnimationStep())); - m_stepSize = 40; - - QAction *playSpeedAction = new QAction(tr("Animations"), this); - playSpeedAction->setMenu(playSpeedMenu); - - showWarningsWindow = new QAction(tr("Show Warnings"), this); - showWarningsWindow->setCheckable((true)); - showWarningsWindow->setChecked(loggerWindow->isVisible()); - connect(showWarningsWindow, SIGNAL(triggered(bool)), this, SLOT(showWarnings(bool))); - - designModeBehaviorAction = new QAction(tr("&Observer Mode"), this); - designModeBehaviorAction->setShortcut(QKeySequence("Ctrl+D")); - designModeBehaviorAction->setCheckable(true); - designModeBehaviorAction->setChecked(observer->designModeBehavior()); - designModeBehaviorAction->setEnabled(QmlJSDebugger::QDeclarativeObserverService::hasDebuggingClient()); - connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool))); - connect(observer, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool))); - connect(QmlJSDebugger::QDeclarativeObserverService::instance(), SIGNAL(debuggingClientChanged(bool)), designModeBehaviorAction, SLOT(setEnabled(bool))); - - QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this); - connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings())); - - QAction *fullscreenAction = new QAction(tr("Full Screen"), this); - fullscreenAction->setCheckable(true); - connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); - - QAction *rotateOrientation = new QAction(tr("Rotate orientation"), this); - rotateOrientation->setShortcut(QKeySequence("Ctrl+T")); - connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation())); - - orientation = new QActionGroup(this); - orientation->setExclusive(true); - connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*))); - - QAction *portraitAction = new QAction(tr("Portrait"), this); - portraitAction->setCheckable(true); - QAction *landscapeAction = new QAction(tr("Landscape"), this); - landscapeAction->setCheckable(true); - QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this); - portraitInvAction->setCheckable(true); - QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this); - landscapeInvAction->setCheckable(true); - - QAction *aboutAction = new QAction(tr("&About Qt..."), this); - connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - - QAction *quitAction = new QAction(tr("&Quit"), this); - quitAction->setShortcut(QKeySequence("Ctrl+Q")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - QMenuBar *menu = menuBar(); - if (!menu) - return; - -#if defined(Q_WS_MAEMO_5) - menu->addAction(openAction); - menu->addAction(reloadAction); - - menu->addAction(snapshotAction); - menu->addAction(recordAction); - - menu->addAction(recordOptions); - menu->addAction(proxyAction); - - menu->addAction(playSpeedMenu); - menu->addAction(showWarningsWindow); - - orientation->addAction(landscapeAction); - orientation->addAction(portraitAction); - menu->addAction(new Maemo5PickerAction(tr("Set orientation"), orientation, this)); - menu->addAction(fullscreenAction); - return; -#endif // Q_WS_MAEMO_5 - - QMenu *fileMenu = menu->addMenu(tr("&File")); - fileMenu->addAction(openAction); - fileMenu->addAction(reloadAction); - fileMenu->addSeparator(); - fileMenu->addAction(quitAction); - -#if !defined(Q_OS_SYMBIAN) - QMenu *recordMenu = menu->addMenu(tr("&Recording")); - recordMenu->addAction(snapshotAction); - recordMenu->addAction(recordAction); - - QMenu *debugMenu = menu->addMenu(tr("&Debugging")); - debugMenu->addAction(playSpeedAction); - debugMenu->addAction(showWarningsWindow); - debugMenu->addAction(designModeBehaviorAction); -#endif // ! Q_OS_SYMBIAN - - QMenu *settingsMenu = menu->addMenu(tr("S&ettings")); - settingsMenu->addAction(proxyAction); -#if !defined(Q_OS_SYMBIAN) - settingsMenu->addAction(recordOptions); - settingsMenu->addMenu(loggerWindow->preferencesMenu()); -#else // ! Q_OS_SYMBIAN - settingsMenu->addAction(fullscreenAction); -#endif // Q_OS_SYMBIAN - settingsMenu->addAction(rotateOrientation); - - QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties")); - - orientation->addAction(portraitAction); - orientation->addAction(landscapeAction); - orientation->addAction(portraitInvAction); - orientation->addAction(landscapeInvAction); - propertiesMenu->addActions(orientation->actions()); - - QMenu *helpMenu = menu->addMenu(tr("&Help")); - helpMenu->addAction(aboutAction); -} - -void QDeclarativeViewer::showProxySettings() -{ - ProxySettings settingsDlg (this); - - connect (&settingsDlg, SIGNAL (accepted()), this, SLOT (proxySettingsChanged ())); - - settingsDlg.exec(); -} - -void QDeclarativeViewer::proxySettingsChanged() -{ - reload (); -} - -void QDeclarativeViewer::rotateOrientation() -{ - QAction *current = orientation->checkedAction(); - QList<QAction *> actions = orientation->actions(); - int index = actions.indexOf(current); - if (index < 0) - return; - - QAction *newOrientation = actions[(index + 1) % actions.count()]; - changeOrientation(newOrientation); -} - -void QDeclarativeViewer::toggleFullScreen() -{ - if (isFullScreen()) - showMaximized(); - else - showFullScreen(); -} - -void QDeclarativeViewer::showWarnings(bool show) -{ - loggerWindow->setVisible(show); -} - -void QDeclarativeViewer::warningsWidgetOpened() -{ - showWarningsWindow->setChecked(true); -} - -void QDeclarativeViewer::warningsWidgetClosed() -{ - showWarningsWindow->setChecked(false); -} - -void QDeclarativeViewer::takeSnapShot() -{ - static int snapshotcount = 1; - QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount); - QPixmap::grabWidget(canvas).save(snapFileName); - qDebug() << "Wrote" << snapFileName; - ++snapshotcount; -} - -void QDeclarativeViewer::pickRecordingFile() -{ - QString fileName = getVideoFileName(); - if (!fileName.isEmpty()) - recdlg->file->setText(fileName); -} - -void QDeclarativeViewer::chooseRecordingOptions() -{ - // File - recdlg->file->setText(record_file); - - // Size - recdlg->setOriginalSize(canvas->size()); - - // Rate - recdlg->setVideoRate(record_rate); - - - // Profile - recdlg->setArguments(record_args.join(" ")); - if (recdlg->exec()) { - // File - record_file = recdlg->file->text(); - // Size - record_outsize = recdlg->videoSize(); - // Rate - record_rate = recdlg->videoRate(); - // Profile - record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); - } -} - -void QDeclarativeViewer::toggleRecordingWithSelection() -{ - if (!recordTimer.isActive()) { - if (record_file.isEmpty()) { - QString fileName = getVideoFileName(); - if (fileName.isEmpty()) - return; - if (!fileName.contains(QRegExp(".[^\\/]*$"))) - fileName += ".avi"; - setRecordFile(fileName); - } - } - toggleRecording(); -} - -void QDeclarativeViewer::toggleRecording() -{ - if (record_file.isEmpty()) { - toggleRecordingWithSelection(); - return; - } - bool recording = !recordTimer.isActive(); - recordAction->setText(recording ? tr("&Stop Recording Video\tF9") : tr("&Start Recording Video\tF9")); - setRecording(recording); -} - -void QDeclarativeViewer::setAnimationsPaused(bool enable) -{ - if (enable) { - setAnimationSpeed(0.0); - } else { - setAnimationSpeed(animationSpeed); - } -} - -void QDeclarativeViewer::pauseAnimations() { - pauseAnimationsAction->setChecked(true); - setAnimationsPaused(true); -} - -void QDeclarativeViewer::stepAnimations() -{ - setAnimationSpeed(1.0); - QTimer::singleShot(m_stepSize, this, SLOT(pauseAnimations())); -} - -void QDeclarativeViewer::setAnimationStep() -{ - bool ok; - int stepSize = QInputDialog::getInt(this, tr("Set animation step duration"), - tr("Step duration (ms):"), m_stepSize, 20, 10000, 1, &ok); - if (ok) m_stepSize = stepSize; -} - -void QDeclarativeViewer::changeAnimationSpeed() -{ - QAction *action = qobject_cast<QAction*>(sender()); - if (action) { - float f = action->data().toFloat(); - animationSpeed = f; - if (!pauseAnimationsAction->isChecked()) - setAnimationSpeed(animationSpeed); - } -} - -void QDeclarativeViewer::addLibraryPath(const QString& lib) -{ - canvas->engine()->addImportPath(lib); -} - -void QDeclarativeViewer::addPluginPath(const QString& plugin) -{ - canvas->engine()->addPluginPath(plugin); -} - -void QDeclarativeViewer::reload() -{ - observer->setDesignModeBehavior(false); - open(currentFileOrUrl); -} - -void QDeclarativeViewer::openFile() -{ - QString cur = canvas->source().toLocalFile(); - if (useQmlFileBrowser) { - open("qrc:/content/Browser.qml"); - } else { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); - if (!fileName.isEmpty()) { - QFileInfo fi(fileName); - open(fi.absoluteFilePath()); - } - } -} - -void QDeclarativeViewer::statusChanged() -{ - if (canvas->status() == QDeclarativeView::Error && tester) - tester->executefailure(); - - if (canvas->status() == QDeclarativeView::Ready) { - initialSize = canvas->initialSize(); - updateSizeHints(true); - } -} - -void QDeclarativeViewer::launch(const QString& file_or_url) -{ - QMetaObject::invokeMethod(this, "open", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); -} - -void QDeclarativeViewer::loadTranslationFile(const QString& directory) -{ - if (!translator) { - translator = new QTranslator(this); - QApplication::installTranslator(translator); - } - - translator->load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); -} - -void QDeclarativeViewer::loadDummyDataFiles(const QString& directory) -{ - QDir dir(directory+"/dummydata", "*.qml"); - QStringList list = dir.entryList(); - for (int i = 0; i < list.size(); ++i) { - QString qml = list.at(i); - QFile f(dir.filePath(qml)); - f.open(QIODevice::ReadOnly); - QByteArray data = f.readAll(); - QDeclarativeComponent comp(canvas->engine()); - comp.setData(data, QUrl()); - QObject *dummyData = comp.create(); - - if(comp.isError()) { - QList<QDeclarativeError> errors = comp.errors(); - foreach (const QDeclarativeError &error, errors) { - qWarning() << error; - } - if (tester) tester->executefailure(); - } - - if (dummyData) { - qWarning() << "Loaded dummy data:" << dir.filePath(qml); - qml.truncate(qml.length()-4); - canvas->rootContext()->setContextProperty(qml, dummyData); - dummyData->setParent(this); - } - } -} - -bool QDeclarativeViewer::open(const QString& file_or_url) -{ - currentFileOrUrl = file_or_url; - - QUrl url; - QFileInfo fi(file_or_url); - if (fi.exists()) - url = QUrl::fromLocalFile(fi.absoluteFilePath()); - else - url = QUrl(file_or_url); - setWindowTitle(tr("%1 - Qt QML Viewer").arg(file_or_url)); - - if (!m_script.isEmpty()) - tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas); - - delete canvas->rootObject(); - canvas->engine()->clearComponentCache(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("qmlViewer", this); -#ifdef Q_OS_SYMBIAN - ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone -#else - ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath()); -#endif - - ctxt->setContextProperty("runtime", Runtime::instance()); - - QString fileName = url.toLocalFile(); - if (!fileName.isEmpty()) { - fi.setFile(fileName); - if (fi.exists()) { - if (fi.suffix().toLower() != QLatin1String("qml")) { - qWarning() << "qml cannot open non-QML file" << fileName; - return false; - } - - QFileInfo fi(fileName); - loadTranslationFile(fi.path()); - loadDummyDataFiles(fi.path()); - } else { - qWarning() << "qml cannot find file:" << fileName; - return false; - } - } - - QTime t; - t.start(); - - canvas->setSource(url); - - return true; -} - -void QDeclarativeViewer::setAutoRecord(int from, int to) -{ - if (from==0) from=1; // ensure resized - record_autotime = to-from; - autoStartTimer.setInterval(from); - autoStartTimer.start(); -} - -void QDeclarativeViewer::setRecordArgs(const QStringList& a) -{ - record_args = a; -} - -void QDeclarativeViewer::setRecordFile(const QString& f) -{ - record_file = f; -} - -void QDeclarativeViewer::setRecordRate(int fps) -{ - record_rate = fps; -} - -void QDeclarativeViewer::sceneResized(QSize) -{ - updateSizeHints(); -} - -void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_0 && devicemode) - exit(0); - else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) { - qDebug() << "F1 - help\n" - << "F2 - save test script\n" - << "F3 - take PNG snapshot\n" - << "F4 - show items and state\n" - << "F5 - reload QML\n" - << "F6 - show object tree\n" - << "F7 - show timing\n" - << "F9 - toggle video recording\n" - << "F10 - toggle orientation\n" - << "device keys: 0=quit, 1..8=F1..F8" - ; - } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { - if (tester && m_scriptOptions & Record) - tester->save(); - } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { - takeSnapShot(); - } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) { - reload(); - } else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) { - toggleRecording(); - } else if (event->key() == Qt::Key_F10) { - rotateOrientation(); - } - - QWidget::keyPressEvent(event); -} - -bool QDeclarativeViewer::event(QEvent *event) -{ - if (event->type() == QEvent::WindowActivate) { - Runtime::instance()->setActiveWindow(true); - } else if (event->type() == QEvent::WindowDeactivate) { - Runtime::instance()->setActiveWindow(false); - } - return QWidget::event(event); -} - -void QDeclarativeViewer::senseImageMagick() -{ - QProcess proc; - proc.start("convert", QStringList() << "-h"); - proc.waitForFinished(2000); - QString help = proc.readAllStandardOutput(); - convertAvailable = help.contains("ImageMagick"); -} - -void QDeclarativeViewer::senseFfmpeg() -{ - QProcess proc; - proc.start("ffmpeg", QStringList() << "-h"); - proc.waitForFinished(2000); - QString ffmpegHelp = proc.readAllStandardOutput(); - ffmpegAvailable = ffmpegHelp.contains("-s "); - ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp; - - QDialog *d = new QDialog(recdlg); - QVBoxLayout *l = new QVBoxLayout(d); - QTextBrowser *b = new QTextBrowser(d); - QFont f = b->font(); - f.setFamily("courier"); - b->setFont(f); - b->setText(ffmpegHelp); - l->addWidget(b); - d->setLayout(l); - ffmpegHelpWindow = d; - connect(recdlg->ffmpegHelp,SIGNAL(clicked()), ffmpegHelpWindow, SLOT(show())); -} - -void QDeclarativeViewer::setRecording(bool on) -{ - if (on == recordTimer.isActive()) - return; - - int period = int(1000/record_rate+0.5); - QUnifiedTimer::instance()->setTimingInterval(on ? period:16); - QUnifiedTimer::instance()->setConsistentTiming(on); - if (on) { - canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - recordTimer.setInterval(period); - recordTimer.start(); - frame_fmt = record_file.right(4).toLower(); - frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); - if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) { - // Stream video to ffmpeg - - QProcess *proc = new QProcess(this); - connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int))); - frame_stream = proc; - - QStringList args; - args << "-y"; - args << "-r" << QString::number(record_rate); - args << "-f" << "rawvideo"; - args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32"); - args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height()); - args << "-i" << "-"; - if (record_outsize.isValid()) { - args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height()); - args << "-aspect" << QString::number(double(canvas->width())/canvas->height()); - } - args += record_args; - args << record_file; - proc->start("ffmpeg",args); - - } else { - // Store frames, save to GIF/PNG - frame_stream = 0; - } - } else { - canvas->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); - recordTimer.stop(); - if (frame_stream) { - qDebug() << "Saving video..."; - frame_stream->close(); - qDebug() << "Wrote" << record_file; - } else { - QProgressDialog progress(tr("Saving frames..."), tr("Cancel"), 0, frames.count()+10, this); - progress.setWindowModality(Qt::WindowModal); - - int frame=0; - QStringList inputs; - qDebug() << "Saving frames..."; - - QString framename; - bool png_output = false; - if (record_file.right(4).toLower()==".png") { - if (record_file.contains('%')) - framename = record_file; - else - framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4); - png_output = true; - } else { - framename = "tmp-frame%04d.png"; - png_output = false; - } - foreach (QImage* img, frames) { - progress.setValue(progress.value()+1); - if (progress.wasCanceled()) - break; - QString name; - name.sprintf(framename.toLocal8Bit(),frame++); - if (record_outsize.isValid()) - *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); - if (record_dither=="ordered") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); - else if (record_dither=="threshold") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name); - else if (record_dither=="floyd") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name); - else - img->save(name); - inputs << name; - delete img; - } - - if (!progress.wasCanceled()) { - if (png_output) { - framename.replace(QRegExp("%\\d*."),"*"); - qDebug() << "Wrote frames" << framename; - inputs.clear(); // don't remove them - } else { - // ImageMagick and gifsicle for GIF encoding - progress.setLabelText(tr("Converting frames to GIF file...")); - QStringList args; - args << "-delay" << QString::number(period/10); - args << inputs; - args << record_file; - qDebug() << "Converting..." << record_file << "(this may take a while)"; - if (0!=QProcess::execute("convert", args)) { - qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted"; - inputs.clear(); // don't remove them - qDebug() << "Wrote frames tmp-frame*.png"; - } else { - if (record_file.right(4).toLower() == ".gif") { - qDebug() << "Compressing..." << record_file; - if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file)) - qWarning() << "Cannot run 'gifsicle' - not compressed"; - } - qDebug() << "Wrote" << record_file; - } - } - } - - progress.setValue(progress.maximum()-1); - foreach (QString name, inputs) - QFile::remove(name); - - frames.clear(); - } - } - qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); -} - -void QDeclarativeViewer::ffmpegFinished(int code) -{ - qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError(); -} - -void QDeclarativeViewer::appAboutToQuit() -{ - // avoid QGLContext errors about invalid contexts on exit - canvas->setViewport(0); - - // avoid crashes if messages are received after app has closed - delete loggerWindow; - loggerWindow = 0; -} - -void QDeclarativeViewer::autoStartRecording() -{ - setRecording(true); - autoStopTimer.setInterval(record_autotime); - autoStopTimer.start(); -} - -void QDeclarativeViewer::autoStopRecording() -{ - setRecording(false); -} - -void QDeclarativeViewer::recordFrame() -{ - canvas->QWidget::render(&frame); - if (frame_stream) { - if (frame_fmt == ".gif") { - // ffmpeg can't do 32bpp with gif - QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888); - frame_stream->write((char*)rgb24.bits(),rgb24.numBytes()); - } else { - frame_stream->write((char*)frame.bits(),frame.numBytes()); - } - } else { - frames.append(new QImage(frame)); - } -} - -void QDeclarativeViewer::changeOrientation(QAction *action) -{ - if (!action) - return; - action->setChecked(true); - - QString o = action->text(); - if (o == QLatin1String("Portrait")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait); - else if (o == QLatin1String("Landscape")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape); - else if (o == QLatin1String("Portrait (inverted)")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted); - else if (o == QLatin1String("Landscape (inverted)")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted); -} - -void QDeclarativeViewer::orientationChanged() -{ - updateSizeHints(); -} - -void QDeclarativeViewer::setDeviceKeys(bool on) -{ - devicemode = on; -} - -void QDeclarativeViewer::setNetworkCacheSize(int size) -{ - namFactory->setCacheSize(size); -} - -void QDeclarativeViewer::setUseGL(bool useGL) -{ -#ifdef GL_SUPPORTED - if (useGL) { - QGLFormat format = QGLFormat::defaultFormat(); -#ifdef Q_WS_MAC - format.setSampleBuffers(true); -#else - format.setSampleBuffers(false); -#endif - - QGLWidget *glWidget = new QGLWidget(format); - //### potentially faster, but causes junk to appear if top-level is Item, not Rectangle - //glWidget->setAutoFillBackground(false); - - canvas->setViewport(glWidget); - } -#else - Q_UNUSED(useGL) -#endif -} - -void QDeclarativeViewer::setUseNativeFileBrowser(bool use) -{ - useQmlFileBrowser = !use; -} - -void QDeclarativeViewer::setSizeToView(bool sizeToView) -{ - QDeclarativeView::ResizeMode resizeMode = sizeToView ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject; - if (resizeMode != canvas->resizeMode()) { - canvas->setResizeMode(resizeMode); - updateSizeHints(); - } -} - -void QDeclarativeViewer::setAnimationSpeed(float f) -{ - QUnifiedTimer::instance()->setSlowdownFactor(f); - QUnifiedTimer::instance()->setSlowModeEnabled(f != 1.0); -} - -void QDeclarativeViewer::updateSizeHints(bool initial) -{ - static bool isRecursive = false; - - if (isRecursive) - return; - isRecursive = true; - - if (initial || (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject)) { - QSize newWindowSize = initial ? initialSize : canvas->sizeHint(); - //qWarning() << "USH:" << (initial ? "INIT:" : "V2R:") << "setting fixed size " << newWindowSize; - if (!isFullScreen() && !isMaximized()) { - m_centralWidget->setFixedSize(newWindowSize.width(), newWindowSize.height() + 32); - canvas->setFixedSize(newWindowSize); - resize(1, 1); - layout()->setSizeConstraint(QLayout::SetFixedSize); - layout()->activate(); - } - } - //qWarning() << "USH: R2V: setting free size "; - layout()->setSizeConstraint(QLayout::SetNoConstraint); - layout()->activate(); - - setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); - - m_centralWidget->setMinimumSize(QSize(0,0)); - m_centralWidget->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); - - isRecursive = false; -} - - -void QDeclarativeViewer::registerTypes() -{ - static bool registered = false; - - if (!registered) { - // registering only for exposing the DeviceOrientation::Orientation enum - qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation",""); - registered = true; - } -} - -QT_END_NAMESPACE - -#include "qmlruntime.moc" diff --git a/src/tools/qml/qmlobserver/qmlruntime.h b/src/tools/qml/qmlobserver/qmlruntime.h deleted file mode 100644 index a0a07f1888..0000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.h +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEWER_H -#define QDECLARATIVEVIEWER_H - -#include <QMainWindow> -#include <QTimer> -#include <QTime> -#include <QList> - -#include "loggerwidget.h" - -namespace QmlJSDebugger { - class QDeclarativeViewObserver; -} -namespace Utils { - class CrumblePath; -} - -QT_BEGIN_NAMESPACE - -class QDeclarativeView; -class PreviewDeviceSkin; -class QDeclarativeTestEngine; -class QProcess; -class RecordingDialog; -class QDeclarativeTester; -class QNetworkReply; -class QNetworkCookieJar; -class NetworkAccessManagerFactory; -class QTranslator; -class QActionGroup; -class QMenuBar; -class QSplitter; - -class QDeclarativeViewer - : public QMainWindow -{ - Q_OBJECT - -public: - explicit QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~QDeclarativeViewer(); - - static void registerTypes(); - - enum ScriptOption { - Play = 0x00000001, - Record = 0x00000002, - TestImages = 0x00000004, - TestErrorProperty = 0x00000008, - SaveOnExit = 0x00000010, - ExitOnComplete = 0x00000020, - ExitOnFailure = 0x00000040, - Snapshot = 0x00000080 - }; - Q_DECLARE_FLAGS(ScriptOptions, ScriptOption) - void setScript(const QString &s) { m_script = s; } - void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; } - void setRecordDither(const QString& s) { record_dither = s; } - void setRecordRate(int fps); - void setRecordFile(const QString&); - void setRecordArgs(const QStringList&); - void setRecording(bool on); - bool isRecording() const { return recordTimer.isActive(); } - void setAutoRecord(int from, int to); - void setDeviceKeys(bool); - void setNetworkCacheSize(int size); - void addLibraryPath(const QString& lib); - void addPluginPath(const QString& plugin); - void setUseGL(bool use); - void setUseNativeFileBrowser(bool); - void setSizeToView(bool sizeToView); - - QDeclarativeView *view() const; - LoggerWidget *warningsWidget() const; - - void enableExperimentalGestures(); - -public slots: - void setDesignModeBehavior(bool value); - void setDebugMode(bool on); - void sceneResized(QSize size); - bool open(const QString&); - void openFile(); - void reload(); - void takeSnapShot(); - void toggleRecording(); - void toggleRecordingWithSelection(); - void ffmpegFinished(int code); - void showProxySettings (); - void proxySettingsChanged (); - void rotateOrientation(); - void statusChanged(); - void setAnimationsPaused(bool); - void pauseAnimations(); - void stepAnimations(); - void setAnimationStep(); - void changeAnimationSpeed(); - void launch(const QString &); - -protected: - virtual void keyPressEvent(QKeyEvent *); - virtual bool event(QEvent *); - void createMenu(); - -private slots: - void appAboutToQuit(); - - void autoStartRecording(); - void autoStopRecording(); - void recordFrame(); - void chooseRecordingOptions(); - void pickRecordingFile(); - void toggleFullScreen(); - void changeOrientation(QAction*); - void orientationChanged(); - - void showWarnings(bool show); - void warningsWidgetOpened(); - void warningsWidgetClosed(); - -private: - void setAnimationSpeed(float f); - void updateSizeHints(bool initial = false); - - QString getVideoFileName(); - - LoggerWidget *loggerWindow; - - QDeclarativeView *canvas; - QmlJSDebugger::QDeclarativeViewObserver *observer; - QSize initialSize; - QString currentFileOrUrl; - QTimer recordTimer; - QString frame_fmt; - QImage frame; - QList<QImage*> frames; - QProcess* frame_stream; - QTimer autoStartTimer; - QTimer autoStopTimer; - QString record_dither; - QString record_file; - QSize record_outsize; - QStringList record_args; - int record_rate; - int record_autotime; - bool devicemode; - QAction *recordAction; - QString currentSkin; - bool scaleSkin; - RecordingDialog *recdlg; - - void senseImageMagick(); - void senseFfmpeg(); - QWidget *ffmpegHelpWindow; - bool ffmpegAvailable; - bool convertAvailable; - - float animationSpeed; - int m_stepSize; - QAction *pauseAnimationsAction; - QAction *animationStepAction; - QAction *animationSetStepAction; - - QActionGroup *orientation; - QAction *showWarningsWindow; - QAction *designModeBehaviorAction; - - QString m_script; - ScriptOptions m_scriptOptions; - QDeclarativeTester *tester; - - QNetworkReply *wgtreply; - QString wgtdir; - NetworkAccessManagerFactory *namFactory; - - bool useQmlFileBrowser; - - QWidget *m_centralWidget; - Utils::CrumblePath *m_crumblePathWidget; - - QTranslator *translator; - void loadTranslationFile(const QString& directory); - - void loadDummyDataFiles(const QString& directory); -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions) - -QT_END_NAMESPACE - -#endif diff --git a/src/tools/qml/qmlobserver/qmlruntime.qrc b/src/tools/qml/qmlobserver/qmlruntime.qrc deleted file mode 100644 index 4136eafa52..0000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>content/Browser.qml</file> - <file>content/images/up.png</file> - <file>content/images/folder.png</file> - <file>content/images/titlebar.sci</file> - <file>content/images/titlebar.png</file> - </qresource> -</RCC> diff --git a/src/tools/qml/qmlobserver/recopts.ui b/src/tools/qml/qmlobserver/recopts.ui deleted file mode 100644 index ce2da30767..0000000000 --- a/src/tools/qml/qmlobserver/recopts.ui +++ /dev/null @@ -1,513 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>RecordingOptions</class> - <widget class="QDialog" name="RecordingOptions"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>316</width> - <height>436</height> - </rect> - </property> - <property name="windowTitle"> - <string>Video options</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>File:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="file"/> - </item> - <item> - <widget class="QToolButton" name="pickfile"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Size</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QRadioButton" name="sizeOriginal"> - <property name="text"> - <string/> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="sizeVGA"> - <property name="text"> - <string>VGA</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="size720p"> - <property name="text"> - <string>720p</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QRadioButton" name="sizeQVGA"> - <property name="text"> - <string>QVGA</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QRadioButton" name="sizeCustom"> - <property name="text"> - <string>Width:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="sizeWidth"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>9999</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Height:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="sizeHeight"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>9999</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="rateOptions"> - <property name="title"> - <string>Rate</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QRadioButton" name="hz60"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>60Hz</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="hz50"> - <property name="text"> - <string>50Hz</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QRadioButton" name="hz25"> - <property name="text"> - <string>25Hz</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="4"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QRadioButton" name="hzCustom"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="hz"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Hz</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="2"> - <widget class="QRadioButton" name="hz24"> - <property name="text"> - <string>24Hz</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="ffmpegOptions"> - <property name="title"> - <string>Profile</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0" colspan="3"> - <widget class="QComboBox" name="profile"/> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLineEdit" name="args"/> - </item> - <item row="1" column="2"> - <widget class="QToolButton" name="ffmpegHelp"> - <property name="text"> - <string>Help</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="warning"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>file</tabstop> - <tabstop>pickfile</tabstop> - <tabstop>sizeOriginal</tabstop> - <tabstop>sizeVGA</tabstop> - <tabstop>size720p</tabstop> - <tabstop>sizeQVGA</tabstop> - <tabstop>sizeCustom</tabstop> - <tabstop>sizeWidth</tabstop> - <tabstop>sizeHeight</tabstop> - <tabstop>hz60</tabstop> - <tabstop>hz25</tabstop> - <tabstop>hz50</tabstop> - <tabstop>hz24</tabstop> - <tabstop>hzCustom</tabstop> - <tabstop>hz</tabstop> - <tabstop>profile</tabstop> - <tabstop>args</tabstop> - <tabstop>ffmpegHelp</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>hzCustom</sender> - <signal>clicked()</signal> - <receiver>hz</receiver> - <slot>setFocus()</slot> - <hints> - <hint type="sourcelabel"> - <x>43</x> - <y>257</y> - </hint> - <hint type="destinationlabel"> - <x>129</x> - <y>262</y> - </hint> - </hints> - </connection> - <connection> - <sender>hz</sender> - <signal>textChanged(QString)</signal> - <receiver>hzCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>143</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>43</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>hz</sender> - <signal>selectionChanged()</signal> - <receiver>hzCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>143</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>43</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>RecordingOptions</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>60</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>RecordingOptions</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>92</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>profile</sender> - <signal>activated(int)</signal> - <receiver>RecordingOptions</receiver> - <slot>pickProfile(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>92</x> - <y>329</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>194</y> - </hint> - </hints> - </connection> - <connection> - <sender>args</sender> - <signal>textEdited(QString)</signal> - <receiver>RecordingOptions</receiver> - <slot>storeCustomArgs(QString)</slot> - <hints> - <hint type="sourcelabel"> - <x>128</x> - <y>357</y> - </hint> - <hint type="destinationlabel"> - <x>102</x> - <y>189</y> - </hint> - </hints> - </connection> - <connection> - <sender>sizeWidth</sender> - <signal>valueChanged(int)</signal> - <receiver>sizeCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>108</x> - <y>133</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>133</y> - </hint> - </hints> - </connection> - <connection> - <sender>sizeHeight</sender> - <signal>valueChanged(int)</signal> - <receiver>sizeCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>212</x> - <y>133</y> - </hint> - <hint type="destinationlabel"> - <x>64</x> - <y>129</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <signal>filePicked(QString)</signal> - <signal>argumentsPicked(QString)</signal> - <slot>pickFile()</slot> - <slot>pickProfile(int)</slot> - <slot>storeCustomArgs(QString)</slot> - </slots> -</ui> diff --git a/src/tools/qml/qmlobserver/recopts_maemo5.ui b/src/tools/qml/qmlobserver/recopts_maemo5.ui deleted file mode 100644 index 3bb5ecabd9..0000000000 --- a/src/tools/qml/qmlobserver/recopts_maemo5.ui +++ /dev/null @@ -1,254 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>RecordingOptions</class> - <widget class="QDialog" name="RecordingOptions"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>469</width> - <height>142</height> - </rect> - </property> - <property name="windowTitle"> - <string>Video options</string> - </property> - <layout class="QGridLayout" name="gridLayout" columnstretch="0,2,0"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinAndMaxSize</enum> - </property> - <property name="leftMargin"> - <number>16</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>16</number> - </property> - <property name="bottomMargin"> - <number>8</number> - </property> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="0" column="1"> - <widget class="QLineEdit" name="file"/> - </item> - <item row="0" column="2" rowspan="3"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>72</width> - <height>56</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Size</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="sizeCombo"> - <item> - <property name="text"> - <string/> - </property> - </item> - <item> - <property name="text"> - <string>VGA</string> - </property> - </item> - <item> - <property name="text"> - <string>QVGA</string> - </property> - </item> - <item> - <property name="text"> - <string>720p</string> - </property> - </item> - </widget> - </item> - <item row="2" column="0" rowspan="2"> - <widget class="QLabel" name="rateLabel"> - <property name="text"> - <string>Rate</string> - </property> - </widget> - </item> - <item row="2" column="1" rowspan="2"> - <widget class="QComboBox" name="rateCombo"> - <item> - <property name="text"> - <string>60 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>50 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>25 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>24 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>20 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>15 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>10 Hz</string> - </property> - </item> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="args"/> - </item> - <item row="4" column="1"> - <widget class="QComboBox" name="profile"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="profileLabel"> - <property name="text"> - <string>Profile</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="2"> - <widget class="QLabel" name="warning"> - <property name="text"> - <string notr="true">warning</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="2" rowspan="3"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QPushButton" name="pickfile"> - <property name="text"> - <string>File</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QPushButton" name="ffmpegHelp"> - <property name="text"> - <string>Options</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>RecordingOptions</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>60</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>RecordingOptions</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>92</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>profile</sender> - <signal>activated(int)</signal> - <receiver>RecordingOptions</receiver> - <slot>pickProfile(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>92</x> - <y>329</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>194</y> - </hint> - </hints> - </connection> - <connection> - <sender>args</sender> - <signal>textEdited(QString)</signal> - <receiver>RecordingOptions</receiver> - <slot>storeCustomArgs(QString)</slot> - <hints> - <hint type="sourcelabel"> - <x>128</x> - <y>357</y> - </hint> - <hint type="destinationlabel"> - <x>102</x> - <y>189</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <signal>filePicked(QString)</signal> - <signal>argumentsPicked(QString)</signal> - <slot>pickFile()</slot> - <slot>pickProfile(int)</slot> - <slot>storeCustomArgs(QString)</slot> - </slots> -</ui> diff --git a/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h b/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h deleted file mode 100644 index bb5567a4c2..0000000000 --- a/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/qplaintextedit.h> -#include <QtGui/qtextedit.h> -#include <QtGui/qabstractkineticscroller.h> -#include <QtGui/qscrollarea.h> -#include <QtDebug> - -#ifndef TEXTEDITAUTORESIZER_H -#define TEXTEDITAUTORESIZER_H - -class TextEditAutoResizer : public QObject -{ - Q_OBJECT -public: - TextEditAutoResizer(QWidget *parent) - : QObject(parent), plainTextEdit(qobject_cast<QPlainTextEdit *>(parent)), - textEdit(qobject_cast<QTextEdit *>(parent)), edit(qobject_cast<QFrame *>(parent)) - { - // parent must either inherit QPlainTextEdit or QTextEdit! - Q_ASSERT(plainTextEdit || textEdit); - - connect(parent, SIGNAL(textChanged()), this, SLOT(textEditChanged())); - connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged())); - - textEditChanged(); - } - -private Q_SLOTS: - inline void textEditChanged(); - -private: - QPlainTextEdit *plainTextEdit; - QTextEdit *textEdit; - QFrame *edit; -}; - -void TextEditAutoResizer::textEditChanged() -{ - QTextDocument *doc = textEdit ? textEdit->document() : plainTextEdit->document(); - QRect cursor = textEdit ? textEdit->cursorRect() : plainTextEdit->cursorRect(); - - QSize s = doc->size().toSize(); - if (plainTextEdit) - s.setHeight((s.height() + 2) * edit->fontMetrics().lineSpacing()); - - const QRect fr = edit->frameRect(); - const QRect cr = edit->contentsRect(); - - edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1))); - - // make sure the cursor is visible in case we have a QAbstractScrollArea parent - QPoint pos = edit->pos(); - QWidget *pw = edit->parentWidget(); - while (pw) { - if (qobject_cast<QScrollArea *>(pw)) - break; - pw = pw->parentWidget(); - } - - if (pw) { - QScrollArea *area = static_cast<QScrollArea *>(pw); - QPoint scrollto = area->widget()->mapFrom(edit, cursor.center()); - QPoint margin(10 + cursor.width(), 2 * cursor.height()); - - if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) { - scroller->ensureVisible(scrollto, margin.x(), margin.y()); - } else { - area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); - } - } -} - -#endif |