summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Stolarek <jan.stolarek@mailbox.org>2025-11-19 19:58:39 +0100
committerJan Stolarek <jan.stolarek@mailbox.org>2025-11-20 17:48:13 +0100
commitb67572713249a327d689ace6f2a8a0c292125ede (patch)
tree44cf74097ad4509be1266a862d4f8d48bf7ccb3d
parent95476f0fb7b21e2157db0cbfded39e113e8a33da (diff)
downloadamarok-jstolarek-T95-search-engine-selection.tar.gz
amarok-jstolarek-T95-search-engine-selection.zip
Allow selecting search engine used for lyrics searchjstolarek-T95-search-engine-selection
Users can now select one of predefined search engines (Google, DuckDuckGo, Kagi, Bing, Qwant, Ecosia, Brave). At the moment this selection affects only the lyrics search in external browser. Fixes #95
-rw-r--r--amarok/src/Options1.ui60
-rw-r--r--amarok/src/Options1.ui.h13
-rw-r--r--amarok/src/amarokcore/amarok.kcfg4
-rw-r--r--amarok/src/configdialog.cpp7
-rw-r--r--amarok/src/contextbrowser.cpp23
5 files changed, 106 insertions, 1 deletions
diff --git a/amarok/src/Options1.ui b/amarok/src/Options1.ui
index 10443a4e..6104159c 100644
--- a/amarok/src/Options1.ui
+++ b/amarok/src/Options1.ui
@@ -332,6 +332,66 @@
</spacer>
</hbox>
</widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Search engine:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>searchEngineComboBox</cstring>
+ </property>
+ </widget>
+ <widget class="KComboBox">
+ <property name="name">
+ <cstring>searchEngineComboBox</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Choose web search engine to be used by Amarok.</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>150</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
</vbox>
</widget>
<widget class="TQGroupBox">
diff --git a/amarok/src/Options1.ui.h b/amarok/src/Options1.ui.h
index 5adf414e..6ff162ff 100644
--- a/amarok/src/Options1.ui.h
+++ b/amarok/src/Options1.ui.h
@@ -64,6 +64,19 @@ void Options1::init()
{
checkBox_customBrowser->setChecked( true );
}
+
+ TQStringList search_engines;
+ search_engines << "Google" << "DuckDuckGo" << "Kagi" << "Bing" << "Qwant"
+ << "Ecosia" << "Brave";
+
+ searchEngineComboBox->insertStringList( search_engines );
+ index = search_engines.findIndex( AmarokConfig::searchEngine() );
+ if( index >= 0 ) {
+ searchEngineComboBox->setCurrentItem( index );
+ } else {
+ // Revert to default if search engine unrecognised
+ searchEngineComboBox->setCurrentItem( 0 );
+ }
}
void Options1::slotUpdateMoodFrame()
diff --git a/amarok/src/amarokcore/amarok.kcfg b/amarok/src/amarokcore/amarok.kcfg
index fe343414..28c2183b 100644
--- a/amarok/src/amarokcore/amarok.kcfg
+++ b/amarok/src/amarokcore/amarok.kcfg
@@ -295,6 +295,10 @@
<label>Filename of the external web browser to be invoked by Amarok.</label>
<default>kfmclient openURL</default>
</entry>
+ <entry key="Search Engine" type="String">
+ <label>Web search engine to be used by Amarok.</label>
+ <default>Google</default>
+ </entry>
<entry key="Use Custom Icon Theme" type="Bool">
<label>Whether Amarok's custom icon theme or the system icon theme is used.</label>
<default>true</default>
diff --git a/amarok/src/configdialog.cpp b/amarok/src/configdialog.cpp
index 5286518a..d4c1b5df 100644
--- a/amarok/src/configdialog.cpp
+++ b/amarok/src/configdialog.cpp
@@ -205,6 +205,7 @@ AmarokConfigDialog::AmarokConfigDialog( TQWidget *parent, const char* name, TDEC
connect( m_opt2->styleComboBox, TQ_SIGNAL( activated( int ) ), TQ_SLOT( updateButtons() ) );
connect( m_opt7->dbSetupFrame->databaseEngine, TQ_SIGNAL( activated( int ) ), TQ_SLOT( updateButtons() ) );
connect( m_opt1->kComboBox_browser, TQ_SIGNAL( activated( int ) ), TQ_SLOT( updateButtons() ) );
+ connect( m_opt1->searchEngineComboBox, TQ_SIGNAL( activated( int ) ), TQ_SLOT( updateButtons() ) );
connect( m_opt1->kLineEdit_customBrowser, TQ_SIGNAL( textChanged( const TQString& ) ), TQ_SLOT( updateButtons() ) );
}
@@ -282,6 +283,11 @@ void AmarokConfigDialog::updateSettings()
soundSystemChanged();
}
+ if ( m_opt1->searchEngineComboBox->currentText() != AmarokConfig::searchEngine() ) {
+ AmarokConfig::setSearchEngine( m_opt1->searchEngineComboBox->currentText() );
+ emit settingsChanged();
+ }
+
if ( m_opt2->styleComboBox->currentText() != AmarokConfig::contextBrowserStyleSheet() ) {
//can't use tdeconfigxt for the style comboxbox's since we need the string, not the index
AmarokConfig::setContextBrowserStyleSheet( m_opt2->styleComboBox->currentText() );
@@ -360,6 +366,7 @@ bool AmarokConfigDialog::hasChanged()
osd->alignment() != AmarokConfig::osdAlignment() ||
osd->alignment() != OSDWidget::Center && osd->y() != AmarokConfig::osdYOffset() ||
#endif
+ m_opt1->searchEngineComboBox->currentText() != AmarokConfig::searchEngine() ||
m_opt2->styleComboBox->currentText() != AmarokConfig::contextBrowserStyleSheet() ||
Amarok::databaseTypeCode( m_opt7->dbSetupFrame->databaseEngine->currentText() ) != AmarokConfig::databaseEngine().toInt() ||
m_engineConfig && m_engineConfig->hasChanged() ||
diff --git a/amarok/src/contextbrowser.cpp b/amarok/src/contextbrowser.cpp
index b1def4a1..6cb740e4 100644
--- a/amarok/src/contextbrowser.cpp
+++ b/amarok/src/contextbrowser.cpp
@@ -3281,7 +3281,28 @@ void ContextBrowser::showLyrics( const TQString &url )
}
}
- m_lyricSearchUrl = TQString( "http://www.google.com/search?ie=UTF-8&q=lyrics+%1+%2" )
+ // Construct lyrics search URL based on user selected search engine
+ TQString searchEngineUrl;
+ TQString searchEngine = AmarokConfig::searchEngine();
+
+ if ( searchEngine == "Kagi" ) {
+ searchEngineUrl = TQString( "https://kagi.com/search?q=lyrics+%1+%2" );
+ } else if ( searchEngine == "DuckDuckGo" ) {
+ searchEngineUrl = TQString( "https://duckduckgo.com/?q=lyrics+%1+%2" );
+ } else if ( searchEngine == "Bing" ) {
+ searchEngineUrl = TQString( "https://www.bing.com/search?q=lyrics+%1+%2" );
+ } else if ( searchEngine == "Qwant" ) {
+ searchEngineUrl = TQString( "https://www.qwant.com/?q=lyrics+%1+%2" );
+ } else if ( searchEngine == "Ecosia" ) {
+ searchEngineUrl = TQString( "https://www.ecosia.org/search?q=lyrics+%1+%2" );
+ } else if ( searchEngine == "Brave" ) {
+ searchEngineUrl = TQString( "https://search.brave.com/search?q=lyrics+%1+%2" );
+ } else {
+ // default to Google
+ searchEngineUrl = TQString( "https://www.google.com/search?ie=UTF-8&q=lyrics+%1+%2" );
+ }
+
+ m_lyricSearchUrl = searchEngineUrl
.arg( KURL::encode_string_no_slash( '"' + artist + '"', 106 /*utf-8*/ ),
KURL::encode_string_no_slash( '"' + title + '"', 106 /*utf-8*/ ) );