summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@nokia.com>2012-09-07 13:31:29 +0200
committerChristian Kandeler <christian.kandeler@nokia.com>2012-09-13 10:14:53 +0200
commit405217c111d22ea2b2913fd08b4f870e4e43aa38 (patch)
tree0e4a5e760c7732396d7ed2c341ec3abeaae5558f /src
parent09674e47078a40a6f0cef8e707f380c46b211124 (diff)
downloadqt-creator-405217c111d22ea2b2913fd08b4f870e4e43aa38.tar.gz
Utils::HostOsInfo: Introduce controlModifier() method.
Change-Id: Ibd244963c5cd643fc0e8358ceabff0ad5f6599eb Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/hostosinfo.h5
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp22
-rw-r--r--src/plugins/find/findtoolbar.cpp6
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp6
-rw-r--r--src/plugins/texteditor/codeassist/genericproposalwidget.cpp6
5 files changed, 18 insertions, 27 deletions
diff --git a/src/libs/utils/hostosinfo.h b/src/libs/utils/hostosinfo.h
index b5d85f2c62..0f945bb0b6 100644
--- a/src/libs/utils/hostosinfo.h
+++ b/src/libs/utils/hostosinfo.h
@@ -72,6 +72,11 @@ public:
{
return isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
}
+
+ static Qt::KeyboardModifier controlModifier()
+ {
+ return isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
+ }
};
HostOsInfo::HostOs HostOsInfo::hostOs()
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 9d9d58ff38..0b6d6d88c5 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -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;
diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp
index 0ea7307bae..d238f65457 100644
--- a/src/plugins/find/findtoolbar.cpp
+++ b/src/plugins/find/findtoolbar.cpp
@@ -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;
}
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index ef093503a8..c766290034 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -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;
diff --git a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
index d7d6af7e1a..fce4f33299 100644
--- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
+++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
@@ -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();