[PC-BSD Commits] r660 - pcbsd/trunk/XGUISource

svn at pcbsd.org svn at pcbsd.org
Tue Sep 4 09:24:38 PDT 2007


Author: kris
Date: 2007-09-04 09:24:37 -0700 (Tue, 04 Sep 2007)
New Revision: 660

Modified:
   pcbsd/trunk/XGUISource/xgui.ui.h
Log:

Added update to XGUI source which now sets the default "driver" combo boxed
to the auto-detected value, which should help users determine which driver
they will be using. 

Also defaulted bit depth to 24



Modified: pcbsd/trunk/XGUISource/xgui.ui.h
===================================================================
--- pcbsd/trunk/XGUISource/xgui.ui.h	2007-09-03 17:04:05 UTC (rev 659)
+++ pcbsd/trunk/XGUISource/xgui.ui.h	2007-09-04 16:24:37 UTC (rev 660)
@@ -52,21 +52,68 @@
 
 void XGUI::loadDrivers()
 {
-    int i = 0;
+    int i = 0, driverFound = 0;
     QString line;
+    QString Command;
+    QString usedDriver;
     
     comboDriver->clear();
 
-        QFile file( "/PCBSD/xorg-gui/settings/drivers.txt" );
+
+   // First try to determine which driver is being used now
+   Command="cat /etc/X11/xorg.conf | grep ' Driver' | grep -v 'keyboard' | grep -v 'mouse' | grep -v 'options' | cut -d '\"' -f 2 | cut -d ' ' -f 1";
+   FILE *readfile = popen(Command, "r");
+   char buffer[100];
+   line = "";
+   char firstChar;
+   if ((firstChar = fgetc(readfile)) != -1) {
+     	line += firstChar;
+	line += fgets(buffer,100,readfile);
+   }
+   pclose(readfile);
+
+   usedDriver = line.stripWhiteSpace();
+   if (usedDriver == "nvidia" ) {
+	usedDriver = "nv";
+   }
+
+   // Check if we have a match first
+    QFile file( "/PCBSD/xorg-gui/settings/drivers.txt" );
     if ( file.open( IO_ReadOnly ) ) {
         QTextStream stream( &file );
              while ( !stream.atEnd() ) {
                line = stream.readLine(); // line of text excluding '\n'
+
+	       if ( line == usedDriver ) {
+		driverFound = 1;
+	       }
+	       i++;
+	}
+	file.close();
+    }
+
+
+	
+   // Now populate the combo box
+    i = 0;
+
+    if ( file.open( IO_ReadOnly ) ) {
+        QTextStream stream( &file );
+             while ( !stream.atEnd() ) {
+               line = stream.readLine(); // line of text excluding '\n'
                comboDriver->insertItem(line);	    
 
-	       if ( line == "vesa" ) {
-		comboDriver->setCurrentItem(i);
+	       if ( driverFound == 1) {
+	      	 if ( line == usedDriver ) {
+			comboDriver->setCurrentItem(i);
+	      	 }
+	       } else {
+	      	 if ( line == "vesa" ) {
+			comboDriver->setCurrentItem(i);
+	      	 }
 	       }
+
+
 	       i++;
 	}
 	file.close();
@@ -77,6 +124,7 @@
 void XGUI::loadDepth()
 {
     QString line;
+    int i = 0;
     
     comboDepth->clear();
 
@@ -86,6 +134,11 @@
              while ( !stream.atEnd() ) {
                line = stream.readLine(); // line of text excluding '\n'
                comboDepth->insertItem(line);	    
+	       if ( line == "24bit" ) {
+		  comboDepth->setCurrentItem(i);
+	       }
+	 i++;
+
 	}
 	file.close();
     }



More information about the Commits mailing list