From 51b0ff6176077674ae20b4f0b63bceb50d352ae2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Rzepecki?= Date: Mon, 23 Feb 2009 06:50:03 +0100 Subject: [PATCH] Some documentation. Method to access the snapshot. --- include/cropwidget.h | 20 ++++++++++++++++++++ src/widget/cropwidget.cpp | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/include/cropwidget.h b/include/cropwidget.h index 2b815a3..c75b7e1 100644 --- a/include/cropwidget.h +++ b/include/cropwidget.h @@ -30,12 +30,20 @@ class CropWidgetPrivate; class CropWidget: public QFrame { Q_OBJECT + Q_PROPERTY(QPixmap snapshot READ snapshot) public: CropWidget(QWidget *parent = 0); virtual ~CropWidget(); virtual QSize sizeHint() const; virtual QSizePolicy sizePolicy() const; + /** + * @brief Get the snapshot. + * @returns pixmap of the snapshot as currently cropped. + * When not snapped returns an invalid pixmap. + */ + QPixmap snapshot() const; + protected: virtual void paintEvent(QPaintEvent *event); virtual void mousePressEvent(QMouseEvent *event); @@ -43,7 +51,19 @@ class CropWidget: public QFrame virtual void mouseReleaseEvent(QMouseEvent *event); public slots: + /** + * @brief Snap or unsnap an image. + * + * When snapped, child widgets are hidden and the snapshot + * (possibly cropped) is painted. + */ virtual void snap(bool snapped = true); + /** + * @brief Crop the image. + * + * Crop the snapshot image according to the rect user has drawn. + * No-op when not snapped or no crop rect set. + */ virtual void crop(); private: diff --git a/src/widget/cropwidget.cpp b/src/widget/cropwidget.cpp index 5c460f3..db541a1 100644 --- a/src/widget/cropwidget.cpp +++ b/src/widget/cropwidget.cpp @@ -52,6 +52,15 @@ CropWidget::~CropWidget() { delete d_ptr; } +QPixmap CropWidget::snapshot() const +{ + Q_D(const CropWidget); + if (d->_snapped) + return d->snapshot; + else + return QPixmap(); +} + void CropWidget::snap(bool snapped) { Q_D(CropWidget); -- 2.11.4.GIT