[Marble-commits] KDE/kdeedu/marble/src/lib
Dennis Nienhüser
earthwings at gentoo.org
Mon Jan 11 23:03:58 CET 2010
SVN commit 1073273 by nienhueser:
When the MarbleWidget is disabled, disable keyboard and mouse input and draw contents grayscaled.
CCBUG: 221490
M +35 -2 MarbleWidget.cpp
M +6 -0 MarbleWidget.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1073272:1073273
@@ -837,9 +837,18 @@
doClip = ( d->m_map->radius() > width() / 2
|| d->m_map->radius() > height() / 2 );
+ QPaintDevice *paintDevice = this;
+ QImage image;
+ if (!isEnabled())
+ {
+ // Paint to an intermediate image
+ image = QImage(rect().size(), QImage::Format_ARGB32_Premultiplied);
+ paintDevice = ℑ
+ }
+
// Create a painter that will do the painting.
- GeoPainter painter( this, map()->viewParams()->viewport(),
- map()->viewParams()->mapQuality(), doClip );
+ GeoPainter painter( paintDevice, map()->viewParams()->viewport(),
+ map()->viewParams()->mapQuality(), doClip );
QRect dirtyRect = evt->rect();
@@ -849,6 +858,20 @@
customPaint( &painter );
d->m_map->d->paintOverlay( painter, dirtyRect );
+ if (!isEnabled())
+ {
+ // Draw a grayscale version of the intermediate image
+ QRgb* pixel = reinterpret_cast<QRgb*>(image.scanLine(0));
+ for (int i=0; i<image.width()*image.height(); ++i, ++pixel) {
+ int gray = qGray(*pixel);
+ *pixel = qRgb(gray,gray,gray);
+ }
+
+ GeoPainter widgetPainter( this, map()->viewParams()->viewport(),
+ map()->viewParams()->mapQuality(), doClip );
+ widgetPainter.drawImage(rect(), image);
+ }
+
if (d->m_map->showFrameRate())
{
qreal fps = 1000.0 / (qreal)( t.elapsed() + 1 );
@@ -1387,6 +1410,16 @@
return d->m_model->floatItems();
}
+void MarbleWidget::changeEvent ( QEvent * event )
+{
+ if (event->type() == QEvent::EnabledChange)
+ {
+ setInputEnabled(isEnabled());
+ }
+
+ QWidget::changeEvent(event);
}
+}
+
#include "MarbleWidget.moc"
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1073272:1073273
@@ -1000,6 +1000,12 @@
void connectNotify ( const char * signal );
void disconnectNotify ( const char * signal );
+ /**
+ * @brief Reimplementation of the changeEvent() function in QWidget to
+ * react to changes of the enabled state
+ */
+ void changeEvent ( QEvent * event );
+
private:
Q_DISABLE_COPY( MarbleWidget )
MarbleWidgetPrivate * const d;
More information about the Marble-commits
mailing list