Commit 51809d12 authored by con's avatar con
Browse files

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
parent 298769ce
......@@ -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
......
......@@ -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,
......
......@@ -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);
......
......@@ -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
......
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