Commit a14e99c8 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

PK: Add a LinkButton to show dependencies

BUG: 383514
parent 3a3171ac
......@@ -13,6 +13,7 @@ add_library(packagekit-backend MODULE PackageKitBackend.cpp
PackageKitSourcesBackend.cpp
LocalFilePKResource.cpp
TransactionSet.cpp
pkui.qrc
)
target_link_libraries(packagekit-backend PRIVATE Discover::Common Qt5::Core PK::packagekitqt5 KF5::ConfigGui KF5::KIOCore KF5::Archive AppStreamQt)
......
......@@ -32,6 +32,7 @@ PackageKitResource::PackageKitResource(QString packageName, QString summary, Pac
: AbstractResource(parent)
, m_summary(std::move(summary))
, m_name(std::move(packageName))
, m_objects({ QStringLiteral("qrc:/qml/DependenciesButton.qml") })
{
setObjectName(m_name);
......
......@@ -30,6 +30,7 @@ class PackageKitBackend;
class PackageKitResource : public AbstractResource
{
Q_OBJECT
Q_PROPERTY(QStringList objects MEMBER m_objects CONSTANT)
public:
explicit PackageKitResource(QString packageName, QString summary, PackageKitBackend* parent);
QString packageName() const override;
......@@ -107,6 +108,7 @@ class PackageKitResource : public AbstractResource
const QString m_name;
PackageKit::Details m_details;
int m_dependenciesCount = -1;
const QStringList m_objects;
};
#endif // PACKAGEKITRESOURCE_H
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file>qml/DependenciesButton.qml</file>
</qresource>
</RCC>
/*
* Copyright (C) 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library/Lesser General Public License
* version 2, or (at your option) any later version, as published by the
* Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library/Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 2.1
import org.kde.kirigami 2.1 as Kirigami
LinkButton
{
text: i18n("Show Dependencies...")
onClicked: overlay.open()
Connections {
target: resource
onDependenciesFound: {
view.model.clear()
console.log("aaa", dependencies)
for (var v in dependencies) {
console.log("xxx", dependencies[v])
view.model.append({display: i18n("<b>%1</b>: %2", v, dependencies[v])})
}
}
}
Popup {
id: overlay
parent: applicationWindow().overlay
bottomPadding: Kirigami.Units.largeSpacing
topPadding: Kirigami.Units.largeSpacing
x: (parent.width - width)/2
y: (parent.height - height)/2
width: parent.width * 1/3
height: Math.min(view.contentHeight + bottomPadding + topPadding, parent.height * 4/5)
ListView {
id: view
anchors.fill: parent
header: Kirigami.Heading {
text: i18n ("%1 Dependencies", resource.name)
}
model: ListModel {}
delegate: Kirigami.BasicListItem {
width: parent.width
text: modelData
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment