forked from qt-creator/qt-creator
Utils::HostOsInfo: Introduce controlModifier() method.
Change-Id: Ibd244963c5cd643fc0e8358ceabff0ad5f6599eb Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -72,6 +72,11 @@ public:
|
|||||||
{
|
{
|
||||||
return isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
|
return isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Qt::KeyboardModifier controlModifier()
|
||||||
|
{
|
||||||
|
return isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HostOsInfo::HostOs HostOsInfo::hostOs()
|
HostOsInfo::HostOs HostOsInfo::hostOs()
|
||||||
|
|||||||
@@ -131,16 +131,8 @@ namespace Internal {
|
|||||||
|
|
||||||
#define EDITOR(s) (m_textedit ? m_textedit->s : m_plaintextedit->s)
|
#define EDITOR(s) (m_textedit ? m_textedit->s : m_plaintextedit->s)
|
||||||
|
|
||||||
enum {
|
#define MetaModifier // Use HostOsInfo::controlModifier() instead
|
||||||
#ifdef Q_OS_MAC
|
#define ControlModifier // Use HostOsInfo::controlModifier() instead
|
||||||
RealControlModifier = Qt::MetaModifier
|
|
||||||
#else
|
|
||||||
RealControlModifier = Qt::ControlModifier
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
// Enforce use of RealControlModifier by breaking the compilation.
|
|
||||||
#define MetaModifier // Use RealControlModifier instead
|
|
||||||
#define ControlModifier // Use RealControlModifier instead
|
|
||||||
|
|
||||||
typedef QLatin1String _;
|
typedef QLatin1String _;
|
||||||
|
|
||||||
@@ -602,12 +594,12 @@ public:
|
|||||||
|
|
||||||
bool is(int c) const
|
bool is(int c) const
|
||||||
{
|
{
|
||||||
return m_xkey == c && m_modifiers != RealControlModifier;
|
return m_xkey == c && m_modifiers != int(HostOsInfo::controlModifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isControl(int c) const
|
bool isControl(int c) const
|
||||||
{
|
{
|
||||||
return m_modifiers == RealControlModifier
|
return m_modifiers == int(HostOsInfo::controlModifier())
|
||||||
&& (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
|
&& (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,7 +781,7 @@ static Input parseVimKeyName(const QString &keyName)
|
|||||||
if (key == "S")
|
if (key == "S")
|
||||||
mods |= Qt::ShiftModifier;
|
mods |= Qt::ShiftModifier;
|
||||||
else if (key == "C")
|
else if (key == "C")
|
||||||
mods |= RealControlModifier;
|
mods |= HostOsInfo::controlModifier();
|
||||||
else
|
else
|
||||||
return Input();
|
return Input();
|
||||||
}
|
}
|
||||||
@@ -1618,7 +1610,7 @@ bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We are interested in overriding most Ctrl key combinations.
|
// We are interested in overriding most Ctrl key combinations.
|
||||||
if (mods == RealControlModifier
|
if (mods == int(HostOsInfo::controlModifier())
|
||||||
&& !config(ConfigPassControlKey).toBool()
|
&& !config(ConfigPassControlKey).toBool()
|
||||||
&& ((key >= Key_A && key <= Key_Z && key != Key_K)
|
&& ((key >= Key_A && key <= Key_Z && key != Key_K)
|
||||||
|| key == Key_BracketLeft || key == Key_BracketRight)) {
|
|| key == Key_BracketLeft || key == Key_BracketRight)) {
|
||||||
@@ -1824,7 +1816,7 @@ void FakeVimHandler::Private::importSelection()
|
|||||||
// Import new selection.
|
// Import new selection.
|
||||||
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
|
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
|
||||||
if (cursor().hasSelection()) {
|
if (cursor().hasSelection()) {
|
||||||
if (mods & RealControlModifier)
|
if (mods & HostOsInfo::controlModifier())
|
||||||
m_visualMode = VisualBlockMode;
|
m_visualMode = VisualBlockMode;
|
||||||
else if (mods & Qt::AltModifier)
|
else if (mods & Qt::AltModifier)
|
||||||
m_visualMode = VisualBlockMode;
|
m_visualMode = VisualBlockMode;
|
||||||
|
|||||||
@@ -291,12 +291,10 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Qt::KeyboardModifier modifier = Utils::HostOsInfo::isMacHost()
|
|
||||||
? Qt::ControlModifier : Qt::MetaModifier;
|
|
||||||
if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
|
if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
|
||||||
&& event->type() == QEvent::KeyPress) {
|
&& event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
||||||
if (ke->key() == Qt::Key_Space && (ke->modifiers() & modifier)) {
|
if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
|
||||||
QString completedText = m_currentDocumentFind->completedFindString();
|
QString completedText = m_currentDocumentFind->completedFindString();
|
||||||
if (!completedText.isEmpty()) {
|
if (!completedText.isEmpty()) {
|
||||||
setFindText(completedText);
|
setFindText(completedText);
|
||||||
@@ -313,7 +311,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (ke->key() == Qt::Key_Space && (ke->modifiers() & modifier)) {
|
} else if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1823,9 +1823,6 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Qt::KeyboardModifiers modifiers
|
|
||||||
= HostOsInfo::isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
|
|
||||||
|
|
||||||
if (!ro && d->m_inBlockSelectionMode) {
|
if (!ro && d->m_inBlockSelectionMode) {
|
||||||
QString text = e->text();
|
QString text = e->text();
|
||||||
if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
|
if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
|
||||||
@@ -1834,7 +1831,8 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->key() == Qt::Key_H && e->modifiers() == modifiers) {
|
if (e->key() == Qt::Key_H
|
||||||
|
&& e->modifiers() == Qt::KeyboardModifiers(HostOsInfo::controlModifier())) {
|
||||||
universalHelper();
|
universalHelper();
|
||||||
e->accept();
|
e->accept();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -516,8 +516,6 @@ void GenericProposalWidget::updatePositionAndSize()
|
|||||||
|
|
||||||
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
||||||
{
|
{
|
||||||
const Qt::KeyboardModifiers modifier = HostOsInfo::isMacHost()
|
|
||||||
? Qt::MetaModifier : Qt::ControlModifier;
|
|
||||||
if (e->type() == QEvent::FocusOut) {
|
if (e->type() == QEvent::FocusOut) {
|
||||||
abort();
|
abort();
|
||||||
#if (QT_VERSION < 0x050000) && defined(Q_OS_DARWIN) && ! defined(QT_MAC_USE_COCOA)
|
#if (QT_VERSION < 0x050000) && defined(Q_OS_DARWIN) && ! defined(QT_MAC_USE_COCOA)
|
||||||
@@ -538,7 +536,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
|||||||
switch (ke->key()) {
|
switch (ke->key()) {
|
||||||
case Qt::Key_N:
|
case Qt::Key_N:
|
||||||
case Qt::Key_P:
|
case Qt::Key_P:
|
||||||
if (ke->modifiers() == modifier) {
|
if (ke->modifiers() == Qt::KeyboardModifiers(HostOsInfo::controlModifier())) {
|
||||||
e->accept();
|
e->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -554,7 +552,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
|||||||
case Qt::Key_P:
|
case Qt::Key_P:
|
||||||
// select next/previous completion
|
// select next/previous completion
|
||||||
d->m_explicitlySelected = true;
|
d->m_explicitlySelected = true;
|
||||||
if (ke->modifiers() == modifier) {
|
if (ke->modifiers() == Qt::KeyboardModifiers(HostOsInfo::controlModifier())) {
|
||||||
int change = (ke->key() == Qt::Key_N) ? 1 : -1;
|
int change = (ke->key() == Qt::Key_N) ? 1 : -1;
|
||||||
int nrows = d->m_model->size();
|
int nrows = d->m_model->size();
|
||||||
int row = d->m_completionListView->currentIndex().row();
|
int row = d->m_completionListView->currentIndex().row();
|
||||||
|
|||||||
Reference in New Issue
Block a user