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