Summary: | search text in lyrics | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Carles Pina i Estany <carles> |
Component: | general | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch implementing the wishlist |
Description
Carles Pina i Estany
2006-12-25 17:34:15 UTC
Created attachment 19031 [details]
Patch implementing the wishlist
-If there is any problem with the code of patch, tell me: I will try to fix
-Patch adds support for Ctrl+/ in contextbrowser, opening a new KLineEdit (if I
remember correctly :-D), Esc to close it, etc.
I would like the shortcut to be "/" as is in Konqueror, Firefox, less, vi, etc... Ljubomir: sorry, I wrote Ctrl+/ but is "/" like in Konqueror, Firefox etc. My mistake, the current patch is already "/" :-) (I made it some days ago and I messed up with other things...) It's actually Shift+/ in the patch SVN commit 616534 by aoliveira: Search inside of lyrics, by using "/" on Context Browser. Patch by Carles Pina i Estany <carles@pina.cat>. I only changed the shortcut from Shift+/ to only /. BUG: 139210 M +6 -4 ChangeLog M +97 -1 src/contextbrowser.cpp M +12 -0 src/contextbrowser.h --- trunk/extragear/multimedia/amarok/ChangeLog #616533:616534 @@ -5,6 +5,8 @@ VERSION 1.4.5 FEATURES: + * Search inside of lyrics, by using "/" on Context Browser. Patch by + Carles Pina i Estany <carles@pina.cat>. (BR 139210) * "Automatically show context browser" feature makes a return, as per popular request. It is however disabled by default. * Improved keyboard navigation: Space key is now a shortcut for Play/Pause, @@ -15,7 +17,7 @@ * Elapsed time can be shown in OSD. Patch by Christian Engels <s9chenge@stud.uni-sb.de>. (BR 120051) * New redownload manager for the Magnatune.com store. Allows re-download - of any previous purchase free of charge (in any format). + of any previous purchase free of charge (in any format). * Star ratings now have different colors for different ratings, to easily identify songs with a particular rating. Thanks to Tristan Olive for the idea. @@ -43,8 +45,8 @@ * Save media device transfer queue when adding items or after transfers. (BR 138885) * Upgraded internal SQLite to 3.3.8. - * MTP media devices are not automatically connected on start-up. This - should solve slow loading times for those with large collections on an + * MTP media devices are not automatically connected on start-up. This + should solve slow loading times for those with large collections on an MTP media device. Contributed by Mikko Seppälä. (BR 138409) * Internationalize unknown artist/album/genre strings. Contributed by Mikko Seppälä. (BR 138409) @@ -61,7 +63,7 @@ * Consistent double-click behavior in sidebar. (BR 138125) * Propose name of currently loaded playlist when saving current one. * Remove support for older libmtp versions. We now require 0.0.15 or - newer. + newer. * Deleting a playlist item on an MTP media device now results in it being removed from the playlist. * Magnatune store is lazy loaded to improve startup times. --- trunk/extragear/multimedia/amarok/src/contextbrowser.cpp #616533:616534 @@ -50,6 +50,7 @@ #include <qtimer.h> #include <qtooltip.h> +#include <kaction.h> #include <kapplication.h> //kapp #include <kcalendarsystem.h> // for Amarok::verboseTimeSince() #include <kconfig.h> // suggested/related/favorite box visibility @@ -223,6 +224,44 @@ m_lyricsToolBar->setIconText( KToolBar::IconOnly, false ); m_lyricsToolBar->insertButton( Amarok::icon( "external" ), LYRICS_BROWSER, true, i18n("Open in external browser") ); + { //Search text inside lyrics. Code inspired/copied from playlistwindow.cpp + m_lyricsTextBar = new KToolBar( m_lyricsTab, "NotMainToolBar" ); + m_lyricsTextBar->hide(); + m_lyricsTextBarShowed=false; + + m_lyricsTextBar->setIconSize( 22, false ); //looks more sensible + m_lyricsTextBar->setFlat( true ); //removes the ugly frame + m_lyricsTextBar->setMovingEnabled( false ); //removes the ugly frame + + m_lyricsTextBar->boxLayout()->addStretch(); + + QWidget *button = new KToolBarButton( "locationbar_erase", 1, m_lyricsTextBar ); + QLabel *filter_label = new QLabel( i18n("S&earch:") + ' ', m_lyricsTextBar ); + m_lyricsSearchText = new ClickLineEdit( i18n( "Search text in lyric" ), m_lyricsTextBar ); + filter_label->setBuddy( m_lyricsSearchText ); + + m_lyricsTextBar->setStretchableWidget(m_lyricsSearchText ); + + m_lyricsSearchText->setFrame( QFrame::Sunken ); + m_lyricsSearchText->installEventFilter( this ); //we intercept keyEvents + + connect( button, SIGNAL(clicked()), m_lyricsSearchText, SLOT(clear()) ); + + QToolTip::add( button, i18n( "Clear search text in lyric" ) ); + QString filtertip = i18n( "Write to search this word in lyric, from the begin. Press enter to search next match" ); + + QToolTip::add( m_lyricsSearchText, filtertip ); + + connect ( button, SIGNAL(clicked()), m_lyricsSearchText, SLOT(clear()) ); + connect ( m_lyricsSearchText, SIGNAL(textChanged(const QString &)), this, SLOT(lyricsSearchText(const QString & )) ); + connect ( m_lyricsSearchText, SIGNAL(returnPressed()), this, (SLOT(lyricsSearchTextNext())) ); + Amarok::actionCollection()->setAutoConnectShortcuts ( true ); + new KAction( i18n("Search text in lyric"), KShortcut("/"), this,SLOT( lyricsSearchTextShow() ), Amarok::actionCollection(), "search_text_lyric"); + Amarok::actionCollection()->setAutoConnectShortcuts ( false ); + } + + + m_lyricsPage = new HTMLView( m_lyricsTab, "lyrics_page", true /* DNDEnabled */, false /* No JScript */ ); m_lyricsTextEdit = new KTextEdit ( m_lyricsTab, "lyrics_text_edit"); m_lyricsTextEdit->setTextFormat( Qt::PlainText ); @@ -3362,8 +3401,52 @@ showLyrics( "reload" ); } +void +ContextBrowser::lyricsSearchText(QString const &text) //SLOT +{ + m_lyricsPage->findText( text, 0 ); + lyricsSearchTextNext(); +} -////////////////////////////////////////////////////////////////////////////////////////// +void +ContextBrowser::lyricsSearchTextNext() //SLOT +{ + m_lyricsPage->findTextNext(); +} + +void +ContextBrowser::lyricsSearchTextShow() //SLOT +{ + m_lyricsSearchText->setEnabled( true ); + m_lyricsTextBar->show(); + m_lyricsTextBarShowed = true; + m_lyricsSearchText->setFocus(); +} + + +void +ContextBrowser::lyricsSearchTextHide() //SLOT +{ + m_lyricsSearchText->setText(""); + m_lyricsSearchText->setEnabled( false ); + m_lyricsTextBar->hide(); + m_lyricsTextBarShowed=false; +} + + +void +ContextBrowser::lyricsSearchTextToggle() //SLOT +{ + if ( m_lyricsTextBarShowed ) + { + lyricsSearchTextHide(); + } + else + { + lyricsSearchTextShow(); + } +} + // Wikipedia-Tab ////////////////////////////////////////////////////////////////////////////////////////// @@ -3615,6 +3698,19 @@ return false; } } + if (o == m_lyricsSearchText) + { + switch ( e->key() ) + { + case Key_Escape: + { + lyricsSearchTextHide(); + return true; + } + default: + return false; + } + } default: break; --- trunk/extragear/multimedia/amarok/src/contextbrowser.h #616533:616534 @@ -13,8 +13,10 @@ #include "engineobserver.h" #include <ktabwidget.h> +#include <ktoolbarbutton.h> #include <kurl.h> +class ClickLineEdit; class CollectionDB; class Color; class HTMLView; @@ -101,6 +103,12 @@ void lyricsRefresh(); void lyricsExternalPage(); + void lyricsSearchText( const QString &text ); + void lyricsSearchTextNext(); + void lyricsSearchTextHide(); + void lyricsSearchTextShow(); + void lyricsSearchTextToggle(); + void wikiHistoryBack(); void wikiHistoryForward(); void wikiBackPopupActivated( int id ); @@ -159,7 +167,11 @@ QString m_lyricsBeingEditedUrl; QString m_lyricsBeingEditedArtist; QString m_lyricsBeingEditedTitle; + ClickLineEdit* m_lyricsSearchText; + KToolBar* m_lyricsTextBar; + bool m_lyricsTextBarShowed; + QString m_wiki; QString m_wikiLanguages; static QString s_wikiLocale; |