forked from qt-creator/qt-creator
Show locator filter descriptions more prominently
- Sort items in the menu. - Disable items for disabled filters. - Show a tool tip when hovering over the magnifying glass menu. - Add descriptions to all filters and make them more consistent. Change-Id: Ic03e303c50422f9de5dd3c512fe32bbdc958d2ba Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -75,7 +75,7 @@ DirectoryFilter::DirectoryFilter(Id id)
|
||||
setId(id);
|
||||
setDefaultIncludedByDefault(true);
|
||||
setDisplayName(defaultDisplayName());
|
||||
setDescription(Tr::tr("Matches all files from a custom set of directories. Append \"+<number>\" "
|
||||
setDescription(Tr::tr("Locates files from a custom set of directories. Append \"+<number>\" "
|
||||
"or \":<number>\" to jump to the given line number. Append another "
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
|
||||
|
||||
@@ -844,7 +844,10 @@ ILocatorFilter::Priority ILocatorFilter::priority() const
|
||||
*/
|
||||
void ILocatorFilter::setEnabled(bool enabled)
|
||||
{
|
||||
if (enabled == m_enabled)
|
||||
return;
|
||||
m_enabled = enabled;
|
||||
emit enabledChanged(m_enabled);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -251,6 +251,9 @@ public:
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
signals:
|
||||
void enabledChanged(bool enabled);
|
||||
|
||||
protected:
|
||||
void setHidden(bool hidden);
|
||||
void setId(Utils::Id id);
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
|
||||
LocatorData::LocatorData()
|
||||
{
|
||||
m_urlFilter.setDescription(Tr::tr("Triggers a web search with the selected search engine."));
|
||||
m_urlFilter.setDefaultShortcutString("r");
|
||||
m_urlFilter.addDefaultUrl("https://www.bing.com/search?q=%1");
|
||||
m_urlFilter.addDefaultUrl("https://www.google.com/search?q=%1");
|
||||
@@ -75,6 +76,7 @@ LocatorData::LocatorData()
|
||||
"http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=%1");
|
||||
m_urlFilter.addDefaultUrl("https://en.wikipedia.org/w/index.php?search=%1");
|
||||
|
||||
m_bugFilter.setDescription(Tr::tr("Triggers a search in the Qt bug tracker."));
|
||||
m_bugFilter.setDefaultShortcutString("bug");
|
||||
m_bugFilter.addDefaultUrl("https://bugreports.qt.io/secure/QuickSearch.jspa?searchString=%1");
|
||||
}
|
||||
|
||||
@@ -101,8 +101,10 @@ QVariant FilterItem::data(int column, int role) const
|
||||
break;
|
||||
}
|
||||
|
||||
if (role == Qt::ToolTipRole)
|
||||
return m_filter->description();
|
||||
if (role == Qt::ToolTipRole) {
|
||||
const QString description = m_filter->description();
|
||||
return description.isEmpty() ? QString() : ("<html>" + description.toHtmlEscaped());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/tooltip/tooltip.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
@@ -599,6 +600,10 @@ LocatorWidget::LocatorWidget(Locator *locator)
|
||||
connect(m_filterMenu, &QMenu::aboutToShow, this, [this] {
|
||||
m_centeredPopupAction->setChecked(Locator::useCenteredPopupForShortcut());
|
||||
});
|
||||
connect(m_filterMenu, &QMenu::hovered, this, [this](QAction *action) {
|
||||
ToolTip::show(m_filterMenu->mapToGlobal(m_filterMenu->actionGeometry(action).topRight()),
|
||||
action->toolTip());
|
||||
});
|
||||
connect(m_centeredPopupAction, &QAction::toggled, locator, [locator](bool toggled) {
|
||||
if (toggled != Locator::useCenteredPopupForShortcut()) {
|
||||
Locator::setUseCenteredPopupForShortcut(toggled);
|
||||
@@ -672,12 +677,20 @@ void LocatorWidget::updatePlaceholderText(Command *command)
|
||||
void LocatorWidget::updateFilterList()
|
||||
{
|
||||
m_filterMenu->clear();
|
||||
const QList<ILocatorFilter *> filters = Locator::filters();
|
||||
const QList<ILocatorFilter *> filters = Utils::sorted(Locator::filters(),
|
||||
[](ILocatorFilter *a, ILocatorFilter *b) {
|
||||
return a->displayName()
|
||||
< b->displayName();
|
||||
});
|
||||
for (ILocatorFilter *filter : filters) {
|
||||
if (filter->shortcutString().isEmpty() || filter->isHidden())
|
||||
continue;
|
||||
QAction *action = m_filterMenu->addAction(filter->displayName());
|
||||
action->setToolTip(filter->description());
|
||||
action->setEnabled(filter->isEnabled());
|
||||
const QString description = filter->description();
|
||||
action->setToolTip(description.isEmpty() ? QString()
|
||||
: ("<html>" + description.toHtmlEscaped()));
|
||||
connect(filter, &ILocatorFilter::enabledChanged, action, &QAction::setEnabled);
|
||||
connect(action, &QAction::triggered, this, [this, filter] {
|
||||
Locator::showFilter(filter, this);
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ OpenDocumentsFilter::OpenDocumentsFilter()
|
||||
{
|
||||
setId("Open documents");
|
||||
setDisplayName(Tr::tr("Open Documents"));
|
||||
setDescription(Tr::tr("Switches to an open document."));
|
||||
setDefaultShortcutString("o");
|
||||
setPriority(High);
|
||||
setDefaultIncludedByDefault(true);
|
||||
|
||||
@@ -225,10 +225,10 @@ SpotlightLocatorFilter::SpotlightLocatorFilter()
|
||||
setDefaultShortcutString("md");
|
||||
setDefaultIncludedByDefault(false);
|
||||
setDisplayName(Tr::tr("File Name Index"));
|
||||
setDescription(
|
||||
Tr::tr("Matches files from a global file system index (Spotlight, Locate, Everything). Append "
|
||||
"\"+<number>\" or \":<number>\" to jump to the given line number. Append another "
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
setDescription(Tr::tr(
|
||||
"Locates files from a global file system index (Spotlight, Locate, Everything). Append "
|
||||
"\"+<number>\" or \":<number>\" to jump to the given line number. Append another "
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
setConfigurable(true);
|
||||
reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user