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