]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanelcontent.h
InformationPanel: Port from Phonon to QtMultimedia
[dolphin.git] / src / panels / information / informationpanelcontent.h
1 /*
2 * SPDX-FileCopyrightText: 2009-2010 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef INFORMATIONPANELCONTENT_H
8 #define INFORMATIONPANELCONTENT_H
9
10 #include "config-dolphin.h"
11 #include <KFileItem>
12
13 #include <QPointer>
14 #include <QUrl>
15 #include <QWidget>
16
17 class KFileItemList;
18 class MediaWidget;
19 class PixmapViewer;
20 class QPixmap;
21 class QDialogButtonBox;
22 class QString;
23 class QLabel;
24 class QScrollArea;
25 class QGestureEvent;
26
27 namespace KIO
28 {
29 class PreviewJob;
30 }
31
32 namespace Baloo
33 {
34 class FileMetaDataWidget;
35 }
36
37 /**
38 * @brief Manages the widgets that display the meta information
39 * for file items of the Information Panel.
40 */
41 class InformationPanelContent : public QWidget
42 {
43 Q_OBJECT
44
45 public:
46 explicit InformationPanelContent(QWidget *parent = nullptr);
47 ~InformationPanelContent() override;
48
49 /**
50 * Shows the meta information for the item \p item.
51 * The preview of the item is generated asynchronously,
52 * the other meta information are fetched synchronously.
53 */
54 void showItem(const KFileItem &item);
55
56 /**
57 * Shows the meta information for the items \p items and its preview
58 */
59 void showItems(const KFileItemList &items);
60
61 KFileItemList items();
62
63 /**
64 * Refreshes the preview display, hiding it if needed
65 */
66 void refreshPreview();
67
68 /**
69 * Switch the metadatawidget into configuration mode
70 */
71 void configureShownProperties();
72
73 /*
74 * Set the auto play media mode for the file previewed
75 * Eventually starting media playback when turning it on
76 * But not stopping it when turning it off
77 */
78 void setPreviewAutoPlay(bool autoPlay);
79
80 Q_SIGNALS:
81 void urlActivated(const QUrl &url);
82 void configurationFinished();
83 void contextMenuRequested(const QPoint &pos);
84
85 public Q_SLOTS:
86 /**
87 * Is invoked after the file meta data configuration dialog has been
88 * closed and refreshes the displayed meta data by the panel.
89 */
90 void refreshMetaData();
91
92 protected:
93 /** @see QObject::eventFilter() */
94 bool eventFilter(QObject *obj, QEvent *event) override;
95
96 bool event(QEvent *event) override;
97
98 private Q_SLOTS:
99 /**
100 * Is invoked if no preview is available for the item. In this
101 * case the icon will be shown.
102 */
103 void showIcon(const KFileItem &item);
104
105 /**
106 * Is invoked if a preview is available for the item. The preview
107 * \a pixmap is shown inside the info page.
108 */
109 void showPreview(const KFileItem &item, const QPixmap &pixmap);
110
111 /**
112 * Marks the currently shown preview as outdated
113 * by greying the content.
114 */
115 void markOutdatedPreview();
116
117 void slotHasVideoChanged(bool hasVideo);
118
119 private:
120 /**
121 * Sets the text for the label \a m_nameLabel and assures that the
122 * text is split in a way that it can be wrapped within the
123 * label width (QLabel::setWordWrap() does not work if the
124 * text represents one extremely long word).
125 */
126 void setNameLabelText(const QString &text);
127
128 /**
129 * Adjusts the sizes of the widgets dependent on the available
130 * width given by \p width.
131 */
132 void adjustWidgetSizes(int width);
133
134 /**
135 * Refreshes the image in the PixmapViewer
136 */
137 void refreshPixmapView();
138
139 bool gestureEvent(QGestureEvent *event);
140
141 private:
142 KFileItem m_item;
143
144 QPointer<KIO::PreviewJob> m_previewJob;
145 QTimer *m_outdatedPreviewTimer;
146
147 PixmapViewer *m_preview;
148 MediaWidget *m_mediaWidget;
149 QLabel *m_nameLabel;
150 Baloo::FileMetaDataWidget *m_metaDataWidget;
151 QScrollArea *m_metaDataArea;
152 QLabel *m_configureLabel;
153 QDialogButtonBox *m_configureButtons;
154
155 bool m_isVideo;
156 };
157
158 #endif // INFORMATIONPANELCONTENT_H