┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp19
-rw-r--r--src/views/dolphinview.h5
2 files changed, 24 insertions, 0 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 794223861..3c973618c 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -130,6 +130,25 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
KItemListController *controller = new KItemListController(m_model, m_view, this);
controller->setAutoActivationEnabled(GeneralSettings::autoExpandFolders());
connect(controller, &KItemListController::doubleClickViewBackground, this, &DolphinView::doubleClickViewBackground);
+ connect(controller, &KItemListController::typeAheadUsed, this, [this](const QString &typedString, std::optional<int> foundIndex) {
+ if (foundIndex.has_value()) {
+ const KFileItem item = m_model->fileItem(foundIndex.value());
+ if (item.isNull()) {
+ return;
+ }
+ const KColorScheme colorScheme = KColorScheme(QPalette::Normal, KColorScheme::Tooltip);
+ const QColor autoCompleteTextColor = colorScheme.foreground(KColorScheme::InactiveText).color();
+
+ Q_EMIT showTypeAheadFeedback(QStringLiteral("%1<font color=\"%2\">%3</font>")
+ .arg(typedString.toHtmlEscaped())
+ .arg(autoCompleteTextColor.name())
+ .arg(item.name().toHtmlEscaped().mid(typedString.size())));
+ } else {
+ const KColorScheme colorScheme = KColorScheme(QPalette::Normal, KColorScheme::Tooltip);
+ const QColor noMatchTextColor = colorScheme.foreground(KColorScheme::NegativeText).color();
+ Q_EMIT showTypeAheadFeedback(QStringLiteral("<font color=\"%1\">%2</font>").arg(noMatchTextColor.name()).arg(typedString.toHtmlEscaped()));
+ }
+ });
// The EnlargeSmallPreviews setting can only be changed after the model
// has been set in the view by KItemListController.
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 6aa5b595d..9b068f92e 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -635,6 +635,11 @@ Q_SIGNALS:
void operationCompletedMessage(const QString &msg);
/**
+ * Is emitted so the \a typeAheadFeedback is displayed to the user. Beware: \a typeAheadFeedback is HTML-escaped rich text.
+ */
+ void showTypeAheadFeedback(const QString &typeAheadFeedback);
+
+ /**
* Is emitted after DolphinView::setUrl() has been invoked and
* the current directory is loaded. If this signal is emitted,
* it is assured that the view contains already the correct root