forked from qt-creator/qt-creator
Spotlight filter/macOS: Interpret space as *
Flows more natural, and is what we do on the other platforms by default too. Change-Id: Ia9510235167a014fa7bdafd023e05c8fe40dd338 Reviewed-by: Alp Öz <aoz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -198,7 +198,7 @@ static QString defaultCommand()
|
||||
static QString defaultArguments(Qt::CaseSensitivity sens = Qt::CaseInsensitive)
|
||||
{
|
||||
if (HostOsInfo::isMacHost())
|
||||
return QString("\"kMDItemFSName = '*%{Query:Escaped}*'%1\"")
|
||||
return QString("\"kMDItemFSName = '*%{Query:EscapedWithWildcards}*'%1\"")
|
||||
.arg(sens == Qt::CaseInsensitive ? QString("c") : "");
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
return QString("%1 -n 10000 %{Query:Escaped}")
|
||||
@@ -211,6 +211,13 @@ const char kCommandKey[] = "command";
|
||||
const char kArgumentsKey[] = "arguments";
|
||||
const char kCaseSensitiveKey[] = "caseSensitive";
|
||||
|
||||
static QString escaped(const QString &query)
|
||||
{
|
||||
QString quoted = query;
|
||||
quoted.replace('\\', "\\\\").replace('\'', "\\\'").replace('\"', "\\\"");
|
||||
return quoted;
|
||||
}
|
||||
|
||||
static MacroExpander *createMacroExpander(const QString &query)
|
||||
{
|
||||
MacroExpander *expander = new MacroExpander;
|
||||
@@ -220,11 +227,14 @@ static MacroExpander *createMacroExpander(const QString &query)
|
||||
expander->registerVariable("Query:Escaped",
|
||||
SpotlightLocatorFilter::tr(
|
||||
"Locator query string with quotes escaped with backslash."),
|
||||
[query] { return escaped(query); });
|
||||
expander->registerVariable("Query:EscapedWithWildcards",
|
||||
SpotlightLocatorFilter::tr(
|
||||
"Locator query string with quotes escaped with backslash and "
|
||||
"spaces replaced with \"*\" wildcards."),
|
||||
[query] {
|
||||
QString quoted = query;
|
||||
quoted.replace('\\', "\\\\")
|
||||
.replace('\'', "\\\'")
|
||||
.replace('\"', "\\\"");
|
||||
QString quoted = escaped(query);
|
||||
quoted.replace(' ', '*');
|
||||
return quoted;
|
||||
});
|
||||
expander->registerVariable("Query:Regex",
|
||||
|
||||
Reference in New Issue
Block a user