[education/rkward] rkward/dialogs: Add (basic) status indication on packages to install/remove

Thomas Friedrichsmeier null at kde.org
Mon May 2 20:59:37 BST 2022


Git commit 3d35767a8f8cc8bf4f17eb9e480f8678e3a030b2 by Thomas Friedrichsmeier.
Committed on 02/05/2022 at 19:59.
Pushed by tfry into branch 'master'.

Add (basic) status indication on packages to install/remove

M  +20   -1    rkward/dialogs/rkloadlibsdialog.cpp
M  +3    -1    rkward/dialogs/rkloadlibsdialog.h

https://invent.kde.org/education/rkward/commit/3d35767a8f8cc8bf4f17eb9e480f8678e3a030b2

diff --git a/rkward/dialogs/rkloadlibsdialog.cpp b/rkward/dialogs/rkloadlibsdialog.cpp
index b06a1330..ef8b1b59 100644
--- a/rkward/dialogs/rkloadlibsdialog.cpp
+++ b/rkward/dialogs/rkloadlibsdialog.cpp
@@ -673,14 +673,32 @@ InstallPackagesWidget::InstallPackagesWidget (RKLoadLibsDialog *dialog) : RKLoad
 	connect(configure_repos_button, &QPushButton::clicked, this, &InstallPackagesWidget::configureRepositories);
 	settingsbox->addWidget(configure_repos_button);
 
+	status_label = new QLabel();
+	vbox->addWidget(status_label);
+	status_label->hide();
+
 	connect(parent, &RKLoadLibsDialog::installedPackagesChanged, this, &InstallPackagesWidget::initialize);
-	connect(packages_status, &RKRPackageInstallationStatus::changed, this, &InstallPackagesWidget::setChanged);
+	connect(packages_status, &RKRPackageInstallationStatus::changed, this, &InstallPackagesWidget::updateStatus);
 }
 
 InstallPackagesWidget::~InstallPackagesWidget () {
 	RK_TRACE (DIALOGS);
 }
 
+void InstallPackagesWidget::updateStatus() {
+	RK_TRACE (DIALOGS);
+	QStringList dummy1, dummy2, dummy3;
+	packages_status->packagesToRemove(&dummy1, &dummy2);
+	dummy3 = packages_status->packagesToInstall();
+	if (dummy3.isEmpty() && dummy1.isEmpty()) status_label->hide();
+	else {
+		// TODO: Obviously, it would be nice to spell out, how many dependencies will be installed
+		status_label->setText(i18n("<b>Install %1 packages (plus dependencies), remove %2 packages</b>", dummy3.size(), dummy1.size()));
+		status_label->show();
+		setChanged();
+	}
+}
+
 void InstallPackagesWidget::activated () {
 	RK_TRACE (DIALOGS);
 
@@ -710,6 +728,7 @@ void InstallPackagesWidget::initialize () {
 		}
 		window()->raise(); // needed on Mac, otherwise the dialog may go hiding behind the main app window, after the progress control window closes, for some reason
 		clearChanged();
+		updateStatus();
 	});
 	RInterface::issueCommand(dummy, parent->chain);
 }
diff --git a/rkward/dialogs/rkloadlibsdialog.h b/rkward/dialogs/rkloadlibsdialog.h
index 0431acbf..b682d540 100644
--- a/rkward/dialogs/rkloadlibsdialog.h
+++ b/rkward/dialogs/rkloadlibsdialog.h
@@ -27,9 +27,9 @@ class QWidget;
 class QCloseEvent;
 class RCommandChain;
 class QCheckBox;
-class PackageInstallParamsWidget;
 class InstallPackagesWidget;
 class RKDynamicSearchLine;
+class QLabel;
 
 class RKLoadLibsDialogPage : public QWidget {
 	Q_OBJECT
@@ -245,6 +245,7 @@ public slots:
 	void rowClicked (const QModelIndex& row);
 private:
 	void doInstall();
+	void updateStatus();
 	QTreeView *packages_view;
 	RKRPackageInstallationStatus *packages_status;
 	RKRPackageInstallationStatusSortFilterModel *model;
@@ -253,6 +254,7 @@ private:
 	QCheckBox *rkward_packages_only;
 	QComboBox *libloc_selector;
 	QCheckBox *suggested_packages;
+	QLabel *status_label;
 
 	RKLoadLibsDialog *parent;
 };


More information about the rkward-tracker mailing list