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(':');
|
||||
}
|
||||
|
||||
static Qt::KeyboardModifier controlModifier()
|
||||
{
|
||||
return isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
|
||||
}
|
||||
};
|
||||
|
||||
HostOsInfo::HostOs HostOsInfo::hostOs()
|
||||
|
||||
@@ -131,16 +131,8 @@ namespace Internal {
|
||||
|
||||
#define EDITOR(s) (m_textedit ? m_textedit->s : m_plaintextedit->s)
|
||||
|
||||
enum {
|
||||
#ifdef Q_OS_MAC
|
||||
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
|
||||
#define MetaModifier // Use HostOsInfo::controlModifier() instead
|
||||
#define ControlModifier // Use HostOsInfo::controlModifier() instead
|
||||
|
||||
typedef QLatin1String _;
|
||||
|
||||
@@ -602,12 +594,12 @@ public:
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -789,7 +781,7 @@ static Input parseVimKeyName(const QString &keyName)
|
||||
if (key == "S")
|
||||
mods |= Qt::ShiftModifier;
|
||||
else if (key == "C")
|
||||
mods |= RealControlModifier;
|
||||
mods |= HostOsInfo::controlModifier();
|
||||
else
|
||||
return Input();
|
||||
}
|
||||
@@ -1618,7 +1610,7 @@ bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev)
|
||||
}
|
||||
|
||||
// We are interested in overriding most Ctrl key combinations.
|
||||
if (mods == RealControlModifier
|
||||
if (mods == int(HostOsInfo::controlModifier())
|
||||
&& !config(ConfigPassControlKey).toBool()
|
||||
&& ((key >= Key_A && key <= Key_Z && key != Key_K)
|
||||
|| key == Key_BracketLeft || key == Key_BracketRight)) {
|
||||
@@ -1824,7 +1816,7 @@ void FakeVimHandler::Private::importSelection()
|
||||
// Import new selection.
|
||||
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
|
||||
if (cursor().hasSelection()) {
|
||||
if (mods & RealControlModifier)
|
||||
if (mods & HostOsInfo::controlModifier())
|
||||
m_visualMode = VisualBlockMode;
|
||||
else if (mods & Qt::AltModifier)
|
||||
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())
|
||||
&& event->type() == QEvent::KeyPress) {
|
||||
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();
|
||||
if (!completedText.isEmpty()) {
|
||||
setFindText(completedText);
|
||||
@@ -313,7 +311,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
|
||||
event->accept();
|
||||
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();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1823,9 +1823,6 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
const Qt::KeyboardModifiers modifiers
|
||||
= HostOsInfo::isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
|
||||
|
||||
if (!ro && d->m_inBlockSelectionMode) {
|
||||
QString text = e->text();
|
||||
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();
|
||||
e->accept();
|
||||
return;
|
||||
|
||||
@@ -516,8 +516,6 @@ void GenericProposalWidget::updatePositionAndSize()
|
||||
|
||||
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
const Qt::KeyboardModifiers modifier = HostOsInfo::isMacHost()
|
||||
? Qt::MetaModifier : Qt::ControlModifier;
|
||||
if (e->type() == QEvent::FocusOut) {
|
||||
abort();
|
||||
#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()) {
|
||||
case Qt::Key_N:
|
||||
case Qt::Key_P:
|
||||
if (ke->modifiers() == modifier) {
|
||||
if (ke->modifiers() == Qt::KeyboardModifiers(HostOsInfo::controlModifier())) {
|
||||
e->accept();
|
||||
return true;
|
||||
}
|
||||
@@ -554,7 +552,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
||||
case Qt::Key_P:
|
||||
// select next/previous completion
|
||||
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 nrows = d->m_model->size();
|
||||
int row = d->m_completionListView->currentIndex().row();
|
||||
|
||||
Reference in New Issue
Block a user