Commit 1532bffd authored by Kåre Särs's avatar Kåre Särs
Browse files

Enable Copy and SelectAll key-sequences in popup

+ fix last missing QPointer
parent 86a8d06e
...@@ -142,6 +142,8 @@ public: ...@@ -142,6 +142,8 @@ public:
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_htmlHl.setDefinition(m_syntaxHlRepo.definitionForName(QStringLiteral("Diff")));
auto updateColors = [this](KTextEditor::Editor *e) { auto updateColors = [this](KTextEditor::Editor *e) {
auto theme = e->theme(); auto theme = e->theme();
m_htmlHl.setTheme(theme); m_htmlHl.setTheme(theme);
...@@ -163,7 +165,32 @@ public: ...@@ -163,7 +165,32 @@ public:
{ {
switch (event->type()) { switch (event->type()) {
case QEvent::KeyPress: case QEvent::KeyPress:
case QEvent::ShortcutOverride:
{
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->matches(QKeySequence::Copy)) {
copy();
}
else if (ke->matches(QKeySequence::SelectAll)) {
selectAll();
}
event->accept();
return true;
}
case QEvent::KeyRelease: case QEvent::KeyRelease:
{
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->matches(QKeySequence::Copy) ||
ke->matches(QKeySequence::SelectAll) ||
ke->key() == Qt::Key_Control ||
ke->key() == Qt::Key_Alt ||
ke->key() == Qt::Key_Shift ||
ke->key() == Qt::Key_AltGr ||
ke->key() == Qt::Key_Meta) {
event->accept();
return true;
}
} // fall through
case QEvent::WindowActivate: case QEvent::WindowActivate:
case QEvent::WindowDeactivate: case QEvent::WindowDeactivate:
hideTooltip(); hideTooltip();
...@@ -183,7 +210,7 @@ public: ...@@ -183,7 +210,7 @@ public:
setHtml(m_htmlHl.html()); setHtml(m_htmlHl.html());
} }
void setView(KTextEditor::View *view) void setView(QPointer<KTextEditor::View> view)
{ {
// view changed? // view changed?
// => update definition // => update definition
...@@ -195,12 +222,11 @@ public: ...@@ -195,12 +222,11 @@ public:
m_view = view; m_view = view;
m_htmlHl.setDefinition(m_syntaxHlRepo.definitionForName(QStringLiteral("Diff")));
updateFont(); updateFont();
}
if (m_view && m_view->focusProxy()) { if (m_view && m_view->focusProxy()) {
m_view->focusProxy()->installEventFilter(this); m_view->focusProxy()->installEventFilter(this);
}
} }
} }
...@@ -216,6 +242,9 @@ public: ...@@ -216,6 +242,9 @@ public:
Q_SLOT void hideTooltip() Q_SLOT void hideTooltip()
{ {
if (m_view && m_view->focusProxy()) {
m_view->focusProxy()->removeEventFilter(this);
}
close(); close();
setText(QString()); setText(QString());
} }
......
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