Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Context not available. | |||||
32 | #include <QMenu> | 32 | #include <QMenu> | ||
---|---|---|---|---|---|
33 | #include <QTextDocument> | 33 | #include <QTextDocument> | ||
34 | 34 | | |||
35 | #ifdef HAVE_BALOO | ||||
35 | #include <Baloo/FileMetaDataWidget> | 36 | #include <Baloo/FileMetaDataWidget> | ||
37 | #endif | ||||
36 | 38 | | |||
37 | #include <panels/places/placesitem.h> | 39 | #include <panels/places/placesitem.h> | ||
38 | #include <panels/places/placesitemmodel.h> | 40 | #include <panels/places/placesitemmodel.h> | ||
Context not available. | |||||
48 | #include <QStyle> | 50 | #include <QStyle> | ||
49 | 51 | | |||
50 | #include "dolphin_informationpanelsettings.h" | 52 | #include "dolphin_informationpanelsettings.h" | ||
53 | #ifdef HAVE_BALOO | ||||
51 | #include "filemetadataconfigurationdialog.h" | 54 | #include "filemetadataconfigurationdialog.h" | ||
55 | #endif | ||||
52 | #include "phononwidget.h" | 56 | #include "phononwidget.h" | ||
53 | #include "pixmapviewer.h" | 57 | #include "pixmapviewer.h" | ||
54 | 58 | | |||
Context not available. | |||||
60 | m_preview(nullptr), | 64 | m_preview(nullptr), | ||
61 | m_phononWidget(nullptr), | 65 | m_phononWidget(nullptr), | ||
62 | m_nameLabel(nullptr), | 66 | m_nameLabel(nullptr), | ||
67 | #ifdef HAVE_BALOO | ||||
63 | m_metaDataWidget(nullptr), | 68 | m_metaDataWidget(nullptr), | ||
69 | #endif | ||||
64 | m_metaDataArea(nullptr), | 70 | m_metaDataArea(nullptr), | ||
65 | m_placesItemModel(nullptr) | 71 | m_placesItemModel(nullptr) | ||
66 | { | 72 | { | ||
Context not available. | |||||
102 | const bool previewsShown = InformationPanelSettings::previewsShown(); | 108 | const bool previewsShown = InformationPanelSettings::previewsShown(); | ||
103 | m_preview->setVisible(previewsShown); | 109 | m_preview->setVisible(previewsShown); | ||
104 | 110 | | |||
111 | #ifdef HAVE_BALOO | ||||
105 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | 112 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | ||
106 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 113 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
107 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | 114 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | ||
108 | this, &InformationPanelContent::urlActivated); | 115 | this, &InformationPanelContent::urlActivated); | ||
109 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | 116 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||
110 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 117 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
118 | #endif | ||||
111 | 119 | | |||
112 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | 120 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | ||
113 | // at the bottom. This prevents that the meta data widget gets vertically stretched | 121 | // at the bottom. This prevents that the meta data widget gets vertically stretched | ||
Context not available. | |||||
116 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | 124 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | ||
117 | containerLayout->setContentsMargins(0, 0, 0, 0); | 125 | containerLayout->setContentsMargins(0, 0, 0, 0); | ||
118 | containerLayout->setSpacing(0); | 126 | containerLayout->setSpacing(0); | ||
127 | #ifdef HAVE_BALOO | ||||
119 | containerLayout->addWidget(m_metaDataWidget); | 128 | containerLayout->addWidget(m_metaDataWidget); | ||
129 | #endif | ||||
120 | containerLayout->addStretch(); | 130 | containerLayout->addStretch(); | ||
121 | 131 | | |||
122 | m_metaDataArea = new QScrollArea(parent); | 132 | m_metaDataArea = new QScrollArea(parent); | ||
Context not available. | |||||
186 | this, &InformationPanelContent::showIcon); | 196 | this, &InformationPanelContent::showIcon); | ||
187 | } | 197 | } | ||
188 | 198 | | |||
199 | #ifdef HAVE_BALOO | ||||
189 | if (m_metaDataWidget) { | 200 | if (m_metaDataWidget) { | ||
190 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 201 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
191 | m_metaDataWidget->show(); | 202 | m_metaDataWidget->show(); | ||
192 | m_metaDataWidget->setItems(KFileItemList() << item); | 203 | m_metaDataWidget->setItems(KFileItemList() << item); | ||
193 | } | 204 | } | ||
205 | #endif | ||||
194 | 206 | | |||
195 | if (InformationPanelSettings::previewsShown()) { | 207 | if (InformationPanelSettings::previewsShown()) { | ||
196 | const QString mimeType = item.mimetype(); | 208 | const QString mimeType = item.mimetype(); | ||
Context not available. | |||||
225 | ); | 237 | ); | ||
226 | setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count())); | 238 | setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count())); | ||
227 | 239 | | |||
240 | #ifdef HAVE_BALOO | ||||
228 | if (m_metaDataWidget) { | 241 | if (m_metaDataWidget) { | ||
229 | m_metaDataWidget->setItems(items); | 242 | m_metaDataWidget->setItems(items); | ||
230 | } | 243 | } | ||
244 | #endif | ||||
231 | 245 | | |||
232 | m_phononWidget->hide(); | 246 | m_phononWidget->hide(); | ||
233 | 247 | | |||
Context not available. | |||||
239 | switch (event->type()) { | 253 | switch (event->type()) { | ||
240 | case QEvent::Resize: { | 254 | case QEvent::Resize: { | ||
241 | QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event); | 255 | QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event); | ||
256 | #ifdef HAVE_BALOO | ||||
242 | if (obj == m_metaDataArea->viewport()) { | 257 | if (obj == m_metaDataArea->viewport()) { | ||
243 | // The size of the meta text area has changed. Adjust the fixed | 258 | // The size of the meta text area has changed. Adjust the fixed | ||
244 | // width in a way that no horizontal scrollbar needs to be shown. | 259 | // width in a way that no horizontal scrollbar needs to be shown. | ||
245 | m_metaDataWidget->setFixedWidth(resizeEvent->size().width()); | 260 | m_metaDataWidget->setFixedWidth(resizeEvent->size().width()); | ||
246 | } else if (obj == parent()) { | 261 | } else if (obj == parent()) { | ||
262 | #endif | ||||
247 | adjustWidgetSizes(resizeEvent->size().width()); | 263 | adjustWidgetSizes(resizeEvent->size().width()); | ||
264 | #ifdef HAVE_BALOO | ||||
248 | } | 265 | } | ||
266 | #endif | ||||
249 | break; | 267 | break; | ||
250 | } | 268 | } | ||
251 | 269 | | |||
Context not available. | |||||
253 | adjustWidgetSizes(parentWidget()->width()); | 271 | adjustWidgetSizes(parentWidget()->width()); | ||
254 | break; | 272 | break; | ||
255 | 273 | | |||
274 | #ifdef HAVE_BALOO | ||||
256 | case QEvent::FontChange: | 275 | case QEvent::FontChange: | ||
257 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | 276 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||
258 | break; | 277 | break; | ||
278 | #endif | ||||
259 | 279 | | |||
260 | default: | 280 | default: | ||
261 | break; | 281 | break; | ||
Context not available. | |||||
268 | { | 288 | { | ||
269 | QMenu popup(this); | 289 | QMenu popup(this); | ||
270 | 290 | | |||
291 | #ifdef HAVE_BALOO | ||||
271 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | 292 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | ||
272 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | 293 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | ||
273 | previewAction->setCheckable(true); | 294 | previewAction->setCheckable(true); | ||
Context not available. | |||||
280 | dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); | 301 | dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); | ||
281 | dateformatAction->setCheckable(true); | 302 | dateformatAction->setCheckable(true); | ||
282 | dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); | 303 | dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); | ||
283 | | ||||
284 | popup.addSeparator(); | 304 | popup.addSeparator(); | ||
305 | #endif | ||||
285 | foreach (QAction* action, customContextMenuActions) { | 306 | foreach (QAction* action, customContextMenuActions) { | ||
286 | popup.addAction(action); | 307 | popup.addAction(action); | ||
287 | } | 308 | } | ||
Context not available. | |||||
293 | return; | 314 | return; | ||
294 | } | 315 | } | ||
295 | 316 | | |||
317 | #ifdef HAVE_BALOO | ||||
296 | const bool isChecked = action->isChecked(); | 318 | const bool isChecked = action->isChecked(); | ||
297 | if (action == previewAction) { | 319 | if (action == previewAction) { | ||
298 | m_preview->setVisible(isChecked); | 320 | m_preview->setVisible(isChecked); | ||
Context not available. | |||||
312 | InformationPanelSettings::setDateFormat(dateFormat); | 334 | InformationPanelSettings::setDateFormat(dateFormat); | ||
313 | refreshMetaData(); | 335 | refreshMetaData(); | ||
314 | } | 336 | } | ||
337 | #endif | ||||
315 | } | 338 | } | ||
316 | 339 | | |||
317 | void InformationPanelContent::showIcon(const KFileItem& item) | 340 | void InformationPanelContent::showIcon(const KFileItem& item) | ||
Context not available. | |||||
397 | 420 | | |||
398 | // The metadata widget also contains a text widget which may return | 421 | // The metadata widget also contains a text widget which may return | ||
399 | // a large preferred width. | 422 | // a large preferred width. | ||
423 | #ifdef HAVE_BALOO | ||||
400 | if (m_metaDataWidget) { | 424 | if (m_metaDataWidget) { | ||
401 | m_metaDataWidget->setMaximumWidth(maxWidth); | 425 | m_metaDataWidget->setMaximumWidth(maxWidth); | ||
402 | } | 426 | } | ||
427 | #endif | ||||
403 | 428 | | |||
404 | // try to increase the preview as large as possible | 429 | // try to increase the preview as large as possible | ||
405 | m_preview->setSizeHint(QSize(maxWidth, maxWidth)); | 430 | m_preview->setSizeHint(QSize(maxWidth, maxWidth)); | ||
Context not available. |