summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-07 04:11:05 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-07 04:11:05 (GMT)
commit9e9ee6ac63038c050ef02b102c23ebb899c45374 (patch)
tree7880b844c930ec7ab68cb98e642cb7eef5b516fe /tools/qmlviewer
parent907f783ae6be3665ea43ebc157c4cd027c11cd28 (diff)
downloadQt-9e9ee6ac63038c050ef02b102c23ebb899c45374.zip
Qt-9e9ee6ac63038c050ef02b102c23ebb899c45374.tar.gz
Qt-9e9ee6ac63038c050ef02b102c23ebb899c45374.tar.bz2
Tweaks to viewer.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r--tools/qmlviewer/main.cpp1
-rw-r--r--tools/qmlviewer/qmlviewer.cpp36
-rw-r--r--tools/qmlviewer/qmlviewer.h3
3 files changed, 34 insertions, 6 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index b588111..3f74ef6 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -60,7 +60,6 @@ int main(int argc, char ** argv)
char raster[] = "raster";
newargv[argc+1] = raster;
-
QApplication app(newargc, newargv);
app.setApplicationName("viewer");
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 7962ed1..04054ec 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -53,7 +53,8 @@ QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, Q
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
- createMenuBar();
+ if (!(flags & Qt::FramelessWindowHint))
+ createMenuBar();
canvas = new QFxView(this);
if(testMode != QFxTestEngine::NoTest)
@@ -85,12 +86,38 @@ void QmlViewer::createMenuBar()
fileMenu->addSeparator();
fileMenu->addAction(quitAction);
+ /*QMenu *recordMenu = menuBar()->addMenu(tr("&Recording"));
+
+ QAction *snapshotAction = new QAction(tr("&Take Snapsot"), this);
+ connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
+ recordMenu->addAction(snapshotAction);
+
+ recordAction = new QAction(tr("&Start Recording Video"), this);
+ connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecording()));
+ recordMenu->addAction(recordAction);*/
+
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
QAction *aboutAction = new QAction(tr("&About Qt..."), this);
connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
helpMenu->addAction(aboutAction);
}
+void QmlViewer::takeSnapShot()
+{
+ static int snapshotcount = 1;
+ QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount);
+ canvas->asImage().save(snapFileName);
+ qDebug() << "Wrote" << snapFileName;
+ ++snapshotcount;
+}
+
+void QmlViewer::toggleRecording()
+{
+ bool recording = recordTimer.isActive();
+ //recordAction->setText(recording ? tr("&Start Recording Video") : tr("&End Recording Video"));
+ setRecording(!recording);
+}
+
void QmlViewer::reload()
{
openQml(currentFileName);
@@ -303,10 +330,9 @@ void QmlViewer::keyPressEvent(QKeyEvent *event)
<< "device keys: 0=quit, 1..8=F1..F8"
;
} else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) {
- setRecording(!recordTimer.isActive());
+ toggleRecording();
} else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) {
- canvas->asImage().save("snapshot.png");
- qDebug() << "Wrote snapshot.png";
+ takeSnapShot();
} else if (event->key() == Qt::Key_F4 || (event->key() == Qt::Key_4 && devicemode)) {
canvas->dumpItems();
canvas->checkState();
@@ -404,7 +430,7 @@ void QmlViewer::setRecording(bool on)
args << "-delay" << QString::number(record_period/10);
args << inputs;
args << record_file;
- qDebug() << "Converting..." << 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
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index b4117a2..405e8d9 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -48,6 +48,8 @@ public slots:
void openQml(const QString& fileName);
void open();
void reload();
+ void takeSnapShot();
+ void toggleRecording();
protected:
virtual void keyPressEvent(QKeyEvent *);
@@ -70,6 +72,7 @@ private:
int record_period;
int record_autotime;
bool devicemode;
+ QAction *recordAction;
QFxTestEngine *testEngine;
};