Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Show All 26 Lines | |||||
27 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
28 | #include <KSeparator> | 28 | #include <KSeparator> | ||
29 | #include <KStringHandler> | 29 | #include <KStringHandler> | ||
30 | 30 | | |||
31 | #include <QIcon> | 31 | #include <QIcon> | ||
32 | #include <QMenu> | 32 | #include <QMenu> | ||
33 | #include <QTextDocument> | 33 | #include <QTextDocument> | ||
34 | 34 | | |||
35 | #ifndef HAVE_BALOO | | |||
36 | #include <KFileMetaDataWidget> | | |||
37 | #else | | |||
38 | #include <Baloo/FileMetaDataWidget> | 35 | #include <Baloo/FileMetaDataWidget> | ||
39 | #endif | | |||
40 | 36 | | |||
41 | #include <panels/places/placesitem.h> | 37 | #include <panels/places/placesitem.h> | ||
42 | #include <panels/places/placesitemmodel.h> | 38 | #include <panels/places/placesitemmodel.h> | ||
43 | 39 | | |||
44 | #include <Phonon/BackendCapabilities> | 40 | #include <Phonon/BackendCapabilities> | ||
45 | #include <Phonon/MediaObject> | 41 | #include <Phonon/MediaObject> | ||
46 | 42 | | |||
47 | #include <QLabel> | 43 | #include <QLabel> | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 66 | { | |||
101 | m_nameLabel->setFont(font); | 97 | m_nameLabel->setFont(font); | ||
102 | m_nameLabel->setTextFormat(Qt::PlainText); | 98 | m_nameLabel->setTextFormat(Qt::PlainText); | ||
103 | m_nameLabel->setAlignment(Qt::AlignHCenter); | 99 | m_nameLabel->setAlignment(Qt::AlignHCenter); | ||
104 | m_nameLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | 100 | m_nameLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | ||
105 | 101 | | |||
106 | const bool previewsShown = InformationPanelSettings::previewsShown(); | 102 | const bool previewsShown = InformationPanelSettings::previewsShown(); | ||
107 | m_preview->setVisible(previewsShown); | 103 | m_preview->setVisible(previewsShown); | ||
108 | 104 | | |||
109 | #ifndef HAVE_BALOO | | |||
110 | m_metaDataWidget = new KFileMetaDataWidget(parent); | | |||
111 | connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated, | | |||
112 | this, &InformationPanelContent::urlActivated); | | |||
113 | #else | | |||
114 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | 105 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | ||
115 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 106 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
116 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | 107 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | ||
117 | this, &InformationPanelContent::urlActivated); | 108 | this, &InformationPanelContent::urlActivated); | ||
118 | #endif | | |||
119 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | 109 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||
120 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 110 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
121 | 111 | | |||
122 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | 112 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | ||
123 | // at the bottom. This prevents that the meta data widget gets vertically stretched | 113 | // at the bottom. This prevents that the meta data widget gets vertically stretched | ||
124 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | 114 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | ||
125 | QWidget* metaDataWidgetContainer = new QWidget(parent); | 115 | QWidget* metaDataWidgetContainer = new QWidget(parent); | ||
126 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | 116 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 161 | } else { | |||
189 | 179 | | |||
190 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | 180 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | ||
191 | this, &InformationPanelContent::showPreview); | 181 | this, &InformationPanelContent::showPreview); | ||
192 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | 182 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | ||
193 | this, &InformationPanelContent::showIcon); | 183 | this, &InformationPanelContent::showIcon); | ||
194 | } | 184 | } | ||
195 | 185 | | |||
196 | if (m_metaDataWidget) { | 186 | if (m_metaDataWidget) { | ||
197 | #ifdef HAVE_BALOO | | |||
198 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | 187 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||
199 | #endif | | |||
200 | m_metaDataWidget->show(); | 188 | m_metaDataWidget->show(); | ||
201 | m_metaDataWidget->setItems(KFileItemList() << item); | 189 | m_metaDataWidget->setItems(KFileItemList() << item); | ||
202 | } | 190 | } | ||
203 | 191 | | |||
204 | if (InformationPanelSettings::previewsShown()) { | 192 | if (InformationPanelSettings::previewsShown()) { | ||
205 | const QString mimeType = item.mimetype(); | 193 | const QString mimeType = item.mimetype(); | ||
206 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | 194 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | ||
207 | if (usePhonon) { | 195 | if (usePhonon) { | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 265 | { | |||
280 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | 268 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | ||
281 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | 269 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | ||
282 | previewAction->setCheckable(true); | 270 | previewAction->setCheckable(true); | ||
283 | previewAction->setChecked(InformationPanelSettings::previewsShown()); | 271 | previewAction->setChecked(InformationPanelSettings::previewsShown()); | ||
284 | 272 | | |||
285 | QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); | 273 | QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); | ||
286 | configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | 274 | configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | ||
287 | 275 | | |||
288 | #ifdef HAVE_BALOO | | |||
289 | QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date")); | 276 | QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date")); | ||
290 | dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); | 277 | dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); | ||
291 | dateformatAction->setCheckable(true); | 278 | dateformatAction->setCheckable(true); | ||
292 | dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); | 279 | dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); | ||
293 | #endif | 280 | | ||
294 | popup.addSeparator(); | 281 | popup.addSeparator(); | ||
295 | foreach (QAction* action, customContextMenuActions) { | 282 | foreach (QAction* action, customContextMenuActions) { | ||
296 | popup.addAction(action); | 283 | popup.addAction(action); | ||
297 | } | 284 | } | ||
298 | 285 | | |||
299 | // Open the popup and adjust the settings for the | 286 | // Open the popup and adjust the settings for the | ||
300 | // selected action. | 287 | // selected action. | ||
301 | QAction* action = popup.exec(QCursor::pos()); | 288 | QAction* action = popup.exec(QCursor::pos()); | ||
Show All 9 Lines | 297 | } else if (action == configureAction) { | |||
311 | FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); | 298 | FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); | ||
312 | dialog->setDescription(i18nc("@label::textbox", | 299 | dialog->setDescription(i18nc("@label::textbox", | ||
313 | "Select which data should be shown in the information panel:")); | 300 | "Select which data should be shown in the information panel:")); | ||
314 | dialog->setItems(m_metaDataWidget->items()); | 301 | dialog->setItems(m_metaDataWidget->items()); | ||
315 | dialog->setAttribute(Qt::WA_DeleteOnClose); | 302 | dialog->setAttribute(Qt::WA_DeleteOnClose); | ||
316 | dialog->show(); | 303 | dialog->show(); | ||
317 | connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); | 304 | connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); | ||
318 | } | 305 | } | ||
319 | #ifdef HAVE_BALOO | | |||
320 | if (action == dateformatAction) { | 306 | if (action == dateformatAction) { | ||
321 | int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat); | 307 | int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat); | ||
322 | 308 | | |||
323 | InformationPanelSettings::setDateFormat(dateFormat); | 309 | InformationPanelSettings::setDateFormat(dateFormat); | ||
324 | refreshMetaData(); | 310 | refreshMetaData(); | ||
325 | } | 311 | } | ||
326 | #endif | | |||
327 | } | 312 | } | ||
328 | 313 | | |||
329 | void InformationPanelContent::showIcon(const KFileItem& item) | 314 | void InformationPanelContent::showIcon(const KFileItem& item) | ||
330 | { | 315 | { | ||
331 | m_outdatedPreviewTimer->stop(); | 316 | m_outdatedPreviewTimer->stop(); | ||
332 | QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); | 317 | QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); | ||
333 | KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); | 318 | KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); | ||
334 | m_preview->setPixmap(pixmap); | 319 | m_preview->setPixmap(pixmap); | ||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |