From: bernie Date: Fri, 8 Aug 2008 10:28:10 +0000 (+0000) Subject: Completely port to Qt4 with no Q3Support X-Git-Tag: 2.0.0~358 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=27cabaafe176d72d9bd634f4bd7680d7337a3f69;p=bertos.git Completely port to Qt4 with no Q3Support git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1576 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/lcd_gfx_qt.cpp b/bertos/drv/lcd_gfx_qt.cpp index 551b48e5..8d04471e 100644 --- a/bertos/drv/lcd_gfx_qt.cpp +++ b/bertos/drv/lcd_gfx_qt.cpp @@ -26,15 +26,14 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2006 Develer S.r.l. (http://www.develer.com/) + * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/) * * --> * * \version $Id$ - * * \author Bernie Innocenti * - * \brief Custom control for graphics LCD emulation (interface) + * \brief Custom control for graphics LCD emulation (implementation) */ #include "lcd_gfx_qt.h" @@ -52,11 +51,14 @@ #define LCD_BG_COLOR 0xBB, 0xCC, 0xBB -EmulLCD::EmulLCD(QWidget *parent, const char *name) : - QFrame(parent, name, Qt::WRepaintNoErase | Qt::WResizeNoErase), +EmulLCD::EmulLCD(QWidget *parent) : + QFrame(parent), fg_color(LCD_FG_COLOR), - bg_color(LCD_BG_COLOR) + bg_brush(QColor(LCD_BG_COLOR)) { + // Optimized rendering: we repaint everything anyway + setAttribute(Qt::WA_NoSystemBackground); + // initialize bitmap memset(raster, 0xAA, sizeof(raster)); @@ -74,7 +76,7 @@ EmulLCD::~EmulLCD() QSizePolicy EmulLCD::sizePolicy() const { - return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, false); + return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, QSizePolicy::Frame); } @@ -93,12 +95,12 @@ QSize EmulLCD::minimumSizeHint() const void EmulLCD::paintEvent(QPaintEvent * /*event*/) { QPainter p(this); - QImage img(raster, WIDTH, HEIGHT, 1, NULL, 0, QImage::BigEndian); + QImage img(raster, WIDTH, HEIGHT, QImage::Format_Mono); p.setBackgroundMode(Qt::OpaqueMode); + p.setBackground(bg_brush); p.setPen(fg_color); - p.setBackgroundColor(bg_color); - p.drawImage(frame_width, frame_width, img); + p.drawImage(QPoint(frame_width, frame_width), img); } void EmulLCD::writeRaster(uint8_t *new_raster) diff --git a/bertos/drv/lcd_gfx_qt.h b/bertos/drv/lcd_gfx_qt.h index 93499a24..a5538f39 100644 --- a/bertos/drv/lcd_gfx_qt.h +++ b/bertos/drv/lcd_gfx_qt.h @@ -26,36 +26,16 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2006 Develer S.r.l. (http://www.develer.com/) + * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/) * All Rights Reserved. * --> * * \version $Id$ - * * \author Bernie Innocenti * * \brief Custom control for graphics LCD emulation (interface) */ -/*#* - *#* $Log$ - *#* Revision 1.5 2006/05/28 12:17:57 bernie - *#* Drop almost all the Qt3 cruft. - *#* - *#* Revision 1.4 2006/02/20 02:00:40 bernie - *#* Port to Qt 4.1. - *#* - *#* Revision 1.3 2006/02/15 09:13:16 bernie - *#* Switch to BITMAP_FMT_PLANAR_V_LSB. - *#* - *#* Revision 1.2 2006/02/10 12:33:51 bernie - *#* Make emulator display a bit larger. - *#* - *#* Revision 1.1 2006/01/16 03:51:35 bernie - *#* Add LCD Qt emulator. - *#* - *#*/ - #ifndef DRV_LCD_GFX_QT_H #define DRV_LCD_GFX_QT_H @@ -77,7 +57,7 @@ public: enum { WIDTH = 128, HEIGHT = 64 }; // Construction - EmulLCD(QWidget *parent = 0, const char *name = 0); + EmulLCD(QWidget *parent = 0); virtual ~EmulLCD(); // Base class overrides @@ -96,8 +76,9 @@ protected: /// Frame thickness int frame_width; - /// LCD colors - QColor fg_color, bg_color; + /// Brushes for painting the LCD + QColor fg_color; + QBrush bg_brush; /// Pixel storage unsigned char raster[(WIDTH + 7 / 8) * HEIGHT]; diff --git a/bertos/emul/emulkbd.cpp b/bertos/emul/emulkbd.cpp index 0fdecc45..7afc1f2a 100644 --- a/bertos/emul/emulkbd.cpp +++ b/bertos/emul/emulkbd.cpp @@ -205,8 +205,7 @@ int EmulKbd::readCols(void) EmulKey *key; int cols = 0; - // FIXME: QLayoutIterator is obsolete in Qt4 - for(QLayoutIterator it(layout->iterator()); (item = it.current()); ++it) + for (int i = 0; (item = layout->itemAt(i)); ++i) { key = static_cast(item->widget()); if (key->row == active_row)