qt6windows7/examples/widgets/gestures/imagegestures/imagewidget.h

66 lines
1.5 KiB
C
Raw Normal View History

2023-10-30 06:33:08 +08:00
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef IMAGEWIDGET_H
#define IMAGEWIDGET_H
#include <QImage>
#include <QLoggingCategory>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QGestureEvent;
class QPanGesture;
class QPinchGesture;
class QSwipeGesture;
QT_END_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcExample)
//! [class definition begin]
class ImageWidget : public QWidget
{
Q_OBJECT
public:
ImageWidget(QWidget *parent = nullptr);
void openDirectory(const QString &path);
void grabGestures(const QList<Qt::GestureType> &gestures);
protected:
bool event(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
bool gestureEvent(QGestureEvent *event);
void panTriggered(QPanGesture*);
void pinchTriggered(QPinchGesture*);
void swipeTriggered(QSwipeGesture*);
//! [class definition begin]
QImage loadImage(const QString &fileName) const;
void loadImage();
void goNextImage();
void goPrevImage();
void goToImage(int index);
QString path;
QStringList files;
int position;
QImage prevImage, nextImage;
QImage currentImage;
qreal horizontalOffset;
qreal verticalOffset;
qreal rotationAngle;
qreal scaleFactor;
qreal currentStepScaleFactor;
//! [class definition end]
};
//! [class definition end]
#endif