summaryrefslogtreecommitdiffstats
path: root/tools/qml/qmlruntime.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2010-05-14 06:24:00 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2010-05-14 14:56:21 (GMT)
commit336feccaf4517605306844690103baf331f11d50 (patch)
tree57dab4708f7c3411af3da2185f597382a7aa5147 /tools/qml/qmlruntime.cpp
parentc25737a44fb22668c67568eefb61c72457166dfe (diff)
downloadQt-336feccaf4517605306844690103baf331f11d50.zip
Qt-336feccaf4517605306844690103baf331f11d50.tar.gz
Qt-336feccaf4517605306844690103baf331f11d50.tar.bz2
Remove skins from qml launcher.
Diffstat (limited to 'tools/qml/qmlruntime.cpp')
-rw-r--r--tools/qml/qmlruntime.cpp244
1 files changed, 2 insertions, 242 deletions
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 16b0ffb..911bf8c 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -53,7 +53,6 @@
#include "qdeclarative.h"
#include <private/qabstractanimation_p.h>
#include <QAbstractAnimation>
-#include "deviceskin.h"
#include <QSettings>
#include <QXmlStreamReader>
@@ -168,89 +167,6 @@ private:
QWidget *refWidget;
};
-
-class PreviewDeviceSkin : public DeviceSkin
-{
- Q_OBJECT
-public:
- explicit PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent);
-
- void setPreview(QWidget *formWidget);
- void setPreviewAndScale(QWidget *formWidget);
-
- void setScreenSize(const QSize& size)
- {
- QMatrix fit;
- fit = fit.scale(qreal(size.width())/m_screenSize.width(),
- qreal(size.height())/m_screenSize.height());
- setTransform(fit);
- QApplication::syncX();
- }
-
- QSize standardScreenSize() const { return m_screenSize; }
-
- QMenu* menu;
-
-private slots:
- void slotSkinKeyPressEvent(int code, const QString& text, bool autorep);
- void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep);
- void slotPopupMenu();
-
-private:
- const QSize m_screenSize;
-};
-
-
-PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent) :
- DeviceSkin(parameters, parent),
- m_screenSize(parameters.screenSize())
-{
- menu = new QMenu(this);
- connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)),
- this, SLOT(slotSkinKeyPressEvent(int,QString,bool)));
- connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)),
- this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool)));
- connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu()));
-}
-
-void PreviewDeviceSkin::setPreview(QWidget *formWidget)
-{
- formWidget->setFixedSize(m_screenSize);
- formWidget->setParent(this, Qt::SubWindow);
- formWidget->setAutoFillBackground(true);
- setView(formWidget);
-}
-
-void PreviewDeviceSkin::setPreviewAndScale(QWidget *formWidget)
-{
- setScreenSize(formWidget->sizeHint());
- formWidget->setParent(this, Qt::SubWindow);
- formWidget->setAutoFillBackground(true);
- setView(formWidget);
-}
-
-void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep)
-{
- if (QWidget *focusWidget = QApplication::focusWidget()) {
- QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
- QApplication::sendEvent(focusWidget, &e);
- }
-
-}
-
-void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep)
-{
- if (QWidget *focusWidget = QApplication::focusWidget()) {
- QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep);
- QApplication::sendEvent(focusWidget, &e);
- }
-}
-
-void PreviewDeviceSkin::slotPopupMenu()
-{
- menu->exec(QCursor::pos());
-}
-
static struct { const char *name, *args; } ffmpegprofiles[] = {
{"Maximum Quality", "-sameq"},
{"High Quality", "-qmax 2"},
@@ -463,7 +379,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
#endif
, loggerWindow(new LoggerWidget())
- , frame_stream(0), scaleSkin(true), mb(0)
+ , frame_stream(0), mb(0)
, portraitOrientation(0), landscapeOrientation(0)
, showWarningsWindow(0)
, m_scriptOptions(0)
@@ -475,7 +391,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
setWindowTitle(tr("Qt Qml Runtime"));
devicemode = false;
- skin = 0;
canvas = 0;
record_autotime = 0;
record_rate = 50;
@@ -653,51 +568,6 @@ void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
if (flatmenu) flatmenu->addSeparator();
- QMenu *skinMenu = flatmenu ? flatmenu->addMenu(tr("&Skin")) : menu->addMenu(tr("&Skin"));
-
- QActionGroup *skinActions;
- QAction *skinAction;
-
- skinActions = new QActionGroup(parent);
- skinAction = new QAction(tr("Scale skin"), parent);
- skinAction->setCheckable(true);
- skinAction->setChecked(scaleSkin);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleSkin()));
- skinAction = new QAction(tr("Resize view"), parent);
- skinAction->setCheckable(true);
- skinAction->setChecked(!scaleSkin);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleView()));
- skinMenu->addSeparator();
-
- skinActions = new QActionGroup(parent);
- QSignalMapper *mapper = new QSignalMapper(parent);
- skinAction = new QAction(tr("None"), parent);
- skinAction->setCheckable(true);
- if (currentSkin.isEmpty())
- skinAction->setChecked(true);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- mapper->setMapping(skinAction, "");
- connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
- skinMenu->addSeparator();
-
- foreach (QString name, builtinSkins()) {
- skinAction = new QAction(name, parent);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- skinAction->setCheckable(true);
- if (":skin/"+name+".skin" == currentSkin)
- skinAction->setChecked(true);
- mapper->setMapping(skinAction, name);
- connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
- }
- connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString)));
-
- if (flatmenu) flatmenu->addSeparator();
#endif // Q_OS_SYMBIAN
QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
@@ -813,31 +683,6 @@ void QDeclarativeViewer::warningsWidgetClosed()
showWarningsWindow->setChecked(false);
}
-void QDeclarativeViewer::setScaleSkin()
-{
- if (scaleSkin)
- return;
- scaleSkin = true;
- if (skin) {
- canvas->resize(initialSize);
- canvas->setFixedSize(initialSize);
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- updateSizeHints();
- }
-}
-
-void QDeclarativeViewer::setScaleView()
-{
- if (!scaleSkin)
- return;
- scaleSkin = false;
- if (skin) {
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- updateSizeHints();
- }
-}
-
-
void QDeclarativeViewer::takeSnapShot()
{
static int snapshotcount = 1;
@@ -1091,83 +936,6 @@ void QDeclarativeViewer::startNetwork()
#endif
}
-QStringList QDeclarativeViewer::builtinSkins() const
-{
- QDir dir(":/skins/","*.skin");
- const QFileInfoList l = dir.entryInfoList();
- QStringList r;
- for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) {
- r += (*it).baseName();
- }
- return r;
-}
-
-void QDeclarativeViewer::setSkin(const QString& skinDirOrName)
-{
- QString skinDirectory = skinDirOrName;
-
- if (!QDir(skinDirOrName).exists() && QDir(":/skins/"+skinDirOrName+".skin").exists())
- skinDirectory = ":/skins/"+skinDirOrName+".skin";
-
- if (currentSkin == skinDirectory)
- return;
-
- currentSkin = skinDirectory;
-
- // XXX QWidget::setMask does not handle changes well, and we may
- // XXX have been signalled from an item in a menu we're replacing,
- // XXX hence some rather convoluted resetting here...
-
- QString err;
- if (skin) {
- skin->hide();
- skin->deleteLater();
- }
-
- DeviceSkinParameters parameters;
- if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) {
- layout()->setEnabled(false);
- if (mb)
- mb->hide();
- if (!err.isEmpty())
- qWarning() << err;
- skin = new PreviewDeviceSkin(parameters,this);
- if (scaleSkin)
- skin->setPreviewAndScale(canvas);
- else
- skin->setPreview(canvas);
- createMenu(0,skin->menu);
- if (scaleSkin) {
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- }
- updateSizeHints();
- skin->show();
- } else if (skin) {
- skin = 0;
- clearMask();
- if ((windowFlags() & Qt::FramelessWindowHint)) {
- menuBar()->clear();
- createMenu(menuBar(),0);
- }
- canvas->setParent(this, Qt::SubWindow);
- setParent(0,windowFlags()); // recreate
- mb->show();
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- updateSizeHints();
-
- layout()->setEnabled(true);
- if (!scaleSkin) {
- canvas->resize(initialSize);
- canvas->setFixedSize(initialSize);
- }
- QSize newWindowSize = canvas->size();
- newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
- resize(newWindowSize);
- show();
- }
- canvas->show();
-}
-
void QDeclarativeViewer::setAutoRecord(int from, int to)
{
if (from==0) from=1; // ensure resized
@@ -1496,24 +1264,16 @@ void QDeclarativeViewer::updateSizeHints()
{
if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) {
QSize newWindowSize = canvas->sizeHint();
- if (!skin)
- newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
+ newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
if (!isFullScreen() && !isMaximized()) {
resize(newWindowSize);
setFixedSize(newWindowSize);
- if (skin && scaleSkin) {
- skin->setScreenSize(newWindowSize);
- }
}
} else { // QDeclarativeView::SizeRootObjectToView
canvas->setMinimumSize(QSize(0,0));
canvas->setMaximumSize(QSize(16777215,16777215));
setMinimumSize(QSize(0,0));
setMaximumSize(QSize(16777215,16777215));
- if (skin && !scaleSkin) {
- canvas->setFixedSize(skin->standardScreenSize());
- skin->setScreenSize(skin->standardScreenSize());
- }
}
updateGeometry();
}