summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcon <qtc-committer@nokia.com>2009-11-23 12:40:08 +0100
committercon <qtc-committer@nokia.com>2009-11-23 12:40:39 +0100
commit51809d12a76784c379ada51bf812ac901952a730 (patch)
tree84c60d52f0514468b59e976b65b65cff89ef8455 /src
parent298769ce71136fb0905d61b9c0963052f48c8e19 (diff)
downloadqt-creator-51809d12a76784c379ada51bf812ac901952a730.tar.gz
Fix the document history popup for cocoa.
Get rid of the hide timer and check modifier keys directly before showing the open documents popup at all. Task-number: QTCREATORBUG-258
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp18
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h2
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp25
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.h6
4 files changed, 23 insertions, 28 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 7f4db0b13a..de6dde0325 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1419,7 +1419,7 @@ void EditorManager::gotoNextDocHistory()
EditorView *view = currentEditorView();
dialog->setEditors(m_d->m_view, view, m_d->m_editorModel);
dialog->selectNextEditor();
- showWindowPopup();
+ showPopupOrSelectDocument();
}
}
@@ -1432,7 +1432,7 @@ void EditorManager::gotoPreviousDocHistory()
EditorView *view = currentEditorView();
dialog->setEditors(m_d->m_view, view, m_d->m_editorModel);
dialog->selectPreviousEditor();
- showWindowPopup();
+ showPopupOrSelectDocument();
}
}
@@ -1535,12 +1535,16 @@ OpenEditorsWindow *EditorManager::windowPopup() const
return m_d->m_windowPopup;
}
-void EditorManager::showWindowPopup() const
+void EditorManager::showPopupOrSelectDocument() const
{
- const QPoint p(mapToGlobal(QPoint(0, 0)));
- m_d->m_windowPopup->move((width()-m_d->m_windowPopup->width())/2 + p.x(),
- (height()-m_d->m_windowPopup->height())/2 + p.y());
- m_d->m_windowPopup->setVisible(true);
+ if (QApplication::keyboardModifiers() == Qt::NoModifier) {
+ windowPopup()->selectAndHide();
+ } else {
+ const QPoint p(mapToGlobal(QPoint(0, 0)));
+ windowPopup()->move((width()-m_d->m_windowPopup->width())/2 + p.x(),
+ (height()-m_d->m_windowPopup->height())/2 + p.y());
+ windowPopup()->setVisible(true);
+ }
}
QByteArray EditorManager::saveState() const
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index 06e88b8bf9..44febeba42 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -159,7 +159,7 @@ public:
void readSettings();
Internal::OpenEditorsWindow *windowPopup() const;
- void showWindowPopup() const;
+ void showPopupOrSelectDocument() const;
void showEditorInfoBar(const QString &kind,
const QString &infoText,
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 6079ee7e60..8a428d87bf 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -63,9 +63,6 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
connect(m_editorList, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
this, SLOT(editorClicked(QTreeWidgetItem*)));
-
- m_autoHide.setSingleShot(true);
- connect(&m_autoHide, SIGNAL(timeout()), this, SLOT(selectAndHide()));
}
void OpenEditorsWindow::selectAndHide()
@@ -78,7 +75,6 @@ void OpenEditorsWindow::setVisible(bool visible)
{
QWidget::setVisible(visible);
if (visible) {
- m_autoHide.start(600);
setFocus();
}
}
@@ -96,19 +92,6 @@ bool OpenEditorsWindow::isCentering()
}
-bool OpenEditorsWindow::event(QEvent *e) {
- if (e->type() == QEvent::KeyRelease) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
- m_autoHide.stop();
- if (ke->modifiers() == 0
- /*HACK this is to overcome some event inconsistencies between platforms*/
- || (ke->modifiers() == Qt::AltModifier && (ke->key() == Qt::Key_Alt || ke->key() == -1))) {
- selectAndHide();
- }
- }
- return QWidget::event(e);
-}
-
bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e)
{
if (obj == m_editorList) {
@@ -122,6 +105,14 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e)
selectEditor(m_editorList->currentItem());
return true;
}
+ } else if (e->type() == QEvent::KeyRelease) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+ if (ke->modifiers() == 0
+ /*HACK this is to overcome some event inconsistencies between platforms*/
+ || (ke->modifiers() == Qt::AltModifier
+ && (ke->key() == Qt::Key_Alt || ke->key() == -1))) {
+ selectAndHide();
+ }
}
}
return QWidget::eventFilter(obj, e);
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.h b/src/plugins/coreplugin/editormanager/openeditorswindow.h
index 12175d66b0..b883170f06 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.h
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.h
@@ -59,17 +59,18 @@ public:
void setEditors(EditorView *mainView, EditorView *view, OpenEditorsModel *model);
- bool event(QEvent *e);
bool eventFilter(QObject *src, QEvent *e);
void focusInEvent(QFocusEvent *);
void setVisible(bool visible);
void selectNextEditor();
void selectPreviousEditor();
+public slots:
+ void selectAndHide();
+
private slots:
void editorClicked(QTreeWidgetItem *item);
void selectEditor(QTreeWidgetItem *item);
- void selectAndHide();
private:
static const int WIDTH;
@@ -85,7 +86,6 @@ private:
bool isSameFile(IEditor *editorA, IEditor *editorB) const;
QTreeWidget *m_editorList;
- QTimer m_autoHide;
};
} // namespace Internal