diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-08-22 04:06:54 +0200 |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-08-22 04:18:37 +0200 |
commit | 67138dcf8e3a1788928fd31256b29a257dae5eee (patch) | |
tree | 5acfb521de78d5a09ec475b4e7baa288c1967041 /src/findbar.cpp | |
parent | Change the Find action to show() instead of toggle() (diff) | |
download | rekonq-67138dcf8e3a1788928fd31256b29a257dae5eee.tar.xz |
Use the selected text as the default search string of the FindBar
The common behavior of the Find action is to start a search with the
current selected text if any.
This patch implement this behavior for Rekonq.
Diffstat (limited to 'src/findbar.cpp')
-rw-r--r-- | src/findbar.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp index bad3bf50..0e3f7385 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -49,16 +49,14 @@ #include <QtCore/QTimer> -FindBar::FindBar(QWidget *parent) - : QWidget(parent) +FindBar::FindBar(MainWindow *window) + : QWidget(window) + , m_mainWindow(window) , m_lineEdit(new KLineEdit(this)) , m_hideTimer(new QTimer(this)) , m_matchCase(new QCheckBox(i18n("&Match case"), this)) , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this)) { - // mainwindow pointer - MainWindow *window = qobject_cast<MainWindow *>(parent); - QHBoxLayout *layout = new QHBoxLayout; // cosmetic @@ -146,6 +144,12 @@ void FindBar::setVisible(bool visible) emit visibilityChanged(visible); if (visible) { + if (!hasFocus()) { + const QString selectedText = m_mainWindow->selectedText(); + if (!selectedText.isEmpty()) + m_lineEdit->setText(selectedText); + } + // show findbar if not visible emit searchString(m_lineEdit->text()); |