File indexing completed on 2024-04-28 15:39:46

0001 // SPDX-FileCopyrightText: 2003-2019 Jesper K. Pedersen <blackie@kde.org>
0002 // SPDX-FileCopyrightText: 2022-2024 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 #ifndef IMAGEPREVIEWWIDGET_H
0007 #define IMAGEPREVIEWWIDGET_H
0008 
0009 // Qt includes
0010 #include <QList>
0011 #include <QWidget>
0012 
0013 // Local includes
0014 #include "ImagePreview.h"
0015 
0016 #include <DB/ImageInfo.h>
0017 
0018 class QCheckBox;
0019 class QPushButton;
0020 class QComboBox;
0021 class KActionCollection;
0022 
0023 namespace AnnotationDialog
0024 {
0025 
0026 class ImagePreviewWidget : public QWidget
0027 {
0028     Q_OBJECT
0029 public:
0030     ImagePreviewWidget(KActionCollection *actions);
0031     void rotate(int angle);
0032     void setImage(const DB::ImageInfo &info);
0033     void setImage(const QString &fileName);
0034     void setImage(const int index);
0035     void configure(QList<DB::ImageInfo> *imageList, bool singleEdit);
0036     /**
0037      * @brief reconfigure configures the ImagePreviewWidget, leaving the edit mode as-is.
0038      * @param imageList the new list of images
0039      * @param index the index of the currently displayed image
0040      */
0041     void reconfigure(QList<DB::ImageInfo> *imageList, int index);
0042     int angle() const;
0043     void anticipate(DB::ImageInfo &info1);
0044     const QString &lastImage();
0045     ImagePreview *preview() const;
0046     bool showAreas() const;
0047     void canCreateAreas(bool state);
0048     void setSearchMode(bool state);
0049     void updatePositionableCategories(QList<QString> positionableCategories = QList<QString>());
0050     QString defaultPositionableCategory() const;
0051     void setToggleFullscreenPreviewEnabled(bool state);
0052 
0053 public Q_SLOTS:
0054     void slotNext();
0055     void slotPrev();
0056     void slotCopyPrevious();
0057     void slotDeleteImage();
0058     void rotateLeft();
0059     void rotateRight();
0060     void slotShowAreas(bool show);
0061 
0062 Q_SIGNALS:
0063     void imageRotated(int angle);
0064     void imageChanged(const DB::ImageInfo &newImage);
0065     void indexChanged(int newIndex);
0066     void copyPrevClicked();
0067     void areaVisibilityChanged(bool visible);
0068     void togglePreview();
0069 
0070 protected:
0071     void showEvent(QShowEvent *) override;
0072 
0073 private: // Functions
0074     /**
0075      * Update labels and tooltip texts when canCreateAreas() changes.
0076      */
0077     void updateTexts();
0078     void toggleFullscreenPreview();
0079 
0080 private: // Variables
0081     ImagePreview *m_preview = nullptr;
0082     QPushButton *m_prevBut = nullptr;
0083     QPushButton *m_nextBut = nullptr;
0084     QPushButton *m_toggleFullscreenPreview = nullptr;
0085     QPushButton *m_rotateLeft = nullptr;
0086     QPushButton *m_rotateRight = nullptr;
0087     QPushButton *m_delBut = nullptr;
0088     QPushButton *m_copyPreviousBut = nullptr;
0089     QPushButton *m_toggleAreasBut = nullptr;
0090     QList<DB::ImageInfo> *m_imageList = nullptr;
0091     int m_current = -1;
0092     bool m_singleEdit = false;
0093     QLabel *m_defaultAreaCategoryLabel = nullptr;
0094     QComboBox *m_defaultAreaCategory = nullptr;
0095     QWidget *m_controlWidget = nullptr;
0096     KActionCollection *m_actions = nullptr;
0097 };
0098 }
0099 
0100 #endif /* IMAGEPREVIEWWIDGET_H */
0101 
0102 // vi:expandtab:tabstop=4 shiftwidth=4: