From d62176f7f2a6a204b5017bc661fff2d3a9f76e6e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 30 Nov 2008 17:30:57 +0100 Subject: - Ported historyMenu to KAction - some adjs on urlbar - added TODO file to remember things --- src/findbar.cpp | 78 ++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 43 deletions(-) (limited to 'src/findbar.cpp') diff --git a/src/findbar.cpp b/src/findbar.cpp index a0e1948d..2d9e0d5c 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -25,14 +25,31 @@ #include #include #include +#include #include -FindBar::FindBar(QWidget *parent) - : KToolBar(parent) +FindBar::FindBar(QMainWindow *parent) + : KToolBar( "FindBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { - initializeFindWidget(); + KAction *close = new KAction(KIcon("dialog-close") , "close" , this); + connect( close , SIGNAL( triggered() ), this, SLOT( hide() ) ); + addAction( close ); + + QLabel *label = new QLabel("Find: "); + addWidget( label ); + + m_lineEdit = new KLineEdit(); + connect( m_lineEdit, SIGNAL( returnPressed() ), parent, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); + addWidget( m_lineEdit ); + + addAction( KStandardAction::findNext(parent, SLOT( slotFindNext() ) , this ) ); + addAction( KStandardAction::findPrev(parent, SLOT( slotFindPrevious() ) , this ) ); + + QLabel *spaceLabel = new QLabel(" "); // FIXME + addWidget( spaceLabel ); // we start off hidden hide(); @@ -51,34 +68,13 @@ KLineEdit *FindBar::lineEdit() } -void FindBar::initializeFindWidget() -{ - addAction( KIcon("dialog-close") , "close" , this, SLOT( hide() ) ); - - QLabel *label = new QLabel("Find: "); - addWidget( label ); - - m_lineEdit = new KLineEdit(); - connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); - addWidget( m_lineEdit ); - - addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - - QLabel *spaceLabel = new QLabel(" "); // FIXME - addWidget( spaceLabel ); -} - - - void FindBar::clear() { m_lineEdit->setText(QString()); } -void FindBar::showFind() +void FindBar::showFindBar() { if (!isVisible()) { @@ -89,21 +85,17 @@ void FindBar::showFind() } - -// void FindBar::frameChanged(int frame) -// { -// /* if (!m_widget) -// return; -// m_widget->move(0, frame); -// int height = qMax(0, m_widget->y() + m_widget->height()); -// setMinimumHeight(height); -// setMaximumHeight(height);*/ -// } - - -void FindBar::slotFindNext() -{} - -void FindBar::slotFindPrevious() -{} - +void FindBar::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Escape) + { + hide(); + return; + } + if(event->key() == Qt::Key_Return && ! ( m_lineEdit->text().isEmpty() ) ) + { + emit searchString( m_lineEdit->text() ); + return; + } + QWidget::keyPressEvent(event); +} -- cgit v1.2.1