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

List:       kde-core-devel
Subject:    [PATCH] improved keyboard navigation for KFileDialog
From:       Alexander Dymo <dymo () ukrpost ! ua>
Date:       2008-07-23 22:37:13
Message-ID: 200807240137.14136.dymo () ukrpost ! ua
[Download RAW message or body]

Hey,
attached little patch makes KFileDialog a bit easier to operate with keyboard:
1) it focuses directory/file selector (KDirOperator) widget on url change and 
return press from places pane and url navigator 
2) it adds Ctrl-L shortcut to focus the url navigator ala 
firefox/konqueror/etc. I found myself trying to press ctrl-l there (certainly 
a habit developed by using browsers) 100 times or more :)

Any objections, comments?


["improved_file_dialog_keyboard_navigation.patch" (text/x-patch)]

Index: kfile/kfilewidget.cpp
===================================================================
--- kfile/kfilewidget.cpp	(revision 837027)
+++ kfile/kfilewidget.cpp	(working copy)
@@ -145,6 +145,7 @@
     void _k_toggleBookmarks( bool );
     void _k_slotAutoSelectExtClicked();
     void _k_placesViewSplitterMoved();
+    void _k_activateUrlNavigator();
 
     void addToRecentDocuments();
 
@@ -380,6 +381,9 @@
     d->toolbar->addAction( coll->action( "mkdir" ) );
     coll->action( "mkdir" )->setWhatsThis(i18n("Click this button to create a new \
folder."));  
+    KAction *goToNavigatorAction = coll->addAction( "gotonavigator", this, SLOT( \
_k_activateUrlNavigator() ) ); +    goToNavigatorAction->setShortcut( \
QKeySequence(Qt::CTRL + Qt::Key_L) ); +
     KToggleAction *showSidebarAction =
         new KToggleAction(i18n("Show Places Navigation Panel"), this);
     coll->addAction("toggleSpeedbar", showSidebarAction);
@@ -435,6 +439,8 @@
 
     connect( d->urlNavigator, SIGNAL( urlChanged( const KUrl&  )),
              this,  SLOT( _k_enterUrl( const KUrl& ) ));
+    connect( d->urlNavigator, SIGNAL( returnPressed() ),
+             d->ops,  SLOT( setFocus() ));
 
     QString whatsThisText;
 
@@ -1336,6 +1342,8 @@
     // tokenize() expects it because uses KUrl::setFileName()
     fixedUrl.adjustPath( KUrl::AddTrailingSlash );
     q->setUrl( fixedUrl );
+    if (!locationEdit->hasFocus())
+        ops->setFocus();
 }
 
 void KFileWidgetPrivate::_k_enterUrl( const QString& url )
@@ -1787,6 +1795,13 @@
     speedBarWidth = sizes[0];
 }
 
+void KFileWidgetPrivate::_k_activateUrlNavigator()
+{
+    urlNavigator->setUrlEditable(true);
+    urlNavigator->setFocus();
+    urlNavigator->editor()->lineEdit()->selectAll();
+}
+
 static QString getExtensionFromPatternList(const QStringList &patternList)
 {
     QString ret;
Index: kfile/kfilewidget.h
===================================================================
--- kfile/kfilewidget.h	(revision 837027)
+++ kfile/kfilewidget.h	(working copy)
@@ -462,6 +462,7 @@
     Q_PRIVATE_SLOT( d, void _k_toggleBookmarks( bool ) )
     Q_PRIVATE_SLOT( d, void _k_slotAutoSelectExtClicked() )
     Q_PRIVATE_SLOT( d, void _k_placesViewSplitterMoved() )
+    Q_PRIVATE_SLOT( d, void _k_activateUrlNavigator() )
 };
 
 #endif /* KABSTRACTFILEWIDGET_H */



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

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