Baloo Widgets

baloofilepropertiesplugin.cpp
1 /*
2  * This file is part of the KDE Baloo Project
3  * Copyright (C) 2017 Kai Uwe Broulik <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) version 3, or any
9  * later version accepted by the membership of KDE e.V. (or its
10  * successor approved by the membership of KDE e.V.), which shall
11  * act as a proxy defined in Section 6 of version 3 of the license.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include "baloofilepropertiesplugin.h"
24 
25 #include <QFrame>
26 #include <QVBoxLayout>
27 #include <QScrollArea>
28 
29 #include <KLocalizedString>
30 #include <KPluginFactory>
31 #include <KIO/JobUiDelegate>
32 #include <KIO/OpenUrlJob>
33 
34 #include "filemetadatawidget.h"
35 
36 K_PLUGIN_CLASS_WITH_JSON(BalooFilePropertiesPlugin, "baloofilepropertiesplugin.json")
37 
38 BalooFilePropertiesPlugin::BalooFilePropertiesPlugin(QObject *parent, const QList<QVariant> &args)
39  : KPropertiesDialogPlugin(qobject_cast<KPropertiesDialog *>(parent))
40 {
41  Q_UNUSED(args);
42 
43  QWidget *widgetContainer = new QWidget();
44 
45  QVBoxLayout *containerLayout = new QVBoxLayout(widgetContainer);
46  containerLayout->setContentsMargins(0, 0, 0, 0);
47  containerLayout->setSpacing(0);
48 
49  auto *metaDataWidget = new Baloo::FileMetaDataWidget();
50  metaDataWidget->setItems(properties->items());
51  connect(metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, [this](const QUrl &url) {
52  KIO::OpenUrlJob *job = new KIO::OpenUrlJob(url);
54  job->start();
55  });
56 
57  containerLayout->addWidget(metaDataWidget);
58  containerLayout->addStretch(1);
59 
60  QScrollArea *metaDataArea = new QScrollArea();
61 
62  metaDataArea->setWidget(widgetContainer);
63  metaDataArea->setWidgetResizable(true);
64  metaDataArea->setFrameShape(QFrame::NoFrame);
65 
66  properties->addPage(metaDataArea, i18nc("Tab page with file meta data", "&Details"));
67 }
68 
69 BalooFilePropertiesPlugin::~BalooFilePropertiesPlugin() = default;
70 
71 #include "baloofilepropertiesplugin.moc"
void setWidget(QWidget *widget)
void setContentsMargins(int left, int top, int right, int bottom)
void setUiDelegate(KJobUiDelegate *delegate)
void setFrameShape(QFrame::Shape)
void start() override
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KGuiItem properties()
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
void setWidgetResizable(bool resizable)
void addStretch(int stretch)
void setSpacing(int spacing)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 18 2021 23:07:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.