summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/snippets
diff options
context:
space:
mode:
authorhjk <qthjk@ovi.com>2012-12-18 15:11:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-20 19:28:19 +0100
commit416168db8a9bb54614117469a43f751a401de854 (patch)
treebe708f7ba13950041eaea0f481c2c1f050f4a9c3 /examples/multimedia/video/snippets
parent5739d43eef89e415974ca64fb348371f9f8659c7 (diff)
Polish and fix qmlvideofx example
Change-Id: I30f6d7d2af784ba018a659a16aceb4876a4b1be6 Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/multimedia/video/snippets')
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp26
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h7
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp44
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitor.h31
4 files changed, 56 insertions, 52 deletions
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
index 1d44f1297..568bbc79f 100644
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
+++ b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include "frequencymonitor.h"
-#include <QtCore/QDebug>
-#include <QtCore/QElapsedTimer>
-#include <QtCore/QString>
-#include <QtCore/QTime>
-#include <QtCore/QTimer>
+#include <QDebug>
+#include <QElapsedTimer>
+#include <QString>
+#include <QTime>
+#include <QTimer>
//#define VERBOSE_TRACE
@@ -61,6 +61,7 @@ static const int DefaultTraceInterval = 0;
class FrequencyMonitorPrivate : public QObject
{
Q_OBJECT
+
public:
FrequencyMonitorPrivate(FrequencyMonitor *parent);
void calculateInstantaneousFrequency();
@@ -116,16 +117,16 @@ void FrequencyMonitorPrivate::calculateInstantaneousFrequency()
m_stalledTimer->start(3 * ms);
if (m_instantaneousFrequency)
q_ptr->setActive(true);
- q_ptr->emit instantaneousFrequencyChanged(m_instantaneousFrequency);
- q_ptr->emit frequencyChanged();
+ emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency);
+ emit q_ptr->frequencyChanged();
}
void FrequencyMonitorPrivate::calculateAverageFrequency()
{
const qint64 ms = m_averageElapsed.restart();
m_averageFrequency = qreal(m_count * 1000) / ms;
- q_ptr->emit averageFrequencyChanged(m_averageFrequency);
- q_ptr->emit frequencyChanged();
+ emit q_ptr->averageFrequencyChanged(m_averageFrequency);
+ emit q_ptr->frequencyChanged();
m_count = 0;
}
@@ -134,14 +135,13 @@ void FrequencyMonitorPrivate::stalled()
if (m_instantaneousFrequency) {
qtVerboseTrace() << "FrequencyMonitor::stalled";
m_instantaneousFrequency = 0;
- q_ptr->emit instantaneousFrequencyChanged(m_instantaneousFrequency);
- q_ptr->emit frequencyChanged();
+ emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency);
+ emit q_ptr->frequencyChanged();
}
}
FrequencyMonitor::FrequencyMonitor(QObject *parent)
: QObject(parent)
-, d_ptr(0)
{
d_ptr = new FrequencyMonitorPrivate(this);
qtTrace() << "FrequencyMonitor::FrequencyMonitor";
@@ -152,7 +152,7 @@ FrequencyMonitor::~FrequencyMonitor()
}
-const QString &FrequencyMonitor::label() const
+QString FrequencyMonitor::label() const
{
return d_func()->m_label;
}
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h
index 1efd8b3ad..f34646f9e 100644
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h
+++ b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h
@@ -42,8 +42,8 @@
#ifndef FREQUENCYMONITOR_H
#define FREQUENCYMONITOR_H
-#include <QtCore/QObject>
-#include <QtCore/QTimer>
+#include <QObject>
+#include <QTimer>
class FrequencyMonitorPrivate;
@@ -64,13 +64,14 @@ class FrequencyMonitor : public QObject
Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged)
Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged)
Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged)
+
public:
FrequencyMonitor(QObject *parent = 0);
~FrequencyMonitor();
static void qmlRegisterType();
- const QString &label() const;
+ QString label() const;
bool active() const;
int samplingInterval() const;
int traceInterval() const;
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp
index 9a7e060b7..07c83485b 100644
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp
+++ b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp
@@ -43,27 +43,27 @@
namespace PerformanceMonitor {
- bool parseArgument(const QString &arg, State &state)
- {
- bool result = false;
- if ("-log-perf" == arg) {
- state.logging = true;
- state.valid = true;
- result = true;
- } else if ("-no-log-perf" == arg) {
- state.logging = false;
- state.valid = true;
- result = true;
- } else if ("-show-perf" == arg) {
- state.visible = true;
- state.valid = true;
- result = true;
- } else if ("-hide-perf" == arg) {
- state.visible = false;
- state.valid = true;
- result = true;
- }
- return result;
+bool State::parseArgument(const QByteArray &arg)
+{
+ bool result = false;
+ if (arg == "-log-perf") {
+ logging = true;
+ valid = true;
+ result = true;
+ } else if (arg == "-no-log-perf") {
+ logging = false;
+ valid = true;
+ result = true;
+ } else if (arg == "-show-perf") {
+ visible = true;
+ valid = true;
+ result = true;
+ } else if (arg == "-hide-perf") {
+ visible = false;
+ valid = true;
+ result = true;
}
-
+ return result;
}
+
+} // namespace PerformanceMonitor
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h
index d87d71eac..f1a443e0b 100644
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h
+++ b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h
@@ -42,24 +42,27 @@
#ifndef PERFORMANCEMONITOR_H
#define PERFORMANCEMONITOR_H
-#include <QtCore/QString>
+#include <QByteArray>
namespace PerformanceMonitor {
- struct State {
- bool valid;
- bool logging;
- bool visible;
- State() : valid(true), logging(false), visible(true) { }
- State(bool l, bool v) : valid(true), logging(l), visible(v) { }
- bool operator==(const State &other) const
- { return logging == other.logging && visible == other.visible; }
- bool operator!=(const State &other) const
- { return logging != other.logging || visible != other.visible; }
- };
+struct State
+{
+ State() : valid(true), logging(false), visible(true) { }
+ State(bool l, bool v) : valid(true), logging(l), visible(v) { }
+ bool operator==(const State &other) const
+ { return logging == other.logging && visible == other.visible; }
+ bool operator!=(const State &other) const
+ { return logging != other.logging || visible != other.visible; }
- bool parseArgument(const QString &arg, State &state);
-}
+ bool parseArgument(const QByteArray &arg);
+
+ bool valid;
+ bool logging;
+ bool visible;
+};
+
+} // namespace PerformanceMonitor
#endif // PERFORMANCEMONITOR_H