forked from qt-creator/qt-creator
Shortcut for just opening search dialog with last filter.
Task-number: 237733
This commit is contained in:
@@ -105,6 +105,14 @@ void FindPlugin::filterChanged()
|
|||||||
QTC_ASSERT(changedFilter, return);
|
QTC_ASSERT(changedFilter, return);
|
||||||
QTC_ASSERT(action, return);
|
QTC_ASSERT(action, return);
|
||||||
action->setEnabled(changedFilter->isEnabled());
|
action->setEnabled(changedFilter->isEnabled());
|
||||||
|
bool haveEnabledFilters = false;
|
||||||
|
foreach (IFindFilter *filter, m_filterActions.keys()) {
|
||||||
|
if (filter->isEnabled()) {
|
||||||
|
haveEnabledFilters = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindPlugin::openFindFilter()
|
void FindPlugin::openFindFilter()
|
||||||
@@ -112,8 +120,6 @@ void FindPlugin::openFindFilter()
|
|||||||
QAction *action = qobject_cast<QAction*>(sender());
|
QAction *action = qobject_cast<QAction*>(sender());
|
||||||
QTC_ASSERT(action, return);
|
QTC_ASSERT(action, return);
|
||||||
IFindFilter *filter = action->data().value<IFindFilter *>();
|
IFindFilter *filter = action->data().value<IFindFilter *>();
|
||||||
QTC_ASSERT(filter, return);
|
|
||||||
QTC_ASSERT(filter->isEnabled(), return);
|
|
||||||
QString currentFindString = (m_currentDocumentFind->isEnabled() ? m_currentDocumentFind->currentFindString() : "");
|
QString currentFindString = (m_currentDocumentFind->isEnabled() ? m_currentDocumentFind->currentFindString() : "");
|
||||||
if (!currentFindString.isEmpty())
|
if (!currentFindString.isEmpty())
|
||||||
m_findDialog->setFindText(currentFindString);
|
m_findDialog->setFindText(currentFindString);
|
||||||
@@ -127,6 +133,7 @@ void FindPlugin::setupMenu()
|
|||||||
Core::ActionContainer *mfind = am->createMenu(Constants::M_FIND);
|
Core::ActionContainer *mfind = am->createMenu(Constants::M_FIND);
|
||||||
medit->addMenu(mfind, Core::Constants::G_EDIT_FIND);
|
medit->addMenu(mfind, Core::Constants::G_EDIT_FIND);
|
||||||
mfind->menu()->setTitle(tr("&Find/Replace"));
|
mfind->menu()->setTitle(tr("&Find/Replace"));
|
||||||
|
mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT);
|
||||||
mfind->appendGroup(Constants::G_FIND_FILTERS);
|
mfind->appendGroup(Constants::G_FIND_FILTERS);
|
||||||
mfind->appendGroup(Constants::G_FIND_FLAGS);
|
mfind->appendGroup(Constants::G_FIND_FLAGS);
|
||||||
mfind->appendGroup(Constants::G_FIND_ACTIONS);
|
mfind->appendGroup(Constants::G_FIND_ACTIONS);
|
||||||
@@ -141,6 +148,12 @@ void FindPlugin::setupMenu()
|
|||||||
separator->setSeparator(true);
|
separator->setSeparator(true);
|
||||||
cmd = am->registerAction(separator, QLatin1String("Find.Sep.Actions"), globalcontext);
|
cmd = am->registerAction(separator, QLatin1String("Find.Sep.Actions"), globalcontext);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
||||||
|
|
||||||
|
m_openFindDialog = new QAction(tr("Find Dialog"), this);
|
||||||
|
cmd = am->registerAction(m_openFindDialog, QLatin1String("Find.Dialog"), globalcontext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
|
||||||
|
mfind->addAction(cmd, Constants::G_FIND_FILTERS);
|
||||||
|
connect(m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindPlugin::setupFilterMenuItems()
|
void FindPlugin::setupFilterMenuItems()
|
||||||
@@ -153,9 +166,13 @@ void FindPlugin::setupFilterMenuItems()
|
|||||||
|
|
||||||
Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND);
|
Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND);
|
||||||
m_filterActions.clear();
|
m_filterActions.clear();
|
||||||
|
bool haveEnabledFilters = false;
|
||||||
foreach (IFindFilter *filter, findInterfaces) {
|
foreach (IFindFilter *filter, findInterfaces) {
|
||||||
QAction *action = new QAction(filter->name(), this);
|
QAction *action = new QAction(QString(" %1").arg(filter->name()), this);
|
||||||
action->setEnabled(filter->isEnabled());
|
bool isEnabled = filter->isEnabled();
|
||||||
|
if (isEnabled)
|
||||||
|
haveEnabledFilters = true;
|
||||||
|
action->setEnabled(isEnabled);
|
||||||
action->setData(qVariantFromValue(filter));
|
action->setData(qVariantFromValue(filter));
|
||||||
cmd = am->registerAction(action, QLatin1String("FindFilter.")+filter->name(), globalcontext);
|
cmd = am->registerAction(action, QLatin1String("FindFilter.")+filter->name(), globalcontext);
|
||||||
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
||||||
@@ -165,6 +182,8 @@ void FindPlugin::setupFilterMenuItems()
|
|||||||
connect(filter, SIGNAL(changed()), this, SLOT(filterChanged()));
|
connect(filter, SIGNAL(changed()), this, SLOT(filterChanged()));
|
||||||
}
|
}
|
||||||
m_findDialog->setFindFilters(findInterfaces);
|
m_findDialog->setFindFilters(findInterfaces);
|
||||||
|
m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument::FindFlags FindPlugin::findFlags() const
|
QTextDocument::FindFlags FindPlugin::findFlags() const
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ private:
|
|||||||
QStringListModel *m_replaceCompletionModel;
|
QStringListModel *m_replaceCompletionModel;
|
||||||
QStringList m_findCompletions;
|
QStringList m_findCompletions;
|
||||||
QStringList m_replaceCompletions;
|
QStringList m_replaceCompletions;
|
||||||
|
QAction *m_openFindDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
|||||||
m_findInDocumentAction = new QAction(tr("Current Document"), this);
|
m_findInDocumentAction = new QAction(tr("Current Document"), this);
|
||||||
cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext);
|
cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence::Find);
|
cmd->setDefaultKeySequence(QKeySequence::Find);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FILTERS);
|
mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT);
|
||||||
connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind()));
|
connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind()));
|
||||||
|
|
||||||
if (QApplication::clipboard()->supportsFindBuffer()) {
|
if (QApplication::clipboard()->supportsFindBuffer()) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace Find {
|
|||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
const char * const M_FIND = "Find.FindMenu";
|
const char * const M_FIND = "Find.FindMenu";
|
||||||
|
const char * const G_FIND_CURRENTDOCUMENT = "Find.FindMenu.CurrentDocument";
|
||||||
const char * const G_FIND_FILTERS = "Find.FindMenu.Filters";
|
const char * const G_FIND_FILTERS = "Find.FindMenu.Filters";
|
||||||
const char * const G_FIND_FLAGS = "Find.FindMenu.Flags";
|
const char * const G_FIND_FLAGS = "Find.FindMenu.Flags";
|
||||||
const char * const G_FIND_ACTIONS = "Find.FindMenu.Actions";
|
const char * const G_FIND_ACTIONS = "Find.FindMenu.Actions";
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ bool AllProjectsFind::isEnabled() const
|
|||||||
|
|
||||||
QKeySequence AllProjectsFind::defaultShortcut() const
|
QKeySequence AllProjectsFind::defaultShortcut() const
|
||||||
{
|
{
|
||||||
return QKeySequence("Ctrl+Shift+F");
|
return QKeySequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AllProjectsFind::files()
|
QStringList AllProjectsFind::files()
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ bool CurrentProjectFind::isEnabled() const
|
|||||||
|
|
||||||
QKeySequence CurrentProjectFind::defaultShortcut() const
|
QKeySequence CurrentProjectFind::defaultShortcut() const
|
||||||
{
|
{
|
||||||
return QKeySequence("Ctrl+Alt+F");
|
return QKeySequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CurrentProjectFind::files()
|
QStringList CurrentProjectFind::files()
|
||||||
|
|||||||
Reference in New Issue
Block a user