]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsearchbox.cpp
Update the KPart host's status bar info when selection changes.
[dolphin.git] / src / dolphinsearchbox.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19 #include "dolphinsearchbox.h"
20
21 #include <kdialog.h>
22 #include <kglobalsettings.h>
23 #include <klineedit.h>
24 #include <klocale.h>
25 #include <kicon.h>
26 #include <kiconloader.h>
27
28 #include <QEvent>
29 #include <QHBoxLayout>
30 #include <QToolButton>
31
32 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
33 QWidget(parent),
34 m_searchButton(0),
35 m_searchInput(0)
36 {
37 QHBoxLayout* hLayout = new QHBoxLayout(this);
38 hLayout->setMargin(0);
39 hLayout->setSpacing(0);
40
41 m_searchButton = new QToolButton(this);
42 m_searchButton->setAutoRaise(true);
43 m_searchButton->setIcon(KIcon("nepomuk"));
44 m_searchButton->setToolTip(i18nc("@info:tooltip", "Search"));
45 hLayout->addWidget(m_searchButton);
46
47 connect(m_searchButton, SIGNAL(clicked()),
48 this, SLOT(emitSearchSignal()));
49
50 m_searchInput = new KLineEdit(this);
51 m_searchInput->setLayoutDirection(Qt::LeftToRight);
52 m_searchInput->setClearButtonShown(true);
53 m_searchInput->setMinimumWidth(150);
54 hLayout->addWidget(m_searchInput);
55
56 connect(m_searchInput, SIGNAL(returnPressed()),
57 this, SLOT(emitSearchSignal()));
58 }
59
60 DolphinSearchBox::~DolphinSearchBox()
61 {
62 }
63
64 bool DolphinSearchBox::event(QEvent* event)
65 {
66 if (event->type() == QEvent::Polish) {
67 m_searchInput->setFont(KGlobalSettings::generalFont());
68 }
69 return QWidget::event(event);
70 }
71
72 void DolphinSearchBox::emitSearchSignal()
73 {
74 emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
75 }
76
77 #include "dolphinsearchbox.moc"