]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/information/informationpanelcontent.cpp
Fix a todo: InformationPanelContent::configureSettings code is moved to InformationPa...
[dolphin.git] / src / panels / information / informationpanelcontent.cpp
index 0cba0cdf0687cb86f04c820a09c305fa0c5d5a8d..7704bdf165942d2fe5d1299f923299efc908280a 100644 (file)
 #include <KStringHandler>
 
 #include <QIcon>
-#include <QMenu>
 #include <QTextDocument>
 
-#ifndef HAVE_BALOO
-#include <KFileMetaDataWidget>
-#else
 #include <Baloo/FileMetaDataWidget>
-#endif
 
 #include <panels/places/placesitem.h>
 #include <panels/places/placesitemmodel.h>
@@ -52,7 +47,6 @@
 #include <QStyle>
 
 #include "dolphin_informationpanelsettings.h"
-#include "filemetadataconfigurationdialog.h"
 #include "phononwidget.h"
 #include "pixmapviewer.h"
 
@@ -106,19 +100,13 @@ 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<Baloo::DateFormats>(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);
+
     // Encapsulate the MetaDataWidget inside a container that has a dummy widget
     // at the bottom. This prevents that the meta data widget gets vertically stretched
     // in the case where the height of m_metaDataArea > m_metaDataWidget.
@@ -180,7 +168,10 @@ void InformationPanelContent::showItem(const KFileItem& item)
             m_outdatedPreviewTimer->start();
         }
 
-        m_previewJob = new KIO::PreviewJob(KFileItemList() << item, QSize(m_preview->width(), m_preview->height()));
+        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()) {
@@ -194,9 +185,7 @@ void InformationPanelContent::showItem(const KFileItem& item)
     }
 
     if (m_metaDataWidget) {
-#ifdef HAVE_BALOO
         m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat()));
-#endif
         m_metaDataWidget->show();
         m_metaDataWidget->setItems(KFileItemList() << item);
     }
@@ -273,59 +262,6 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
     return QWidget::eventFilter(obj, event);
 }
 
-void InformationPanelContent::configureSettings(const QList<QAction*>& 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")));
-
-#ifdef HAVE_BALOO
-    QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date"));
-    dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic")));
-    dateformatAction->setCheckable(true);
-    dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat));
-#endif
-    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);
-    }
-#ifdef HAVE_BALOO
-    if (action == dateformatAction) {
-        int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat);
-
-        InformationPanelSettings::setDateFormat(dateFormat);
-        refreshMetaData();
-    }
-#endif
-}
-
 void InformationPanelContent::showIcon(const KFileItem& item)
 {
     m_outdatedPreviewTimer->stop();
@@ -354,6 +290,14 @@ 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);