]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsearchbox.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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"
22 #include <kglobalsettings.h>
23 #include <klineedit.h>
26 #include <kiconloader.h>
29 #include <QHBoxLayout>
30 #include <QToolButton>
32 DolphinSearchBox::DolphinSearchBox(QWidget
* parent
) :
37 QHBoxLayout
* hLayout
= new QHBoxLayout(this);
38 hLayout
->setMargin(0);
39 hLayout
->setSpacing(0);
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()));
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()));
58 DolphinSearchBox::~DolphinSearchBox()
62 bool DolphinSearchBox::event(QEvent
* event
)
64 if (event
->type() == QEvent::Polish
) {
65 m_searchInput
->setFont(KGlobalSettings::generalFont());
67 return QWidget::event(event
);
70 void DolphinSearchBox::emitSearchSignal()
72 emit
search(KUrl("nepomuksearch:/" + m_searchInput
->text()));
75 #include "dolphinsearchbox.moc"