/usr/share/qt5/doc/qtmultimedia/qtmultimedia-video-qmlvideofx-main-cpp.html is in qtmultimedia5-doc-html 5.2.1-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main.cpp Example File (video/qmlvideofx/main.cpp) | QtMultimedia 5.2</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.2</li>
<li><a href="qtmultimedia-index.html">Qt Multimedia</a></li>
<li>main.cpp Example File (video/qmlvideofx/main.cpp)</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<h1 class="title">main.cpp Example File</h1>
<span class="small-subtitle">video/qmlvideofx/main.cpp</span>
<!-- $$$video/qmlvideofx/main.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp"><span class="comment">/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/</span>
<span class="preprocessor">#include <QtCore/QStandardPaths></span>
<span class="preprocessor">#include <QtCore/QStringList></span>
<span class="preprocessor">#include <QtQml/QQmlContext></span>
<span class="preprocessor">#include <QtGui/QGuiApplication></span>
<span class="preprocessor">#include <QtQuick/QQuickItem></span>
<span class="preprocessor">#include <QtQuick/QQuickView></span>
<span class="preprocessor">#include "filereader.h"</span>
<span class="preprocessor">#include "trace.h"</span>
<span class="preprocessor">#ifdef SMALL_SCREEN_LAYOUT</span>
<span class="keyword">static</span> <span class="keyword">const</span> QLatin1String MainQmlFile(<span class="string">"main-smallscreen.qml"</span>);
<span class="preprocessor">#else</span>
<span class="keyword">static</span> <span class="keyword">const</span> QLatin1String MainQmlFile(<span class="string">"main-largescreen.qml"</span>);
<span class="preprocessor">#endif</span>
<span class="preprocessor">#ifdef PERFORMANCEMONITOR_SUPPORT</span>
<span class="preprocessor">#include "performancemonitordeclarative.h"</span>
<span class="preprocessor">#endif</span>
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
<span class="type">QGuiApplication</span> app(argc<span class="operator">,</span> argv);
<span class="preprocessor">#ifdef PERFORMANCEMONITOR_SUPPORT</span>
PerformanceMonitor<span class="operator">::</span>qmlRegisterTypes();
<span class="preprocessor">#endif</span>
<span class="type">QUrl</span> fileName;
<span class="type">qreal</span> volume <span class="operator">=</span> <span class="number">0.5</span>;
<span class="type">QStringList</span> args <span class="operator">=</span> app<span class="operator">.</span>arguments();
<span class="preprocessor">#ifdef PERFORMANCEMONITOR_SUPPORT</span>
PerformanceMonitor<span class="operator">::</span>State performanceMonitorState;
<span class="preprocessor">#endif</span>
<span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">1</span>; i <span class="operator"><</span> args<span class="operator">.</span>size(); <span class="operator">+</span><span class="operator">+</span>i) {
<span class="keyword">const</span> <span class="type">QByteArray</span> arg <span class="operator">=</span> args<span class="operator">.</span>at(i)<span class="operator">.</span>toUtf8();
<span class="keyword">if</span> (arg<span class="operator">.</span>startsWith(<span class="char">'-'</span>)) {
<span class="keyword">if</span> (<span class="string">"-volume"</span> <span class="operator">=</span><span class="operator">=</span> arg) {
<span class="keyword">if</span> (i <span class="operator">+</span> <span class="number">1</span> <span class="operator"><</span> args<span class="operator">.</span>size())
volume <span class="operator">=</span> <span class="number">0.01</span> <span class="operator">*</span> args<span class="operator">.</span>at(<span class="operator">+</span><span class="operator">+</span>i)<span class="operator">.</span>toInt();
<span class="keyword">else</span>
qtTrace() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Option \"-volume\" takes a value"</span>;
}
<span class="preprocessor">#ifdef PERFORMANCEMONITOR_SUPPORT</span>
<span class="keyword">else</span> <span class="keyword">if</span> (performanceMonitorState<span class="operator">.</span>parseArgument(arg)) {
<span class="comment">// Do nothing</span>
}
<span class="preprocessor">#endif</span>
<span class="keyword">else</span> {
qtTrace() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Option"</span> <span class="operator"><</span><span class="operator"><</span> arg <span class="operator"><</span><span class="operator"><</span> <span class="string">"ignored"</span>;
}
} <span class="keyword">else</span> {
<span class="keyword">if</span> (fileName<span class="operator">.</span>isEmpty())
fileName <span class="operator">=</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(arg);
<span class="keyword">else</span>
qtTrace() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Argument"</span> <span class="operator"><</span><span class="operator"><</span> arg <span class="operator"><</span><span class="operator"><</span> <span class="string">"ignored"</span>;
}
}
<span class="type">QQuickView</span> viewer;
viewer<span class="operator">.</span>setSource(QLatin1String(<span class="string">"qrc:///qml/qmlvideofx/"</span>) <span class="operator">+</span> MainQmlFile);
<span class="type">QQuickItem</span> <span class="operator">*</span>rootObject <span class="operator">=</span> viewer<span class="operator">.</span>rootObject();
rootObject<span class="operator">-</span><span class="operator">></span>setProperty(<span class="string">"fileName"</span><span class="operator">,</span> fileName);
viewer<span class="operator">.</span>rootObject()<span class="operator">-</span><span class="operator">></span>setProperty(<span class="string">"volume"</span><span class="operator">,</span> volume);
<span class="preprocessor">#ifdef PERFORMANCEMONITOR_SUPPORT</span>
<span class="keyword">if</span> (performanceMonitorState<span class="operator">.</span>valid) {
rootObject<span class="operator">-</span><span class="operator">></span>setProperty(<span class="string">"perfMonitorsLogging"</span><span class="operator">,</span> performanceMonitorState<span class="operator">.</span>logging);
rootObject<span class="operator">-</span><span class="operator">></span>setProperty(<span class="string">"perfMonitorsVisible"</span><span class="operator">,</span> performanceMonitorState<span class="operator">.</span>visible);
}
<span class="type">QObject</span><span class="operator">::</span>connect(<span class="operator">&</span>viewer<span class="operator">,</span> SIGNAL(afterRendering())<span class="operator">,</span>
rootObject<span class="operator">,</span> SLOT(qmlFramePainted()));
<span class="preprocessor">#endif</span>
FileReader fileReader;
viewer<span class="operator">.</span>rootContext()<span class="operator">-</span><span class="operator">></span>setContextProperty(<span class="string">"fileReader"</span><span class="operator">,</span> <span class="operator">&</span>fileReader);
<span class="keyword">const</span> <span class="type">QUrl</span> appPath(<span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(app<span class="operator">.</span>applicationDirPath()));
<span class="keyword">const</span> <span class="type">QStringList</span> picturesLocation <span class="operator">=</span> <span class="type">QStandardPaths</span><span class="operator">::</span>standardLocations(<span class="type">QStandardPaths</span><span class="operator">::</span>PicturesLocation);
<span class="keyword">const</span> <span class="type">QUrl</span> imagePath <span class="operator">=</span> picturesLocation<span class="operator">.</span>isEmpty() <span class="operator">?</span> appPath : <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(picturesLocation<span class="operator">.</span>first());
viewer<span class="operator">.</span>rootContext()<span class="operator">-</span><span class="operator">></span>setContextProperty(<span class="string">"imagePath"</span><span class="operator">,</span> imagePath);
<span class="keyword">const</span> <span class="type">QStringList</span> moviesLocation <span class="operator">=</span> <span class="type">QStandardPaths</span><span class="operator">::</span>standardLocations(<span class="type">QStandardPaths</span><span class="operator">::</span>MoviesLocation);
<span class="keyword">const</span> <span class="type">QUrl</span> videoPath <span class="operator">=</span> moviesLocation<span class="operator">.</span>isEmpty() <span class="operator">?</span> appPath : <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(moviesLocation<span class="operator">.</span>first());
viewer<span class="operator">.</span>rootContext()<span class="operator">-</span><span class="operator">></span>setContextProperty(<span class="string">"videoPath"</span><span class="operator">,</span> videoPath);
viewer<span class="operator">.</span>setTitle(<span class="string">"qmlvideofx"</span>);
viewer<span class="operator">.</span>setFlags(<span class="type">Qt</span><span class="operator">::</span>Window <span class="operator">|</span> <span class="type">Qt</span><span class="operator">::</span>WindowSystemMenuHint <span class="operator">|</span> <span class="type">Qt</span><span class="operator">::</span>WindowTitleHint <span class="operator">|</span>
<span class="type">Qt</span><span class="operator">::</span>WindowMinMaxButtonsHint <span class="operator">|</span> <span class="type">Qt</span><span class="operator">::</span>WindowCloseButtonHint);
viewer<span class="operator">.</span>setMinimumSize(<span class="type">QSize</span>(<span class="number">600</span><span class="operator">,</span> <span class="number">400</span>));
<span class="preprocessor">#ifdef SMALL_SCREEN_PHYSICAL</span>
viewer<span class="operator">.</span>showFullScreen();
<span class="preprocessor">#else</span>
viewer<span class="operator">.</span>show();
<span class="preprocessor">#endif</span>
<span class="comment">// Delay invocation of init until the event loop has started, to work around</span>
<span class="comment">// a GL context issue on Harmattan: without this, we get the following error</span>
<span class="comment">// when the first ShaderEffectItem is created:</span>
<span class="comment">// "QGLShaderProgram::addShader: Program and shader are not associated with same context"</span>
<span class="type">QMetaObject</span><span class="operator">::</span>invokeMethod(viewer<span class="operator">.</span>rootObject()<span class="operator">,</span> <span class="string">"init"</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>QueuedConnection);
<span class="keyword">return</span> app<span class="operator">.</span>exec();
}</pre>
</div>
<!-- @@@video/qmlvideofx/main.cpp -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|