Polish and fix qmlvideofx example

Change-Id: I30f6d7d2af784ba018a659a16aceb4876a4b1be6
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-12-18 15:11:44 +01:00
committed by The Qt Project
parent 5739d43eef
commit 416168db8a
33 changed files with 122 additions and 123 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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