[PC-BSD Commits] r2280 - pcbsd/trunk/PCInstall
svn at pcbsd.org
svn at pcbsd.org
Sat Jul 5 15:18:02 PDT 2008
Author: kris
Date: 2008-07-05 15:18:01 -0700 (Sat, 05 Jul 2008)
New Revision: 2280
Modified:
pcbsd/trunk/PCInstall/main.cpp
Log:
Added a feature to the installer which sets font sizes based on DPI info, so
they should look nicer on different screens now
Modified: pcbsd/trunk/PCInstall/main.cpp
===================================================================
--- pcbsd/trunk/PCInstall/main.cpp 2008-07-04 14:34:22 UTC (rev 2279)
+++ pcbsd/trunk/PCInstall/main.cpp 2008-07-05 22:18:01 UTC (rev 2280)
@@ -5,6 +5,7 @@
#include <qfont.h>
#include <qtranslator.h>
#include <qtextcodec.h>
+#include <qmessagebox.h>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
@@ -56,23 +57,60 @@
}
+
+ // Lets get the output of xdpyinfo and figure out what font size will work best in this case
+ QString command = "/usr/local/pcbsd/bin/xdpyinfo | grep resolution | cut -d 'x' -f 2 | cut -d ' ' -f 1";
+ int fontSize = 12;
+
+ FILE *file = popen(command,"r");
+
+ char buffer[100];
+
+ QString line = "";
+ char firstChar;
+
+ if ((firstChar = fgetc(file)) != -1){
+ line += firstChar;
+ line += fgets(buffer,100,file);
+ }
+
+ pclose(file);
+
+ bool ok;
+ line.toInt(&ok);
+ if ( ok ) {
+ QMessageBox::warning( 0, "PCBSD Installer", "dpi" + line, "Retry", "Quit", 0, 0, 1 );
+ if ( line.toInt() < 70 )
+ {
+ fontSize = 12;
+ } else if (line.toInt() < 85) {
+ fontSize = 10;
+ } else {
+ fontSize = 9;
+ }
+ }
+
+
+
// Check if we are running in chinese, and set the font to Serif
if ( nlang == "zh_CN" || nlang == "zh_TW" )
{
- QFont f( "mingunittf", 10);
+ QFont f( "mingunittf", fontSize);
a.setFont( f);
} else if (nlang == "ja" ) {
- QFont f( "vlgothic", 10);
+ QFont f( "vlgothic", fontSize);
a.setFont( f);
- } else if (nlang == "en" || nlang == "" ) {
- QFont f( "Dejavu", 12);
+ }
+else if (nlang == "en" || nlang == "" ) {
+ QFont f( "Dejavu",fontSize);
a.setFont( f);
} else {
- QFont f( "Dejavu", 12);
+ QFont f( "Dejavu",fontSize);
a.setFont( f);
}
+
QTranslator translator(0);
translator.load( QString("PCInstall_" + nlang), "/usr/local/pcbsd/LANGS/" );
a.installTranslator( &translator );
More information about the Commits
mailing list