diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/effects/effects.pro | 3 | ||||
-rw-r--r-- | examples/effects/fademessage/README.txt | 2 | ||||
-rw-r--r-- | examples/effects/fademessage/background.jpg | bin | 0 -> 159108 bytes | |||
-rw-r--r-- | examples/effects/fademessage/fademessage.cpp | 124 | ||||
-rw-r--r-- | examples/effects/fademessage/fademessage.h | 72 | ||||
-rw-r--r-- | examples/effects/fademessage/fademessage.pro | 13 | ||||
-rw-r--r-- | examples/effects/fademessage/fademessage.qrc | 5 | ||||
-rw-r--r-- | examples/effects/fademessage/main.cpp | 56 | ||||
-rw-r--r-- | examples/effects/lighting/lighting.cpp | 4 | ||||
-rw-r--r-- | examples/graphicsview/anchorlayout/main.cpp | 83 | ||||
-rw-r--r-- | examples/multimedia/audio/audiodevices/audiodevices.cpp | 12 | ||||
-rw-r--r-- | examples/multimedia/audio/audiodevices/audiodevicesbase.ui | 6 | ||||
-rw-r--r-- | examples/opengl/hellogl_es2/glwidget.cpp | 4 |
13 files changed, 322 insertions, 62 deletions
diff --git a/examples/effects/effects.pro b/examples/effects/effects.pro index 60b5baf..01fa293 100644 --- a/examples/effects/effects.pro +++ b/examples/effects/effects.pro @@ -2,7 +2,8 @@ TEMPLATE = \ subdirs SUBDIRS = \ blurpicker \ - lighting + lighting \ + fademessage contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2):SUBDIRS += customshader diff --git a/examples/effects/fademessage/README.txt b/examples/effects/fademessage/README.txt new file mode 100644 index 0000000..f639e76 --- /dev/null +++ b/examples/effects/fademessage/README.txt @@ -0,0 +1,2 @@ +The background is taken from a public domain photo at: +http://www.photos8.com/view/windows_problem_blue-800x600.html diff --git a/examples/effects/fademessage/background.jpg b/examples/effects/fademessage/background.jpg Binary files differnew file mode 100644 index 0000000..9884233 --- /dev/null +++ b/examples/effects/fademessage/background.jpg diff --git a/examples/effects/fademessage/fademessage.cpp b/examples/effects/fademessage/fademessage.cpp new file mode 100644 index 0000000..818d00f --- /dev/null +++ b/examples/effects/fademessage/fademessage.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fademessage.h" + +#include <QtGui> + +FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent), m_index(0.0) +{ + setScene(&m_scene); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + setupScene(); + + m_timeLine = new QTimeLine(500, this); + m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); + connect(m_timeLine, SIGNAL(valueChanged(qreal)), m_effect, SLOT(setStrength(qreal))); + + setRenderHint(QPainter::Antialiasing, true); + setFrameStyle(QFrame::NoFrame); +} + +void FadeMessage::togglePopup() +{ + if (m_message->isVisible()) { + m_message->setVisible(false); + m_timeLine->setDirection(QTimeLine::Backward); + m_timeLine->start(); + } else { + m_message->setVisible(true); + m_timeLine->setDirection(QTimeLine::Forward); + m_timeLine->start(); + } +} + +void FadeMessage::setupScene() +{ + QGraphicsRectItem *parent = m_scene.addRect(0, 0, 400, 600); + parent->setPen(Qt::NoPen); + parent->setZValue(0); + + QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/background.jpg")); + bg->setParentItem(parent); + bg->setZValue(-1); + + for (int i = 1; i < 5; ++i) + for (int j = 2; j < 5; ++j) { + QGraphicsRectItem *item = m_scene.addRect(i * 50, j * 50, 38, 38); + item->setParentItem(parent); + item->setZValue(1); + int hue = 12 * (i * 5 + j); + item->setBrush(QColor::fromHsv(hue, 128, 128)); + } + + QFont font; + font.setPointSize(font.pointSize() * 2); + font.setBold(true); + int fh = QFontMetrics(font).height(); + + QGraphicsRectItem *block = m_scene.addRect(50, 300, 300, fh + 3); + block->setPen(Qt::NoPen); + block->setBrush(QColor(102, 153, 51)); + + QGraphicsTextItem *text = m_scene.addText("Qt Everywhere!", font); + text->setDefaultTextColor(Qt::white); + text->setPos(50, 300); + block->setZValue(2); + block->hide(); + + text->setParentItem(block); + m_message = block; + + m_effect = new QGraphicsColorizeEffect; + m_effect->setColor(QColor(122, 193, 66)); + m_effect->setStrength(0); + m_effect->setEnabled(true); + parent->setGraphicsEffect(m_effect); + + QPushButton *press = new QPushButton; + press->setText(tr("Press me")); + connect(press, SIGNAL(clicked()), SLOT(togglePopup())); + m_scene.addWidget(press); + press->move(300, 500); +} + diff --git a/examples/effects/fademessage/fademessage.h b/examples/effects/fademessage/fademessage.h new file mode 100644 index 0000000..34e2fb8 --- /dev/null +++ b/examples/effects/fademessage/fademessage.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FADEMESSAGE_H +#define FADEMESSAGE_H + +#include <QGraphicsEffect> +#include <QGraphicsView> +#include <QTimeLine> + +#include "fademessage.h" + +class FadeMessage: public QGraphicsView +{ + Q_OBJECT + +public: + FadeMessage(QWidget *parent = 0); + +private: + void setupScene(); + +private slots: + void togglePopup(); + +private: + qreal m_index; + QGraphicsScene m_scene; + QGraphicsColorizeEffect *m_effect; + QGraphicsItem *m_message; + QTimeLine *m_timeLine; +}; + +#endif // FADEMESSAGE_H diff --git a/examples/effects/fademessage/fademessage.pro b/examples/effects/fademessage/fademessage.pro new file mode 100644 index 0000000..ed9e53d --- /dev/null +++ b/examples/effects/fademessage/fademessage.pro @@ -0,0 +1,13 @@ +SOURCES += main.cpp fademessage.cpp +HEADERS += fademessage.h +RESOURCES += fademessage.qrc +INSTALLS += target sources + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/effects/fademessage +sources.files = $$SOURCES \ + $$HEADERS \ + $$RESOURCES \ + $$FORMS \ + fademessage.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/effects/fademessage diff --git a/examples/effects/fademessage/fademessage.qrc b/examples/effects/fademessage/fademessage.qrc new file mode 100644 index 0000000..9efea6a --- /dev/null +++ b/examples/effects/fademessage/fademessage.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/" > + <file>background.jpg</file> + </qresource> +</RCC> diff --git a/examples/effects/fademessage/main.cpp b/examples/effects/fademessage/main.cpp new file mode 100644 index 0000000..65a4291 --- /dev/null +++ b/examples/effects/fademessage/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "fademessage.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + FadeMessage widget; + widget.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Popup Message with Effect")); + widget.setFixedSize(400, 600); + widget.show(); + + return app.exec(); +} diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp index 0dd6057..7026b66 100644 --- a/examples/effects/lighting/lighting.cpp +++ b/examples/effects/lighting/lighting.cpp @@ -96,7 +96,9 @@ void Lighting::setupScene() item->setPen(QPen(Qt::black)); item->setBrush(QBrush(Qt::white)); - item->setGraphicsEffect(new QGraphicsDropShadowEffect); + QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; + effect->setBlurRadius(8); + item->setGraphicsEffect(effect); item->setZValue(1); item->setPos(i * 80, j * 80); m_scene.addItem(item); diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp index 4269eaa..a4bf1d0 100644 --- a/examples/graphicsview/anchorlayout/main.cpp +++ b/examples/graphicsview/anchorlayout/main.cpp @@ -79,66 +79,45 @@ int main(int argc, char **argv) QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setSpacing(0); QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); w->setPos(20, 20); w->setLayout(l); // vertical - l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); - l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0); - l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); - l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0); - - l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); - l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0); - l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); - l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0); - l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); - l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); - l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); - l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0); - - l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); - l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); - l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); - l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); - - l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); - l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0); - l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); - l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0); - l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); - l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); - l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); - l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0); + QGraphicsAnchor *anchor = l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); + anchor = l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); + + anchor = l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); + anchor = l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); + anchor = l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + anchor = l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); + + anchor = l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + anchor = l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); + + anchor = l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); + anchor = l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); + anchor = l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); + anchor = l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); // horizontal - l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); - l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); - l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); - l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0); - l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); - l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); - - l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); - l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); - l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); - l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0); - - l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); - l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0); - l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); - l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0); - l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); - l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0); - - l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); - l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0); - l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); - l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0); - l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); - l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0); + anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + anchor = l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); + anchor = l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + + anchor = l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + anchor = l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); + + anchor = l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); + anchor = l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); + anchor = l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); + + anchor = l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); + anchor = l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); + anchor = l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); + scene.addItem(w); scene.setBackgroundBrush(Qt::darkGreen); diff --git a/examples/multimedia/audio/audiodevices/audiodevices.cpp b/examples/multimedia/audio/audiodevices/audiodevices.cpp index 52aa4db..0d305ff 100644 --- a/examples/multimedia/audio/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audio/audiodevices/audiodevices.cpp @@ -58,6 +58,14 @@ AudioDevicesBase::~AudioDevicesBase() {} AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) : AudioDevicesBase( parent, f ) { + nearestFreq->setDisabled(true); + nearestChannel->setDisabled(true); + nearestCodec->setDisabled(true); + nearestSampleSize->setDisabled(true); + nearestSampleType->setDisabled(true); + nearestEndian->setDisabled(true); + logOutput->setDisabled(true); + mode = QAudio::AudioOutput; modeBox->addItem("Input"); modeBox->addItem("Output"); @@ -87,6 +95,8 @@ AudioTest::~AudioTest() void AudioTest::test() { // tries to set all the settings picked. + logOutput->clear(); + logOutput->append("NOTE: an invalid codec audio/test exists for testing, to get a fail condition."); if(device) { if(device->isFormatSupported(settings)) { @@ -179,7 +189,7 @@ void AudioTest::deviceChanged(int idx) if(codecz.size()) settings.setCodec(codecz.at(0)); // Add false to create failed condition! - codecsBox->addItem("audio/mpeg"); + codecsBox->addItem("audio/test"); sampleSizesBox->clear(); QList<int> sampleSizez = device->supportedSampleSizes(); diff --git a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui index 29dd40e..5207338 100644 --- a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui @@ -14,8 +14,8 @@ <string>AudioDevicesBase</string> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> <widget class="QLabel" name="deviceLabel"> @@ -222,7 +222,7 @@ <x>0</x> <y>0</y> <width>504</width> - <height>22</height> + <height>19</height> </rect> </property> </widget> diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index 5200467..a31c34a 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -92,7 +92,6 @@ void GLWidget::showBubbles(bool bubbles) void GLWidget::paintQtLogo() { - glDisable(GL_TEXTURE_2D); program1.setAttributeArray(vertexAttr1, vertices.constData()); program1.setAttributeArray(normalAttr1, normals.constData()); glDrawArrays(GL_TRIANGLES, 0, vertices.size()); @@ -102,7 +101,6 @@ void GLWidget::paintQtLogo() void GLWidget::paintTexturedCube() { - glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_uiTexture); GLfloat afVertices[] = { -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5, @@ -172,7 +170,6 @@ void GLWidget::initializeGL () { glClearColor(0.1f, 0.1f, 0.2f, 1.0f); - glEnable(GL_TEXTURE_2D); glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); @@ -270,7 +267,6 @@ void GLWidget::paintGL() glClearColor(0.1f, 0.1f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); |