digiKam
imagedialog.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-03-13
7  * Description : Image files selection dialog.
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_IMAGE_DIALOG_H
25 #define DIGIKAM_IMAGE_DIALOG_H
26 
27 // Qt includes
28 
29 #include <QUrl>
30 #include <QScrollArea>
31 #include <QFileIconProvider>
32 #include <QIcon>
33 #include <QImage>
34 #include <QModelIndex>
35 #include <QFileInfo>
36 #include <QAbstractItemView>
37 
38 // Local includes
39 
40 #include "digikam_export.h"
41 #include "ditemtooltip.h"
42 
43 namespace Digikam
44 {
45 
46 class LoadingDescription;
47 class ThumbnailImageCatcher;
48 
49 class DIGIKAM_EXPORT ImageDialogPreview : public QScrollArea
50 {
51  Q_OBJECT
52 
53 public:
54 
55  explicit ImageDialogPreview(QWidget* const parent = nullptr);
56  ~ImageDialogPreview() override;
57 
58  QSize sizeHint() const override;
59 
60  static QString identifyItem(const QUrl& url, const QImage& preview = QImage());
61 
62 public Q_SLOTS:
63 
64  void slotShowPreview(const QUrl& url);
65 
66 private Q_SLOTS:
67 
68  void showPreview();
69  void slotClearPreview();
70  void slotThumbnail(const LoadingDescription& desc, const QPixmap& pix);
71 
72 private:
73 
74  void resizeEvent(QResizeEvent* e) override;
75 
76 private:
77 
78  class Private;
79  Private* const d;
80 };
81 
82 // ------------------------------------------------------------------------
83 
85 {
86  Q_OBJECT
87 
88 public:
89 
90  explicit ImageDialogToolTip();
91  ~ImageDialogToolTip() override;
92 
93  void setData(QAbstractItemView* const view,
94  const QModelIndex& index,
95  const QUrl& url);
96 
97 private:
98 
99  QRect repositionRect() override;
100  QString tipContents() override;
101 
102 private:
103 
104  class Private;
105  Private* const d;
106 };
107 
108 // ------------------------------------------------------------------------
109 
110 class DIGIKAM_EXPORT ImageDialogIconProvider : public QFileIconProvider
111 {
112 
113 public:
114 
115  explicit ImageDialogIconProvider();
116  ~ImageDialogIconProvider() override;
117 
118 #if (QT_VERSION > QT_VERSION_CHECK(5, 99, 0))
119  QIcon icon(QAbstractFileIconProvider::IconType type) const override;
120 #else
121  QIcon icon(QFileIconProvider::IconType type) const override;
122 #endif
123 
124  QIcon icon(const QFileInfo& info) const override;
125 
126 private:
127 
128  class Private;
129  Private* const d;
130 };
131 
132 // ------------------------------------------------------------------------
133 
134 class DIGIKAM_EXPORT ImageDialog : public QObject
135 {
136  Q_OBJECT
137 
138 public:
139 
140  explicit ImageDialog(QWidget* const parent,
141  const QUrl& url,
142  bool singleSelect = false,
143  const QString& caption = QString());
144  ~ImageDialog();
145 
146  QUrl url() const;
147  QList<QUrl> urls() const;
148  QStringList fileFormats() const;
149 
150  void setEnableToolTips(bool val);
151 
152  static QUrl getImageURL(QWidget* const parent,
153  const QUrl& url,
154  const QString& caption = QString());
155 
156  static QList<QUrl> getImageURLs(QWidget* const parent,
157  const QUrl& url,
158  const QString& caption = QString());
159 
160 private:
161 
162  bool eventFilter(QObject* obj, QEvent* ev);
163 
164  void hideToolTip();
165  bool acceptToolTip(const QUrl& url) const;
166 
167  // Disable
168  ImageDialog(const ImageDialog&) = delete;
169  ImageDialog& operator=(const ImageDialog&) = delete;
170 
171 private Q_SLOTS:
172 
173  void slotToolTip();
174 
175 private:
176 
177  class Private;
178  Private* const d;
179 };
180 
181 } // namespace Digikam
182 
183 #endif // DIGIKAM_IMAGE_DIALOG_H
Definition: ditemtooltip.h:75
Definition: imagedialog.h:111
QIcon icon(QFileIconProvider::IconType type) const override
Definition: imagedialog.h:50
Definition: imagedialog.h:85
void setData(QAbstractItemView *const view, const QModelIndex &index, const QUrl &url)
Definition: imagedialog_tooltip.cpp:68
~ImageDialogToolTip() override
Definition: imagedialog_tooltip.cpp:58
ImageDialogToolTip()
Definition: imagedialog_tooltip.cpp:48
Definition: imagedialog.h:135
Definition: loadingdescription.h:45
Definition: datefolderview.cpp:43