Commit cf99bcef authored by Kåre Särs's avatar Kåre Särs

Add a signal to let plugins detect unhandled ShortcutOverride's (Esc)

REVIEW:104466
parent 5e5cf873
......@@ -962,5 +962,13 @@ void KateMainWindow::queueModifiedOnDisc(KTextEditor::Document *doc)
}
}
bool KateMainWindow::event( QEvent *e )
{
if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent *k = static_cast<QKeyEvent *>(e);
emit unhandledShortcutOverride (k);
}
return KateMDI::MainWindow::event(e);
}
// kate: space-indent on; indent-width 2; replace-tabs on;
......@@ -222,6 +222,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
Q_SIGNALS:
void statusBarToggled ();
void unhandledShortcutOverride (QEvent *e);
public:
void openUrl (const QString &name = QString());
......@@ -309,6 +310,8 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
public Q_SLOTS:
void showPluginConfigPage(Kate::PluginConfigPageInterface *configpageinterface,uint id);
protected:
virtual bool event( QEvent *e );
};
#endif
......
......@@ -46,6 +46,8 @@ namespace Kate
{
d = new PrivateMainWindow;
d->win = (KateMainWindow*) mainWindow;
connect(d->win, SIGNAL(unhandledShortcutOverride(QEvent*)),
this, SIGNAL(unhandledShortcutOverride(QEvent*)));
}
MainWindow::~MainWindow ()
......
......@@ -163,6 +163,11 @@ namespace Kate
void viewCreated(KTextEditor::View * view);
/**
* This signal is emitted for every unhandled ShortcutOverride in a view
*/
void unhandledShortcutOverride (QEvent *e);
/*
* ToolView stuff, here all stuff belong which allows to
* add/remove and manipulate the toolview of this main windows
......
......@@ -189,7 +189,7 @@ m_curResults(0)
m_ui.topLayout->setColumnMinimumWidth(0, padWidth);
m_ui.topLayout->setAlignment(m_ui.newTabButton, Qt::AlignHCenter);
m_ui.optionsLayout->setColumnMinimumWidth(0, padWidth);
// the order here is important to get the tabBar hidden for only one tab
addTab();
m_ui.resultTabWidget->tabBar()->hide();
......@@ -247,6 +247,9 @@ m_curResults(0)
connect(m_ui.searchCombo, SIGNAL(customContextMenuRequested(QPoint)), this,
SLOT(searchContextMenu(QPoint)));
connect(mainWindow(), SIGNAL(unhandledShortcutOverride(QEvent*)),
this, SLOT(handleEsc(QEvent*)));
m_replacer.setDocumentManager(m_kateApp->documentManager());
searchPlaceChanged();
......@@ -312,6 +315,22 @@ void KatePluginSearchView::openSearchView()
}
}
void KatePluginSearchView::handleEsc(QEvent *e)
{
if (!mainWindow()) return;
QKeyEvent *k = static_cast<QKeyEvent *>(e);
if (k->key() == Qt::Key_Escape && k->modifiers() == Qt::NoModifier) {
if (m_toolView->isVisible()) {
mainWindow()->hideToolView(m_toolView);
}
else {
clearMarks();
}
}
}
void KatePluginSearchView::setSearchString(const QString &pattern)
{
m_ui.searchCombo->lineEdit()->setText(pattern);
......@@ -835,7 +854,6 @@ bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event)
}
if ((obj == m_toolView) && (ke->key() == Qt::Key_Escape)) {
mainWindow()->hideToolView(m_toolView);
clearMarks();
event->accept();
return true;
}
......
......@@ -91,6 +91,7 @@ public Q_SLOTS:
private Q_SLOTS:
void openSearchView();
void handleEsc(QEvent *e);
void addTab();
void closeTab(QWidget *widget);
void toggleOptions(bool show);
......
......@@ -1481,9 +1481,13 @@ void KateSearchBar::enterIncrementalMode() {
}
void KateSearchBar::clearHighlights() {
bool KateSearchBar::clearHighlights() {
if (m_hlRanges.isEmpty()) {
return false;
}
qDeleteAll(m_hlRanges);
m_hlRanges.clear();
return true;
}
void KateSearchBar::updateHighlightColors()
......
......@@ -109,7 +109,7 @@ public Q_SLOTS:
void enterPowerMode();
void enterIncrementalMode();
void clearHighlights();
bool clearHighlights();
void updateHighlightColors();
protected:
......
......@@ -2157,9 +2157,11 @@ bool KateViewInternal::eventFilter( QObject *obj, QEvent *e )
return true;
} else if (m_view->hasSearchBar()) {
// hide search&replace highlights
m_view->searchBar()->clearHighlights();
k->accept();
return true;
if (m_view->searchBar()->clearHighlights()) {
k->accept();
//kDebug() << obj << "shortcut override" << k->key() << "hide search&replace highlights";
return true;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment