[PC-BSD Commits] r8133 - pcbsd/current/src-qt4/pc-xgui

svn at pcbsd.org svn at pcbsd.org
Thu Dec 2 09:02:28 PST 2010


Author: kris
Date: 2010-12-02 09:02:28 -0800 (Thu, 02 Dec 2010)
New Revision: 8133

Modified:
   pcbsd/current/src-qt4/pc-xgui/xgui.cpp
   pcbsd/current/src-qt4/pc-xgui/xgui.h
Log:

Added functionality to check if a driver is really available on the system before listing
it in the combobox as an option



Modified: pcbsd/current/src-qt4/pc-xgui/xgui.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-xgui/xgui.cpp	2010-12-02 16:29:51 UTC (rev 8132)
+++ pcbsd/current/src-qt4/pc-xgui/xgui.cpp	2010-12-02 17:02:28 UTC (rev 8133)
@@ -10,14 +10,15 @@
 ** destructor.
 *****************************************************************************/
 #include "xgui.h"
-#include <qfile.h>
-#include <qmessagebox.h>
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+#include <QMessageBox>
 #include <QTextStream>
-#include <QDir>
-#include <QDebug>
 #include "../config.h"
 
 const QString PROGDIR( PREFIX + "/share/pcbsd/xorg-gui" );
+const QString XDRIVERDIR( PREFIX + "/lib/xorg/modules/drivers" );
 #define TMPDIR QString("/tmp/.xgui")
 
 
@@ -209,10 +210,11 @@
         QTextStream stream( &file );
              while ( !stream.atEnd() ) {
                line = stream.readLine(); // line of text excluding '\n'
-               comboDriver->addItem(line);	    
-	       if ( line == "vesa" ) {
-	   	 comboDriver->setCurrentIndex(i);
-               }
+	  	if ( isDriverAvailable(line) ) {
+                  comboDriver->addItem(line);	    
+	          if ( line == "vesa" )
+	   	    comboDriver->setCurrentIndex(i);
+		}
 	       i++;
 	}
 	file.close();
@@ -337,3 +339,12 @@
         return line.simplified();
 }
 
+// Script to check if a particular xorg driver is available on the system
+bool XGUI::isDriverAvailable(QString driver)
+{
+	// Make sure to strip the -3d-enable flag off
+	if ( driver.indexOf("-3d-enable") != -1 )
+		driver.truncate(driver.indexOf("-3d-enable"));
+
+	return QFile::exists(XDRIVERDIR + "/" + driver + "_drv.so");
+}

Modified: pcbsd/current/src-qt4/pc-xgui/xgui.h
===================================================================
--- pcbsd/current/src-qt4/pc-xgui/xgui.h	2010-12-02 16:29:51 UTC (rev 8132)
+++ pcbsd/current/src-qt4/pc-xgui/xgui.h	2010-12-02 17:02:28 UTC (rev 8133)
@@ -1,9 +1,9 @@
 #ifndef XGUI_H
 #define XGUI_H
 
-#include <qfile.h>
-#include <qmessagebox.h>
+#include <QFile>
 #include <QMainWindow>
+#include <QMessageBox>
 #include "ui_xgui.h"
 
 class XGUI : public QMainWindow, private Ui::XGUI
@@ -21,19 +21,20 @@
 public slots:
 
 private slots:
+    void applySlot();
     void closeSlot();
-    void applySlot();
+    void dualChangedSlot();
     void monitorChangedSlot();
-    void dualChangedSlot();
 
 private:
+    void checkUnprobedMonitor();
+    QString getLineFromCommandOutput(QString command);
+    bool isDriverAvailable(QString driver);
+    void loadDepth();
     void loadDeviceInformation();
+    void loadDrivers();
     void loadResolutions();
-    void loadDrivers();
-    void loadDepth();
-    void checkUnprobedMonitor();
     void suggestDriver(QString driver);
-    QString getLineFromCommandOutput(QString command);
 
 signals:
 



More information about the Commits mailing list