diff options
Diffstat (limited to 'examples/threads/mandelbrot')
-rw-r--r-- | examples/threads/mandelbrot/main.cpp | 4 | ||||
-rw-r--r-- | examples/threads/mandelbrot/mandelbrot.desktop | 11 | ||||
-rw-r--r-- | examples/threads/mandelbrot/mandelbrot.pro | 1 | ||||
-rw-r--r-- | examples/threads/mandelbrot/mandelbrotwidget.cpp | 18 | ||||
-rw-r--r-- | examples/threads/mandelbrot/mandelbrotwidget.h | 30 |
5 files changed, 62 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.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 diff --git a/examples/threads/mandelbrot/mandelbrot.pro b/examples/threads/mandelbrot/mandelbrot.pro index c19a9bd1aa..0e053af072 100644 --- a/examples/threads/mandelbrot/mandelbrot.pro +++ b/examples/threads/mandelbrot/mandelbrot.pro @@ -14,3 +14,4 @@ INSTALLS += target sources symbian: CONFIG += qt_example QT += widgets +maemo5: CONFIG += qt_example diff --git a/examples/threads/mandelbrot/mandelbrotwidget.cpp b/examples/threads/mandelbrot/mandelbrotwidget.cpp index b4233538d9..7cee70f547 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; |