diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-01-27 12:21:11 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-01-27 12:21:11 +0100 |
commit | feb5472021e697aa2722806a4a46ec56dfa1579f (patch) | |
tree | 57b64d46973a5352284ae77cd4b7c3fdf63ab114 /src | |
parent | 1st introduction of new bookmarks line (diff) | |
download | rekonq-feb5472021e697aa2722806a4a46ec56dfa1579f.tar.xz |
We now have the FINAL search bar!! Yeah!!!
Diffstat (limited to 'src')
-rw-r--r-- | src/findbar.cpp | 54 | ||||
-rw-r--r-- | src/findbar.h | 5 | ||||
-rw-r--r-- | src/mainwindow.cpp | 25 |
3 files changed, 53 insertions, 31 deletions
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 <QtGui> -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; diff --git a/src/findbar.h b/src/findbar.h index d70a9de1..f2c59ce9 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -25,12 +25,12 @@ #include <KToolBar> #include <KXmlGuiWindow> -class FindBar : public KToolBar +class FindBar : public QWidget // KateViewHelpers.h { Q_OBJECT public: - FindBar(KXmlGuiWindow *parent); + FindBar(KXmlGuiWindow *mainwindow); ~FindBar(); KLineEdit *lineEdit(); @@ -46,7 +46,6 @@ signals: private: KLineEdit *m_lineEdit; - QWidget *m_centralWidget; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a7ec427..10d6f8ce 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -57,6 +57,7 @@ #include <QWebFrame> #include <QWebHistory> #include <QDebug> +#include <QVBoxLayout> MainWindow::MainWindow() @@ -73,8 +74,18 @@ MainWindow::MainWindow() // creating a new tab m_view->newTab(); - // tell the KXmlGuiWindow that this is indeed the main widget - setCentralWidget(m_view); + // creating a centralWidget containing m_view and the hidden findbar + QWidget *centralWidget = new QWidget; + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(m_view); + + // Find Bar + m_findBar = new FindBar(this); + connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); + layout->addWidget(m_findBar); + + centralWidget->setLayout(layout); + setCentralWidget(centralWidget); // connect signals and slots connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); @@ -116,10 +127,6 @@ MainWindow::MainWindow() m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); - - // Find Bar - m_findBar = new FindBar( this ); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); } @@ -543,7 +550,9 @@ void MainWindow::slotFind(const QString & search) { m_lastSearch = search; if (!currentTab()->findText(m_lastSearch)) + { slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } } } @@ -556,7 +565,7 @@ void MainWindow::slotViewFindBar() void MainWindow::slotFindNext() { - if (!currentTab() && !m_lastSearch.isEmpty()) + if (!currentTab() && m_lastSearch.isEmpty()) return; currentTab()->findText(m_lastSearch); } @@ -564,7 +573,7 @@ void MainWindow::slotFindNext() void MainWindow::slotFindPrevious() { - if (!currentTab() && !m_lastSearch.isEmpty()) + if (!currentTab() && m_lastSearch.isEmpty()) return; currentTab()->findText(m_lastSearch, QWebPage::FindBackward); } |