search text inside lyric

Carles Pina i Estany carles at pina.cat
Sat Nov 11 10:53:34 UTC 2006


Hello,

Some days ago I sent wishlist and question/patch, see here:
http://mail.kde.org/pipermail/amarok/2006-November/001881.html

Nobody said anything (maybe this feature is not interesting? I think
that this is interesting for non-English people who wants to practise
English listening songs...)

I send now a better patch, using Amarok typical user interface (other
one was too crappy, I know).

This version adds in lyrics tab a field search (like playlistwindow
search option). It allows to do something like incremental search, plus
jump to next matches using "enter" button. 

I have used new Amarok sources, so patch should apply without problems.

I am thinking to change the lyrics toolbar from QVLayout to QLayout to
have two lines (now it is needed to resize lyrics tab to see the search
field, but otherwise is fine because is not a common option; who
need/wants to use it only needs to resize a little bit...).

Any feedback is welcomed.

-- 
Carles Pina i Estany		GPG id: 0x8CBDAE64
	http://pinux.info	Manresa - Barcelona
-------------- next part --------------
Index: src/contextbrowser.h
===================================================================
--- src/contextbrowser.h	(revision 604031)
+++ src/contextbrowser.h	(working copy)
@@ -28,6 +28,7 @@
 class KTextEdit;
 
 class CueFile;
+class ClickLineEdit;
 
 namespace Browser { class ToolBar; }
 namespace KIO { class Job; class TransferJob; }
@@ -95,6 +96,8 @@
         void lyricsSearch();
         void lyricsRefresh();
         void lyricsExternalPage();
+	void lyricsSearchText(const QString &text);
+	void lyricsSearchTextNext();
 
         void wikiHistoryBack();
         void wikiHistoryForward();
@@ -151,6 +154,7 @@
         QString       m_lyricsBeingEditedUrl;
         QString       m_lyricsBeingEditedArtist;
         QString       m_lyricsBeingEditedTitle;
+	ClickLineEdit *m_lineEdit;
 
         QString       m_wiki;
         QString       m_wikiLanguages;
Index: src/contextbrowser.cpp
===================================================================
--- src/contextbrowser.cpp	(revision 604031)
+++ src/contextbrowser.cpp	(working copy)
@@ -13,6 +13,7 @@
 #include "app.h"
 #include "browserToolBar.h"
 #include "debug.h"
+#include "clicklineedit.h"
 #include "collectiondb.h"
 #include "collectionbrowser.h"
 #include "colorgenerator.h"
@@ -214,6 +215,14 @@
     m_lyricsToolBar->insertButton( Amarok::icon( "search" ), LYRICS_SEARCH, true, i18n("Search") );
     m_lyricsToolBar->setIconText( KToolBar::IconOnly, false );
     m_lyricsToolBar->insertButton( Amarok::icon( "external" ), LYRICS_BROWSER, true, i18n("Open in external browser") );
+   
+    //Search text inside lyrics
+    m_lineEdit = new ClickLineEdit (i18n ("Search text in lyrics"),m_lyricsToolBar);
+    m_lyricsToolBar->setStretchableWidget(m_lineEdit);
+    m_lineEdit->installEventFilter( this );
+    connect (m_lineEdit,SIGNAL(textChanged(const QString &)), this, SLOT(lyricsSearchText(const QString & )));
+    connect (m_lineEdit,SIGNAL(returnPressed()),this,(SLOT(lyricsSearchTextNext())));
+    //End Search text
 
     m_lyricsPage = new HTMLView( m_lyricsTab, "lyrics_page", true /* DNDEnabled */, false /* No JScript */ );
     m_lyricsTextEdit = new KTextEdit ( m_lyricsTab, "lyrics_text_edit");
@@ -3153,7 +3162,22 @@
     showLyrics( "reload" );
 }
 
+void
+ContextBrowser::lyricsSearchText(QString const &text) //SLOT
+{
+    m_lyricsPage->findText(text,0);
+    lyricsSearchTextNext();
+}
 
+void
+ContextBrowser::lyricsSearchTextNext() //SLOT
+{
+    m_lyricsPage->findTextNext();
+}
+
+
+
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // Wikipedia-Tab
 //////////////////////////////////////////////////////////////////////////////////////////


More information about the Amarok mailing list