File 0001-Hide-option-to-install-updates-on-Tumbleweed.patch of Package plasma5-pk-updates
From 475d92af692c7bbba389c7b807ee27d843cdebb7 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Tue, 12 Jun 2018 19:21:43 +0200
Subject: [PATCH] Hide option to install updates on Tumbleweed
---
src/declarative/pkupdates.cpp | 16 ++++++++++++++++
src/declarative/pkupdates.h | 6 ++++++
src/plasma/contents/ui/Full.qml | 17 +++++++++++++++--
src/plasma/contents/ui/PackageDelegate.qml | 2 ++
4 files changed, 39 insertions(+), 2 deletions(-)
Index: plasma-pk-updates-0.3.2/src/declarative/pkupdates.cpp
===================================================================
--- plasma-pk-updates-0.3.2.orig/src/declarative/pkupdates.cpp
+++ plasma-pk-updates-0.3.2/src/declarative/pkupdates.cpp
@@ -20,6 +20,7 @@
#include <limits.h>
#include <QDebug>
+#include <QFile>
#include <QTimer>
#include <QDBusReply>
#include <QDBusInterface>
@@ -179,6 +180,21 @@ bool PkUpdates::isOnBattery() const
return Solid::PowerManagement::appShouldConserveResources();
}
+bool PkUpdates::isTumbleweed() const
+{
+ QFile osRelease("/etc/os-release");
+ if(!osRelease.open(QIODevice::ReadOnly))
+ return false;
+
+ while(!osRelease.atEnd()) {
+ QByteArray line = osRelease.readLine();
+ if(line.startsWith("NAME=\"openSUSE Tumbleweed\""))
+ return true;
+ }
+
+ return false;
+}
+
void PkUpdates::getUpdateDetails(const QString &pkgID)
{
qCDebug(PLASMA_PK_UPDATES) << "Requesting update details for" << pkgID;
Index: plasma-pk-updates-0.3.2/src/declarative/pkupdates.h
===================================================================
--- plasma-pk-updates-0.3.2.orig/src/declarative/pkupdates.h
+++ plasma-pk-updates-0.3.2/src/declarative/pkupdates.h
@@ -55,6 +55,7 @@ class PkUpdates : public QObject
Q_PROPERTY(bool isNetworkOnline READ isNetworkOnline NOTIFY networkStateChanged)
Q_PROPERTY(bool isNetworkMobile READ isNetworkMobile NOTIFY networkStateChanged)
Q_PROPERTY(bool isOnBattery READ isOnBattery NOTIFY isOnBatteryChanged)
+ Q_PROPERTY(bool isTumbleweed READ isTumbleweed CONSTANT)
public:
enum Activity {Idle, CheckingUpdates, GettingUpdates, InstallingUpdates};
@@ -133,6 +134,11 @@ public:
*/
bool isOnBattery() const;
+ /**
+ * @return whether /etc/os-release indicates openSUSE Tumbleweed
+ */
+ bool isTumbleweed() const;
+
signals:
/**
* Emitted when the number uf updates has changed
Index: plasma-pk-updates-0.3.2/src/plasma/contents/ui/Full.qml
===================================================================
--- plasma-pk-updates-0.3.2.orig/src/plasma/contents/ui/Full.qml
+++ plasma-pk-updates-0.3.2/src/plasma/contents/ui/Full.qml
@@ -140,6 +140,7 @@ Item {
currentIndex: -1
boundsBehavior: Flickable.StopAtBounds
delegate: PackageDelegate {
+ checkboxVisible: !PkUpdates.isTumbleweed
onClicked: {
if (updatesView.currentIndex === index) {
updatesView.currentIndex = -1
@@ -160,7 +161,7 @@ Item {
}
RowLayout {
- visible: PkUpdates.count && PkUpdates.isNetworkOnline && !PkUpdates.isActive
+ visible: PkUpdates.count && PkUpdates.isNetworkOnline && !PkUpdates.isActive && !PkUpdates.isTumbleweed
PlasmaComponents.CheckBox {
id: chkSelectAll
anchors {
@@ -218,7 +219,7 @@ Item {
PlasmaComponents.Button {
id: btnUpdate
- visible: PkUpdates.count && PkUpdates.isNetworkOnline && !PkUpdates.isActive
+ visible: PkUpdates.count && PkUpdates.isNetworkOnline && !PkUpdates.isActive && !PkUpdates.isTumbleweed
enabled: fullRepresentation.anySelected
anchors {
bottom: parent.bottom
@@ -230,6 +231,18 @@ Item {
onClicked: PkUpdates.installUpdates(selectedPackages())
}
+ PlasmaComponents.Label {
+ id: lblUseZypper
+ visible: PkUpdates.count && PkUpdates.isNetworkOnline && !PkUpdates.isActive && PkUpdates.isTumbleweed
+ height: paintedHeight
+ anchors {
+ bottom: parent.bottom
+ horizontalCenter: parent.horizontalCenter
+ }
+ elide: Text.ElideRight;
+ text: i18n("Run 'zypper dup' manually to install updated packages.")
+ }
+
PlasmaComponents.BusyIndicator {
running: PkUpdates.isActive
visible: running
Index: plasma-pk-updates-0.3.2/src/plasma/contents/ui/PackageDelegate.qml
===================================================================
--- plasma-pk-updates-0.3.2.orig/src/plasma/contents/ui/PackageDelegate.qml
+++ plasma-pk-updates-0.3.2/src/plasma/contents/ui/PackageDelegate.qml
@@ -32,6 +32,7 @@ PlasmaComponents.ListItem {
property string updateText
property variant updateUrls: []
readonly property bool expanded: ListView.isCurrentItem
+ property alias checkboxVisible: checkbox.visible
signal checkedStateChanged(bool checked)
@@ -42,6 +43,7 @@ PlasmaComponents.ListItem {
PlasmaComponents.CheckBox {
id: checkbox
+ width: checkboxVisible ? implicitWidth : 0
anchors {
left: parent.left
verticalCenter: packageInfoColumn.verticalCenter