search text inside lyric

Carles Pina i Estany carles at pina.cat
Sat Nov 11 14:13:56 UTC 2006


Hi again,

On Nov/11/2006, Carles Pina i Estany wrote:
> 
> Hi,
> 
> On Nov/11/2006, Carles Pina i Estany wrote:
> 
> > 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
> 
> Actually I am adding something even better, so if you wait some hours I
> will send new patch (lunch time now)

As I promised, I send attached the new patch and also a screenshot. 

(some menus are in catalan, sorry)

I will add a shortcut, so search field gets the focus. Maybe now or
maybe tomorrow.

I can do that this feature is hidden, until user press Ctrl+F or Ctrl+/,
or click in some menu. I don't think that this is needed.

Thanks,

-- 
Carles Pina i Estany		GPG id: 0x8CBDAE64
	http://pinux.info	Manresa - Barcelona
-------------- next part --------------
A non-text attachment was scrubbed...
Name: search-text1.png
Type: image/png
Size: 79944 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/amarok/attachments/20061111/8750b168/attachment.png>
-------------- 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_lyricsSearchText;
 
         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,7 +215,39 @@
     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. Code inspired/copied from playlistwindow.cpp
+        KToolBar *bar = new KToolBar( m_lyricsTab, "NotMainToolBar" );
 
+        bar->setIconSize( 22, false ); //looks more sensible
+        bar->setFlat( true ); //removes the ugly frame
+        bar->setMovingEnabled( false ); //removes the ugly frame
+
+	bar->boxLayout()->addStretch();
+        
+	QWidget *button = new KToolBarButton( "locationbar_erase", 1, bar );
+        QLabel *filter_label = new QLabel( i18n("S&earch:") + ' ', bar );
+        m_lyricsSearchText = new ClickLineEdit( i18n( "Search text in lyric" ), bar );
+        filter_label->setBuddy( m_lyricsSearchText );
+
+        bar->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())) );
+    } 
+
     m_lyricsPage = new HTMLView( m_lyricsTab, "lyrics_page", true /* DNDEnabled */, false /* No JScript */ );
     m_lyricsTextEdit = new KTextEdit ( m_lyricsTab, "lyrics_text_edit");
     m_lyricsTextEdit->hide();
@@ -3153,7 +3186,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