mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-21 17:52:10 +02:00
Use selected text in searchToolBar
Summary: With this patch, the currently selected text in a webpage is automatically inserted into the searchToolBar when it is opened. This matches the behaviour of the search tool bar in Kate. Test Plan: Open a webpage. Select a single line of text. Press Ctrl+F. The selected text is inserted into the searchToolBar. Reviewers: #falkon, drosca Reviewed By: #falkon, drosca Subscribers: drosca Differential Revision: https://phabricator.kde.org/D11210
This commit is contained in:
parent
a5223ddb0c
commit
d708fea839
|
@ -1148,7 +1148,12 @@ void BrowserWindow::webSearch()
|
||||||
void BrowserWindow::searchOnPage()
|
void BrowserWindow::searchOnPage()
|
||||||
{
|
{
|
||||||
if (weView() && weView()->webTab()) {
|
if (weView() && weView()->webTab()) {
|
||||||
weView()->webTab()->showSearchToolBar();
|
const QString searchText = weView()->page()->selectedText();
|
||||||
|
if (!searchText.contains('\n')) {
|
||||||
|
weView()->webTab()->showSearchToolBar(searchText);
|
||||||
|
} else {
|
||||||
|
weView()->webTab()->showSearchToolBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ SearchToolBar::SearchToolBar(WebView* view, QWidget* parent)
|
||||||
ui->previous->setShortcut(QKeySequence("Ctrl+Shift+G"));
|
ui->previous->setShortcut(QKeySequence("Ctrl+Shift+G"));
|
||||||
|
|
||||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(findNext()));
|
connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(findNext()));
|
||||||
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(findNext()));
|
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(findNext()));
|
||||||
connect(ui->next, SIGNAL(clicked()), this, SLOT(findNext()));
|
connect(ui->next, SIGNAL(clicked()), this, SLOT(findNext()));
|
||||||
connect(ui->previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
|
connect(ui->previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
|
||||||
|
@ -113,6 +113,11 @@ void SearchToolBar::caseSensitivityChanged()
|
||||||
searchText(ui->lineEdit->text());
|
searchText(ui->lineEdit->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchToolBar::setText(const QString &text)
|
||||||
|
{
|
||||||
|
ui->lineEdit->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void SearchToolBar::searchText(const QString &text)
|
void SearchToolBar::searchText(const QString &text)
|
||||||
{
|
{
|
||||||
QPointer<SearchToolBar> guard = this;
|
QPointer<SearchToolBar> guard = this;
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
bool eventFilter(QObject* obj, QEvent* event);
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void setText(const QString &text);
|
||||||
void searchText(const QString &text);
|
void searchText(const QString &text);
|
||||||
void updateFindFlags();
|
void updateFindFlags();
|
||||||
void caseSensitivityChanged();
|
void caseSensitivityChanged();
|
||||||
|
|
|
@ -237,7 +237,7 @@ void WebTab::toggleWebInspector()
|
||||||
delete m_splitter->widget(1);
|
delete m_splitter->widget(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebTab::showSearchToolBar()
|
void WebTab::showSearchToolBar(const QString &searchText)
|
||||||
{
|
{
|
||||||
const int index = 1;
|
const int index = 1;
|
||||||
|
|
||||||
|
@ -252,6 +252,9 @@ void WebTab::showSearchToolBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT(toolBar);
|
Q_ASSERT(toolBar);
|
||||||
|
if (!searchText.isEmpty()) {
|
||||||
|
toolBar->setText(searchText);
|
||||||
|
}
|
||||||
toolBar->focusSearchLine();
|
toolBar->focusSearchLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
void showWebInspector(bool inspectElement = false);
|
void showWebInspector(bool inspectElement = false);
|
||||||
void toggleWebInspector();
|
void toggleWebInspector();
|
||||||
|
|
||||||
void showSearchToolBar();
|
void showSearchToolBar(const QString &searchText = QString());
|
||||||
|
|
||||||
bool isRestored() const;
|
bool isRestored() const;
|
||||||
void restoreTab(const SavedTab &tab);
|
void restoreTab(const SavedTab &tab);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user