aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qmlviewer/loggerwidget.cpp14
-rw-r--r--tools/qmlviewer/main.cpp91
-rw-r--r--tools/qmlviewer/proxysettings.cpp36
-rw-r--r--tools/qmlviewer/proxysettings_maemo5.ui6
-rw-r--r--tools/qmlviewer/qdeclarativetester.cpp10
-rw-r--r--tools/qmlviewer/qmlruntime.cpp109
-rw-r--r--tools/qmlviewer/qmlviewer.pro2
7 files changed, 142 insertions, 126 deletions
diff --git a/tools/qmlviewer/loggerwidget.cpp b/tools/qmlviewer/loggerwidget.cpp
index 3f2337a622..9a07402eb0 100644
--- a/tools/qmlviewer/loggerwidget.cpp
+++ b/tools/qmlviewer/loggerwidget.cpp
@@ -139,10 +139,10 @@ QAction *LoggerWidget::showAction()
void LoggerWidget::readSettings()
{
QSettings settings;
- QString warningsPreferences = settings.value("warnings", "hide").toString();
- if (warningsPreferences == "show") {
+ QString warningsPreferences = settings.value(QLatin1String("warnings"), QLatin1String("hide")).toString();
+ if (warningsPreferences == QLatin1String("show")) {
m_visibility = ShowWarnings;
- } else if (warningsPreferences == "hide") {
+ } else if (warningsPreferences == QLatin1String("hide")) {
m_visibility = HideWarnings;
} else {
m_visibility = AutoShowWarnings;
@@ -154,15 +154,15 @@ void LoggerWidget::saveSettings()
if (m_visibilityOrigin != SettingsOrigin)
return;
- QString value = "autoShow";
+ QString value = QLatin1String("autoShow");
if (defaultVisibility() == ShowWarnings) {
- value = "show";
+ value = QLatin1String("show");
} else if (defaultVisibility() == HideWarnings) {
- value = "hide";
+ value = QLatin1String("hide");
}
QSettings settings;
- settings.setValue("warnings", value);
+ settings.setValue(QLatin1String("warnings"), value);
}
void LoggerWidget::warningsPreferenceChanged(QAction *action)
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index b1a10ff6c4..236edfe5a6 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -50,6 +50,7 @@
#include <QDebug>
#include <QMessageBox>
#include <QAtomicInt>
+#include <QLibraryInfo>
#include "qdeclarativetester.h"
#include <private/qdeclarativedebughelper_p.h>
@@ -67,7 +68,7 @@ void exitApp(int i)
// Debugging output is not visible by default on Windows -
// therefore show modal dialog with errors instead.
if (!warnings.isEmpty()) {
- QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings);
+ QMessageBox::warning(0, QApplication::translate("QDeclarativeViewer", "Qt QML Viewer"), warnings);
}
#endif
exit(i);
@@ -123,7 +124,7 @@ void myMessageOutput(QtMsgType type, const char *msg)
static QDeclarativeViewer* globalViewer = 0;
// The qml file that is shown if the user didn't specify a QML file
-QString initialFile = "qrc:/startup/startup.qml";
+QString initialFile = QLatin1String("qrc:/startup/startup.qml");
void usage()
{
@@ -199,7 +200,7 @@ struct ViewerOptions
fps(0.0),
autorecord_from(0),
autorecord_to(0),
- dither("none"),
+ dither(QLatin1String("none")),
runScript(false),
devkeys(false),
cache(0),
@@ -336,54 +337,54 @@ static void parseCommandLineOptions(const QStringList &arguments)
for (int i = 1; i < arguments.count(); ++i) {
bool lastArg = (i == arguments.count() - 1);
QString arg = arguments.at(i);
- if (arg == "-frameless") {
+ if (arg == QLatin1String("-frameless")) {
opts.frameless = true;
- } else if (arg == "-maximized") {
+ } else if (arg == QLatin1String("-maximized")) {
opts.maximized = true;
- } else if (arg == "-fullscreen") {
+ } else if (arg == QLatin1String("-fullscreen")) {
opts.fullScreen = true;
- } else if (arg == "-stayontop") {
+ } else if (arg == QLatin1String("-stayontop")) {
opts.stayOnTop = true;
- } else if (arg == "-netcache") {
+ } else if (arg == QLatin1String("-netcache")) {
if (lastArg) usage();
opts.cache = arguments.at(++i).toInt();
- } else if (arg == "-recordrate") {
+ } else if (arg == QLatin1String("-recordrate")) {
if (lastArg) usage();
opts.fps = arguments.at(++i).toDouble();
- } else if (arg == "-recordfile") {
+ } else if (arg == QLatin1String("-recordfile")) {
if (lastArg) usage();
opts.recordfile = arguments.at(++i);
- } else if (arg == "-record") {
+ } else if (arg == QLatin1String("-record")) {
if (lastArg) usage();
opts.recordargs << arguments.at(++i);
- } else if (arg == "-recorddither") {
+ } else if (arg == QLatin1String("-recorddither")) {
if (lastArg) usage();
opts.dither = arguments.at(++i);
- } else if (arg == "-autorecord") {
+ } else if (arg == QLatin1String("-autorecord")) {
if (lastArg) usage();
QString range = arguments.at(++i);
- int dash = range.indexOf('-');
+ int dash = range.indexOf(QLatin1Char('-'));
if (dash > 0)
opts.autorecord_from = range.left(dash).toInt();
opts.autorecord_to = range.mid(dash+1).toInt();
- } else if (arg == "-devicekeys") {
+ } else if (arg == QLatin1String("-devicekeys")) {
opts.devkeys = true;
- } else if (arg == "-dragthreshold") {
+ } else if (arg == QLatin1String("-dragthreshold")) {
if (lastArg) usage();
qApp->setStartDragDistance(arguments.at(++i).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
qWarning("Qt QML Viewer version %s", QT_VERSION_STR);
exitApp(0);
- } else if (arg == "-translation") {
+ } else if (arg == QLatin1String("-translation")) {
if (lastArg) usage();
opts.translationFile = arguments.at(++i);
- } else if (arg == "-no-opengl") {
+ } else if (arg == QLatin1String("-no-opengl")) {
opts.useGL = false;
- } else if (arg == "-opengl") {
+ } else if (arg == QLatin1String("-opengl")) {
opts.useGL = true;
- } else if (arg == "-qmlbrowser") {
+ } else if (arg == QLatin1String("-qmlbrowser")) {
opts.useNativeFileBrowser = false;
- } else if (arg == "-warnings") {
+ } else if (arg == QLatin1String("-warnings")) {
if (lastArg) usage();
QString warningsStr = arguments.at(++i);
if (warningsStr == QLatin1String("show")) {
@@ -393,8 +394,8 @@ static void parseCommandLineOptions(const QStringList &arguments)
} else {
usage();
}
- } else if (arg == "-I" || arg == "-L") {
- if (arg == "-L")
+ } else if (arg == QLatin1String("-I") || arg == QLatin1String("-L")) {
+ if (arg == QLatin1String("-L"))
qWarning("-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
@@ -403,32 +404,32 @@ static void parseCommandLineOptions(const QStringList &arguments)
exitApp(0);
}
opts.imports << arguments.at(++i);
- } else if (arg == "-P") {
+ } else if (arg == QLatin1String("-P")) {
if (lastArg) usage();
opts.plugins << arguments.at(++i);
- } else if (arg == "-script") {
+ } else if (arg == QLatin1String("-script")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
- } else if (arg == "-scriptopts") {
+ } else if (arg == QLatin1String("-scriptopts")) {
if (lastArg) usage();
opts.scriptopts = arguments.at(++i);
- } else if (arg == "-savescript") {
+ } else if (arg == QLatin1String("-savescript")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = false;
- } else if (arg == "-playscript") {
+ } else if (arg == QLatin1String("-playscript")) {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = true;
- } else if (arg == "-sizeviewtorootobject") {
+ } else if (arg == QLatin1String("-sizeviewtorootobject")) {
opts.sizeToView = false;
- } else if (arg == "-sizerootobjecttoview") {
+ } else if (arg == QLatin1String("-sizerootobjecttoview")) {
opts.sizeToView = true;
- } else if (arg == "-experimentalgestures") {
+ } else if (arg == QLatin1String("-experimentalgestures")) {
opts.experimentalGestures = true;
- } else if (!arg.startsWith('-')) {
+ } else if (!arg.startsWith(QLatin1Char('-'))) {
fileNames.append(arg);
- } else if (true || arg == "-help") {
+ } else if (true || arg == QLatin1String("-help")) {
usage();
}
}
@@ -529,29 +530,41 @@ int main(int argc, char ** argv)
//### default to using raster graphics backend for now
bool gsSpecified = false;
for (int i = 0; i < argc; ++i) {
- QString arg = argv[i];
- if (arg == "-graphicssystem") {
+ QString arg = QString::fromAscii(argv[i]);
+ if (arg == QLatin1String("-graphicssystem")) {
gsSpecified = true;
break;
}
}
if (!gsSpecified)
- QApplication::setGraphicsSystem("raster");
+ QApplication::setGraphicsSystem(QLatin1String("raster"));
#endif
QDeclarativeDebugHelper::enableDebugging();
Application app(argc, argv);
- app.setApplicationName("QtQmlViewer");
- app.setOrganizationName("Nokia");
- app.setOrganizationDomain("nokia.com");
+ app.setApplicationName(QLatin1String("QtQmlViewer"));
+ app.setOrganizationName(QLatin1String("Nokia"));
+ app.setOrganizationDomain(QLatin1String("nokia.com"));
QDeclarativeViewer::registerTypes();
QDeclarativeTester::registerTypes();
parseCommandLineOptions(app.arguments());
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ if (translator.load(QLatin1String("qmlviewer_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ app.installTranslator(&translator);
+ if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ app.installTranslator(&qtTranslator);
+ } else {
+ app.removeTranslator(&translator);
+ }
+ }
+
QTranslator qmlTranslator;
if (!opts.translationFile.isEmpty()) {
if (qmlTranslator.load(opts.translationFile)) {
diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp
index c4dc087263..78963da9a6 100644
--- a/tools/qmlviewer/proxysettings.cpp
+++ b/tools/qmlviewer/proxysettings.cpp
@@ -54,17 +54,17 @@ ProxySettings::ProxySettings (QWidget * parent)
#if !defined Q_WS_MAEMO_5
// the onscreen keyboard can't cope with masks
- proxyServerEdit->setInputMask ("000.000.000.000;_");
+ proxyServerEdit->setInputMask(QLatin1String("000.000.000.000;_"));
#endif
QIntValidator *validator = new QIntValidator (0, 9999, this);
- proxyPortEdit->setValidator (validator);
+ proxyPortEdit->setValidator(validator);
QSettings settings;
- proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ());
- proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ());
- proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ());
- usernameEdit->insert (settings.value ("http_proxy/username", "").toString ());
- passwordEdit->insert (settings.value ("http_proxy/password", "").toString ());
+ proxyCheckBox->setChecked(settings.value(QLatin1String("http_proxy/use"), 0).toBool());
+ proxyServerEdit->insert(settings.value(QLatin1String("http_proxy/hostname")).toString());
+ proxyPortEdit->insert(settings.value(QLatin1String("http_proxy/port"), QLatin1String("80")).toString ());
+ usernameEdit->insert(settings.value(QLatin1String("http_proxy/username")).toString ());
+ passwordEdit->insert(settings.value(QLatin1String("http_proxy/password")).toString ());
}
ProxySettings::~ProxySettings()
@@ -75,11 +75,11 @@ void ProxySettings::accept ()
{
QSettings settings;
- settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ());
- settings.setValue ("http_proxy/hostname", proxyServerEdit->text ());
- settings.setValue ("http_proxy/port", proxyPortEdit->text ());
- settings.setValue ("http_proxy/username", usernameEdit->text ());
- settings.setValue ("http_proxy/password", passwordEdit->text ());
+ settings.setValue(QLatin1String("http_proxy/use"), proxyCheckBox->isChecked());
+ settings.setValue(QLatin1String("http_proxy/hostname"), proxyServerEdit->text());
+ settings.setValue(QLatin1String("http_proxy/port"), proxyPortEdit->text());
+ settings.setValue(QLatin1String("http_proxy/username"), usernameEdit->text());
+ settings.setValue(QLatin1String("http_proxy/password"), passwordEdit->text());
QDialog::accept ();
}
@@ -89,13 +89,13 @@ QNetworkProxy ProxySettings::httpProxy ()
QSettings settings;
QNetworkProxy proxy;
- bool proxyInUse = settings.value ("http_proxy/use", 0).toBool ();
+ bool proxyInUse = settings.value(QLatin1String("http_proxy/use"), 0).toBool();
if (proxyInUse) {
proxy.setType (QNetworkProxy::HttpProxy);
- proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5"
- proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080
- proxy.setUser (settings.value ("http_proxy/username", "").toString ());
- proxy.setPassword (settings.value ("http_proxy/password", "").toString ());
+ proxy.setHostName (settings.value(QLatin1String("http_proxy/hostname")).toString());// "192.168.220.5"
+ proxy.setPort (settings.value(QLatin1String("http_proxy/port"), 80).toInt()); // 8080
+ proxy.setUser (settings.value(QLatin1String("http_proxy/username")).toString());
+ proxy.setPassword (settings.value(QLatin1String("http_proxy/password")).toString());
//QNetworkProxy::setApplicationProxy (proxy);
}
else {
@@ -107,7 +107,7 @@ QNetworkProxy ProxySettings::httpProxy ()
bool ProxySettings::httpProxyInUse()
{
QSettings settings;
- return settings.value ("http_proxy/use", 0).toBool ();
+ return settings.value(QLatin1String("http_proxy/use"), 0).toBool();
}
QT_END_NAMESPACE
diff --git a/tools/qmlviewer/proxysettings_maemo5.ui b/tools/qmlviewer/proxysettings_maemo5.ui
index 83f0c2a9de..75875d835b 100644
--- a/tools/qmlviewer/proxysettings_maemo5.ui
+++ b/tools/qmlviewer/proxysettings_maemo5.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>449</width>
- <height>164</height>
+ <width>447</width>
+ <height>162</height>
</rect>
</property>
<property name="windowTitle">
@@ -88,7 +88,7 @@
<item row="1" column="1">
<widget class="QLineEdit" name="proxyPortEdit">
<property name="text">
- <string>8080</string>
+ <string notr="true">8080</string>
</property>
</widget>
</item>
diff --git a/tools/qmlviewer/qdeclarativetester.cpp b/tools/qmlviewer/qdeclarativetester.cpp
index 11f81fc169..fa8af8f314 100644
--- a/tools/qmlviewer/qdeclarativetester.cpp
+++ b/tools/qmlviewer/qdeclarativetester.cpp
@@ -205,7 +205,7 @@ void QDeclarativeTester::save()
QString filename = m_script + QLatin1String(".qml");
QFileInfo filenameInfo(filename);
QDir saveDir = filenameInfo.absoluteDir();
- saveDir.mkpath(".");
+ saveDir.mkpath(QLatin1String("."));
QFile file(filename);
file.open(QIODevice::WriteOnly);
@@ -224,8 +224,8 @@ void QDeclarativeTester::save()
if (!fe.hash.isEmpty()) {
ts << " hash: \"" << fe.hash.toHex() << "\"\n";
} else if (!fe.image.isNull()) {
- QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png";
- fe.image.save(m_script + "." + QString::number(imgCount) + ".png");
+ QString filename = filenameInfo.baseName() + QLatin1String(".") + QString::number(imgCount) + QLatin1String(".png");
+ fe.image.save(m_script + QLatin1String(".") + QString::number(imgCount) + QLatin1String(".png"));
imgCount++;
ts << " image: \"" << filename << "\"\n";
}
@@ -375,7 +375,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
imagefailure();
}
if (goodImage != img) {
- QString reject(frame->image().toLocalFile() + ".reject.png");
+ QString reject(frame->image().toLocalFile() + QLatin1String(".reject.png"));
qWarning() << "QDeclarativeTester(" << m_script << "): Image mismatch. Reject saved to:"
<< reject;
img.save(reject);
@@ -393,7 +393,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
}
}
}
- QString diff(frame->image().toLocalFile() + ".diff.png");
+ QString diff(frame->image().toLocalFile() + QLatin1String(".diff.png"));
diffimg.save(diff);
qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff;
}
diff --git a/tools/qmlviewer/qmlruntime.cpp b/tools/qmlviewer/qmlruntime.cpp
index 4bae7f3ec0..e49c7f3d42 100644
--- a/tools/qmlviewer/qmlruntime.cpp
+++ b/tools/qmlviewer/qmlruntime.cpp
@@ -265,7 +265,7 @@ public:
hz->setValidator(new QDoubleValidator(hz));
#endif
for (int i=0; ffmpegprofiles[i].name; ++i) {
- profile->addItem(ffmpegprofiles[i].name);
+ profile->addItem(QString::fromAscii(ffmpegprofiles[i].name));
}
}
@@ -273,9 +273,9 @@ public:
{
int i;
for (i=0; ffmpegprofiles[i].args[0]; ++i) {
- if (ffmpegprofiles[i].args == a) {
+ if (QString::fromAscii(ffmpegprofiles[i].args) == a) {
profile->setCurrentIndex(i);
- args->setText(QLatin1String(ffmpegprofiles[i].args));
+ args->setText(QString::fromAscii(ffmpegprofiles[i].args));
return;
}
}
@@ -465,14 +465,14 @@ private:
}
}
QSettings settings;
- settings.setValue("Cookies",data);
+ settings.setValue(QLatin1String("Cookies"), data);
}
void load()
{
QMutexLocker lock(&mutex);
QSettings settings;
- QByteArray data = settings.value("Cookies").toByteArray();
+ QByteArray data = settings.value(QLatin1String("Cookies")).toByteArray();
setAllCookies(QNetworkCookie::parseCookies(data));
}
@@ -490,7 +490,7 @@ public:
if (proxyDirty)
setupProxy();
QString protocolTag = query.protocolTag();
- if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
+ if (httpProxyInUse && (protocolTag == QLatin1String("http") || protocolTag == QLatin1String("https"))) {
QList<QNetworkProxy> ret;
ret << httpProxy;
return ret;
@@ -597,7 +597,7 @@ QString QDeclarativeViewer::getVideoFileName()
if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)");
types += tr("Individual PNG frames")+QLatin1String(" (*.png)");
if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)");
- return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
+ return QFileDialog::getSaveFileName(this, title, QString(), types.join(QLatin1String(";; ")));
}
QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
@@ -725,18 +725,18 @@ void QDeclarativeViewer::createMenu()
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this);
- snapshotAction->setShortcut(QKeySequence("F3"));
+ snapshotAction->setShortcut(QKeySequence(tr("F3")));
connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
recordAction = new QAction(tr("Start Recording &Video"), this);
- recordAction->setShortcut(QKeySequence("F9"));
+ recordAction->setShortcut(QKeySequence(tr("F9")));
connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
QAction *recordOptions = new QAction(tr("Video &Options..."), this);
connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
QAction *slowAction = new QAction(tr("&Slow Down Animations"), this);
- slowAction->setShortcut(QKeySequence("Ctrl+."));
+ slowAction->setShortcut(QKeySequence(tr("Ctrl+.")));
slowAction->setCheckable(true);
connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
@@ -755,7 +755,7 @@ void QDeclarativeViewer::createMenu()
connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
rotateAction = new QAction(tr("Rotate orientation"), this);
- rotateAction->setShortcut(QKeySequence("Ctrl+T"));
+ rotateAction->setShortcut(QKeySequence(tr("Ctrl+T")));
connect(rotateAction, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
orientation = new QActionGroup(this);
@@ -963,7 +963,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
// Profile
- recdlg->setArguments(record_args.join(" "));
+ recdlg->setArguments(record_args.join(QLatin1String(" ")));
if (recdlg->exec()) {
// File
record_file = recdlg->file->text();
@@ -972,7 +972,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
// Rate
record_rate = recdlg->videoRate();
// Profile
- record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
+ record_args = recdlg->arguments().split(QLatin1Char(' '),QString::SkipEmptyParts);
}
}
@@ -983,8 +983,8 @@ void QDeclarativeViewer::toggleRecordingWithSelection()
QString fileName = getVideoFileName();
if (fileName.isEmpty())
return;
- if (!fileName.contains(QRegExp(".[^\\/]*$")))
- fileName += ".avi";
+ if (!fileName.contains(QRegExp(QLatin1String(".[^\\/]*$"))))
+ fileName += QLatin1String(".avi");
setRecordFile(fileName);
}
}
@@ -1026,7 +1026,7 @@ void QDeclarativeViewer::openFile()
{
QString cur = canvas->source().toLocalFile();
if (useQmlFileBrowser) {
- open("qrc:/browser/Browser.qml");
+ open(QLatin1String("qrc:/browser/Browser.qml"));
} else {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
if (!fileName.isEmpty()) {
@@ -1072,7 +1072,7 @@ void QDeclarativeViewer::loadTranslationFile(const QString& directory)
void QDeclarativeViewer::loadDummyDataFiles(const QString& directory)
{
- QDir dir(directory+"/dummydata", "*.qml");
+ QDir dir(directory + QLatin1String("/dummydata"), QLatin1String("*.qml"));
QStringList list = dir.entryList();
for (int i = 0; i < list.size(); ++i) {
QString qml = list.at(i);
@@ -1114,14 +1114,14 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
delete canvas->rootObject();
canvas->engine()->clearComponentCache();
QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("qmlViewer", this);
+ ctxt->setContextProperty(QLatin1String("qmlViewer"), this);
#ifdef Q_OS_SYMBIAN
- ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
+ ctxt->setContextProperty(QLatin1String("qmlViewerFolder"), QLatin1String("E:\\")); // Documents on your S60 phone
#else
- ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
+ ctxt->setContextProperty(QLatin1String("qmlViewerFolder"), QDir::currentPath());
#endif
- ctxt->setContextProperty("runtime", Runtime::instance());
+ ctxt->setContextProperty(QLatin1String("runtime"), Runtime::instance());
QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
@@ -1224,26 +1224,26 @@ bool QDeclarativeViewer::event(QEvent *event)
void QDeclarativeViewer::senseImageMagick()
{
QProcess proc;
- proc.start("convert", QStringList() << "-h");
+ proc.start(QLatin1String("convert"), QStringList() << QLatin1String("-h"));
proc.waitForFinished(2000);
- QString help = proc.readAllStandardOutput();
- convertAvailable = help.contains("ImageMagick");
+ QString help = QString::fromAscii(proc.readAllStandardOutput());
+ convertAvailable = help.contains(QLatin1String("ImageMagick"));
}
void QDeclarativeViewer::senseFfmpeg()
{
QProcess proc;
- proc.start("ffmpeg", QStringList() << "-h");
+ proc.start(QLatin1String("ffmpeg"), QStringList() << QLatin1String("-h"));
proc.waitForFinished(2000);
- QString ffmpegHelp = proc.readAllStandardOutput();
- ffmpegAvailable = ffmpegHelp.contains("-s ");
- ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp;
+ QString ffmpegHelp = QString::fromAscii(proc.readAllStandardOutput());
+ ffmpegAvailable = ffmpegHelp.contains(QLatin1String("-s "));
+ ffmpegHelp = tr("Video recording uses ffmpeg:") + QLatin1String("\n\n") + ffmpegHelp;
QDialog *d = new QDialog(recdlg);
QVBoxLayout *l = new QVBoxLayout(d);
QTextBrowser *b = new QTextBrowser(d);
QFont f = b->font();
- f.setFamily("courier");
+ f.setFamily(QLatin1String("courier"));
b->setFont(f);
b->setText(ffmpegHelp);
l->addWidget(b);
@@ -1266,7 +1266,7 @@ void QDeclarativeViewer::setRecording(bool on)
recordTimer.start();
frame_fmt = record_file.right(4).toLower();
frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32);
- if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) {
+ if (frame_fmt != QLatin1String(".png") && (!convertAvailable || frame_fmt != QLatin1String(".gif"))) {
// Stream video to ffmpeg
QProcess *proc = new QProcess(this);
@@ -1274,19 +1274,19 @@ void QDeclarativeViewer::setRecording(bool on)
frame_stream = proc;
QStringList args;
- args << "-y";
- args << "-r" << QString::number(record_rate);
- args << "-f" << "rawvideo";
- args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32");
- args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height());
- args << "-i" << "-";
+ args << QLatin1String("-y");
+ args << QLatin1String("-r") << QString::number(record_rate);
+ args << QLatin1String("-f") << QLatin1String("rawvideo");
+ args << QLatin1String("-pix_fmt") << (frame_fmt == QLatin1String(".gif") ? QLatin1String("rgb24") : QLatin1String("rgb32"));
+ args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(canvas->width()).arg(canvas->height());
+ args << QLatin1String("-i") << QLatin1String("-");
if (record_outsize.isValid()) {
- args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
- args << "-aspect" << QString::number(double(canvas->width())/canvas->height());
+ args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
+ args << QLatin1String("-aspect") << QString::number(double(canvas->width())/canvas->height());
}
args += record_args;
args << record_file;
- proc->start("ffmpeg",args);
+ proc->start(QLatin1String("ffmpeg"), args);
} else {
// Store frames, save to GIF/PNG
@@ -1309,14 +1309,14 @@ void QDeclarativeViewer::setRecording(bool on)
QString framename;
bool png_output = false;
- if (record_file.right(4).toLower()==".png") {
- if (record_file.contains('%'))
+ if (record_file.right(4).toLower() == QLatin1String(".png")) {
+ if (record_file.contains(QLatin1Char('%')))
framename = record_file;
else
- framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4);
+ framename = record_file.left(record_file.length()-4) + QLatin1String("%04d") + record_file.right(4);
png_output = true;
} else {
- framename = "tmp-frame%04d.png";
+ framename = QLatin1String("tmp-frame%04d.png");
png_output = false;
}
foreach (QImage* img, frames) {
@@ -1327,11 +1327,11 @@ void QDeclarativeViewer::setRecording(bool on)
name.sprintf(framename.toLocal8Bit(),frame++);
if (record_outsize.isValid())
*img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
- if (record_dither=="ordered")
+ if (record_dither==QLatin1String("ordered"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name);
- else if (record_dither=="threshold")
+ else if (record_dither==QLatin1String("threshold"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name);
- else if (record_dither=="floyd")
+ else if (record_dither==QLatin1String("floyd"))
img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name);
else
img->save(name);
@@ -1341,25 +1341,26 @@ void QDeclarativeViewer::setRecording(bool on)
if (!progress.wasCanceled()) {
if (png_output) {
- framename.replace(QRegExp("%\\d*."),"*");
+ framename.replace(QRegExp(QLatin1String("%\\d*.")), QLatin1String("*"));
qDebug() << "Wrote frames" << framename;
inputs.clear(); // don't remove them
} else {
// ImageMagick and gifsicle for GIF encoding
progress.setLabelText(tr("Converting frames to GIF file..."));
QStringList args;
- args << "-delay" << QString::number(period/10);
+ args << QLatin1String("-delay") << QString::number(period/10);
args << inputs;
args << record_file;
qDebug() << "Converting..." << record_file << "(this may take a while)";
- if (0!=QProcess::execute("convert", args)) {
+ if (0!=QProcess::execute(QLatin1String("convert"), args)) {
qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
inputs.clear(); // don't remove them
qDebug() << "Wrote frames tmp-frame*.png";
} else {
- if (record_file.right(4).toLower() == ".gif") {
+ if (record_file.right(4).toLower() == QLatin1String(".gif")) {
qDebug() << "Compressing..." << record_file;
- if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file))
+ if (0!=QProcess::execute(QLatin1String("gifsicle"), QStringList() << QLatin1String("-O2")
+ << QLatin1String("-o") << record_file << record_file))
qWarning() << "Cannot run 'gifsicle' - not compressed";
}
qDebug() << "Wrote" << record_file;
@@ -1410,7 +1411,7 @@ void QDeclarativeViewer::recordFrame()
{
canvas->QWidget::render(&frame);
if (frame_stream) {
- if (frame_fmt == ".gif") {
+ if (frame_fmt == QLatin1String(".gif")) {
// ffmpeg can't do 32bpp with gif
QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888);
frame_stream->write((char*)rgb24.bits(),rgb24.numBytes());
@@ -1542,8 +1543,8 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
- qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation","");
- qmlRegisterUncreatableType<DeviceOrientation>("QtQuick",1,0,"Orientation","");
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt", 4, 7, "Orientation", QString());
+ qmlRegisterUncreatableType<DeviceOrientation>("QtQuick", 1, 0, "Orientation", QString());
registered = true;
}
}
diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro
index a185bdc9b4..87b5899fcc 100644
--- a/tools/qmlviewer/qmlviewer.pro
+++ b/tools/qmlviewer/qmlviewer.pro
@@ -10,6 +10,8 @@ INCLUDEPATH += ../../include/QtDeclarative
INCLUDEPATH += ../../src/declarative/util
INCLUDEPATH += ../../src/declarative/graphicsitems
+DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
+
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target