Currently, the URL navigator is not updated when the search box is cleared. This MR restores the URL, by closing and reopening the box.
The call for emitting closeRequest() on pressing Esc has been replaced with emitCloseRequest(). The wait duration before starting a search has been reduced to 500ms to increase responsiveness.
Also, the bugfix for BUG: 423328 is slightly incorrect and causes the search term to not be displayed when opening a saved search for the first time. As a better solution for this bug, DolphinSearchBox::setText() now updates the text only if the text has changed.
BUG: 473775
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
+ connect(m_searchBox, &DolphinSearchBox::openRequest, this, &DolphinViewContainer::openSearchBox);
connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
connect(m_searchBox, &DolphinSearchBox::focusViewRequest, this, &DolphinViewContainer::requestFocus);
connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
connect(m_searchBox, &DolphinSearchBox::focusViewRequest, this, &DolphinViewContainer::requestFocus);
+void DolphinViewContainer::openSearchBox()
+{
+ setSearchModeEnabled(true);
+}
+
void DolphinViewContainer::closeSearchBox()
{
setSearchModeEnabled(false);
void DolphinViewContainer::closeSearchBox()
{
setSearchModeEnabled(false);
* Gets the search URL from the searchbox and starts searching.
*/
void startSearching();
* Gets the search URL from the searchbox and starts searching.
*/
void startSearching();
void closeSearchBox();
/**
void closeSearchBox();
/**
void DolphinSearchBox::setText(const QString &text)
{
void DolphinSearchBox::setText(const QString &text)
{
- m_searchInput->setText(text);
+ if (m_searchInput->text() != text) {
+ m_searchInput->setText(text);
+ }
}
QString DolphinSearchBox::text() const
}
QString DolphinSearchBox::text() const
QWidget::keyReleaseEvent(event);
if (event->key() == Qt::Key_Escape) {
if (m_searchInput->text().isEmpty()) {
QWidget::keyReleaseEvent(event);
if (event->key() == Qt::Key_Escape) {
if (m_searchInput->text().isEmpty()) {
} else {
m_searchInput->clear();
}
} else {
m_searchInput->clear();
}
void DolphinSearchBox::slotSearchTextChanged(const QString &text)
{
if (text.isEmpty()) {
void DolphinSearchBox::slotSearchTextChanged(const QString &text)
{
if (text.isEmpty()) {
- m_startSearchTimer->stop();
+ // Restore URL when search box is cleared by closing and reopening the box.
+ emitCloseRequest();
+ QTimer::singleShot(0, this, [this] {
+ Q_EMIT openRequest();
+ });
} else {
m_startSearchTimer->start();
}
} else {
m_startSearchTimer->start();
}
void DolphinSearchBox::slotReturnPressed()
{
void DolphinSearchBox::slotReturnPressed()
{
+ if (m_searchInput->text().isEmpty()) {
+ return;
+ }
+
emitSearchRequest();
Q_EMIT focusViewRequest();
}
emitSearchRequest();
Q_EMIT focusViewRequest();
}
loadSettings();
// The searching should be started automatically after the user did not change
loadSettings();
// The searching should be started automatically after the user did not change
- // the text within one second
+ // the text for a while
m_startSearchTimer = new QTimer(this);
m_startSearchTimer->setSingleShot(true);
m_startSearchTimer = new QTimer(this);
m_startSearchTimer->setSingleShot(true);
- m_startSearchTimer->setInterval(1000);
+ m_startSearchTimer->setInterval(500);
connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
}
connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
}
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
}
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
}
- // If the input box has focus, do not update to avoid messing with user typing
- if (!m_searchInput->hasFocus()) {
- setText(query.text());
- }
if (query.hasContentSearch()) {
m_contentButton->setChecked(true);
if (query.hasContentSearch()) {
m_contentButton->setChecked(true);
+ /**
+ * Is emitted when the search box should be opened.
+ */
+ void openRequest();
+
/**
* Is emitted, if the searchbox has been activated by
* an user interaction
/**
* Is emitted, if the searchbox has been activated by
* an user interaction