File indexing completed on 2024-05-12 04:34:48

0001 /* ============================================================
0002 * Date        : 2009-08-26
0003 * Description : Preview image viewer.
0004 *
0005 * SPDX-FileCopyrightText: 2008-2012 Kåre Särs <kare.sars@iki .fi>
0006 *
0007 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0008 *
0009 * This program is distributed in the hope that it will be useful,
0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012 * GNU General Public License for more details.
0013 *
0014 * You should have received a copy of the GNU General Public License.
0015 * along with this program.  If not, see <http://www.gnu.org/licenses/>
0016 *
0017 * ============================================================ */
0018 
0019 #ifndef IMAGE_VIEWER_H
0020 #define IMAGE_VIEWER_H
0021 
0022 #include <QGraphicsView>
0023 class QWheelEvent;
0024 
0025 class ImageViewer : public QGraphicsView
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit ImageViewer(QWidget *parent = nullptr);
0030     ~ImageViewer() override;
0031 
0032     void setQImage(QImage *img);
0033 
0034 public Q_SLOTS:
0035     void zoomIn();
0036     void zoomOut();
0037     void zoom2Fit();
0038     void zoomActualSize();
0039 
0040 protected:
0041     void wheelEvent(QWheelEvent *e) override;
0042     void drawBackground(QPainter *painter, const QRectF &rect) override;
0043 
0044 private:
0045     struct Private;
0046     Private *const d;
0047 
0048 };
0049 
0050 #endif
0051