Baloo Widgets

baloofilepropertiesplugin.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 Kai Uwe Broulik <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "baloofilepropertiesplugin.h"
8 
9 #include <QFrame>
10 #include <QScrollArea>
11 #include <QVBoxLayout>
12 
13 #include <KIO/JobUiDelegate>
14 #include <KIO/OpenUrlJob>
15 #include <KLocalizedString>
16 #include <KPluginFactory>
17 
18 #include "filemetadatawidget.h"
19 
20 K_PLUGIN_CLASS_WITH_JSON(BalooFilePropertiesPlugin, "baloofilepropertiesplugin.json")
21 
22 BalooFilePropertiesPlugin::BalooFilePropertiesPlugin(QObject *parent, const QList<QVariant> &args)
23  : KPropertiesDialogPlugin(qobject_cast<KPropertiesDialog *>(parent))
24 {
25  Q_UNUSED(args);
26 
27  auto widgetContainer = new QWidget();
28 
29  auto containerLayout = new QVBoxLayout(widgetContainer);
30  containerLayout->setContentsMargins(0, 0, 0, 0);
31  containerLayout->setSpacing(0);
32 
33  auto metaDataWidget = new Baloo::FileMetaDataWidget();
34  metaDataWidget->setItems(properties->items());
35  connect(metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, [this](const QUrl &url) {
36  auto job = new KIO::OpenUrlJob(url);
37  job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, properties));
38  job->start();
39  });
40 
41  containerLayout->addWidget(metaDataWidget);
42  containerLayout->addStretch(1);
43 
44  auto metaDataArea = new QScrollArea();
45 
46  metaDataArea->setWidget(widgetContainer);
47  metaDataArea->setWidgetResizable(true);
48  metaDataArea->setFrameShape(QFrame::NoFrame);
49 
50  connect(metaDataWidget, &Baloo::FileMetaDataWidget::metaDataRequestFinished, this, [this, metaDataArea, metaDataWidget] {
51  properties->addPage(metaDataArea, i18nc("Tab page with file meta data", "&Details"));
52  });
53 }
54 
55 BalooFilePropertiesPlugin::~BalooFilePropertiesPlugin() = default;
56 
57 #include "baloofilepropertiesplugin.moc"
KGuiItem properties()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:13:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.