Kstars

thumbimage.h
1/*
2 SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QLabel>
10#include <QPixmap>
11
12#include <memory>
13
14class ThumbImage : public QLabel
15{
17 public:
18 explicit ThumbImage(QWidget *parent, const char *name = nullptr);
19 virtual ~ThumbImage() override = default;
20
21 void setImage(QPixmap *pm)
22 {
23 *Image = *pm;
24 setFixedSize(Image->width(), Image->height());
25 }
26 QPixmap *image() { return Image.get(); }
27 QPixmap croppedImage();
28
29 void setCropRect(int x, int y, int w, int h) { CropRect->setRect(x, y, w, h); }
30 QRect *cropRect() const { return CropRect.get(); }
31
32 signals:
33 void cropRegionModified();
34
35 protected:
36 // void resizeEvent( QResizeEvent *e);
37 void paintEvent(QPaintEvent *) override;
38 void mousePressEvent(QMouseEvent *e) override;
39 void mouseReleaseEvent(QMouseEvent *e) override;
40 void mouseMoveEvent(QMouseEvent *e) override;
41
42 private:
43 std::unique_ptr<QRect> CropRect;
44 std::unique_ptr<QPoint> Anchor;
45 std::unique_ptr<QPixmap> Image;
46
47 bool bMouseButtonDown { false };
48 bool bTopLeftGrab { false };
49 bool bBottomLeftGrab { false };
50 bool bTopRightGrab { false };
51 bool bBottomRightGrab { false };
52 int HandleSize { 10 };
53};
Q_OBJECTQ_OBJECT
QObject * parent() const const
void setFixedSize(const QSize &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.