]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsearchbox.cpp
allow to disable the preview of the Information Panel
[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_searchInput(0),
35 m_searchButton(0)
36 {
37 QHBoxLayout* hLayout = new QHBoxLayout(this);
38 hLayout->setMargin(0);
39 hLayout->setSpacing(0);
40
41 m_searchInput = new KLineEdit(this);
42 m_searchInput->setLayoutDirection(Qt::LeftToRight);
43 m_searchInput->setClearButtonShown(true);
44 m_searchInput->setMinimumWidth(150);
45 hLayout->addWidget(m_searchInput);
46 connect(m_searchInput, SIGNAL(returnPressed()),
47 this, SLOT(emitSearchSignal()));
48
49 m_searchButton = new QToolButton(this);
50 m_searchButton->setAutoRaise(true);
51 m_searchButton->setIcon(KIcon("edit-find"));
52 m_searchButton->setToolTip(i18nc("@info:tooltip", "Search"));
53 hLayout->addWidget(m_searchButton);
54 connect(m_searchButton, SIGNAL(clicked()),
55 this, SLOT(emitSearchSignal()));
56 }
57
58 DolphinSearchBox::~DolphinSearchBox()
59 {
60 }
61
62 bool DolphinSearchBox::event(QEvent* event)
63 {
64 if (event->type() == QEvent::Polish) {
65 m_searchInput->setFont(KGlobalSettings::generalFont());
66 }
67 return QWidget::event(event);
68 }
69
70 void DolphinSearchBox::emitSearchSignal()
71 {
72 emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
73 }
74
75 #include "dolphinsearchbox.moc"