Make find options in tool bar more accessible.

Open a popup that doesn't close on every change of an option.
Make the options button accessible through tab.

Task-number: QTCREATORBUG-11340

Change-Id: I61b83243ead4b0b3d7075c1e8f8327cd31d9c2c4
Reviewed-by: Bojan Petrovic <bojan85@gmail.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Eike Ziller
2014-02-25 18:38:35 +01:00
parent 880a834b11
commit 8e51a93d37
4 changed files with 156 additions and 14 deletions

View File

@@ -30,13 +30,14 @@
#include "execmenu.h"
#include "fancylineedit.h"
#include "historycompleter.h"
#include "hostosinfo.h"
#include "qtcassert.h"
#include <QAbstractItemView>
#include <QDebug>
#include <QKeyEvent>
#include <QMenu>
#include <QPainter>
#include <QStylePainter>
#include <QPropertyAnimation>
#include <QStyle>
@@ -184,6 +185,11 @@ bool FancyLineEdit::isButtonVisible(Side side) const
return d->m_iconEnabled[side];
}
QAbstractButton *FancyLineEdit::button(FancyLineEdit::Side side) const
{
return d->m_iconbutton[side];
}
void FancyLineEdit::iconClicked()
{
IconButton *button = qobject_cast<IconButton *>(sender());
@@ -480,7 +486,7 @@ IconButton::IconButton(QWidget *parent)
void IconButton::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QStylePainter painter(this);
QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height());
pixmapRect.moveCenter(rect().center());
@@ -488,6 +494,18 @@ void IconButton::paintEvent(QPaintEvent *)
painter.setOpacity(m_iconOpacity);
painter.drawPixmap(pixmapRect, m_pixmap);
if (hasFocus()) {
QStyleOptionFocusRect focusOption;
focusOption.initFrom(this);
focusOption.rect = pixmapRect;
if (HostOsInfo::isMacHost()) {
focusOption.rect.adjust(-4, -4, 4, 4);
painter.drawControl(QStyle::CE_FocusFrame, focusOption);
} else {
painter.drawPrimitive(QStyle::PE_FrameFocusRect, focusOption);
}
}
}
void IconButton::animateShow(bool visible)
@@ -505,4 +523,20 @@ void IconButton::animateShow(bool visible)
}
}
void IconButton::keyPressEvent(QKeyEvent *ke)
{
QAbstractButton::keyPressEvent(ke);
if (!ke->modifiers() && (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return))
click();
// do not forward to line edit
ke->accept();
}
void IconButton::keyReleaseEvent(QKeyEvent *ke)
{
QAbstractButton::keyReleaseEvent(ke);
// do not forward to line edit
ke->accept();
}
} // namespace Utils