summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/deviceorientation.h1
-rw-r--r--tools/qml/main.cpp4
-rw-r--r--tools/qml/qdeclarativetester.cpp11
-rw-r--r--tools/qml/qml.pro2
-rw-r--r--tools/qml/qmlruntime.cpp61
-rw-r--r--tools/qml/qmlruntime.h4
6 files changed, 62 insertions, 21 deletions
diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h
index c8125cd..d209005 100644
--- a/tools/qml/deviceorientation.h
+++ b/tools/qml/deviceorientation.h
@@ -50,6 +50,7 @@ class DeviceOrientationPrivate;
class DeviceOrientation : public QObject
{
Q_OBJECT
+ Q_ENUMS(Orientation)
public:
enum Orientation { UnknownOrientation, Portrait, Landscape };
virtual Orientation orientation() const = 0;
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 01b3912..341908e 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -121,6 +121,8 @@ void scriptOptsUsage()
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");
@@ -309,6 +311,8 @@ int main(int argc, char ** argv)
scriptOptions |= QDeclarativeViewer::ExitOnFailure;
} else if (option == QLatin1String("saveonexit")) {
scriptOptions |= QDeclarativeViewer::SaveOnExit;
+ } else if (option == QLatin1String("snapshot")) {
+ scriptOptions |= QDeclarativeViewer::Snapshot;
} else {
scriptOptsUsage();
}
diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp
index 6245124..cf537ee 100644
--- a/tools/qml/qdeclarativetester.cpp
+++ b/tools/qml/qdeclarativetester.cpp
@@ -240,6 +240,8 @@ void QDeclarativeTester::save()
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);
@@ -249,11 +251,13 @@ void QDeclarativeTester::updateCurrentTime(int msec)
m_view->render(&p);
}
+ bool snapshot = msec == 16 && options & QDeclarativeViewer::Snapshot;
+
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)) {
+ } else if (0 == (m_savedFrameEvents.count() % 60) || snapshot) {
fe.image = img;
} else {
QCryptographicHash hash(QCryptographicHash::Md5);
@@ -366,8 +370,11 @@ void QDeclarativeTester::updateCurrentTime(int msec)
filterEvents = true;
- if (testscript && testscript->count() <= testscriptidx)
+ 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()
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index bc6d032..1ed8b2c 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -56,7 +56,7 @@ symbian {
INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
LIBS += -lesock -lcommdb -lconnmon -linsock
- TARGET.CAPABILITY = "All -TCB"
+ TARGET.CAPABILITY = NetworkServices ReadUserData
}
mac {
QMAKE_INFO_PLIST=Info_mac.plist
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index c4ebd80..df29294 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -112,33 +112,47 @@
QT_BEGIN_NAMESPACE
-class Screen : public QObject
+class Runtime : public QObject
{
Q_OBJECT
- Q_PROPERTY(Orientation orientation READ orientation NOTIFY orientationChanged)
- Q_ENUMS(Orientation)
+ Q_PROPERTY(bool isActiveWindow READ isActiveWindow NOTIFY isActiveWindowChanged)
+ Q_PROPERTY(DeviceOrientation::Orientation orientation READ orientation NOTIFY orientationChanged)
public:
- Screen(QObject *parent=0) : QObject(parent) {
- connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()),
- this, SIGNAL(orientationChanged()));
+ static Runtime* instance()
+ {
+ static Runtime *instance = 0;
+ if (!instance)
+ instance = new Runtime;
+ return instance;
}
- enum Orientation { UnknownOrientation = DeviceOrientation::UnknownOrientation,
- Portrait = DeviceOrientation::Portrait,
- Landscape = DeviceOrientation::Landscape };
- Orientation orientation() const { return Orientation(DeviceOrientation::instance()->orientation()); }
+ bool isActiveWindow() const { return activeWindow; }
+ void setActiveWindow(bool active)
+ {
+ if (active == activeWindow)
+ return;
+ activeWindow = active;
+ emit isActiveWindowChanged();
+ }
-signals:
+ DeviceOrientation::Orientation orientation() const { return DeviceOrientation::instance()->orientation(); }
+
+Q_SIGNALS:
+ void isActiveWindowChanged();
void orientationChanged();
-};
-QT_END_NAMESPACE
+private:
+ Runtime(QObject *parent=0) : QObject(parent), activeWindow(false)
+ {
+ connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()),
+ this, SIGNAL(orientationChanged()));
+ }
-QML_DECLARE_TYPE(Screen)
+ bool activeWindow;
+};
-QT_BEGIN_NAMESPACE
class SizedMenuBar : public QMenuBar
{
@@ -1035,7 +1049,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url)
url = QUrl(file_or_url);
setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url));
- if (!m_script.isEmpty())
+ if (!m_script.isEmpty())
tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas);
delete canvas->rootObject();
@@ -1048,6 +1062,8 @@ void QDeclarativeViewer::openQml(const QString& file_or_url)
ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
#endif
+ ctxt->setContextProperty("runtime", Runtime::instance());
+
QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
QFileInfo fi(fileName);
@@ -1249,6 +1265,16 @@ void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
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;
@@ -1474,7 +1500,8 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use)
void QDeclarativeViewer::registerTypes()
{
- qmlRegisterType<Screen>("QDeclarativeViewer", 1, 0, "Screen");
+ // registering only for exposing the DeviceOrientation::Orientation enum
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation");
}
QT_END_NAMESPACE
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 6f1e425..1ae771a 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -81,7 +81,8 @@ public:
TestErrorProperty = 0x00000008,
SaveOnExit = 0x00000010,
ExitOnComplete = 0x00000020,
- ExitOnFailure = 0x00000040
+ ExitOnFailure = 0x00000040,
+ Snapshot = 0x00000080
};
Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
void setScript(const QString &s) { m_script = s; }
@@ -125,6 +126,7 @@ public slots:
protected:
virtual void keyPressEvent(QKeyEvent *);
+ virtual bool event(QEvent *);
void createMenu(QMenuBar *menu, QMenu *flatmenu);