From feb5472021e697aa2722806a4a46ec56dfa1579f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 27 Jan 2009 12:21:11 +0100 Subject: We now have the FINAL search bar!! Yeah!!! --- src/findbar.cpp | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'src/findbar.cpp') diff --git a/src/findbar.cpp b/src/findbar.cpp index 6ba310ca..e3f4b231 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -33,33 +33,47 @@ #include -FindBar::FindBar(KXmlGuiWindow *parent) - : KToolBar( "findBar" , parent, Qt::BottomToolBarArea, true, false, false) +FindBar::FindBar(KXmlGuiWindow *mainwindow) + : QWidget() , m_lineEdit(0) { - KAction *close = new KAction(KIcon("dialog-close") , "close" , this); - connect( close , SIGNAL( triggered() ), this, SLOT( hide() ) ); - addAction( close ); + QHBoxLayout *layout = new QHBoxLayout; - QLabel *label = new QLabel("Find: "); - addWidget( label ); + // cosmetic + layout->setMargin(2); + + // hide button + QToolButton *hideButton = new QToolButton(this); + hideButton->setAutoRaise(true); + hideButton->setIcon(KIcon("dialog-close")); + connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + layout->addWidget(hideButton); + layout->setAlignment( hideButton, Qt::AlignLeft|Qt::AlignTop ); - m_lineEdit = new KLineEdit(); - m_lineEdit->setMaximumWidth( 200 ); + // label + QLabel *label = new QLabel("Find: "); + layout->addWidget(label); - connect( m_lineEdit, SIGNAL( returnPressed() ), parent, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); - addWidget( m_lineEdit ); + // lineEdit, focusProxy + m_lineEdit = new KLineEdit(this); + setFocusProxy(m_lineEdit); + m_lineEdit->setMaximumWidth( 250 ); + connect( m_lineEdit, SIGNAL( returnPressed() ), mainwindow, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), mainwindow, SLOT( slotFindNext() ) ); + layout->addWidget( m_lineEdit ); + // buttons KPushButton *findNext = new KPushButton( KIcon("go-down"), "&Next", this ); KPushButton *findPrev = new KPushButton( KIcon("go-up"), "&Previous", this ); - // perhaps we don't need working on style.. -// findNext->setStyle(); -// findPrev->setStyle(); - connect( findNext, SIGNAL( clicked() ), parent, SLOT( slotFindNext() ) ); - connect( findPrev, SIGNAL( clicked() ), parent, SLOT( slotFindPrevious() ) ); - addWidget( findNext ); - addWidget( findPrev ); + connect( findNext, SIGNAL( clicked() ), mainwindow, SLOT( slotFindNext() ) ); + connect( findPrev, SIGNAL( clicked() ), mainwindow, SLOT( slotFindPrevious() ) ); + layout->addWidget( findNext ); + layout->addWidget( findPrev ); + + // stretching widget on the left + layout->addStretch(); + + setLayout(layout); // we start off hidden hide(); @@ -102,7 +116,7 @@ void FindBar::keyPressEvent(QKeyEvent* event) hide(); return; } - if(event->key() == Qt::Key_Return && ! ( m_lineEdit->text().isEmpty() ) ) + if(event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty() ) { emit searchString( m_lineEdit->text() ); return; -- cgit v1.2.1