]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinsearchbox.cpp
fixed issue that the video preview size was wrong during resizing the information...
[dolphin.git] / src / dolphinsearchbox.cpp
index 4263aacf61bc15937db99f51cd4eeb25d27c5076..d27b080148e1e3138e00f2e70823a87e9c7cb66b 100644 (file)
 #include <kiconloader.h>
 
 #include <QEvent>
+#include <QKeyEvent>
 #include <QHBoxLayout>
 #include <QToolButton>
 
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
-    m_searchButton(0),
-    m_searchInput(0)
+    m_searchInput(0),
+    m_searchButton(0)
 {
     QHBoxLayout* hLayout = new QHBoxLayout(this);
     hLayout->setMargin(0);
-
-    m_searchButton = new QToolButton(this);
-    m_searchButton->setAutoRaise(true);
-    m_searchButton->setIcon(KIcon("nepomuk"));
-    m_searchButton->setToolTip(i18nc("@info:tooltip", "Search"));
-    hLayout->addWidget(m_searchButton);
-
-    connect(m_searchButton, SIGNAL(clicked()),
-            this, SLOT(emitSearchSignal()));
+    hLayout->setSpacing(0);
 
     m_searchInput = new KLineEdit(this);
-    m_searchInput->setLayoutDirection(Qt::LeftToRight);
     m_searchInput->setClearButtonShown(true);
     m_searchInput->setMinimumWidth(150);
+    m_searchInput->setClickMessage(i18nc("@label:textbox", "Search..."));
     hLayout->addWidget(m_searchInput);
-
     connect(m_searchInput, SIGNAL(returnPressed()),
             this, SLOT(emitSearchSignal()));
+
+    m_searchButton = new QToolButton(this);
+    m_searchButton->setAutoRaise(true);
+    m_searchButton->setIcon(KIcon("edit-find"));
+    m_searchButton->setToolTip(i18nc("@info:tooltip", "Click to begin the search"));
+    hLayout->addWidget(m_searchButton);
+    connect(m_searchButton, SIGNAL(clicked()),
+            this, SLOT(emitSearchSignal()));
 }
 
 DolphinSearchBox::~DolphinSearchBox()
@@ -64,6 +64,10 @@ bool DolphinSearchBox::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
         m_searchInput->setFont(KGlobalSettings::generalFont());
+    } else if (event->type() == QEvent::KeyPress) {
+        if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
+            m_searchInput->clear();
+        }
     }
     return QWidget::event(event);
 }