From 336feccaf4517605306844690103baf331f11d50 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 May 2010 08:24:00 +0200 Subject: Remove skins from qml launcher. --- tools/qml/main.cpp | 21 ---- tools/qml/qml.pri | 2 - tools/qml/qmlruntime.cpp | 244 +---------------------------------------------- tools/qml/qmlruntime.h | 6 -- 4 files changed, 2 insertions(+), 271 deletions(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 116ca71..d1fc118 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -119,9 +119,6 @@ void usage() qWarning(" -maximized................................ run maximized"); qWarning(" -fullscreen............................... run fullscreen"); qWarning(" -stayontop................................ keep viewer window on top"); - qWarning(" -skin ...................... run with a skin window frame"); - qWarning(" \"list\" for a list of built-ins"); - qWarning(" -resizeview .............................. resize the view, not the skin"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); @@ -209,7 +206,6 @@ int main(int argc, char ** argv) QDeclarativeFolderListModel::registerTypes(); bool frameless = false; - bool resizeview = false; QString fileName; double fps = 0; int autorecord_from = 0; @@ -219,7 +215,6 @@ int main(int argc, char ** argv) QStringList recordargs; QStringList imports; QStringList plugins; - QString skin; QString script; QString scriptopts; bool runScript = false; @@ -252,11 +247,6 @@ int main(int argc, char ** argv) fullScreen = true; } else if (arg == "-stayontop") { stayOnTop = true; - } else if (arg == "-skin") { - if (lastArg) usage(); - skin = QString(argv[++i]); - } else if (arg == "-resizeview") { - resizeview = true; } else if (arg == "-netcache") { if (lastArg) usage(); cache = QString(argv[++i]).toInt(); @@ -418,21 +408,10 @@ int main(int argc, char ** argv) viewer->setNetworkCacheSize(cache); viewer->setRecordFile(recordfile); viewer->setSizeToView(sizeToView); - if (resizeview) - viewer->setScaleView(); if (fps>0) viewer->setRecordRate(fps); if (autorecord_to) viewer->setAutoRecord(autorecord_from,autorecord_to); - if (!skin.isEmpty()) { - if (skin == "list") { - foreach (QString s, viewer->builtinSkins()) - qWarning() << qPrintable(s); - exit(0); - } else { - viewer->setSkin(skin); - } - } if (devkeys) viewer->setDeviceKeys(true); viewer->setRecordDither(dither); diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 3c86d31..a2058c7 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -32,5 +32,3 @@ symbian { FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui - -include(../shared/deviceskin/deviceskin.pri) 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 #include -#include "deviceskin.h" #include #include @@ -168,89 +167,6 @@ private: QWidget *refWidget; }; - -class PreviewDeviceSkin : public DeviceSkin -{ - Q_OBJECT -public: - explicit PreviewDeviceSkin(const DeviceSkinParameters ¶meters, 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 ¶meters, 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(); } diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index b021d0d..0416b32 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,7 +105,6 @@ public: void setUseNativeFileBrowser(bool); void updateSizeHints(); void setSizeToView(bool sizeToView); - QStringList builtinSkins() const; QMenuBar *menuBar() const; @@ -123,10 +122,8 @@ public slots: void toggleRecording(); void toggleRecordingWithSelection(); void ffmpegFinished(int code); - void setSkin(const QString& skinDirectory); void showProxySettings (); void proxySettingsChanged (); - void setScaleView(); void toggleOrientation(); void statusChanged(); void setSlowMode(bool); @@ -143,7 +140,6 @@ private slots: void recordFrame(); void chooseRecordingOptions(); void pickRecordingFile(); - void setScaleSkin(); void setPortrait(); void setLandscape(); void startNetwork(); @@ -159,8 +155,6 @@ private: int menuBarHeight() const; LoggerWidget *loggerWindow; - PreviewDeviceSkin *skin; - QSize skinscreensize; QDeclarativeView *canvas; QSize initialSize; QString currentFileOrUrl; -- cgit v0.12