[PC-BSD Commits] r17683 - pcbsd/current/src-qt4/libpcbsd

svn at pcbsd.org svn at pcbsd.org
Mon Jul 9 07:40:36 PDT 2012


Author: kris
Date: 2012-07-09 14:40:36 +0000 (Mon, 09 Jul 2012)
New Revision: 17683

Modified:
   pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.cpp
   pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.h
   pcbsd/current/src-qt4/libpcbsd/metaWidget.cpp
   pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
   pcbsd/current/src-qt4/libpcbsd/utils.cpp
Log:

Improve the meta package widget, now when the user tries to 
force close the progress dialog, we intercept, and ask if they really want 
to cancel. If so, we kill the pc-metapkgmanager process and stop. 



Modified: pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.cpp	2012-07-09 13:13:58 UTC (rev 17682)
+++ pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.cpp	2012-07-09 14:40:36 UTC (rev 17683)
@@ -12,6 +12,7 @@
 #include "dialogMetaProgress.h"
 #include "ui_dialogMetaProgress.h"
 #include <QtGui>
+#include <QMessageBox>
 
 void dialogMetaProgress::programInit( QString desc )
 {
@@ -62,3 +63,19 @@
 {
     return progressSub->value();
 }
+
+void dialogMetaProgress::closeEvent(QCloseEvent *event)
+{
+   Q_UNUSED(event);
+
+   int ret = QMessageBox::warning(this, tr("Meta-Package Changes"),
+                                tr("Warning: Packages are still being modifed!\n" 
+				"If you cancel now the packages may be corrupted. Cancel anyway?"),
+                                QMessageBox::Yes | QMessageBox::No,
+                                QMessageBox::No);
+   if ( ret != QMessageBox::Yes)
+      return;
+
+   emit canceled();
+   close();
+}

Modified: pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.h
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.h	2012-07-09 13:13:58 UTC (rev 17682)
+++ pcbsd/current/src-qt4/libpcbsd/dialogMetaProgress.h	2012-07-09 14:40:36 UTC (rev 17683)
@@ -45,7 +45,11 @@
 private:
     QString PkgSet;
 
+protected:
+   void closeEvent(QCloseEvent *event);
+
 signals:
+   void canceled();
 
 } ;
 #endif // DIALOGMETAPROGRESS_H

Modified: pcbsd/current/src-qt4/libpcbsd/metaWidget.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/metaWidget.cpp	2012-07-09 13:13:58 UTC (rev 17682)
+++ pcbsd/current/src-qt4/libpcbsd/metaWidget.cpp	2012-07-09 14:40:36 UTC (rev 17683)
@@ -258,15 +258,32 @@
 
 }
 
+void metaWidget::slotMetaDelCanceled()
+{
+  canceled=true;
+  qDebug() << "Stopping pc-metapkgmanager";
+  delMetaProc->terminate();
+  delMetaProc->waitForFinished(500);
+  while ( delMetaProc->state() != QProcess::NotRunning ) {
+     QCoreApplication::processEvents();
+     delMetaProc->waitForFinished(100);
+     delMetaProc->kill();
+  }
+  qDebug() << "Done stopping pc-metapkgmanager";
+}
+
 void metaWidget::startMetaChanges()
 {
 
+        canceled=false;
         qDebug() << "Starting meta deletion";
 	// We've gotten this far, now time to do the actual meta pkg changes
 	if ( ! delPkgs.isEmpty() ) {
 
 		metaProgressDel = new metaProgressDialog();
                 metaProgressDel->programInit(tr("Performing system-package changes."));
+		// Connect canceled slot
+		connect( (QObject*)metaProgressDel, SIGNAL(canceled()), (QObject*)this, SLOT(slotMetaDelCanceled()) );
 		metaProgressDel->show();
 
 		delMetaProc = new QProcess();
@@ -318,16 +335,36 @@
 	}
 }
 
+void metaWidget::slotMetaAddCanceled()
+{
+  canceled=true;
+  qDebug() << "Stopping pc-metapkgmanager";
+  addMetaProc->terminate();
+  addMetaProc->waitForFinished(500);
+  while ( addMetaProc->state() != QProcess::NotRunning ) {
+     QCoreApplication::processEvents();
+     addMetaProc->waitForFinished(100);
+     addMetaProc->kill();
+  }
+  qDebug() << "Done stopping pc-metapkgmanager";
+}
+
 void metaWidget::slotMetaDelDone()
 {
 	if ( ! delPkgs.isEmpty() )
 		metaProgressDel->close();
 
+        // If the user canceled the process, we can stop here
+        if ( canceled )
+	      return;
+
 	// We've gotten this far, now time to do the actual meta pkg changes
 	if ( ! addPkgs.isEmpty() ) {
 	
 		metaProgressAdd = new metaProgressDialog();
                 metaProgressAdd->programInit(tr("Performing system-package changes."));
+		// Connect canceled slot
+		connect( (QObject*)metaProgressAdd, SIGNAL(canceled()), (QObject*)this, SLOT(slotMetaAddCanceled()) );
 		metaProgressAdd->show();
 
 		addMetaProc = new QProcess();
@@ -390,7 +427,11 @@
  
 	populateMetaPkgs();
 
-	if ( addMetaProc->exitCode() != 0 )
+        // If the user canceled the process, we can stop here
+        if ( canceled )
+	      return;
+
+	if ( addMetaProc->exitCode() != 0 && addMetaProc->exitStatus() != QProcess::NormalExit )
         	QMessageBox::critical(this, tr("System Packages"),
         	tr("The meta-pkg manager returned an error. For more details please look at the log file:") + " /tmp/.pc-metapkgmanager.log",
         	QMessageBox::Ok,

Modified: pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h	2012-07-09 13:13:58 UTC (rev 17682)
+++ pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h	2012-07-09 14:40:36 UTC (rev 17683)
@@ -75,8 +75,10 @@
 };
 
 class dialogMetaProgress;
-class metaProgressDialog {
+class metaProgressDialog:public QObject {
 
+  Q_OBJECT
+
 public:
   metaProgressDialog();
   void programInit(QString desc);
@@ -91,8 +93,15 @@
   void show();
   void close();
 
+private slots:
+  void slotCancel();
+
 private:
   dialogMetaProgress *d_p;
+
+signals:
+  void canceled();
+
 };
 
 
@@ -168,8 +177,10 @@
    void slotDeskPkgsChanged(QTreeWidgetItem *aItem, int __unused);
    void slotApplyMetaChanges();
    void slotMetaAddDone();
+   void slotMetaAddCanceled();
    void slotMetaAddRead(); 
    void slotMetaDelDone();
+   void slotMetaDelCanceled();
    void slotMetaDelRead();
    void startMetaChanges();
    void slotFinishLoadingMetaPkgs();
@@ -195,6 +206,7 @@
    QString chrootArg1;
    QString chrootArg2;
    bool stopped;
+   bool canceled;
    QString PkgSet;
 
    QMenu *popup;

Modified: pcbsd/current/src-qt4/libpcbsd/utils.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/utils.cpp	2012-07-09 13:13:58 UTC (rev 17682)
+++ pcbsd/current/src-qt4/libpcbsd/utils.cpp	2012-07-09 14:40:36 UTC (rev 17683)
@@ -856,6 +856,7 @@
 metaProgressDialog::metaProgressDialog() {
   d_p = new dialogMetaProgress;
   d_p->setWindowModality(Qt::ApplicationModal);
+  d_p->connect( (QObject*)d_p, SIGNAL(canceled()), (QObject*)this, SLOT(slotCancel()));
 }
 
 void metaProgressDialog::programInit(QString desc) {
@@ -902,7 +903,11 @@
   d_p->close();
 }
 
+void metaProgressDialog::slotCancel() {
+  emit canceled();
+}
 
+
 // PLMPL class for dialogwpaenterprise
 dialogWPAE::dialogWPAE() {
   d_wpae = new dialogWPAEnterprise;



More information about the Commits mailing list