summaryrefslogtreecommitdiffstats
path: root/examples/threads/mandelbrot
diff options
context:
space:
mode:
Diffstat (limited to 'examples/threads/mandelbrot')
-rw-r--r--examples/threads/mandelbrot/main.cpp4
-rw-r--r--examples/threads/mandelbrot/mandelbrot.pro1
-rw-r--r--examples/threads/mandelbrot/mandelbrotwidget.cpp18
-rw-r--r--examples/threads/mandelbrot/mandelbrotwidget.h30
4 files changed, 51 insertions, 2 deletions
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 <QPixmap>
#include <QWidget>
-
#include "renderthread.h"
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
+#include <QPushButton>
+
+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;