diff options
Diffstat (limited to 'konq-plugins/searchbar')
-rw-r--r-- | konq-plugins/searchbar/Makefile.am | 21 | ||||
-rw-r--r-- | konq-plugins/searchbar/icons/Makefile.am | 3 | ||||
-rw-r--r-- | konq-plugins/searchbar/icons/cr16-action-google.png | bin | 0 -> 820 bytes | |||
-rw-r--r-- | konq-plugins/searchbar/searchbar.cpp | 556 | ||||
-rw-r--r-- | konq-plugins/searchbar/searchbar.desktop | 121 | ||||
-rw-r--r-- | konq-plugins/searchbar/searchbar.h | 168 | ||||
-rw-r--r-- | konq-plugins/searchbar/searchbar.lsm | 13 | ||||
-rw-r--r-- | konq-plugins/searchbar/searchbar.rc | 6 |
8 files changed, 888 insertions, 0 deletions
diff --git a/konq-plugins/searchbar/Makefile.am b/konq-plugins/searchbar/Makefile.am new file mode 100644 index 0000000..3a4c1b5 --- /dev/null +++ b/konq-plugins/searchbar/Makefile.am @@ -0,0 +1,21 @@ +SUBDIRS = icons + +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = libsearchbarplugin.la + +libsearchbarplugin_la_SOURCES = searchbar.cpp +libsearchbarplugin_la_LIBADD = $(LIB_KHTML) +libsearchbarplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +pluginsdir = $(kde_datadir)/konqueror/kpartplugins +plugins_DATA = searchbar.rc searchbar.desktop + +install-data-local: $(srcdir)/../uninstall.desktop + $(mkinstalldirs) $(DESTDIR)$(pluginsdir) + $(INSTALL_DATA) $(srcdir)/../uninstall.desktop $(DESTDIR)$(pluginsdir)/searchbarplugin.desktop + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/searchbarplugin.pot diff --git a/konq-plugins/searchbar/icons/Makefile.am b/konq-plugins/searchbar/icons/Makefile.am new file mode 100644 index 0000000..131e26a --- /dev/null +++ b/konq-plugins/searchbar/icons/Makefile.am @@ -0,0 +1,3 @@ +searchbariconsdir = $(kde_datadir)/konqueror/icons +searchbaricons_ICON = AUTO + diff --git a/konq-plugins/searchbar/icons/cr16-action-google.png b/konq-plugins/searchbar/icons/cr16-action-google.png Binary files differnew file mode 100644 index 0000000..03ae14a --- /dev/null +++ b/konq-plugins/searchbar/icons/cr16-action-google.png diff --git a/konq-plugins/searchbar/searchbar.cpp b/konq-plugins/searchbar/searchbar.cpp new file mode 100644 index 0000000..51f5455 --- /dev/null +++ b/konq-plugins/searchbar/searchbar.cpp @@ -0,0 +1,556 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Arend van Beelen jr. <arend@auton.nl> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <unistd.h> + +#include <dcopclient.h> +#include <kapplication.h> +#include <kaction.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdesktopfile.h> +#include <kgenericfactory.h> +#include <kglobal.h> +#include <khtml_part.h> +#include <kiconloader.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmimetype.h> +#include <kprocess.h> +#include <kprotocolmanager.h> +#include <kstandarddirs.h> +#include <kurifilter.h> + +#include <kparts/mainwindow.h> +#include <kparts/partmanager.h> + +#include <qpainter.h> +#include <qpopupmenu.h> +#include <qtimer.h> +#include <qstyle.h> +#include <qwhatsthis.h> +#include "searchbar.h" + +typedef KGenericFactory<SearchBarPlugin> SearchBarPluginFactory; +K_EXPORT_COMPONENT_FACTORY(libsearchbarplugin, + SearchBarPluginFactory("searchbarplugin")) + + +SearchBarPlugin::SearchBarPlugin(QObject *parent, const char *name, + const QStringList &) : + KParts::Plugin(parent, name), + m_searchCombo(0), + m_searchMode(UseSearchProvider), + m_urlEnterLock(false) +{ + m_searchCombo = new SearchBarCombo(0L, "search combo"); + m_searchCombo->setDuplicatesEnabled(false); + m_searchCombo->setMaxCount(5); + m_searchCombo->setFixedWidth(180); + m_searchCombo->setLineEdit(new KLineEdit(m_searchCombo)); + m_searchCombo->lineEdit()->installEventFilter(this); + + m_popupMenu = 0; + + m_searchComboAction = new KWidgetAction(m_searchCombo, i18n("Search Bar"), 0, + 0, 0, actionCollection(), "toolbar_search_bar"); + m_searchComboAction->setShortcutConfigurable(false); + + connect(m_searchCombo, SIGNAL(activated(const QString &)), + SLOT(startSearch(const QString &))); + connect(m_searchCombo, SIGNAL(iconClicked()), SLOT(showSelectionMenu())); + + QWhatsThis::add(m_searchCombo, i18n("Search Bar<p>" + "Enter a search term. Click on the icon to change search mode or provider.")); + + new KAction( i18n( "Focus Searchbar" ), CTRL+Key_S, + this, SLOT(focusSearchbar()), + actionCollection(), "focus_search_bar"); + + configurationChanged(); + + KParts::MainWindow *mainWin = static_cast<KParts::MainWindow*>(parent); + + //Grab the part manager. Don't know of any other way, and neither does Tronical, so.. + KParts::PartManager *partMan = static_cast<KParts::PartManager*>(mainWin->child(0, "KParts::PartManager")); + if (partMan) + { + connect(partMan, SIGNAL(activePartChanged(KParts::Part*)), + SLOT (partChanged (KParts::Part*))); + partChanged(partMan->activePart()); + } +} + +SearchBarPlugin::~SearchBarPlugin() +{ + KConfig *config = kapp->config(); + config->setGroup("SearchBar"); + config->writeEntry("Mode", (int) m_searchMode); + config->writeEntry("CurrentEngine", m_currentEngine); + + delete m_searchCombo; + m_searchCombo = 0L; +} + +QChar delimiter() +{ + KConfig config( "kuriikwsfilterrc", true, false ); + config.setGroup( "General" ); + return config.readNumEntry( "KeywordDelimiter", ':' ); +} + +bool SearchBarPlugin::eventFilter(QObject *o, QEvent *e) +{ + if( o==m_searchCombo->lineEdit() && e->type() == QEvent::KeyPress ) + { + QKeyEvent *k = (QKeyEvent *)e; + if(k->state() & ControlButton) + { + if(k->key()==Key_Down) + { + nextSearchEntry(); + return true; + } + if(k->key()==Key_Up) + { + previousSearchEntry(); + return true; + } + } + } + return false; +} + +void SearchBarPlugin::nextSearchEntry() +{ + if(m_searchMode == FindInThisPage) + { + m_searchMode = UseSearchProvider; + if(m_searchEngines.count()) + { + m_currentEngine = *m_searchEngines.at(0); + } + else + { + m_currentEngine = "google"; + } + } + else + { + QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine); + it++; + if(it==m_searchEngines.end()) + { + m_searchMode = FindInThisPage; + } + else + { + m_currentEngine = *it; + } + } + setIcon(); +} + +void SearchBarPlugin::previousSearchEntry() +{ + if(m_searchMode == FindInThisPage) + { + m_searchMode = UseSearchProvider; + if(m_searchEngines.count()) + { + m_currentEngine = *m_searchEngines.fromLast(); + } + else + { + m_currentEngine = "google"; + } + } + else + { + QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine); + if(it==m_searchEngines.begin()) + { + m_searchMode = FindInThisPage; + } + else + { + it--; + m_currentEngine = *it; + } + } + setIcon(); +} + +void SearchBarPlugin::startSearch(const QString &search) +{ + if(m_urlEnterLock || search.isEmpty() || !m_part) + return; + + if(m_searchMode == FindInThisPage) + { + m_part->findText(search, 0); + m_part->findTextNext(); + } + else if(m_searchMode == UseSearchProvider) + { + m_urlEnterLock = true; + KService::Ptr service; + KURIFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); + if (service) { + const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter(); + data.setData( searchProviderPrefix + search ); + } + + if(!service || !KURIFilter::self()->filterURI(data, list)) + { + data.setData( QString::fromLatin1( "google" ) + delimiter() + search ); + KURIFilter::self()->filterURI( data, list ); + } + + if(KApplication::keyboardMouseState() & Qt::ControlButton) + { + KParts::URLArgs args; + args.setNewTab(true); + emit m_part->browserExtension()->createNewWindow( data.uri(), args ); + } + else + { + emit m_part->browserExtension()->openURLRequest(data.uri()); + } + } + + if(m_searchCombo->text(0).isEmpty()) + { + m_searchCombo->changeItem(m_searchIcon, search, 0); + } + else + { + if(m_searchCombo->findHistoryItem(search) == -1) + { + m_searchCombo->insertItem(m_searchIcon, search, 0); + } + } + + m_searchCombo->setCurrentText(""); + m_urlEnterLock = false; +} + +void SearchBarPlugin::setIcon() +{ + QString hinttext; + if(m_searchMode == FindInThisPage) + { + m_searchIcon = SmallIcon("find"); + hinttext = i18n("Find in This Page"); + } + else + { + QString providername; + KService::Ptr service; + KURIFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); + if (service) { + const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter(); + data.setData( searchProviderPrefix + "some keyword" ); + } + + if (service && KURIFilter::self()->filterURI(data, list)) + { + QString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png"); + if(iconPath.isEmpty()) + { + m_searchIcon = SmallIcon("enhanced_browsing"); + } + else + { + m_searchIcon = QPixmap(iconPath); + } + providername = service->name(); + } + else + { + m_searchIcon = SmallIcon("google"); + providername = "Google"; + } + hinttext = i18n("%1 Search").arg(providername);; + } + static_cast<KLineEdit*>(m_searchCombo->lineEdit())->setClickMessage(hinttext); + + // Create a bit wider icon with arrow + QPixmap arrowmap = QPixmap(m_searchIcon.width()+5,m_searchIcon.height()+5); + arrowmap.fill(m_searchCombo->lineEdit()->backgroundColor()); + QPainter p( &arrowmap ); + p.drawPixmap(0, 2, m_searchIcon); + QStyle::SFlags arrowFlags = QStyle::Style_Default; + m_searchCombo->style().drawPrimitive(QStyle::PE_ArrowDown, &p, QRect(arrowmap.width()-6, + arrowmap.height()-6, 6, 5), m_searchCombo->colorGroup(), arrowFlags, QStyleOption() ); + p.end(); + m_searchIcon = arrowmap; + + m_searchCombo->setIcon(m_searchIcon); +} + +void SearchBarPlugin::showSelectionMenu() +{ + if(!m_popupMenu) + { + KService::Ptr service; + QPixmap icon; + KURIFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + m_popupMenu = new QPopupMenu(m_searchCombo, "search selection menu"); + m_popupMenu->insertItem(SmallIcon("find"), i18n("Find in This Page"), this, SLOT(useFindInThisPage()), 0, 999); + m_popupMenu->insertSeparator(); + + int i=-1; + for (QStringList::ConstIterator it = m_searchEngines.begin(); it != m_searchEngines.end(); ++it ) + { + i++; + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(*it)); + if(!service) + { + continue; + } + const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter(); + data.setData( searchProviderPrefix + "some keyword" ); + + if(KURIFilter::self()->filterURI(data, list)) + { + QString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png"); + if(iconPath.isEmpty()) + { + icon = SmallIcon("enhanced_browsing"); + } + else + { + icon = QPixmap( iconPath ); + } + m_popupMenu->insertItem(icon, service->name(), i); + } + } + + m_popupMenu->insertSeparator(); + m_popupMenu->insertItem(SmallIcon("enhanced_browsing"), i18n("Select Search Engines..."), + this, SLOT(selectSearchEngines()), 0, 1000); + connect(m_popupMenu, SIGNAL(activated(int)), SLOT(useSearchProvider(int))); + } + m_popupMenu->popup(m_searchCombo->mapToGlobal(QPoint(0, m_searchCombo->height() + 1)), 0); +} + +void SearchBarPlugin::useFindInThisPage() +{ + m_searchMode = FindInThisPage; + setIcon(); +} + +void SearchBarPlugin::useSearchProvider(int id) +{ + if(id>900) + { + // Not a search engine entry selected + return; + } + m_searchMode = UseSearchProvider; + m_currentEngine = *m_searchEngines.at(id); + setIcon(); +} + +void SearchBarPlugin::selectSearchEngines() +{ + KProcess *process = new KProcess; + + *process << "kcmshell" << "ebrowsing"; + + connect(process, SIGNAL(processExited(KProcess *)), SLOT(searchEnginesSelected(KProcess *))); + + if(!process->start()) + { + kdDebug(1202) << "Couldn't invoke kcmshell." << endl; + delete process; + } +} + +void SearchBarPlugin::searchEnginesSelected(KProcess *process) +{ + if(!process || process->exitStatus() == 0) + { + KConfig *config = kapp->config(); + config->setGroup("SearchBar"); + config->writeEntry("CurrentEngine", m_currentEngine); + config->sync(); + configurationChanged(); + } + delete process; +} + +void SearchBarPlugin::configurationChanged() +{ + KConfig *config = new KConfig("kuriikwsfilterrc"); + config->setGroup("General"); + QString engine = config->readEntry("DefaultSearchEngine", "google"); + + QStringList favoriteEngines; + favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia"; + favoriteEngines = config->readListEntry("FavoriteSearchEngines", favoriteEngines); + + delete m_popupMenu; + m_popupMenu = 0; + m_searchEngines.clear(); + m_searchEngines << engine; + for (QStringList::ConstIterator it = favoriteEngines.begin(); it != favoriteEngines.end(); ++it ) + if(*it!=engine) + m_searchEngines << *it; + + delete config; + if(engine.isEmpty()) + { + m_providerName = "Google"; + } + else + { + KDesktopFile file("searchproviders/" + engine + ".desktop", true, "services"); + m_providerName = file.readName(); + } + + config = kapp->config(); + config->setGroup("SearchBar"); + m_searchMode = (SearchModes) config->readNumEntry("Mode", (int) UseSearchProvider); + m_currentEngine = config->readEntry("CurrentEngine", engine); + + if ( m_currentEngine.isEmpty() ) + m_currentEngine = "google"; + + setIcon(); +} + +void SearchBarPlugin::partChanged(KParts::Part *newPart) +{ + m_part = ::qt_cast<KHTMLPart*>(newPart); + + //Delay since when destroying tabs part 0 gets activated for a bit, before the proper part + QTimer::singleShot(0, this, SLOT(updateComboVisibility())); +} + +void SearchBarPlugin::updateComboVisibility() +{ + if (m_part.isNull() || !m_searchComboAction->isPlugged()) + { + m_searchCombo->setPluginActive(false); + m_searchCombo->hide(); + } + else + { + m_searchCombo->setPluginActive(true); + m_searchCombo->show(); + } +} + +void SearchBarPlugin::focusSearchbar() +{ + QFocusEvent::setReason( QFocusEvent::Shortcut ); + m_searchCombo->setFocus(); + QFocusEvent::resetReason(); +} + +SearchBarCombo::SearchBarCombo(QWidget *parent, const char *name) : + KHistoryCombo(parent, name), + m_pluginActive(true) +{ + connect(this, SIGNAL(cleared()), SLOT(historyCleared())); +} + +const QPixmap &SearchBarCombo::icon() const +{ + return m_icon; +} + +void SearchBarCombo::setIcon(const QPixmap &icon) +{ + m_icon = icon; + + if(count() == 0) + { + insertItem(m_icon, 0); + } + else + { + for(int i = 0; i < count(); i++) + { + changeItem(m_icon, text(i), i); + } + } +} + +int SearchBarCombo::findHistoryItem(const QString &searchText) +{ + for(int i = 0; i < count(); i++) + { + if(text(i) == searchText) + { + return i; + } + } + + return -1; +} + +void SearchBarCombo::mousePressEvent(QMouseEvent *e) +{ + int x0 = QStyle::visualRect( style().querySubControlMetrics( QStyle::CC_ComboBox, this, QStyle::SC_ComboBoxEditField ), this ).x(); + + if(e->x() > x0 + 2 && e->x() < lineEdit()->x()) + { + emit iconClicked(); + + e->accept(); + } + else + { + KHistoryCombo::mousePressEvent(e); + } +} + +void SearchBarCombo::historyCleared() +{ + setIcon(m_icon); +} + +void SearchBarCombo::setPluginActive(bool pluginActive) +{ + m_pluginActive = pluginActive; +} + +void SearchBarCombo::show() +{ + if(m_pluginActive) + { + KHistoryCombo::show(); + } +} + +#include "searchbar.moc" diff --git a/konq-plugins/searchbar/searchbar.desktop b/konq-plugins/searchbar/searchbar.desktop new file mode 100644 index 0000000..cbb2f57 --- /dev/null +++ b/konq-plugins/searchbar/searchbar.desktop @@ -0,0 +1,121 @@ +[Desktop Entry] +Icon=google +Type=Service +X-KDE-Library=searchbar +X-KDE-PluginInfo-Author=Arend van Beelen jr. +X-KDE-PluginInfo-Email=arend@auton.nl +X-KDE-PluginInfo-Name=searchbar +X-KDE-PluginInfo-Version=1.0.0 +X-KDE-PluginInfo-Website= +X-KDE-PluginInfo-Category=Extensions +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Name=Search Bar Plugin +Name[bg]=Приставка за търсене +Name[br]=Lugent ar varenn glask +Name[bs]=Dodatak za traku pretrage +Name[ca]=Connector de barra de cerca +Name[cs]=Modul vyhledávací lišty +Name[da]=Søgelinje plugin +Name[de]=Suchleisten-Modul +Name[el]=Πρόσθετο γραμμής αναζήτησης +Name[eo]=Serĉlistela kromaĵo +Name[es]=Complemento de barra de búsqueda +Name[et]=Otsimisriba plugin +Name[eu]=Bilaketa-barra plugina +Name[fa]=وصلۀ میلۀ جستجو +Name[fi]=Etsintäpalkki-liitännäinen +Name[fr]=Module de barre de recherche +Name[fy]=Sykbalkeplugin +Name[ga]=Breiseán Barra Cuardaigh +Name[gl]=Plugin de Barra de Procura +Name[he]=תוסף סרגל חיפוש +Name[hi]=सर्च बार प्लगइन +Name[hr]=Dodatak trake za pretraživanje +Name[hu]=Keresősáv-bővítőmodul +Name[is]=Leitarslár-íforrit +Name[it]=Plugin per la barra di ricerca +Name[ja]=検索バープラグイン +Name[ka]=ძიების ველის მოდული +Name[kk]=Іздеу панелінің плагин модулі +Name[km]=កម្មវិធីជំនួយរបារស្វែងរក +Name[lt]=Paieškos juostos priedas +Name[mk]=Приклучок за лента за барање +Name[ms]=Plugin Bar Carian +Name[nb]=Søkelinje-programtillegg +Name[nds]=Söökbalken-Moduul +Name[ne]=पट्टी प्लगइन खोज्नुहोस् +Name[nl]=Zoekbalkplugin +Name[nn]=Søkelinjeprogramtillegg +Name[pa]=ਖੋਜ ਪੱਟੀ ਪਲੱਗਇਨ +Name[pl]=Wtyczka paska wyszukiwania +Name[pt]='Plugin' de Barra de Procura +Name[pt_BR]=Plug-in de Barra de Busca +Name[ru]=Модуль панели поиска +Name[sk]=Modul pre vyhľadávací pruh +Name[sl]=Vstavek iskalne vrstice +Name[sr]=Прикључак претраживачке траке +Name[sr@Latn]=Priključak pretraživačke trake +Name[sv]=Sökradsinsticksprogram +Name[ta]=பட்டி சொருகு சாதனத்தைத் தேடு +Name[tg]=Модули панели ҷустуҷӯ +Name[tr]=Arama Çubuğu Eklentisi +Name[uk]=Втулок смужки пошуку +Name[uz]=Qidirish paneli plagini +Name[uz@cyrillic]=Қидириш панели плагини +Name[vi]=Bổ sung thanh tìm +Name[zh_CN]=搜索栏插件 +Name[zh_TW]=搜尋列外掛程式 +Comment=Presents you with a textbox for direct access to search engines like Google. +Comment[bg]=Поле за търсене на в търсещите машини от сорта на Google +Comment[bs]=Prikazuje tekstualno polja za direktan pristup pretraživačima kao što je Google. +Comment[ca]=Presenta una àrea de text per accés directe a motors de cerca com Google. +Comment[cs]=Textové pole pro přímý přístup k vyhledávání jako je Google. +Comment[da]=Præsenterer dig for et tekstfelt med direkte adgang til søgemaskiner såsom Google. +Comment[de]=Zeigt ein Eingabefeld für direkten Zugriff auf Suchmaschinen wie Google. +Comment[el]=Σας παρουσιάζει ένα πεδίο κειμένου για απευθείας πρόσβαση σε μηχανές αναζήτησης όπως το Google. +Comment[eo]=Elmontras al vi tekstoskatolon por senpera aliro al serĉiloj kiel Guglo. +Comment[es]=Se muestra como un cuadro de texto con el que se tendrá acceso directo a motores de búsqueda del estilo de Google. +Comment[et]=Pakub tekstikasti, mis võimaldab vahetult kasutada mitmesuguseid otsingumootoreid, näiteks Google. +Comment[eu]=Google bezalako bilaketa motoreak zuzenean atzitzeko testu kutxa bat aurkezten dizu +Comment[fa]=جعبه متنی را برای دستیابی مستقیم به موتورهای جستجو نظیر گوگل، به شما ارائه میکند. +Comment[fi]=Lisää tekstilaatikon suoraan hakukoneen käyttöön kuten Google. +Comment[fr]=Vous présente une zone de texte pour un accès direct aux moteurs de recherche comme Google. +Comment[fy]=Levert in ynfierfjild wêrmei't jo direkte tagong krije ta sykmasines lykas Google. +Comment[gl]=Dá-lle unha caixa de texto para aceder directamente a motores de procura como Google. +Comment[he]= מציג לך שורת קלט לגישה ישירה אל מנועי חיפוש כמו Google +Comment[hi]=गूगल जैसे सर्च इंजनों पर सीधे पहुँच के लिए आपको एक पाठ बक्सा प्रदान करता है. +Comment[hr]=Pruža tekstualni okvir za izravan pristup tražilicama poput Google-a. +Comment[hu]=Gyors hozzáférést biztosít az internetes keresők (pl. Google) szolgáltatásaihoz. +Comment[is]=Birtir textabox sem er beintengt leitarvélum eins og Google. +Comment[it]=Ti presenta una casella di testo per l'accesso diretto a dei motori di ricerca quali Google. +Comment[ja]=Google のような検索エンジンへの直接アクセスのテキストボックスを提供します。 +Comment[ka]=წარმოგიდგენთ ტექსტურ ველს რომელის საძიებო სისტემასთანაა კავსირში, მაგ. Google. +Comment[kk]=Google секілді іздеу тетіктеріне тікелей қатынау панелі. +Comment[km]=បង្ហាញអ្នកដោយប្រអប់អត្ថបទមួយ ដើម្បីចូលដំណើរការម៉ាស៊ីនស្វែងរក ដូចជា Google ។ +Comment[lt]=Pateikia teksto lauką tiesioginei prieigai prie paieškos sistemų, tokių, kaip Google. +Comment[mk]=Ви дава текстуално поле за директен пристап до машини за пребарување како Google +Comment[ms]=Mempersembahkan kepada anda buku teks untuk akses terus ke enjin cari seperti Google. +Comment[nb]=Viser en tekstboks for direkte tilgang til søkemotorer som Google. +Comment[nds]=Gifft Di en Textfeld för den Direkttogriep op Söökmaschinen, as t.B. "Google". +Comment[ne]=तपाईँलाई गुगल जस्तै खोजी इन्जिनमा प्रत्यक्ष पहुँच प्राप्त गर्न पाठबाकस प्रस्तुत गर्छ । +Comment[nl]=Levert een invoerveld waarmee u directe toegang hebt tot zoekmachines zoals Google. +Comment[nn]=Visar ein tekstboks for direkte tilgang til søkemotorar som Google. +Comment[pl]=Pokazuje okienko umożliwiające bezpośrednie uruchamianie przeszukiwarek, takich jak Google. +Comment[pt]=Dá-lhe uma caixa de texto para acesso directo a motores de procura com o Google. +Comment[pt_BR]=Apresenta a você uma caixa de texto para o acesso direto a mecanismos de busca como o Google. +Comment[ru]=Поле ввода для быстрого поиска в Google. +Comment[sk]=Zobrazí textové pole pre priamy prístup k vyhľadávačom ako je Google. +Comment[sl]=Poda besedilni okvir za neposreden odnos do iskalnih strežnikov, kot je Google. +Comment[sr]=Приказује текстуално поље за директан приступ претраживачима као што је Google. +Comment[sr@Latn]=Prikazuje tekstualno polje za direktan pristup pretraživačima kao što je Google. +Comment[sv]=Visar en textruta för direktåtkomst av söktjänster som Google. +Comment[ta]=கூகுலில் இருப்பது போன்று தேடு இயந்திரங்களின் நேரடியான அணுகலுக்கு ஒரு உரைப்பெட்டியுடன் வழங்கும். +Comment[tg]=Фосидаи хурди воридот барои ҷустуҷуйи тез дар Google. +Comment[tr]=Bir metin kutusu ile sizin Google gibi arma motorlarına ulaşmanızı sağlar. +Comment[uk]=Надає прямий доступ до пошукових систем таких, як Google. +Comment[vi]=Hiển thị hộp nhập trực tiếp chuỗi tìm bằng Google v.v. +Comment[zh_CN]=为您添加一个文本框,以便可直接访问像 Google 这样的搜索引擎。 +Comment[zh_TW]=提供您直接到像 Google 之類的搜尋引擎搜尋文字的方法 +X-KDE-ParentApp=konqueror diff --git a/konq-plugins/searchbar/searchbar.h b/konq-plugins/searchbar/searchbar.h new file mode 100644 index 0000000..3f03eb9 --- /dev/null +++ b/konq-plugins/searchbar/searchbar.h @@ -0,0 +1,168 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Arend van Beelen jr. <arend@auton.nl> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SEARCHBAR_PLUGIN +#define SEARCHBAR_PLUGIN + +#include <kcombobox.h> +#include <klibloader.h> +#include <kparts/plugin.h> +#include <kparts/mainwindow.h> + +#include <qguardedptr.h> +#include <qpixmap.h> +#include <qstring.h> + +class KHTMLPart; +class KProcess; +class QPopupMenu; + +/** + * Combo box which catches mouse clicks on the pixmap. + */ +class SearchBarCombo : public KHistoryCombo +{ + Q_OBJECT + + public: + /** + * Constructor. + */ + SearchBarCombo(QWidget *parent, const char *name); + + /** + * Returns the icon currently displayed in the combo box. + */ + const QPixmap &icon() const; + + /** + * Sets the icon displayed in the combo box. + */ + void setIcon(const QPixmap &icon); + + /** + * Finds a history item by its text. + * @return The item number, or -1 if the item is not found. + */ + int findHistoryItem(const QString &text); + + /** + * Sets whether the plugin is active. It can be inactive + * in case the current Konqueror part isn't a KHTML part. + */ + void setPluginActive(bool pluginActive); + + public slots: + virtual void show(); + + signals: + /** + * Emitted when the icon was clicked. + */ + void iconClicked(); + + protected: + /** + * Captures mouse clicks and emits iconClicked() if the icon + * was clicked. + */ + virtual void mousePressEvent(QMouseEvent *e); + + private slots: + void historyCleared(); + + private: + QPixmap m_icon; + bool m_pluginActive; +}; + +/** + * Plugin that provides a search bar for Konqueror. This search bar is located + * next to the location bar and will show a small icon indicating the search + * provider it will use. + * + * @author Arend van Beelen jr. <arend@auton.nl> + * @version $Id$ + */ +class SearchBarPlugin : public KParts::Plugin +{ + Q_OBJECT + + public: + /** Possible search modes */ + enum SearchModes { FindInThisPage = 0, UseSearchProvider }; + + SearchBarPlugin(QObject *parent, const char *name, + const QStringList &); + virtual ~SearchBarPlugin(); + + protected: + bool eventFilter(QObject *o, QEvent *e); + + private slots: + /** + * Starts a search by putting the query URL from the selected + * search provider in the locationbar and calling goURL() + */ + void startSearch(const QString &search); + + /** + * Sets the icon to indicate which search engine is used. + */ + void setIcon(); + + /** + * Opens the selection menu. + */ + void showSelectionMenu(); + + void useFindInThisPage(); + void useSearchProvider(int); + void selectSearchEngines(); + void searchEnginesSelected(KProcess *process); + void configurationChanged(); + + /** + * We keep track of part activations to know when to show or hide ourselves + */ + void partChanged(KParts::Part *newPart); + + /** + * Show or hide the combo box + */ + void updateComboVisibility(); + + void focusSearchbar(); + private: + void nextSearchEntry(); + void previousSearchEntry(); + + QGuardedPtr<KHTMLPart> m_part; + SearchBarCombo *m_searchCombo; + KWidgetAction *m_searchComboAction; + QPopupMenu *m_popupMenu; + QPixmap m_searchIcon; + SearchModes m_searchMode; + QString m_providerName; + bool m_urlEnterLock; + QString m_currentEngine; + QStringList m_searchEngines; +}; + +#endif // SEARCHBAR_PLUGIN diff --git a/konq-plugins/searchbar/searchbar.lsm b/konq-plugins/searchbar/searchbar.lsm new file mode 100644 index 0000000..94537f9 --- /dev/null +++ b/konq-plugins/searchbar/searchbar.lsm @@ -0,0 +1,13 @@ +Begin3 +Title: SearchBarPlugin +Version: 0.1 +Entered-date: 08/02/2004 +Description: Puts an extra textbox for access to search engines like + Google next to Konqueror's location bar. +Keywords: KDE Qt +Author: Arend van Beelen jr. <arend@auton.nl> +Maintained-by: Arend van Beelen jr. <arend@auton.nl> +Home-page: +Platform: Linux. Tested against Qt/KDE 3.2, might work with earlier versions. +Copying-policy: GPL +End diff --git a/konq-plugins/searchbar/searchbar.rc b/konq-plugins/searchbar/searchbar.rc new file mode 100644 index 0000000..c98fdb5 --- /dev/null +++ b/konq-plugins/searchbar/searchbar.rc @@ -0,0 +1,6 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="searchbar" library="libsearchbarplugin" version="3"> +<ToolBar fullWidth="true" name="locationToolBar" newline="true"><text>Search Toolbar</text> + <Action name="toolbar_search_bar" /> +</ToolBar> +</kpartplugin> |