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

List:       kfm-devel
Subject:    Re: [Patch] Fixing the Access Key system
From:       bj () altern ! org
Date:       2004-07-14 22:20:02
Message-ID: 200407150028.03385.bj () altern ! org
[Download RAW message or body]

Ok, I finally committed the change in the accesskey system (fixing #83053). 
You now have to press and release the ctrl button before pressing your 
accesskey. I commited in a hurry, because of the new string. 

I also managed to make a much improved version of my "display all accesskeys" 
feature, using QLabels as Lubos suggested (patch attached). They now 
integrate & scroll nicely with the view. I didn't commit this part, since It 
is kind of a new feature & don't want to take the decision alone.

Hope it's ok with everyone.
Regards - Jean-Baptiste

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

Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.647
diff -u -3 -r1.647 khtmlview.cpp
--- khtmlview.cpp	14 Jul 2004 21:51:40 -0000	1.647
+++ khtmlview.cpp	14 Jul 2004 22:18:00 -0000
@@ -69,6 +69,7 @@
 
 #include <qtooltip.h>
 #include <qpainter.h>
+#include <qlabel.h>
 #include <qpaintdevicemetrics.h>
 #include <qstylesheet.h>
 #include <kapplication.h>
@@ -1364,10 +1365,10 @@
     if (d->accessKeysPreActivate && _ke->key() != Key_Control) d->accessKeysPreActivate=false;
     if (_ke->key() == Key_Control &&  d->accessKeysPreActivate && _ke->state() == Qt::ControlButton)
 	{
+	    if (d->accessKeysActivated) displayAccessKeys();
 	    QString accessMsg=i18n("Access Keys activated");    
-	    #if 0 // added i18n string in case the feature makes it in KDE 3.3
 	    accessMsg+=i18n(" -- press Ctrl to display all available access keys");
-	    #endif
+
 	    m_part->setStatusBarText(accessMsg,KHTMLPart::BarHoverText);
 	    d->accessKeysActivated = true;
 	    d->accessKeysPreActivate = false;
@@ -1829,12 +1830,36 @@
     }
 }
 
+void KHTMLView::displayAccessKeys()
+{
+    for( NodeImpl* n = m_part->xmlDocImpl(); n != NULL; n = n->traverseNextNode()) {
+        if( n->isElementNode()) {
+            ElementImpl* en = static_cast< ElementImpl* >( n );
+            DOMString s = en->getAttribute( ATTR_ACCESSKEY );
+            if( s.length() == 1) {	    
+	        QRect rec=static_cast<DOM::ElementImpl*>(n)->getRect();
+	        QLabel *lab=new QLabel(s.string(),viewport());
+	        connect( this, SIGNAL(hideAccessKeys()), lab, SLOT(close()) );
+	        connect( this, SIGNAL(repaintAccessKeys()), lab, SLOT(repaint()));
+	        lab->setPalette(QToolTip::palette());
+	        lab->setLineWidth(2);
+	        lab->setFrameStyle(QFrame::Box | QFrame::Plain);
+	        lab->setAlignment( AlignAuto | AlignTop );
+	        lab->setMargin(3);
+	        lab->adjustSize();
+	        addChild(lab,rec.left()+rec.width()/2,rec.top()+rec.height()/2);
+	        showChild(lab);
+	    }
+        }
+    }
+}
 
 void KHTMLView::accessKeysTimeout()
 {
 d->accessKeysActivated=false;
 d->accessKeysPreActivate = false;
 m_part->setStatusBarText(QString::null, KHTMLPart::BarHoverText);
+emit hideAccessKeys();
 }
 
 // Handling of the HTML accesskey attribute.
@@ -2642,6 +2667,7 @@
             if ( (w = d->visibleWidgets.take(r) ) )
                 addChild(w, 0, -500000);
     }
+    if (d->accessKeysActivated) emit repaintAccessKeys();
 }
 
 void KHTMLView::scheduleRelayout(khtml::RenderObject * /*clippedObj*/)
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.210
diff -u -3 -r1.210 khtmlview.h
--- khtmlview.h	14 Jul 2004 21:50:20 -0000	1.210
+++ khtmlview.h	14 Jul 2004 22:18:00 -0000
@@ -160,11 +160,19 @@
      * ensure the display is up to date
      */
     void layout(); // KDE 4.0: make private
+    /**
+     * Display all accesskeys in small tooltips
+     */
+    void displayAccessKeys();
+    
+    
 
 signals:
     void finishedLayout();
     void cleared();
     void zoomView( int );
+    void hideAccessKeys();
+    void repaintAccessKeys();
 
 protected:
     void clear();


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

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