diff options
Diffstat (limited to 'demos/embeddeddialogs')
-rw-r--r-- | demos/embeddeddialogs/No-Ones-Laughing-3.jpg | bin | 30730 -> 0 bytes | |||
-rw-r--r-- | demos/embeddeddialogs/customproxy.cpp | 167 | ||||
-rw-r--r-- | demos/embeddeddialogs/customproxy.h | 76 | ||||
-rw-r--r-- | demos/embeddeddialogs/embeddeddialog.cpp | 106 | ||||
-rw-r--r-- | demos/embeddeddialogs/embeddeddialog.h | 66 | ||||
-rw-r--r-- | demos/embeddeddialogs/embeddeddialog.ui | 87 | ||||
-rw-r--r-- | demos/embeddeddialogs/embeddeddialogs.pro | 20 | ||||
-rw-r--r-- | demos/embeddeddialogs/embeddeddialogs.qrc | 5 | ||||
-rw-r--r-- | demos/embeddeddialogs/main.cpp | 83 |
9 files changed, 0 insertions, 610 deletions
diff --git a/demos/embeddeddialogs/No-Ones-Laughing-3.jpg b/demos/embeddeddialogs/No-Ones-Laughing-3.jpg Binary files differdeleted file mode 100644 index 445567fbda..0000000000 --- a/demos/embeddeddialogs/No-Ones-Laughing-3.jpg +++ /dev/null diff --git a/demos/embeddeddialogs/customproxy.cpp b/demos/embeddeddialogs/customproxy.cpp deleted file mode 100644 index 13f5f654c2..0000000000 --- a/demos/embeddeddialogs/customproxy.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customproxy.h" - -#include <QtWidgets> - -CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(0) -{ - timeLine = new QTimeLine(250, this); - connect(timeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(updateStep(qreal))); - connect(timeLine, SIGNAL(stateChanged(QTimeLine::State)), - this, SLOT(stateChanged(QTimeLine::State))); -} - -QRectF CustomProxy::boundingRect() const -{ - return QGraphicsProxyWidget::boundingRect().adjusted(0, 0, 10, 10); -} - -void CustomProxy::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - const QColor color(0, 0, 0, 64); - - QRectF r = windowFrameRect(); - QRectF right(r.right(), r.top() + 10, 10, r.height() - 10); - QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10); - bool intersectsRight = right.intersects(option->exposedRect); - bool intersectsBottom = bottom.intersects(option->exposedRect); - if (intersectsRight && intersectsBottom) { - QPainterPath path; - path.addRect(right); - path.addRect(bottom); - painter->setPen(Qt::NoPen); - painter->setBrush(color); - painter->drawPath(path); - } else if (intersectsBottom) { - painter->fillRect(bottom, color); - } else if (intersectsRight) { - painter->fillRect(right, color); - } - - QGraphicsProxyWidget::paintWindowFrame(painter, option, widget); -} - -void CustomProxy::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - QGraphicsProxyWidget::hoverEnterEvent(event); - scene()->setActiveWindow(this); - if (timeLine->currentValue() != 1) - zoomIn(); -} - -void CustomProxy::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - QGraphicsProxyWidget::hoverLeaveEvent(event); - if (!popupShown && (timeLine->direction() != QTimeLine::Backward || timeLine->currentValue() != 0)) - zoomOut(); -} - -bool CustomProxy::sceneEventFilter(QGraphicsItem *watched, QEvent *event) -{ - if (watched->isWindow() && (event->type() == QEvent::UngrabMouse || event->type() == QEvent::GrabMouse)) { - popupShown = watched->isVisible(); - if (!popupShown && !isUnderMouse()) - zoomOut(); - } - return QGraphicsProxyWidget::sceneEventFilter(watched, event); -} - -QVariant CustomProxy::itemChange(GraphicsItemChange change, const QVariant &value) -{ - if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { - if (change == ItemChildAddedChange) { - currentPopup = qvariant_cast<QGraphicsItem *>(value); - currentPopup->setCacheMode(ItemCoordinateCache); - if (scene()) - currentPopup->installSceneEventFilter(this); - } else if (scene()) { - currentPopup->removeSceneEventFilter(this); - currentPopup = 0; - } - } else if (currentPopup && change == ItemSceneHasChanged) { - currentPopup->installSceneEventFilter(this); - } - return QGraphicsProxyWidget::itemChange(change, value); -} - -void CustomProxy::updateStep(qreal step) -{ - QRectF r = boundingRect(); - setTransform(QTransform() - .translate(r.width() / 2, r.height() / 2) - .rotate(step * 30, Qt::XAxis) - .rotate(step * 10, Qt::YAxis) - .rotate(step * 5, Qt::ZAxis) - .scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, -r.height() / 2)); -} - -void CustomProxy::stateChanged(QTimeLine::State state) -{ - if (state == QTimeLine::Running) { - if (timeLine->direction() == QTimeLine::Forward) - setCacheMode(ItemCoordinateCache); - } else if (state == QTimeLine::NotRunning) { - if (timeLine->direction() == QTimeLine::Backward) - setCacheMode(DeviceCoordinateCache); - } -} - -void CustomProxy::zoomIn() -{ - if (timeLine->direction() != QTimeLine::Forward) - timeLine->setDirection(QTimeLine::Forward); - if (timeLine->state() == QTimeLine::NotRunning) - timeLine->start(); -} - -void CustomProxy::zoomOut() -{ - if (timeLine->direction() != QTimeLine::Backward) - timeLine->setDirection(QTimeLine::Backward); - if (timeLine->state() == QTimeLine::NotRunning) - timeLine->start(); -} diff --git a/demos/embeddeddialogs/customproxy.h b/demos/embeddeddialogs/customproxy.h deleted file mode 100644 index 0ac7c7afe4..0000000000 --- a/demos/embeddeddialogs/customproxy.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMPROXY_H -#define CUSTOMPROXY_H - -#include <QtCore/qtimeline.h> -#include <QtWidgets/qgraphicsproxywidget.h> - -class CustomProxy : public QGraphicsProxyWidget -{ - Q_OBJECT -public: - CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); - - QRectF boundingRect() const; - void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget); - -protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private slots: - void updateStep(qreal step); - void stateChanged(QTimeLine::State); - void zoomIn(); - void zoomOut(); - -private: - QTimeLine *timeLine; - bool popupShown; - QGraphicsItem *currentPopup; -}; - -#endif diff --git a/demos/embeddeddialogs/embeddeddialog.cpp b/demos/embeddeddialogs/embeddeddialog.cpp deleted file mode 100644 index f608fc5558..0000000000 --- a/demos/embeddeddialogs/embeddeddialog.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "embeddeddialog.h" -#include "ui_embeddeddialog.h" - -#include <QtWidgets> - -EmbeddedDialog::EmbeddedDialog(QWidget *parent) - : QDialog(parent) -{ - ui = new Ui_embeddedDialog; - ui->setupUi(this); - ui->layoutDirection->setCurrentIndex(layoutDirection() != Qt::LeftToRight); - - foreach (QString styleName, QStyleFactory::keys()) { - ui->style->addItem(styleName); - if (style()->objectName().toLower() == styleName.toLower()) - ui->style->setCurrentIndex(ui->style->count() - 1); - } - - connect(ui->layoutDirection, SIGNAL(activated(int)), - this, SLOT(layoutDirectionChanged(int))); - connect(ui->spacing, SIGNAL(valueChanged(int)), - this, SLOT(spacingChanged(int))); - connect(ui->fontComboBox, SIGNAL(currentFontChanged(QFont)), - this, SLOT(fontChanged(QFont))); - connect(ui->style, SIGNAL(activated(QString)), - this, SLOT(styleChanged(QString))); -} - -EmbeddedDialog::~EmbeddedDialog() -{ - delete ui; -} - -void EmbeddedDialog::layoutDirectionChanged(int index) -{ - setLayoutDirection(index == 0 ? Qt::LeftToRight : Qt::RightToLeft); -} - -void EmbeddedDialog::spacingChanged(int spacing) -{ - layout()->setSpacing(spacing); - adjustSize(); -} - -void EmbeddedDialog::fontChanged(const QFont &font) -{ - setFont(font); -} - -static void setStyleHelper(QWidget *widget, QStyle *style) -{ - widget->setStyle(style); - widget->setPalette(style->standardPalette()); - foreach (QObject *child, widget->children()) { - if (QWidget *childWidget = qobject_cast<QWidget *>(child)) - setStyleHelper(childWidget, style); - } -} - -void EmbeddedDialog::styleChanged(const QString &styleName) -{ - QStyle *style = QStyleFactory::create(styleName); - if (style) - setStyleHelper(this, style); -} diff --git a/demos/embeddeddialogs/embeddeddialog.h b/demos/embeddeddialogs/embeddeddialog.h deleted file mode 100644 index 1c7051fac9..0000000000 --- a/demos/embeddeddialogs/embeddeddialog.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef EMBEDDEDDIALOG_H -#define EMBEDDEDDIALOG_H - -#include <QtWidgets/qdialog.h> - -QT_FORWARD_DECLARE_CLASS(Ui_embeddedDialog); - -class EmbeddedDialog : public QDialog -{ - Q_OBJECT -public: - EmbeddedDialog(QWidget *parent = 0); - ~EmbeddedDialog(); - -private slots: - void layoutDirectionChanged(int index); - void spacingChanged(int spacing); - void fontChanged(const QFont &font); - void styleChanged(const QString &styleName); - -private: - Ui_embeddedDialog *ui; -}; - -#endif diff --git a/demos/embeddeddialogs/embeddeddialog.ui b/demos/embeddeddialogs/embeddeddialog.ui deleted file mode 100644 index f967b10085..0000000000 --- a/demos/embeddeddialogs/embeddeddialog.ui +++ /dev/null @@ -1,87 +0,0 @@ -<ui version="4.0" > - <class>embeddedDialog</class> - <widget class="QDialog" name="embeddedDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>407</width> - <height>134</height> - </rect> - </property> - <property name="windowTitle" > - <string>Embedded Dialog</string> - </property> - <layout class="QFormLayout" name="formLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Layout Direction:</string> - </property> - <property name="buddy" > - <cstring>layoutDirection</cstring> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QComboBox" name="layoutDirection" > - <item> - <property name="text" > - <string>Left to Right</string> - </property> - </item> - <item> - <property name="text" > - <string>Right to Left</string> - </property> - </item> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>Select Font:</string> - </property> - <property name="buddy" > - <cstring>fontComboBox</cstring> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QFontComboBox" name="fontComboBox" /> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="label_3" > - <property name="text" > - <string>Style:</string> - </property> - <property name="buddy" > - <cstring>style</cstring> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QComboBox" name="style" /> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="label_4" > - <property name="text" > - <string>Layout spacing:</string> - </property> - <property name="buddy" > - <cstring>spacing</cstring> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QSlider" name="spacing" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/demos/embeddeddialogs/embeddeddialogs.pro b/demos/embeddeddialogs/embeddeddialogs.pro deleted file mode 100644 index 30cde78751..0000000000 --- a/demos/embeddeddialogs/embeddeddialogs.pro +++ /dev/null @@ -1,20 +0,0 @@ -SOURCES += main.cpp -SOURCES += customproxy.cpp embeddeddialog.cpp -HEADERS += customproxy.h embeddeddialog.h - -FORMS += embeddeddialog.ui -RESOURCES += embeddeddialogs.qrc - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -# install -target.path = $$[QT_INSTALL_DEMOS]/qtbase/embeddeddialogs -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.png *.jpg *.plist *.icns *.ico *.rc *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embeddeddialogs -INSTALLS += target sources - -symbian: CONFIG += qt_demo -QT += widgets widgets diff --git a/demos/embeddeddialogs/embeddeddialogs.qrc b/demos/embeddeddialogs/embeddeddialogs.qrc deleted file mode 100644 index 33be5038da..0000000000 --- a/demos/embeddeddialogs/embeddeddialogs.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource> - <file>No-Ones-Laughing-3.jpg</file> - </qresource> -</RCC> diff --git a/demos/embeddeddialogs/main.cpp b/demos/embeddeddialogs/main.cpp deleted file mode 100644 index 76d77538d8..0000000000 --- a/demos/embeddeddialogs/main.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "customproxy.h" -#include "embeddeddialog.h" - -#include <QtWidgets> - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(embeddeddialogs); - QApplication app(argc, argv); - - QGraphicsScene scene; - scene.setStickyFocus(true); -#ifndef Q_OS_WINCE - const int gridSize = 10; -#else - const int gridSize = 5; -#endif - - for (int y = 0; y < gridSize; ++y) { - for (int x = 0; x < gridSize; ++x) { - CustomProxy *proxy = new CustomProxy(0, Qt::Window); - proxy->setWidget(new EmbeddedDialog); - - QRectF rect = proxy->boundingRect(); - - proxy->setPos(x * rect.width() * 1.05, y * rect.height() * 1.05); - proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - - scene.addItem(proxy); - } - } - scene.setSceneRect(scene.itemsBoundingRect()); - - QGraphicsView view(&scene); - view.scale(0.5, 0.5); - view.setRenderHints(view.renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - view.setBackgroundBrush(QPixmap(":/No-Ones-Laughing-3.jpg")); - view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view.show(); - view.setWindowTitle("Embedded Dialogs Demo"); - return app.exec(); -} |