search text inside lyric
Carles Pina i Estany
carles at pina.cat
Sat Nov 11 22:27:26 UTC 2006
Hello,
On Nov/11/2006, Ljubomir Simin wrote:
> > However, as Carles said, for non-English speakers especially, it could be
> > useful. So I'm leaning towards saying that we should include this, but
> > only if the user activates it via Ctrl-F (which isn't too unintuitive, as
> > it behaves like searching for most other apps).
> >
> > --Jeff
> >
>
> I agree with the idea of search being hidden by default. However I would like
> to suggest slash ("/") as shortcut. It is default shortcut for incremental
> search in both Firefox and Konqueror (an possibly many other apps), and I
> tried it without thinking many times so far in lyrics browser. Maybe a
> combination of both Ctrl+F and / (like in Firefox) should be used?
I send attached last version of searchLyrics patch.
This version:
a) it starts with search in lyric option (edit field) hidden. So, there
is no changes if user doesn't want :-)
b) when user press "/" in any place of Amarok, it will be shown (but I
don't change context browser menu, so if user is not in lyrics tab,
apparently nothing will happen -I am not sure if this is a correct
behaviour, maybe I should show contextbrowser, lyrics-tab when user
press "/")
c) there is no way to hide the new edit field (I don't think that is
needed, but I can do it -just tell me which is the best user interface
way to do it)
d) if user press again "/", edit field gets the focus (very useful,
IMHO)
Thanks for the previous comments.
Of course, I accept new feedback :-)
PS: i also attach the previous .png image, as it is the same and can help to
think the UI way to hide the edit field, if it is needed
--
Carles Pina i Estany GPG id: 0x8CBDAE64
http://pinux.info Manresa - Barcelona
-------------- next part --------------
Index: src/app.h
===================================================================
--- src/app.h (revision 604031)
+++ src/app.h (working copy)
@@ -79,7 +79,6 @@
void setRating5() { setRating( 5 ); }
void continueInit();
-
public slots:
void applySettings( bool firstTime = false );
void slotConfigAmarok( const QCString& page = QCString() );
Index: src/app.cpp
===================================================================
--- src/app.cpp (revision 604031)
+++ src/app.cpp (working copy)
@@ -400,6 +400,10 @@
m_pGlobalAccel->insert( "rating5", i18n( "Rate Current Track: 5" ), 0, KKey("WIN+5"), 0,
this, SLOT( setRating5() ), true, true );
+
+ m_pGlobalAccel->insert( "lyricSearchText", i18n( "Search text in current lyric" ), 0, KKey("/"), 0,
+ ContextBrowser::instance(), SLOT( lyricsSearchTextShow() ), true, true );
+
m_pGlobalAccel->setConfigGroup( "Shortcuts" );
m_pGlobalAccel->readSettings( kapp->config() );
m_pGlobalAccel->updateConnections();
@@ -492,7 +496,6 @@
KMessageBox::information( 0, text, i18n( "Warning" ), "showHyperThreadingWarning" );
}
-
/////////////////////////////////////////////////////////////////////////////////////
// METHODS
/////////////////////////////////////////////////////////////////////////////////////
Index: src/contextbrowser.h
===================================================================
--- src/contextbrowser.h (revision 604031)
+++ src/contextbrowser.h (working copy)
@@ -12,6 +12,7 @@
#include "engineobserver.h"
#include <ktabwidget.h>
+#include <ktoolbarbutton.h>
#include <kurl.h>
class CollectionDB;
@@ -28,6 +29,7 @@
class KTextEdit;
class CueFile;
+class ClickLineEdit;
namespace Browser { class ToolBar; }
namespace KIO { class Job; class TransferJob; }
@@ -95,6 +97,9 @@
void lyricsSearch();
void lyricsRefresh();
void lyricsExternalPage();
+ void lyricsSearchText(const QString &text);
+ void lyricsSearchTextNext();
+ void lyricsSearchTextShow();
void wikiHistoryBack();
void wikiHistoryForward();
@@ -151,6 +156,8 @@
QString m_lyricsBeingEditedUrl;
QString m_lyricsBeingEditedArtist;
QString m_lyricsBeingEditedTitle;
+ ClickLineEdit * m_lyricsSearchText;
+ KToolBar * m_lyricsBar;
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
+ m_lyricsBar = new KToolBar( m_lyricsTab, "NotMainToolBar" );
+ m_lyricsBar->hide();
+ m_lyricsBar->setIconSize( 22, false ); //looks more sensible
+ m_lyricsBar->setFlat( true ); //removes the ugly frame
+ m_lyricsBar->setMovingEnabled( false ); //removes the ugly frame
+
+ m_lyricsBar->boxLayout()->addStretch();
+
+ QWidget *button = new KToolBarButton( "locationbar_erase", 1, m_lyricsBar );
+ QLabel *filter_label = new QLabel( i18n("S&earch:") + ' ', m_lyricsBar );
+ m_lyricsSearchText = new ClickLineEdit( i18n( "Search text in lyric" ), m_lyricsBar );
+ filter_label->setBuddy( m_lyricsSearchText );
+
+ m_lyricsBar->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,27 @@
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_lyricsBar->show();
+ m_lyricsSearchText->setFocus();
+}
+
+
//////////////////////////////////////////////////////////////////////////////////////////
// Wikipedia-Tab
//////////////////////////////////////////////////////////////////////////////////////////
-------------- 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/20061112/59a79cb3/attachment.png>
More information about the Amarok
mailing list