qt5base-lts/examples/widgets/gestures/imagegestures/imagewidget.h
Lucie Gérard 05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00

66 lines
1.5 KiB
C++

// 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