X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/848abc5922167a467bb73107ee6b72e9af3c8317..bff373d598c031cb1:/src/panels/information/informationpanelcontent.cpp diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 7507d54fb..4b34e55e3 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -21,21 +21,17 @@ #include #include -#include #include #include -#include +#include #include -#include #include #include + +#include #include -#ifndef HAVE_BALOO -#include -#else #include -#endif #include #include @@ -51,7 +47,6 @@ #include #include "dolphin_informationpanelsettings.h" -#include "filemetadataconfigurationdialog.h" #include "phononwidget.h" #include "pixmapviewer.h" @@ -105,15 +100,10 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : const bool previewsShown = InformationPanelSettings::previewsShown(); m_preview->setVisible(previewsShown); -#ifndef HAVE_BALOO - m_metaDataWidget = new KFileMetaDataWidget(parent); - connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated, - this, &InformationPanelContent::urlActivated); -#else m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); + m_metaDataWidget->setDateFormat(static_cast(InformationPanelSettings::dateFormat())); connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, &InformationPanelContent::urlActivated); -#endif m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); @@ -159,41 +149,43 @@ void InformationPanelContent::showItem(const KFileItem& item) const QUrl itemUrl = item.url(); const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && item.localPath().isEmpty(); - if (!applyPlace(itemUrl)) { - setNameLabelText(item.text()); - if (isSearchUrl) { - // in the case of a search-URL the URL is not readable for humans - // (at least not useful to show in the Information Panel) - m_preview->setPixmap( - QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) - ); - } else { - // try to get a preview pixmap from the item... - - // Mark the currently shown preview as outdated. This is done - // with a small delay to prevent a flickering when the next preview - // can be shown within a short timeframe. This timer is not started - // for directories, as directory previews might fail and return the - // same icon. - if (!item.isDir()) { - m_outdatedPreviewTimer->start(); - } - - m_previewJob = new KIO::PreviewJob(KFileItemList() << item, QSize(m_preview->width(), m_preview->height())); - m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); - m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); - if (m_previewJob->uiDelegate()) { - KJobWidgets::setWindow(m_previewJob, this); - } + setNameLabelText(item.text()); + if (isSearchUrl) { + // in the case of a search-URL the URL is not readable for humans + // (at least not useful to show in the Information Panel) + m_preview->setPixmap( + QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) + ); + } else { + // try to get a preview pixmap from the item... + + // Mark the currently shown preview as outdated. This is done + // with a small delay to prevent a flickering when the next preview + // can be shown within a short timeframe. This timer is not started + // for directories, as directory previews might fail and return the + // same icon. + if (!item.isDir()) { + m_outdatedPreviewTimer->start(); + } - connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, - this, &InformationPanelContent::showPreview); - connect(m_previewJob.data(), &KIO::PreviewJob::failed, - this, &InformationPanelContent::showIcon); + QStringList plugins = KIO::PreviewJob::availablePlugins(); + m_previewJob = new KIO::PreviewJob(KFileItemList() << item, + QSize(m_preview->width(), m_preview->height()), + &plugins); + m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); + m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); + if (m_previewJob->uiDelegate()) { + KJobWidgets::setWindow(m_previewJob, this); } + + connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, + this, &InformationPanelContent::showPreview); + connect(m_previewJob.data(), &KIO::PreviewJob::failed, + this, &InformationPanelContent::showIcon); } if (m_metaDataWidget) { + m_metaDataWidget->setDateFormat(static_cast(InformationPanelSettings::dateFormat())); m_metaDataWidget->show(); m_metaDataWidget->setItems(KFileItemList() << item); } @@ -270,53 +262,12 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event) return QWidget::eventFilter(obj, event); } -void InformationPanelContent::configureSettings(const QList& customContextMenuActions) -{ - QMenu popup(this); - - QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); - previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); - previewAction->setCheckable(true); - previewAction->setChecked(InformationPanelSettings::previewsShown()); - - QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); - configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); - - popup.addSeparator(); - foreach (QAction* action, customContextMenuActions) { - popup.addAction(action); - } - - // Open the popup and adjust the settings for the - // selected action. - QAction* action = popup.exec(QCursor::pos()); - if (!action) { - return; - } - - const bool isChecked = action->isChecked(); - if (action == previewAction) { - m_preview->setVisible(isChecked); - InformationPanelSettings::setPreviewsShown(isChecked); - } else if (action == configureAction) { - FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); - dialog->setDescription(i18nc("@label::textbox", - "Select which data should be shown in the information panel:")); - dialog->setItems(m_metaDataWidget->items()); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); - connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); - } -} - void InformationPanelContent::showIcon(const KFileItem& item) { m_outdatedPreviewTimer->stop(); - if (!applyPlace(item.targetUrl())) { - QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); - KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); - m_preview->setPixmap(pixmap); - } + QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); + KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); + m_preview->setPixmap(pixmap); } void InformationPanelContent::showPreview(const KFileItem& item, @@ -339,9 +290,17 @@ void InformationPanelContent::markOutdatedPreview() m_preview->setPixmap(disabledPixmap); } +void InformationPanelContent::setPreviewVisible(bool visible) { + m_preview->setVisible(visible); +} + +KFileItemList InformationPanelContent::items() { + return m_metaDataWidget->items(); +} + void InformationPanelContent::slotHasVideoChanged(bool hasVideo) { - m_preview->setVisible(!hasVideo); + m_preview->setVisible(InformationPanelSettings::previewsShown() && !hasVideo); } void InformationPanelContent::refreshMetaData() @@ -351,21 +310,6 @@ void InformationPanelContent::refreshMetaData() } } -bool InformationPanelContent::applyPlace(const QUrl& url) -{ - const int count = m_placesItemModel->count(); - for (int i = 0; i < count; ++i) { - const PlacesItem* item = m_placesItemModel->placesItem(i); - if (item->url().matches(url, QUrl::StripTrailingSlash)) { - setNameLabelText(item->text()); - m_preview->setPixmap(QIcon::fromTheme(item->icon()).pixmap(128, 128)); - return true; - } - } - - return false; -} - void InformationPanelContent::setNameLabelText(const QString& text) { QTextOption textOption;