[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] KLineEdit Context Menu
From:       Leandro Emanuel Lopez <lopezlean () gmail ! com>
Date:       2007-07-18 21:35:51
Message-ID: 200707181836.02622.lopezlean () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


El Miércoles, 18 de Julio de 2007 05:40, Oswald Buddenhagen escribió:
> On Tue, Jul 17, 2007 at 09:42:31PM -0300, Leandro Emanuel López wrote:
> > +    showMenu ? QLineEdit::setContextMenuPolicy( Qt::DefaultContextMenu )
> > : QLineEdit::setContextMenuPolicy( Qt::NoContextMenu );
>
> this is from the "most obscure use of the ?: operator" department ...
Ok, i changed that in the new attached file

-- 
Leandro Emanuel López

["klineedit.diff" (text/x-diff)]

Index: widgets/klineedit.cpp
===================================================================
--- widgets/klineedit.cpp	(revision 689092)
+++ widgets/klineedit.cpp	(working copy)
@@ -110,7 +110,6 @@
     bool enableClickMsg:1;
     bool drawClickMsg:1;
 
-    bool bEnableMenu :1; 
     bool possibleTripleClick :1;  // set in mousePressEvent, deleted in tripleClickTimeout
 
     bool clickInClear:1;
@@ -152,7 +151,7 @@
     d->bgRole = backgroundRole();
 
     // Enable the context menu by default.
-    KLineEdit::setContextMenuEnabled( true );
+    QLineEdit::setContextMenuPolicy( Qt::DefaultContextMenu );
     KCursor::setAutoHideCursor( this, true, true );
     installEventFilter( this );
 
@@ -1064,7 +1063,7 @@
 
 void KLineEdit::contextMenuEvent( QContextMenuEvent *e )
 {
-    if ( !d->bEnableMenu )
+    if ( QLineEdit::contextMenuPolicy() != Qt::DefaultContextMenu )
       return;
     QMenu *popup = createStandardContextMenu();
 
@@ -1557,12 +1556,15 @@
 
 void KLineEdit::setContextMenuEnabled( bool showMenu )
 {
-    d->bEnableMenu = showMenu;
+    if ( showMenu )
+        QLineEdit::setContextMenuPolicy( Qt::DefaultContextMenu );
+    else
+        QLineEdit::setContextMenuPolicy( Qt::NoContextMenu );
 }
 
 bool KLineEdit::isContextMenuEnabled() const
 {
-    return  d->bEnableMenu;
+    return  ( contextMenuPolicy() == Qt::DefaultContextMenu );
 }
 
 void KLineEdit::setPasswordMode(bool b)

[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic