mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01: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,9 +1148,14 @@ void BrowserWindow::webSearch()
|
|||
void BrowserWindow::searchOnPage()
|
||||
{
|
||||
if (weView() && weView()->webTab()) {
|
||||
const QString searchText = weView()->page()->selectedText();
|
||||
if (!searchText.contains('\n')) {
|
||||
weView()->webTab()->showSearchToolBar(searchText);
|
||||
} else {
|
||||
weView()->webTab()->showSearchToolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::openFile()
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ SearchToolBar::SearchToolBar(WebView* view, QWidget* parent)
|
|||
ui->previous->setShortcut(QKeySequence("Ctrl+Shift+G"));
|
||||
|
||||
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->next, SIGNAL(clicked()), this, SLOT(findNext()));
|
||||
connect(ui->previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
|
||||
|
@ -113,6 +113,11 @@ void SearchToolBar::caseSensitivityChanged()
|
|||
searchText(ui->lineEdit->text());
|
||||
}
|
||||
|
||||
void SearchToolBar::setText(const QString &text)
|
||||
{
|
||||
ui->lineEdit->setText(text);
|
||||
}
|
||||
|
||||
void SearchToolBar::searchText(const QString &text)
|
||||
{
|
||||
QPointer<SearchToolBar> guard = this;
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setText(const QString &text);
|
||||
void searchText(const QString &text);
|
||||
void updateFindFlags();
|
||||
void caseSensitivityChanged();
|
||||
|
|
|
@ -237,7 +237,7 @@ void WebTab::toggleWebInspector()
|
|||
delete m_splitter->widget(1);
|
||||
}
|
||||
|
||||
void WebTab::showSearchToolBar()
|
||||
void WebTab::showSearchToolBar(const QString &searchText)
|
||||
{
|
||||
const int index = 1;
|
||||
|
||||
|
@ -252,6 +252,9 @@ void WebTab::showSearchToolBar()
|
|||
}
|
||||
|
||||
Q_ASSERT(toolBar);
|
||||
if (!searchText.isEmpty()) {
|
||||
toolBar->setText(searchText);
|
||||
}
|
||||
toolBar->focusSearchLine();
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
void showWebInspector(bool inspectElement = false);
|
||||
void toggleWebInspector();
|
||||
|
||||
void showSearchToolBar();
|
||||
void showSearchToolBar(const QString &searchText = QString());
|
||||
|
||||
bool isRestored() const;
|
||||
void restoreTab(const SavedTab &tab);
|
||||
|
|
Loading…
Reference in New Issue
Block a user