From kde-core-devel Wed Jul 23 22:37:13 2008 From: Alexander Dymo Date: Wed, 23 Jul 2008 22:37:13 +0000 To: kde-core-devel Subject: [PATCH] improved keyboard navigation for KFileDialog Message-Id: <200807240137.14136.dymo () ukrpost ! ua> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=121685262124558 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_aK7hI/5N46+AnB4" --Boundary-00=_aK7hI/5N46+AnB4 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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? --Boundary-00=_aK7hI/5N46+AnB4 Content-Type: text/x-patch; charset="us-ascii"; name="improved_file_dialog_keyboard_navigation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="improved_file_dialog_keyboard_navigation.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 */ --Boundary-00=_aK7hI/5N46+AnB4--