File indexing completed on 2023-10-01 04:44:13
0001 /* 0002 SPDX-FileCopyrightText: 2017 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "baloofilepropertiesplugin.h" 0008 0009 #include <QFrame> 0010 #include <QScrollArea> 0011 #include <QVBoxLayout> 0012 0013 #include <kio_version.h> 0014 #if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) 0015 #include <KIO/JobUiDelegateFactory> 0016 #else 0017 #include <KIO/JobUiDelegate> 0018 #endif 0019 0020 #include <KIO/OpenUrlJob> 0021 #include <KLocalizedString> 0022 #include <KPluginFactory> 0023 0024 #include "filemetadatawidget.h" 0025 0026 K_PLUGIN_CLASS_WITH_JSON(BalooFilePropertiesPlugin, "baloofilepropertiesplugin.json") 0027 0028 BalooFilePropertiesPlugin::BalooFilePropertiesPlugin(QObject *parent, const QList<QVariant> &args) 0029 : KPropertiesDialogPlugin(qobject_cast<KPropertiesDialog *>(parent)) 0030 { 0031 Q_UNUSED(args); 0032 0033 auto widgetContainer = new QWidget(); 0034 0035 auto containerLayout = new QVBoxLayout(widgetContainer); 0036 containerLayout->setContentsMargins(0, 0, 0, 0); 0037 containerLayout->setSpacing(0); 0038 0039 auto metaDataWidget = new Baloo::FileMetaDataWidget(); 0040 metaDataWidget->setItems(properties->items()); 0041 connect(metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, [this](const QUrl &url) { 0042 auto job = new KIO::OpenUrlJob(url); 0043 #if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) 0044 job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, properties)); 0045 #else 0046 job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, properties)); 0047 #endif 0048 job->start(); 0049 }); 0050 0051 containerLayout->addWidget(metaDataWidget); 0052 containerLayout->addStretch(1); 0053 0054 auto metaDataArea = new QScrollArea(); 0055 0056 metaDataArea->setWidget(widgetContainer); 0057 metaDataArea->setWidgetResizable(true); 0058 metaDataArea->setFrameShape(QFrame::NoFrame); 0059 0060 connect(metaDataWidget, &Baloo::FileMetaDataWidget::metaDataRequestFinished, this, [this, metaDataArea] { 0061 properties->addPage(metaDataArea, i18nc("Tab page with file meta data", "&Details")); 0062 }); 0063 } 0064 0065 BalooFilePropertiesPlugin::~BalooFilePropertiesPlugin() = default; 0066 0067 #include "baloofilepropertiesplugin.moc" 0068 0069 #include "moc_baloofilepropertiesplugin.cpp"