[PC-BSD Commits] r15597 - pcbsd/current/src-qt4/pc-usermanager

svn at pcbsd.org svn at pcbsd.org
Sat Feb 25 09:45:56 PST 2012


Author: tim
Date: 2012-02-25 17:45:55 +0000 (Sat, 25 Feb 2012)
New Revision: 15597

Modified:
   pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.cpp
   pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.h
Log:
Enhanced the UserManager so that the user is notified of uncommitted changes when they attempt to close the dialog. At this point they'll be able to select yes (quit & commit changes), no (quit and don't commit changes), and cancel (don't quit or commit changes).

Modified: pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.cpp	2012-02-25 17:14:31 UTC (rev 15596)
+++ pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.cpp	2012-02-25 17:45:55 UTC (rev 15597)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim McCormick   *
+ *   Copyright (C) 2007, 2012 by Tim McCormick   *
  *   tim at pcbsd.org   *
  *                                                                         *
  *   Permission is hereby granted, free of charge, to any person obtaining *
@@ -31,6 +31,7 @@
 void PCBSDUserManager::setupUMDialogs()
 {
     layout = new QGridLayout(widgetUserContainer);
+    changesMade = false;
 
     //Init GUI
     if (getuid() == 0) //Check for root
@@ -82,7 +83,8 @@
 
 void PCBSDUserManager::configChanged()
 {
-  pushSave->setEnabled(true); 
+  pushSave->setEnabled(true);
+  changesMade = true;
 }
 
 void PCBSDUserManager::slotSave()
@@ -95,5 +97,23 @@
 
 void PCBSDUserManager::slotClose()
 {
+  if(changesMade)
+  {
+      int answer = QMessageBox::question(this,
+                                         tr("Apply pending changes?"),
+                                         tr("There are pending changes which have not been applied. Would you like to apply them before quitting?") ,
+                                         QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
+                                         QMessageBox::Cancel);
+      if(answer == QMessageBox::Yes) back->commit();
+      else if(answer == QMessageBox::Cancel) return;
+  }
   close();
 }
+
+/**
+  * Override QDialog's closeEvent() which is triggered when the window 'X' is hit and use our close slot
+  */
+void PCBSDUserManager::closeEvent(QCloseEvent*)
+{
+    slotClose();
+}

Modified: pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.h
===================================================================
--- pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.h	2012-02-25 17:14:31 UTC (rev 15596)
+++ pcbsd/current/src-qt4/pc-usermanager/pcbsdusermanager.h	2012-02-25 17:45:55 UTC (rev 15597)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim McCormick				   *
+ *   Copyright (C) 2007, 2012 by Tim McCormick				   *
  *   Modified 2009 by Kris Moore					   *
  *   kris at pcbsd.org				    	    	 	   *	 
  *                                                                         *
@@ -47,6 +47,7 @@
     
     ~PCBSDUserManager();
     void setupUMDialogs();
+    virtual void closeEvent(QCloseEvent*);
 
 public slots:
     void switchToAdvanced();
@@ -62,6 +63,7 @@
     UserManagerBackend *back;
     SimpleDlgCode *simpleGui;
     QGridLayout *layout;
+    bool changesMade;
 };
 
 #endif



More information about the Commits mailing list