diff options
Diffstat (limited to 'examples')
35 files changed, 773 insertions, 133 deletions
diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index 9bde031..aae6b5d 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -9,7 +9,7 @@ Item { id: map
anchors.fill: parent
url: "map.html"
- javaScriptWindowObjects: Object {
+ javaScriptWindowObjects: QtObject {
WebView.windowObjectName: "qml"
property real lat: page.latitude
property real lng: page.longitude
diff --git a/examples/declarative/webview/evalandattach.qml b/examples/declarative/webview/evalandattach.qml index e755819..1b211c9 100644 --- a/examples/declarative/webview/evalandattach.qml +++ b/examples/declarative/webview/evalandattach.qml @@ -37,12 +37,12 @@ Item { focus: true settings.pluginsEnabled: true javaScriptWindowObjects: [ - Object { + QtObject { id: txt WebView.windowObjectName: "statusText1" property string text: "Click me!" }, - Object { + QtObject { id: txt2 WebView.windowObjectName: "statusText2" property string text: "" diff --git a/examples/effects/blurpicker/blurpicker.cpp b/examples/effects/blurpicker/blurpicker.cpp index 1f46444..4911c73 100644 --- a/examples/effects/blurpicker/blurpicker.cpp +++ b/examples/effects/blurpicker/blurpicker.cpp @@ -49,24 +49,29 @@ #define M_PI 3.14159265358979323846 #endif -BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0) +BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0), m_animation(this, "index") { setBackgroundBrush(QPixmap(":/images/background.jpg")); - setScene(&m_scene); + setScene(new QGraphicsScene(this)); setupScene(); - updateIconPositions(); + setIndex(0); - connect(&m_timeLine, SIGNAL(valueChanged(qreal)), SLOT(updateIconPositions())); - m_timeLine.setDuration(400); + m_animation.setDuration(400); + m_animation.setEasingCurve(QEasingCurve::InOutSine); setRenderHint(QPainter::Antialiasing, true); setFrameStyle(QFrame::NoFrame); } -void BlurPicker::updateIconPositions() +qreal BlurPicker::index() const { - m_index = m_timeLine.currentFrame() / 1000.0; + return m_index; +} + +void BlurPicker::setIndex(qreal index) +{ + m_index = index; qreal baseline = 0; for (int i = 0; i < m_icons.count(); ++i) { @@ -82,12 +87,12 @@ void BlurPicker::updateIconPositions() static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline); } - m_scene.update(); + scene()->update(); } void BlurPicker::setupScene() { - m_scene.setSceneRect(-200, -120, 400, 240); + scene()->setSceneRect(-200, -120, 400, 240); QStringList names; names << ":/images/accessories-calculator.png"; @@ -101,32 +106,34 @@ void BlurPicker::setupScene() for (int i = 0; i < names.count(); i++) { QPixmap pixmap(names[i]); - QGraphicsPixmapItem *icon = m_scene.addPixmap(pixmap); + QGraphicsPixmapItem *icon = scene()->addPixmap(pixmap); icon->setZValue(1); icon->setGraphicsEffect(new BlurEffect(icon)); m_icons << icon; } - QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/images/background.jpg")); + QGraphicsPixmapItem *bg = scene()->addPixmap(QPixmap(":/images/background.jpg")); bg->setZValue(0); bg->setPos(-200, -150); } void BlurPicker::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Left) { - if (m_timeLine.state() == QTimeLine::NotRunning) { - m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 - 1000); - m_timeLine.start(); - event->accept(); - } + int delta = 0; + switch (event->key()) + { + case Qt::Key_Left: + delta = -1; + break; + case Qt::Key_Right: + delta = 1; + break; + default: + break; } - - if (event->key() == Qt::Key_Right) { - if (m_timeLine.state() == QTimeLine::NotRunning) { - m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 + 1000); - m_timeLine.start(); + if (m_animation.state() == QAbstractAnimation::Stopped && delta) { + m_animation.setEndValue(m_index + delta); + m_animation.start(); event->accept(); - } } } diff --git a/examples/effects/blurpicker/blurpicker.h b/examples/effects/blurpicker/blurpicker.h index b460df4..b302db4 100644 --- a/examples/effects/blurpicker/blurpicker.h +++ b/examples/effects/blurpicker/blurpicker.h @@ -44,31 +44,31 @@ #include <QGraphicsEffect> #include <QGraphicsView> -#include <QTimeLine> +#include <QPropertyAnimation> #include "blureffect.h" class BlurPicker: public QGraphicsView { Q_OBJECT + Q_PROPERTY(qreal index READ index WRITE setIndex); public: BlurPicker(QWidget *parent = 0); + qreal index() const; + void setIndex(qreal); + protected: void keyPressEvent(QKeyEvent *event); -private slots: - void updateIconPositions(); - private: void setupScene(); private: qreal m_index; - QGraphicsScene m_scene; QList<QGraphicsItem*> m_icons; - QTimeLine m_timeLine; + QPropertyAnimation m_animation; }; #endif // BLURPICKER_H diff --git a/examples/effects/customshader/blurpicker.cpp b/examples/effects/customshader/blurpicker.cpp index 6cda711..d38d99b 100644 --- a/examples/effects/customshader/blurpicker.cpp +++ b/examples/effects/customshader/blurpicker.cpp @@ -50,24 +50,29 @@ #define M_PI 3.14159265358979323846 #endif -BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0) +BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0), m_animation(this, "index") { setBackgroundBrush(QPixmap(":/images/background.jpg")); - setScene(&m_scene); + setScene(new QGraphicsScene(this)); setupScene(); - updateIconPositions(); + setIndex(0); - connect(&m_timeLine, SIGNAL(valueChanged(qreal)), SLOT(updateIconPositions())); - m_timeLine.setDuration(400); + m_animation.setDuration(400); + m_animation.setEasingCurve(QEasingCurve::InOutSine); setRenderHint(QPainter::Antialiasing, true); setFrameStyle(QFrame::NoFrame); } -void BlurPicker::updateIconPositions() +qreal BlurPicker::index() const { - m_index = m_timeLine.currentFrame() / 1000.0; + return m_index; +} + +void BlurPicker::setIndex(qreal index) +{ + m_index = index; qreal baseline = 0; for (int i = 0; i < m_icons.count(); ++i) { @@ -84,12 +89,12 @@ void BlurPicker::updateIconPositions() static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline); } - m_scene.update(); + scene()->update(); } void BlurPicker::setupScene() { - m_scene.setSceneRect(-200, -120, 400, 240); + scene()->setSceneRect(-200, -120, 400, 240); QStringList names; names << ":/images/accessories-calculator.png"; @@ -103,7 +108,7 @@ void BlurPicker::setupScene() for (int i = 0; i < names.count(); i++) { QPixmap pixmap(names[i]); - QGraphicsPixmapItem *icon = m_scene.addPixmap(pixmap); + QGraphicsPixmapItem *icon = scene()->addPixmap(pixmap); icon->setZValue(1); if (i == 3) icon->setGraphicsEffect(new CustomShaderEffect()); @@ -112,26 +117,28 @@ void BlurPicker::setupScene() m_icons << icon; } - QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/images/background.jpg")); + QGraphicsPixmapItem *bg = scene()->addPixmap(QPixmap(":/images/background.jpg")); bg->setZValue(0); bg->setPos(-200, -150); } void BlurPicker::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Left) { - if (m_timeLine.state() == QTimeLine::NotRunning) { - m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 - 1000); - m_timeLine.start(); - event->accept(); - } + int delta = 0; + switch (event->key()) + { + case Qt::Key_Left: + delta = -1; + break; + case Qt::Key_Right: + delta = 1; + break; + default: + break; } - - if (event->key() == Qt::Key_Right) { - if (m_timeLine.state() == QTimeLine::NotRunning) { - m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 + 1000); - m_timeLine.start(); + if (m_animation.state() == QAbstractAnimation::Stopped && delta) { + m_animation.setEndValue(m_index + delta); + m_animation.start(); event->accept(); - } } } diff --git a/examples/effects/customshader/blurpicker.h b/examples/effects/customshader/blurpicker.h index b460df4..b302db4 100644 --- a/examples/effects/customshader/blurpicker.h +++ b/examples/effects/customshader/blurpicker.h @@ -44,31 +44,31 @@ #include <QGraphicsEffect> #include <QGraphicsView> -#include <QTimeLine> +#include <QPropertyAnimation> #include "blureffect.h" class BlurPicker: public QGraphicsView { Q_OBJECT + Q_PROPERTY(qreal index READ index WRITE setIndex); public: BlurPicker(QWidget *parent = 0); + qreal index() const; + void setIndex(qreal); + protected: void keyPressEvent(QKeyEvent *event); -private slots: - void updateIconPositions(); - private: void setupScene(); private: qreal m_index; - QGraphicsScene m_scene; QList<QGraphicsItem*> m_icons; - QTimeLine m_timeLine; + QPropertyAnimation m_animation; }; #endif // BLURPICKER_H diff --git a/examples/effects/fademessage/fademessage.cpp b/examples/effects/fademessage/fademessage.cpp index 818d00f..4128a59 100644 --- a/examples/effects/fademessage/fademessage.cpp +++ b/examples/effects/fademessage/fademessage.cpp @@ -43,7 +43,7 @@ #include <QtGui> -FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent), m_index(0.0) +FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent) { setScene(&m_scene); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -51,9 +51,12 @@ FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent), m_index(0.0) setupScene(); - m_timeLine = new QTimeLine(500, this); - m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve); - connect(m_timeLine, SIGNAL(valueChanged(qreal)), m_effect, SLOT(setStrength(qreal))); + m_animation = new QPropertyAnimation(m_effect, "strength", this); + m_animation->setDuration(500); + m_animation->setEasingCurve(QEasingCurve::InOutSine); + m_animation->setStartValue(0); + m_animation->setEndValue(1); + setRenderHint(QPainter::Antialiasing, true); setFrameStyle(QFrame::NoFrame); @@ -63,13 +66,12 @@ void FadeMessage::togglePopup() { if (m_message->isVisible()) { m_message->setVisible(false); - m_timeLine->setDirection(QTimeLine::Backward); - m_timeLine->start(); + m_animation->setDirection(QAbstractAnimation::Backward); } else { m_message->setVisible(true); - m_timeLine->setDirection(QTimeLine::Forward); - m_timeLine->start(); + m_animation->setDirection(QAbstractAnimation::Forward); } + m_animation->start(); } void FadeMessage::setupScene() @@ -94,13 +96,17 @@ void FadeMessage::setupScene() QFont font; font.setPointSize(font.pointSize() * 2); font.setBold(true); - int fh = QFontMetrics(font).height(); + QFontMetrics fontMetrics(font); + int fh = fontMetrics.height(); + + QString sceneText = "Qt Everywhere!"; + int sceneTextWidth = fontMetrics.width(sceneText); - QGraphicsRectItem *block = m_scene.addRect(50, 300, 300, fh + 3); + QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3); block->setPen(Qt::NoPen); block->setBrush(QColor(102, 153, 51)); - QGraphicsTextItem *text = m_scene.addText("Qt Everywhere!", font); + QGraphicsTextItem *text = m_scene.addText(sceneText, font); text->setDefaultTextColor(Qt::white); text->setPos(50, 300); block->setZValue(2); diff --git a/examples/effects/fademessage/fademessage.h b/examples/effects/fademessage/fademessage.h index 34e2fb8..e73ef6b 100644 --- a/examples/effects/fademessage/fademessage.h +++ b/examples/effects/fademessage/fademessage.h @@ -44,7 +44,7 @@ #include <QGraphicsEffect> #include <QGraphicsView> -#include <QTimeLine> +#include <QPropertyAnimation> #include "fademessage.h" @@ -62,11 +62,10 @@ private slots: void togglePopup(); private: - qreal m_index; QGraphicsScene m_scene; QGraphicsColorizeEffect *m_effect; QGraphicsItem *m_message; - QTimeLine *m_timeLine; + QPropertyAnimation *m_animation; }; #endif // FADEMESSAGE_H diff --git a/examples/effects/fademessage/fademessage.pro b/examples/effects/fademessage/fademessage.pro index ed9e53d..cb1fda7 100644 --- a/examples/effects/fademessage/fademessage.pro +++ b/examples/effects/fademessage/fademessage.pro @@ -11,3 +11,6 @@ sources.files = $$SOURCES \ $$FORMS \ fademessage.pro sources.path = $$[QT_INSTALL_EXAMPLES]/effects/fademessage + +DEPLOYMENT_PLUGIN += qjpeg + diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp index 7026b66..51fa9f8 100644 --- a/examples/effects/lighting/lighting.cpp +++ b/examples/effects/lighting/lighting.cpp @@ -94,7 +94,7 @@ void Lighting::setupScene() else item = new QGraphicsRectItem(0, 0, 50, 50); - item->setPen(QPen(Qt::black)); + item->setPen(QPen(Qt::black, 1)); item->setBrush(QBrush(Qt::white)); QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; effect->setBlurRadius(8); diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp index 3e19f18..f898d1d 100644 --- a/examples/graphicsview/anchorlayout/main.cpp +++ b/examples/graphicsview/anchorlayout/main.cpp @@ -76,8 +76,8 @@ int main(int argc, char **argv) QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); - QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F"); - QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G"); + QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)"); + QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; l->setSpacing(0); diff --git a/examples/graphicsview/weatheranchorlayout/main.cpp b/examples/graphicsview/weatheranchorlayout/main.cpp index 9002828..d835ae3 100644 --- a/examples/graphicsview/weatheranchorlayout/main.cpp +++ b/examples/graphicsview/weatheranchorlayout/main.cpp @@ -185,20 +185,12 @@ int main(int argc, char **argv) QGraphicsScene scene; scene.setSceneRect(0, 0, 800, 480); -#ifdef DEBUG_MODE - QGraphicsProxyWidget *title = createItem("Title"); - QGraphicsProxyWidget *place = createItem("Place"); - QGraphicsProxyWidget *sun = createItem("Sun"); - QGraphicsProxyWidget *details = createItem("Details"); - QGraphicsProxyWidget *tabbar = createItem("Tabbar"); -#else - // pixmaps widgets - PixmapWidget *title = new PixmapWidget(QPixmap(":/images/title.jpg")); - PlaceWidget *place = new PlaceWidget(QPixmap(":/images/place.jpg")); - PixmapWidget *details = new PixmapWidget(QPixmap(":/images/5days.jpg")); - PixmapWidget *sun = new PixmapWidget(QPixmap(":/images/weather-few-clouds.png")); - PixmapWidget *tabbar = new PixmapWidget(QPixmap(":/images/tabbar.jpg")); -#endif + // pixmaps widgets + PixmapWidget *title = new PixmapWidget(QPixmap(":/images/title.jpg")); + PlaceWidget *place = new PlaceWidget(QPixmap(":/images/place.jpg")); + PixmapWidget *details = new PixmapWidget(QPixmap(":/images/5days.jpg")); + PixmapWidget *sunnyWeather = new PixmapWidget(QPixmap(":/images/weather-few-clouds.png")); + PixmapWidget *tabbar = new PixmapWidget(QPixmap(":/images/tabbar.jpg")); // setup sizes @@ -215,9 +207,9 @@ int main(int argc, char **argv) tabbar->setPreferredSize(QSizeF(70, 24)); tabbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - sun->setPreferredSize(QSizeF(128, 97)); - sun->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - sun->setZValue(9999); + sunnyWeather->setPreferredSize(QSizeF(128, 97)); + sunnyWeather->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + sunnyWeather->setZValue(9999); // start anchor layout QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; @@ -238,8 +230,8 @@ int main(int argc, char **argv) anchor = l->addAnchor(place, Qt::AnchorBottom, l, Qt::AnchorBottom); anchor->setSpacing(12); - anchor = l->addAnchor(sun, Qt::AnchorTop, title, Qt::AnchorTop); - anchor = l->addAnchor(sun, Qt::AnchorBottom, l, Qt::AnchorVerticalCenter); + anchor = l->addAnchor(sunnyWeather, Qt::AnchorTop, title, Qt::AnchorTop); + anchor = l->addAnchor(sunnyWeather, Qt::AnchorBottom, l, Qt::AnchorVerticalCenter); anchor = l->addAnchor(tabbar, Qt::AnchorTop, title, Qt::AnchorBottom); anchor->setSpacing(5); @@ -257,8 +249,8 @@ int main(int argc, char **argv) anchor = l->addAnchor(place, Qt::AnchorRight, details, Qt::AnchorLeft); anchor->setSpacing(35); - anchor = l->addAnchor(sun, Qt::AnchorLeft, place, Qt::AnchorHorizontalCenter); - anchor = l->addAnchor(sun, Qt::AnchorRight, l, Qt::AnchorHorizontalCenter); + anchor = l->addAnchor(sunnyWeather, Qt::AnchorLeft, place, Qt::AnchorHorizontalCenter); + anchor = l->addAnchor(sunnyWeather, Qt::AnchorRight, l, Qt::AnchorHorizontalCenter); anchor = l->addAnchor(tabbar, Qt::AnchorHorizontalCenter, details, Qt::AnchorHorizontalCenter); anchor = l->addAnchor(details, Qt::AnchorRight, l, Qt::AnchorRight); diff --git a/examples/help/contextsensitivehelp/doc/source.html b/examples/help/contextsensitivehelp/doc/source.html index 2140765..68b2f8c 100644 --- a/examples/help/contextsensitivehelp/doc/source.html +++ b/examples/help/contextsensitivehelp/doc/source.html @@ -4,8 +4,8 @@ <title>Water Source</title> </head> <body> - The current pipe system connects to four different sources. Be aware that only - a limited amount of water can be taken from some sources. + The current pipe system connects to four different sources. Be aware + that only a limited amount of water can be taken from some sources. <br> <table border=1> <tr> @@ -13,7 +13,7 @@ <td>Amount</td> </tr> <tr> - <td>Foundain</td> + <td>Fountain</td> <td>4000</td> </tr> <tr> diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qch b/examples/help/contextsensitivehelp/doc/wateringmachine.qch Binary files differindex e74f9b8..35d29be 100644 --- a/examples/help/contextsensitivehelp/doc/wateringmachine.qch +++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qch diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qhc b/examples/help/contextsensitivehelp/doc/wateringmachine.qhc Binary files differindex 3227c3a2..b5653c3 100644 --- a/examples/help/contextsensitivehelp/doc/wateringmachine.qhc +++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qhc diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qhp b/examples/help/contextsensitivehelp/doc/wateringmachine.qhp index 745d881..6dd08e7 100644 --- a/examples/help/contextsensitivehelp/doc/wateringmachine.qhp +++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qhp @@ -1,25 +1,25 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8" ?> <QtHelpProject version="1.0"> - <virtualFolder>wateringmachine</virtualFolder> - <namespace>wateringcompany.com.1_0_0.premium</namespace> - <filterSection> - <keywords> - <keyword name="plants" id="plants" ref="plants.html"/> - <keyword name="temperature" id="temperature" ref="temperature.html"/> - <keyword name="rain" id="rain" ref="rain.html"/> - <keyword name="time" id="time" ref="time.html"/> - <keyword name="amount" id="amount" ref="amount.html"/> - <keyword name="source" id="source" ref="source.html"/> - <keyword name="filtering" id="filtering" ref="filter.html"/> - </keywords> - <files> - <file>plants.html</file> - <file>temperature.html</file> - <file>rain.html</file> - <file>time.html</file> - <file>amount.html</file> - <file>source.html</file> - <file>filter.html</file> - </files> - </filterSection> + <virtualFolder>wateringmachine</virtualFolder> + <namespace>wateringcompany.com.1-0-0.premium</namespace> + <filterSection> + <keywords> + <keyword name="plants" id="plants" ref="plants.html"/> + <keyword name="temperature" id="temperature" ref="temperature.html"/> + <keyword name="rain" id="rain" ref="rain.html"/> + <keyword name="time" id="time" ref="time.html"/> + <keyword name="amount" id="amount" ref="amount.html"/> + <keyword name="source" id="source" ref="source.html"/> + <keyword name="filtering" id="filtering" ref="filter.html"/> + </keywords> + <files> + <file>plants.html</file> + <file>temperature.html</file> + <file>rain.html</file> + <file>time.html</file> + <file>amount.html</file> + <file>source.html</file> + <file>filter.html</file> + </files> + </filterSection> </QtHelpProject> diff --git a/examples/help/contextsensitivehelp/wateringconfigdialog.ui b/examples/help/contextsensitivehelp/wateringconfigdialog.ui index a7f5349..d7a473a 100644 --- a/examples/help/contextsensitivehelp/wateringconfigdialog.ui +++ b/examples/help/contextsensitivehelp/wateringconfigdialog.ui @@ -258,7 +258,7 @@ <widget class="QComboBox" name="sourceComboBox" > <item> <property name="text" > - <string>Foundain</string> + <string>Fountain</string> </property> </item> <item> diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp index b731f7a..a3d7c23 100644 --- a/examples/network/blockingfortuneclient/blockingclient.cpp +++ b/examples/network/blockingfortuneclient/blockingclient.cpp @@ -50,7 +50,22 @@ BlockingClient::BlockingClient(QWidget *parent) hostLabel = new QLabel(tr("&Server name:")); portLabel = new QLabel(tr("S&erver port:")); - hostLineEdit = new QLineEdit("Localhost"); + // find out which IP to connect to + QString ipAddress; + QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); + // use the first non-localhost IPv4 address + for (int i = 0; i < ipAddressesList.size(); ++i) { + if (ipAddressesList.at(i) != QHostAddress::LocalHost && + ipAddressesList.at(i).toIPv4Address()) { + ipAddress = ipAddressesList.at(i).toString(); + break; + } + } + // if we did not find one, use IPv4 localhost + if (ipAddress.isEmpty()) + ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); + + hostLineEdit = new QLineEdit(ipAddress); portLineEdit = new QLineEdit; portLineEdit->setValidator(new QIntValidator(1, 65535, this)); diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index ca5d40e..e043f78 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -62,8 +62,10 @@ Client::Client(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 52b7d61..06f6eeb 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -68,8 +68,10 @@ Server::Server(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/network/network.pro b/examples/network/network.pro index 0849271..c5a97fb 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -19,6 +19,7 @@ SUBDIRS = blockingfortuneclient \ symbian: SUBDIRS = qftp contains(QT_CONFIG, openssl):SUBDIRS += securesocketclient +contains(QT_CONFIG, openssl-linked):SUBDIRS += securesocketclient # install sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS network.pro README diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp index b1ea395..d0d3fc0 100644 --- a/examples/network/threadedfortuneserver/dialog.cpp +++ b/examples/network/threadedfortuneserver/dialog.cpp @@ -67,8 +67,10 @@ Dialog::Dialog(QWidget *parent) // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); + break; + } } // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index 56ba65b..d843a73 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -175,7 +175,11 @@ void GLWidget::perspectiveProjection() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef QT_OPENGL_ES + glFrustumf(-aspect, +aspect, -1.0, +1.0, 4.0, 15.0); +#else glFrustum(-aspect, +aspect, -1.0, +1.0, 4.0, 15.0); +#endif glMatrixMode(GL_MODELVIEW); } @@ -183,7 +187,11 @@ void GLWidget::orthographicProjection() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef QT_OPENGL_ES + glOrthof(-1.0, +1.0, -1.0, +1.0, -90.0, +90.0); +#else glOrtho(-1.0, +1.0, -1.0, +1.0, -90.0, +90.0); +#endif glMatrixMode(GL_MODELVIEW); } diff --git a/examples/webkit/domtraversal/domtraversal.pro b/examples/webkit/domtraversal/domtraversal.pro new file mode 100644 index 0000000..49400de --- /dev/null +++ b/examples/webkit/domtraversal/domtraversal.pro @@ -0,0 +1,11 @@ +QT += webkit network +FORMS = window.ui +HEADERS = window.h +SOURCES = main.cpp \ + window.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/webkit/domtraversal +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/domtraversal +INSTALLS += target sources diff --git a/examples/webkit/domtraversal/main.cpp b/examples/webkit/domtraversal/main.cpp new file mode 100644 index 0000000..c8a1aec --- /dev/null +++ b/examples/webkit/domtraversal/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 "window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Window window; + window.show(); + window.setUrl(QUrl("http://qt.nokia.com/")); + return app.exec(); +} diff --git a/examples/webkit/domtraversal/window.cpp b/examples/webkit/domtraversal/window.cpp new file mode 100644 index 0000000..704a6e1 --- /dev/null +++ b/examples/webkit/domtraversal/window.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 <QtGui> +#include <QtWebKit> + +#include "window.h" + +//! [Window constructor] +Window::Window(QWidget *parent) + : QMainWindow(parent) +{ + setupUi(this); +} +//! [Window constructor] + +//! [set URL] +void Window::setUrl(const QUrl &url) +{ + webView->setUrl(url); +} +//! [set URL] + +//! [begin document inspection] +void Window::on_webView_loadFinished() +{ + treeWidget->clear(); + + QWebFrame *frame = webView->page()->mainFrame(); + QWebElement document = frame->documentElement(); + + examineChildElements(document, treeWidget->invisibleRootItem()); +} +//! [begin document inspection] + +//! [traverse document] +void Window::examineChildElements(const QWebElement &parentElement, + QTreeWidgetItem *parentItem) +{ + QWebElement element = parentElement.firstChild(); + while (!element.isNull()) { + + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setText(0, element.tagName()); + parentItem->addChild(item); + + examineChildElements(element, item); + + element = element.nextSibling(); + } +} +//! [traverse document] diff --git a/examples/webkit/domtraversal/window.h b/examples/webkit/domtraversal/window.h new file mode 100644 index 0000000..5988df9 --- /dev/null +++ b/examples/webkit/domtraversal/window.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 WINDOW_H +#define WINDOW_H + +#include <QMainWindow> +#include <QUrl> +#include <QWebElement> + +class QTreeWidgetItem; + +//! [Window class definition] +#include "ui_window.h" + +class Window : public QMainWindow, private Ui::Window +{ + Q_OBJECT + +public: + Window(QWidget *parent = 0); + void setUrl(const QUrl &url); + +public slots: + void on_webView_loadFinished(); + +private: + void examineChildElements(const QWebElement &parentElement, + QTreeWidgetItem *parentItem); +}; +//! [Window class definition] + +#endif diff --git a/examples/webkit/domtraversal/window.ui b/examples/webkit/domtraversal/window.ui new file mode 100644 index 0000000..0fce035 --- /dev/null +++ b/examples/webkit/domtraversal/window.ui @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Window</class> + <widget class="QMainWindow" name="Window"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Web Element DOM Traversal</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="topMargin"> + <number>4</number> + </property> + <property name="bottomMargin"> + <number>4</number> + </property> + <item> + <widget class="QWebView" name="webView"> + <property name="url"> + <url> + <string>http://qt.nokia.com/</string> + </url> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>27</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <widget class="QDockWidget" name="dockWidget"> + <property name="allowedAreas"> + <set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set> + </property> + <property name="windowTitle"> + <string>Document Structure</string> + </property> + <attribute name="dockWidgetArea"> + <number>1</number> + </attribute> + <widget class="QWidget" name="dockWidgetContents"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="margin"> + <number>4</number> + </property> + <item> + <widget class="QTreeWidget" name="treeWidget"> + <attribute name="headerVisible"> + <bool>false</bool> + </attribute> + <attribute name="headerVisible"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + <customwidgets> + <customwidget> + <class>QWebView</class> + <extends>QWidget</extends> + <header>QtWebKit/QWebView</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/examples/webkit/simpleselector/main.cpp b/examples/webkit/simpleselector/main.cpp new file mode 100644 index 0000000..74c5469 --- /dev/null +++ b/examples/webkit/simpleselector/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> +#include "window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Window window; + window.setUrl(QUrl("http://www.webkit.org")); + window.show(); + return app.exec(); +} +//! [main program] diff --git a/examples/webkit/simpleselector/simpleselector.pro b/examples/webkit/simpleselector/simpleselector.pro new file mode 100644 index 0000000..3f3037f --- /dev/null +++ b/examples/webkit/simpleselector/simpleselector.pro @@ -0,0 +1,11 @@ +QT += webkit +FORMS = window.ui +HEADERS = window.h +SOURCES = main.cpp \ + window.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/webkit/simpleselector +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/simpleselector +INSTALLS += target sources diff --git a/examples/webkit/simpleselector/window.cpp b/examples/webkit/simpleselector/window.cpp new file mode 100644 index 0000000..ad54487 --- /dev/null +++ b/examples/webkit/simpleselector/window.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 <QWebElement> +#include <QWebFrame> +#include "window.h" + +//! [Window class constructor] +Window::Window(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); +} +//! [Window class constructor] + +//! [return pressed] +void Window::on_elementLineEdit_returnPressed() +{ + QWebFrame *frame = webView->page()->mainFrame(); + +//! [select elements] + QWebElement document = frame->documentElement(); + QWebElementCollection elements = document.findAll(elementLineEdit->text()); +//! [select elements] + + foreach (QWebElement element, elements) + element.setAttribute("style", "background-color: #f0f090"); +} +//! [return pressed] + +//! [button clicked] +void Window::on_highlightButton_clicked() +{ + on_elementLineEdit_returnPressed(); +} +//! [button clicked] + +//! [set URL] +void Window::setUrl(const QUrl &url) +{ + webView->setUrl(url); +} +//! [set URL] diff --git a/examples/webkit/simpleselector/window.h b/examples/webkit/simpleselector/window.h new file mode 100644 index 0000000..9f9344a --- /dev/null +++ b/examples/webkit/simpleselector/window.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 WINDOW_H +#define WINDOW_H + +#include <QUrl> +#include <QWidget> +//! [Window class definition] +#include "ui_window.h" + +class Window : public QWidget, private Ui::Window +{ + Q_OBJECT + +public: + Window(QWidget *parent = 0); + void setUrl(const QUrl &url); + +public slots: + void on_elementLineEdit_returnPressed(); + void on_highlightButton_clicked(); +}; +//! [Window class definition] + +#endif diff --git a/examples/webkit/simpleselector/window.ui b/examples/webkit/simpleselector/window.ui new file mode 100644 index 0000000..aa824df --- /dev/null +++ b/examples/webkit/simpleselector/window.ui @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Window</class> + <widget class="QWidget" name="Window"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Web Element Selector</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QWebView" name="webView"> + <property name="url"> + <url> + <string>http://webkit.org/</string> + </url> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="elementLabel"> + <property name="text"> + <string>&Element:</string> + </property> + <property name="buddy"> + <cstring>elementLineEdit</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="elementLineEdit"> + <property name="text"> + <string>li a</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="highlightButton"> + <property name="text"> + <string>&Highlight</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>QWebView</class> + <extends>QWidget</extends> + <header>QtWebKit/QWebView</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/examples/webkit/webkit.pro b/examples/webkit/webkit.pro index 0a1d6bd..c985ed5 100644 --- a/examples/webkit/webkit.pro +++ b/examples/webkit/webkit.pro @@ -1,7 +1,9 @@ TEMPLATE = subdirs -SUBDIRS += formextractor \ +SUBDIRS += domtraversal \ + formextractor \ previewer \ - fancybrowser + fancybrowser \ + simpleselector contains(QT_CONFIG, openssl):SUBDIRS += googlechat diff --git a/examples/xmlpatterns/filetree/filetree.pro b/examples/xmlpatterns/filetree/filetree.pro index 1683491..4fcf7cb 100644 --- a/examples/xmlpatterns/filetree/filetree.pro +++ b/examples/xmlpatterns/filetree/filetree.pro @@ -2,7 +2,6 @@ SOURCES += main.cpp filetree.cpp mainwindow.cpp ../shared/xmlsyntaxhighlighter.c HEADERS += filetree.h mainwindow.h ../shared/xmlsyntaxhighlighter.h FORMS += forms/mainwindow.ui QT += xmlpatterns -CONFIG -= app_bundle RESOURCES += queries.qrc INCLUDEPATH += ../shared/ |