On Sun, 6 May 2012, Oliver Eichler wrote:

[left hand action menu on OS X]
It's still not perfect, though (text color of selected item should be
white):
http://a98.shuttle.de/~michael/qlgt-actionmenu-osx.png

Michael


Have a look at the isCurrent if clauses in initStyleOption. Probably you have to ad some #ifdef to fine tune that stuff for OS X.

Found it, it's QPalette::HighlightedText ;-)

Michael
From 2b66b066ce6356c842292c80dd94fa5b98e5c2b6 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Mon, 14 May 2012 23:26:56 +0200
Subject: [PATCH] fix action menu selected item color on OS X

add workaround for spurious mouse move events in CCanvas while the
context menu is shown
---
 src/CCanvas.cpp   |   15 ++++++++++++---
 src/CCanvas.h     |    3 +++
 src/CMegaMenu.cpp |    3 +++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/CCanvas.cpp b/src/CCanvas.cpp
index 1a1c5e4..7c21d64 100644
--- a/src/CCanvas.cpp
+++ b/src/CCanvas.cpp
@@ -76,6 +76,7 @@ CCanvas::CCanvas(QWidget * parent)
 : QWidget(parent)
 , mouse(0)
 , info(0)
+, contextMenuActive(false)
 {
     setMouseTracking(true);
     setFocusPolicy(Qt::StrongFocus);
@@ -257,9 +258,15 @@ void CCanvas::paintEvent(QPaintEvent * e)
 
 void CCanvas::mouseMoveEvent(QMouseEvent * e)
 {
-    posMouse = e->pos();
-    mouseMoveEventCoord(e);
-    mouse->mouseMoveEvent(e);
+    // this check shouldn't be necessary in an ideal world.  However, at least
+    // on OS X with Qt 4.7.4 I've seen sporadic mouse move events messing up
+    // posMouse while the context menu is shown
+    if (!contextMenuActive)
+    {
+        posMouse = e->pos();
+        mouseMoveEventCoord(e);
+        mouse->mouseMoveEvent(e);
+    }
 }
 
 
@@ -799,7 +806,9 @@ void CCanvas::raiseContextMenu(const QPoint& pos)
 
     QPoint p = mapToGlobal(pos);
     setMouseTracking(false);
+    contextMenuActive = true;
     menu.exec(p);
+    contextMenuActive = false;
     setMouseTracking(true);
 }
 
diff --git a/src/CCanvas.h b/src/CCanvas.h
index 1db3970..35d2244 100644
--- a/src/CCanvas.h
+++ b/src/CCanvas.h
@@ -198,5 +198,8 @@ class CCanvas : public QWidget
 
         QTimer * timerFadingMessage;
         QString fadingMessage;
+
+        // work around possible Qt/OS X bug
+        bool contextMenuActive;
 };
 #endif                           //CCANVAS_H
diff --git a/src/CMegaMenu.cpp b/src/CMegaMenu.cpp
index ea85bf2..ebb4f5e 100644
--- a/src/CMegaMenu.cpp
+++ b/src/CMegaMenu.cpp
@@ -179,6 +179,9 @@ void CMegaMenu::initStyleOption(QStyleOptionMenuItem 
*option, const QAction *act
     if (isCurrent && !action->isSeparator())
     {
         option->state |= QStyle::State_Selected | (mouseDown ? 
QStyle::State_Sunken : QStyle::State_None);
+#ifdef Q_WS_MAC
+        option->palette.setColor(QPalette::Normal, QPalette::HighlightedText, 
Qt::white);
+#endif
     }
 
     //     option->menuHasCheckableItems = d->hasCheckableItems;
-- 
1.7.9.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users

Reply via email to