我教你konqueror的移植
Konqueror很多人用,反正比某些瀏覽器強多了,本文教給大家konqueror的移植的方法。
1、編譯QTE庫
一般,如果你要做Qt/Embedded的開發(fā),***把Qt/Embedded編譯成為兩個版本,一個是主機版,一個是目標(biāo)版。
2、在獲得Qt/ Embeded 的源碼之后,將其分別解壓到兩個目錄
3、編譯主機版本
1) export環(huán)境變量
export QTDIR=/usr/local/qtopia/work/qt-2.3.5
export QTEDIR=$QTDIR
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
2) 運行./configure
./configure -depths 4,8,16.32 -no-ipv6 -no-cups -no-pch -qvfb
3) 編譯Qt/Embedded函數(shù)庫
make sub-src
4) 編譯Qt/Embedded輔助開發(fā)工具
cd tools;make
這一步就會成一個可以在主機環(huán)境(x86)下運行的uic指令,放在$QTDIR/bin目錄中。
這時可以使用qte提供的qvfb工具 可以在qvfb窗口中運行examples 中的例子
四. 編譯目標(biāo)版本
首先安裝交叉編譯工具
qte 版本是qt-2.3.5
由于我使用的是PXA255的板子 它所帶的觸摸屏驅(qū)動與qt-embedded 中的觸摸屏接口不符
必須修改qte目錄下src/kernel/qwsmouse_qws.cpp
在定義QCustomTPanelHandlerPrivate類時 增加一個成員變量unsigned char prevstate
以下為修改后的類定義
class QCustomTPanelHandlerPrivate : public QWSMouseHandler {
Q_OBJECT
public:
QCustomTPanelHandlerPrivate(MouseProtocol, QString dev);
~QCustomTPanelHandlerPrivate();
private:
int mouseFD;
unsigned char prevstate;
private slots:
void readMouseData();
};
然后修改成員函數(shù)readMouseData
修改為:
void QCustomTPanelHandlerPrivate::readMouseData()
{
if(!qt_screen)
return;
CustomTPdata data;
short data2[4]={0};
int ret;
ret=read(mouseFD,data2,sizeof(data2));
if(ret) {
data.status=data2[0];
data.xpos=data2[1];
data.ypos=data2[2];
QPoint q;
q.setX(data.xpos);
q.setY(data.ypos);
mousePos=q;
if(data.status && !prevstate) {
emit mouseChanged(mousePos,Qt::LeftButton);
} else if(!data.status&&prevstate){
emit mouseChanged(mousePos,0);
}
prevstate=data.status;
}
if(ret<0) {
qDebug("Error %s",strerror(errno));
}
}
然后編譯qte
編譯腳本如下 :
#!/bin/sh
export QTDIR=`pwd`
export CC=arm-linux-gcc
export AR=arm-linux-ar
export NM=arm-linux-nm
export RANLIB=arm-linux-ranlib
export CXX=arm-linux-g++
export LINKER=arm-linux-g++
export STIRP=arm-linux-strip
export OPTIONS="-DQT_QWS_IPAQ -DQWS -dno-exceptions -fno-rtti -pipe"
make clean
echo yes | ./configure -release -shared -gif -no-sm -no-thread -system-zlib -system-libpng -no-mng -system-jpeg -no-nas-sound -no-opengl -no-xft -qconfig qpe -depths 16 -no-qvfb -vnc -xplatform linux-ipaq-g++ &&
make
#p#
五 編譯qtopia目標(biāo)平臺版本
與qte2.3.5對應(yīng)的 qtopia版本是qtopia 1.6.*
我選擇的是 qtopia-commercial-1.6.1
編譯腳本如下
#!/bin/sh
unset TMAKEPATH
export QTDIR=`pwd`/../../qt-2.3.5
export QTEDIR=$QTDIR
export QPEDIR=`pwd`/../
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export CC=arm-linux-gcc
export AR=arm-linux-ar
export NM=arm-linux-nm
export RANLIB=arm-linux-ranlib
export CXX=arm-linux-g++
export LINKER=arm-linux-g++
export STIRP=arm-linux-strip
export LD=arm-linux-ld
make clean
./configure -release -shared -platform linux-ipaq-g++ &&
make
六 編譯konqueror
在konqueror homepage下有很多konqueror-embedded-snapshot的包下載
http://developer.kde.org/~hausmann/snapshots/Attic/
我下載的是konqueror-embedded-snapshot-20030705.tar.gz 解壓縮
為了支持中文網(wǎng)頁 konqueror 的字體必須設(shè)置為unifont 而不是默認的helvetica
在dropin目錄下修改kglobalsettings.cpp
將KGlobalSettings類 generalFont成員函數(shù)找到初始化QFont對象
s_generalFont = new QFont( "helvetica", 12 );
其中的helvetica改為unifont
我的交叉編譯腳本:
export QTDIR=/usr/local/Qt/qt-2.3.5
export QTEDIR=$QTDIR
export QPEDIR=/usr/local/Qt/ qtopia-commercial-1.6.1
export PATH=$QTDIR/bin:$QPEDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib:$LD_LIBRARY_PATH
export AR=arm-linux-ar
export AS=arm-linux-as
export LD=arm-linux-ld
export RANLIB=arm-linux-ranlib
export CC=arm-linux-gcc
export CXX=arm-linux-g++
export NM=arm-linux-nm
./configure --disable-debug --libdir=$QPEDIR/lib --host=arm-linux --prefix=$QPEDIR/image/opt/Qtopia --enable-qt-embedded --enable-embedded --enable-qtopia --enable-qpe --enable-readwrite --enable-cgi --enable-sidebar --enable-fontsubs --disable-jshostext --enable-largeicons --with-qt-dir=$QTDIR --with-qt-libraries=$QTDIR/lib --with-qtopia-dir=$QPEDIR --with-gui=qpe --with-qt-includes=$QTDIR/include
make
make install
這時在konqueror 的文件夾中 konq-embed/src下 可以找到konqueor可執(zhí)行文件 konqueror.desktop
和konqueror.png
把可執(zhí)行文件拷貝到$QPEDIR/bin下 把konqueror .desktop拷貝到$QPEDIR/apps/Application下
把konqueror.png 拷貝到$QPEDIR/pic下
備注:在拷貝konqueror.desktop之前 ,在PC機上選擇該文件,右鍵選擇快捷菜單中的屬性,在彈出的窗口中選擇啟動器標(biāo)簽 ,在命令一欄konqueror的后面添上-font unifont 以顯示中文網(wǎng)頁
在PC機的 /usr/local下有一個kde文件夾 將這個文件夾拷貝到嵌入式文件系統(tǒng)下的某個目錄 (我拷貝在嵌入式文件系統(tǒng)的 /usr/local下 )
這個文件夾下的子目錄下的 html4.css和 charsets二個 文件是運行konqueror必須的
六 移植并執(zhí)行
在PC機編譯好的qtopia目錄下有一個createdesktop腳本 運行這個腳本 生成一個.tar文件 可以將這個文件拷貝到嵌入式文件系統(tǒng)下的某個目錄 同時還要將交叉編譯的qt-2.3.5中的lib目錄下的庫文件和font文件愛你夾拷貝加入到qtopia的lib目錄下
我將tar包解壓縮后拷貝在/usr/person下(當(dāng)然也可以拷貝tar包,運行qpe時再將tar包解壓縮)
為了使qt能找到觸摸屏驅(qū)動 需建立鏈接 在rootfs中的/etc/init.d/rcS中加入
ln -s /dev/misc/touchscreen/ucb1x00 /dev/ts
ln -s /dev/misc/touchscreen/ucb1x00 /dev/h3600_ts
ln -s /dev/misc/touchscreen/ucb1x00 /dev/tpanel
ln -s /dev/misc/touchscreen/ucb1x00 /dev/touchpanel
為了使konqueror能訪問Internet 需要設(shè)置網(wǎng)關(guān) 在rootfs中的/etc/init.d/rcS中加入
route add default gw 192.168.2.1 (192.168.2.1是網(wǎng)關(guān)IP)
***運行qtopia需要校正 用戶在觸摸屏上指定4個角和中心點的位置
這時qpe會向/tmp/poitercal這個文件里寫數(shù)據(jù) 而原先這個文件是空的
文件內(nèi)容為:73763 0 -1058203 0 76106 -1382584 65536
可以在init.d/rcS中加入相關(guān)命令 省去每次加電運行qpe 均需校正的麻煩
/home/zhangyu/rootfs/usr/person/qtopia-commercial-1.6.1
在PXA255上運行qtopia的腳本:
export HOME=/usr/person/qtopia-commercial-1.6.1
export QTDIR=/usr/person/qtopia-commercial-1.6.1
export QPEDIR=/usr/person/qtopia-commercial-1.6.1
export QWS_MOUSE_PROTO=TPanel:/dev/h3600_ts
export LD_LIBRARY_PATH=/usr/person/qtopia-commercial-1.6.1/lib:$LD_LIBRARY_PATH:/usr/local/qt-2.3.5/lib
export KDEDIR=/usr/local/kde
/usr/person/qtopia-commercial-1.6.1/bin/qpe -qws -font unifont &
一定要指明kde路徑 否則運行konqueror時提示找不到html4.css和 charsets二個 文件
這時候就可以看見qtopia 的啟動畫面 如果在選擇語言為中文或韓文后發(fā)現(xiàn)標(biāo)題和圖標(biāo)文字為方塊 可以在settting下進行appearence和launch拉中選擇字體文unifont
在應(yīng)用程序中有個web browser的圖標(biāo) 點擊就打開瀏覽器
備注:顏色顯示問題 由于我燒寫的內(nèi)核framebuffer中對16位深度的像素,RGB顏色分配位數(shù)均為5位
可參考內(nèi)核dirve/video/pxafb.c
if (var->bits_per_pixel == 16) {
var->red.offset = 10; var->red.length = 5;
var->green.offset = 5; var->green.length = 5;
var->blue.offset = 0; var->blue.length = 5;
}
而qt-embedded在將RGB顏色轉(zhuǎn)換為16位深度時 定義的RGB分別占用5位 6位 5位 若不改動會造成色彩失真 在圖像邊緣處尤其明顯
轉(zhuǎn)換的函數(shù)在src/kernel/qcolor_qws.cpp中被調(diào)用
case 16: {
return pix = qt_convRgbTo16(rgbVal);
#endif
} case 24:
該函數(shù)和占位格式的定義在qgfx_qws.h中
# define QT_QWS_DEPTH16_RGB 565 改為# define QT_QWS_DEPTH16_RGB 555
隨后的
static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
static const int qt_green_shift = qt_bbits-(8-qt_gbits);
static const int qt_neg_blue_shift = 8-qt_bbits;
RGB的占位和偏移量均由QT_QWS_DEPTH16_RGB 常量決定
修改后 顏色顯示正常
怎么樣?通過閱讀文章,覺得做開發(fā)一個Konqueror還是有點難度的,趕快學(xué)習(xí)吧!
【編輯推薦】