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

List:       kfm-devel
Subject:    Last step for accesskeys...
From:       bj () altern ! org
Date:       2004-07-27 23:14:49
Message-ID: 200407280124.03246.bj () altern ! org
[Download RAW message or body]

I just committed a fix that makes accesskeys work also with sticky keys (with 
some help from Olaf & Gunnar). 
Basically, you need to press & release the ctrl key, then press the accesskey.
If sticky keys are enabled, you need to press ctrl twice (to "unstick" it), 
then press the accesskey.

Now, i would like to commit my last change to the accesskeys system, that 
displays all accesskeys in small tooltips. I finally decided to activate it 
as soon as the ctrl key is released, since it is the not very intrusive & 
much easier for users with sticky keys. 
I think this patch is quite necessary to have a working accesskey 
implementation since Konqueror currently doesn't show accesskeys in any way. 
It also makes it really easy  to check if a web page has accesskeys.

If there is no opposition, I will commit at the end of the week.
Regards

Jean-Baptiste

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

Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.651
diff -u -3 -r1.651 khtmlview.cpp
--- khtmlview.cpp	27 Jul 2004 22:20:48 -0000	1.651
+++ khtmlview.cpp	27 Jul 2004 23:01:18 -0000
@@ -69,6 +69,7 @@
 
 #include <qtooltip.h>
 #include <qpainter.h>
+#include <qlabel.h>
 #include <qpaintdevicemetrics.h>
 #include <qstylesheet.h>
 #include <kapplication.h>
@@ -679,6 +680,7 @@
         d->layoutSchedulingEnabled=false;
 
         if (document->isHTMLDocument()) {
+	     emit hideAccessKeys();
              NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body();
              if(body && body->renderer() && body->id() == ID_FRAMESET) {
                  QScrollView::setVScrollBarMode(AlwaysOff);
@@ -1413,11 +1415,8 @@
     if (d->accessKeysPreActivate && _ke->key() != Key_Control) \
                d->accessKeysPreActivate=false;
     if (_ke->key() == Key_Control &&  d->accessKeysPreActivate && _ke->state() == \
Qt::ControlButton && KApplication::keyboardModifiers()==0)  {
-	    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);
+	    displayAccessKeys();
+	    m_part->setStatusBarText(i18n("Access Keys \
activated"),KHTMLPart::BarHoverText);  d->accessKeysActivated = true;
 	    d->accessKeysPreActivate = false;
 	    d->accessKeysTimer.start(5000, true);
@@ -1889,12 +1888,35 @@
     }
 }
 
+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=en->getRect();
+	        QLabel *lab=new QLabel(s.string(),viewport(),0,Qt::WDestructiveClose);
+	        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->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.
@@ -2709,6 +2731,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.211
diff -u -3 -r1.211 khtmlview.h
--- khtmlview.h	27 Jul 2004 22:11:51 -0000	1.211
+++ khtmlview.h	27 Jul 2004 23:01:18 -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