diff options
author | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-08 08:30:31 +0000 |
---|---|---|
committer | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-08 08:30:31 +0000 |
commit | f3ade25de71804c56cbb047bbd8629d09c24a50c (patch) | |
tree | 87d258a0c846e7bf62917e453c2d930e7cdd2d8a | |
parent | bcb5ee25bc0ce0a036db50db9db3493979407e3f (diff) | |
download | navit-svn-f3ade25de71804c56cbb047bbd8629d09c24a50c.tar.gz |
Fix:graphics/qt_qpainter:Graphics now shutdowns navit
correctly, when used without widget overriding gui
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@3141 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | graphics/qt_qpainter/graphics_qt_qpainter.cpp | 93 |
1 files changed, 55 insertions, 38 deletions
diff --git a/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/graphics/qt_qpainter/graphics_qt_qpainter.cpp index 68ce605c..31b1e894 100644 --- a/graphics/qt_qpainter/graphics_qt_qpainter.cpp +++ b/graphics/qt_qpainter/graphics_qt_qpainter.cpp @@ -42,6 +42,7 @@ #include "window.h" #include "keys.h" #include "navit/font/freetype/font_freetype.h" +#include "navit.h" #include <qglobal.h> #if QT_VERSION < 0x040000 @@ -72,6 +73,45 @@ #include <QtGui> #endif +class RenderArea; + +//############################################################################################################## +//# Description: +//# Comment: +//# Authors: Martin Schaller (04/2008) +//############################################################################################################## +struct graphics_gc_priv { + QPen *pen; + QBrush *brush; + struct color c; +}; + +//############################################################################################################## +//# Description: +//# Comment: +//# Authors: Martin Schaller (04/2008) +//############################################################################################################## +struct graphics_priv { +#ifdef HAVE_QPE + QPEApplication *app; +#else + QApplication *app; +#endif + RenderArea *widget; + QPainter *painter; + struct graphics_gc_priv *background_gc; + unsigned char rgba[4]; + enum draw_mode_num mode; + struct graphics_priv *parent,*overlays,*next; + struct point p,pclean; + int cleanup; + int overlay_disable; + int wraparound; + struct font_priv * (*font_freetype_new)(void *meth); + struct font_freetype_methods freetype_methods; + int w,h; + struct navit* nav; +}; //############################################################################################################## //# Description: RenderArea (QWidget) class for the main window (map, menu, ...) @@ -103,6 +143,7 @@ class RenderArea : public QWidget void mouseMoveEvent(QMouseEvent *event); void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); + void closeEvent(QCloseEvent *event); #if QT_VERSION < 0x040000 void timerEvent(QTimerEvent *event); #endif @@ -110,46 +151,8 @@ class RenderArea : public QWidget void watchEvent(int fd); }; - #include "graphics_qt_qpainter.moc" -//############################################################################################################## -//# Description: -//# Comment: -//# Authors: Martin Schaller (04/2008) -//############################################################################################################## -struct graphics_gc_priv { - QPen *pen; - QBrush *brush; - struct color c; -}; - -//############################################################################################################## -//# Description: -//# Comment: -//# Authors: Martin Schaller (04/2008) -//############################################################################################################## -struct graphics_priv { -#ifdef HAVE_QPE - QPEApplication *app; -#else - QApplication *app; -#endif - RenderArea *widget; - QPainter *painter; - struct graphics_gc_priv *background_gc; - unsigned char rgba[4]; - enum draw_mode_num mode; - struct graphics_priv *parent,*overlays,*next; - struct point p,pclean; - int cleanup; - int overlay_disable; - int wraparound; - struct font_priv * (*font_freetype_new)(void *meth); - struct font_freetype_methods freetype_methods; - int w,h; -}; - static void overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, int clean, QRect *r) { @@ -260,6 +263,19 @@ RenderArea::RenderArea(struct graphics_priv *priv, QWidget *parent, int w, int h } //############################################################################################################## +//# Description: QWidget:closeEvent +//# Comment: Deletes navit object and stops event loop on graphics shutdown +//############################################################################################################## +void RenderArea::closeEvent(QCloseEvent* event) +{ + struct attr navit; + navit.type=attr_navit; + navit.u.navit=this->gra->nav; + navit_destroy(navit.u.navit); + event_main_loop_quit(); + event->accept(); +} +//############################################################################################################## //# Description: QWidget:sizeHint //# Comment: This property holds the recommended size for the widget //# Authors: Martin Schaller (04/2008) @@ -1177,6 +1193,7 @@ static struct graphics_priv * graphics_qt_qpainter_new(struct navit *nav, struct ret=g_new0(struct graphics_priv, 1); ret->font_freetype_new=font_freetype_new; *meth=graphics_methods; + ret->nav=nav; #if 1 font_freetype_new(&ret->freetype_methods); meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new; |