From 0748751c9f097d9d866605306bbdd4b96e2a5c4e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 27 Apr 2011 19:16:41 +0200 Subject: Squashed commit of the changes from the mobile-examples repository (4.7-generated-declarative branch). --- examples/threads/mandelbrot/main.cpp | 4 ++++ examples/threads/mandelbrot/mandelbrot.pro | 1 + examples/threads/mandelbrot/mandelbrotwidget.cpp | 18 ++++++++++++++ examples/threads/mandelbrot/mandelbrotwidget.h | 30 ++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) (limited to 'examples/threads/mandelbrot') diff --git a/examples/threads/mandelbrot/main.cpp b/examples/threads/mandelbrot/main.cpp index 610534d4a3..5211c2051c 100644 --- a/examples/threads/mandelbrot/main.cpp +++ b/examples/threads/mandelbrot/main.cpp @@ -47,7 +47,11 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); MandelbrotWidget widget; +#if defined(Q_WS_S60) + widget.showMaximized(); +#else widget.show(); +#endif return app.exec(); } //! [0] diff --git a/examples/threads/mandelbrot/mandelbrot.pro b/examples/threads/mandelbrot/mandelbrot.pro index fe72cd58a7..d0fb4993af 100644 --- a/examples/threads/mandelbrot/mandelbrot.pro +++ b/examples/threads/mandelbrot/mandelbrot.pro @@ -13,3 +13,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/threads/mandelbrot INSTALLS += target sources symbian: CONFIG += qt_example +maemo5: CONFIG += qt_example diff --git a/examples/threads/mandelbrot/mandelbrotwidget.cpp b/examples/threads/mandelbrot/mandelbrotwidget.cpp index 8dc1f5d811..47eb473425 100644 --- a/examples/threads/mandelbrot/mandelbrotwidget.cpp +++ b/examples/threads/mandelbrot/mandelbrotwidget.cpp @@ -44,6 +44,7 @@ #include "mandelbrotwidget.h" + //! [0] const double DefaultCenterX = -0.637011f; const double DefaultCenterY = -0.0395159f; @@ -72,6 +73,21 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent) setCursor(Qt::CrossCursor); #endif resize(550, 400); + +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) + ZoomButton *zoomIn = new ZoomButton(tr("Zoom In"), ZoomInFactor, this); + ZoomButton *zoomOut = new ZoomButton(tr("Zoom Out"), ZoomOutFactor, this); + + QGridLayout *layout = new QGridLayout(this); + layout->addWidget(zoomIn, 0, 1); + layout->addWidget(zoomOut, 1, 1); + layout->setColumnStretch(0, 10); + layout->setRowStretch(2, 10); + setLayout(layout); + + connect(zoomIn, SIGNAL(zoom(double)), this, SLOT(zoom(double))); + connect(zoomOut, SIGNAL(zoom(double)), this, SLOT(zoom(double))); +#endif } //! [1] @@ -113,6 +129,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */) } //! [8] //! [9] +#if !defined(Q_WS_S60) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR) QString text = tr("Use mouse wheel or the '+' and '-' keys to zoom. " "Press and hold left mouse button to scroll."); QFontMetrics metrics = painter.fontMetrics(); @@ -125,6 +142,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */) painter.setPen(Qt::white); painter.drawText((width() - textWidth) / 2, metrics.leading() + metrics.ascent(), text); +#endif } //! [9] diff --git a/examples/threads/mandelbrot/mandelbrotwidget.h b/examples/threads/mandelbrot/mandelbrotwidget.h index 5af3a8dffd..53bbeb6469 100644 --- a/examples/threads/mandelbrot/mandelbrotwidget.h +++ b/examples/threads/mandelbrot/mandelbrotwidget.h @@ -43,9 +43,35 @@ #include #include - #include "renderthread.h" +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) +#include + +class ZoomButton : public QPushButton +{ + Q_OBJECT +public: + ZoomButton(const QString &text, double zoomFactor, QWidget *parent = NULL) + : QPushButton(text, parent), m_ZoomFactor(zoomFactor) + { + connect(this, SIGNAL(clicked()), this, SLOT(handleClick())); + } + +signals: + void zoom(double zoomFactor); + +private slots: + void handleClick() + { + emit zoom(m_ZoomFactor); + } + +private: + const double m_ZoomFactor; +}; +#endif + //! [0] class MandelbrotWidget : public QWidget { @@ -65,9 +91,9 @@ protected: private slots: void updatePixmap(const QImage &image, double scaleFactor); + void zoom(double zoomFactor); private: - void zoom(double zoomFactor); void scroll(int deltaX, int deltaY); RenderThread thread; -- cgit v1.2.3 From 0cbcc61ef35b9bce1d65d048853c79004b755b87 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 11 May 2011 17:35:46 +0200 Subject: Squashed commit of changes from the 4.8-temp branch. --- examples/threads/mandelbrot/mandelbrot.desktop | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/threads/mandelbrot/mandelbrot.desktop (limited to 'examples/threads/mandelbrot') diff --git a/examples/threads/mandelbrot/mandelbrot.desktop b/examples/threads/mandelbrot/mandelbrot.desktop new file mode 100644 index 0000000000..3e70e1aa06 --- /dev/null +++ b/examples/threads/mandelbrot/mandelbrot.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Mandelbrot +Exec=/opt/usr/bin/mandelbrot +Icon=mandelbrot +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable -- cgit v1.2.3