Commit 76fe997a authored by Jens Bache-Wiig's avatar Jens Bache-Wiig

Improve focus and keyboard interaction with projectselector

This kills the event filter since it is not really neccessary.
Most combo boxes should be disabled by default now. I Removed
redundant focus widgets from the keyboard chain and I
indicate that the list has focus by saturation.
parent 1b86bc50
......@@ -643,6 +643,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
case CE_ComboBoxLabel:
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (panelWidget(widget)) {
painter->save();
QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
QPalette customPal = cb->palette;
......@@ -671,13 +672,18 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
customPal.setBrush(QPalette::All, QPalette::ButtonText, QColor(0, 0, 0, 70));
QString text = option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, editRect.width());
drawItemText(painter, editRect.translated(0, 1),
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
if ((option->state & State_Enabled))
drawItemText(painter, editRect.translated(0, 1),
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
else
painter->setOpacity(0.8);
customPal.setBrush(QPalette::All, QPalette::ButtonText, Utils::StyleHelper::panelTextColor());
drawItemText(painter, editRect,
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
painter->restore();
} else {
QProxyStyle::drawControl(element, option, painter, widget);
}
......
......@@ -99,7 +99,10 @@ void TargetSelectorDelegate::paint(QPainter *painter,
selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png"));
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight().color().darker(140));
QColor color =(option.state & QStyle::State_HasFocus) ?
option.palette.highlight().color() :
option.palette.dark().color();
painter->fillRect(option.rect, color.darker(140));
Utils::StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5);
painter->setPen(QColor(255, 255, 255, 60));
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
......@@ -363,7 +366,6 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
setProperty("panelwidget", true);
setContentsMargins(QMargins(0, 1, 1, 8));
setWindowFlags(Qt::Popup);
setFocusPolicy(Qt::WheelFocus);
targetSelectorAction->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
targetSelectorAction->setProperty("titledAction", true);
......@@ -397,18 +399,15 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
m_projectsBox->setFixedHeight(panelHeight);
m_projectsBox->setProperty("hideborder", true);
m_projectsBox->setObjectName(QString::fromUtf8("ProjectsBox"));
m_projectsBox->setFocusPolicy(Qt::WheelFocus);
m_projectsBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_projectsBox->setMaximumWidth(200);
m_projectsBox->installEventFilter(this);
toolLayout->addWidget(lbl);
toolLayout->addWidget(new Utils::StyledSeparator);
toolLayout->addWidget(m_projectsBox);
m_widgetStack = new QStackedWidget;
m_widgetStack->setFocusPolicy(Qt::WheelFocus);
m_widgetStack->installEventFilter(this);
m_widgetStack->setFocusPolicy(Qt::NoFocus);
layout->addWidget(m_widgetStack);
connect(m_projectsBox, SIGNAL(activated(int)),
......@@ -448,7 +447,6 @@ void MiniProjectTargetSelector::addProject(ProjectExplorer::Project* project)
{
QTC_ASSERT(project, return);
ProjectListWidget *targetList = new ProjectListWidget(project);
targetList->installEventFilter(this);
targetList->setStyleSheet(QString::fromLatin1("QListWidget { background: %1; border: none; }")
.arg(QColor(70, 70, 70).name()));
int pos = m_widgetStack->addWidget(targetList);
......@@ -514,11 +512,6 @@ void MiniProjectTargetSelector::addTarget(ProjectExplorer::Target *target, bool
MiniTargetWidget *targetWidget = new MiniTargetWidget(target);
connect(targetWidget, SIGNAL(changed()), this, SLOT(updateAction()));
targetWidget->installEventFilter(this);
if (targetWidget->buildSettingsComboBox())
targetWidget->buildSettingsComboBox()->installEventFilter(this);
if (targetWidget->runSettingsComboBox())
targetWidget->runSettingsComboBox()->installEventFilter(this);
targetWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
// width==0 size hint to avoid horizontal scrolling in list widget
lwi->setSizeHint(QSize(0, targetWidget->sizeHint().height()));
......@@ -634,48 +627,3 @@ void MiniProjectTargetSelector::paintEvent(QPaintEvent *)
static QImage image(QLatin1String(":/projectexplorer/images/targetpanel_bottom.png"));
Utils::StyleHelper::drawCornerImage(image, &painter, bottomRect, 1, 1, 1, 1);
}
bool MiniProjectTargetSelector::eventFilter(QObject *o, QEvent *ev)
{
switch(ev->type())
{
case QEvent::KeyPress: {
QKeyEvent *kev = static_cast<QKeyEvent*>(ev);
if (kev->key() == Qt::Key_Tab) {
if(o == m_projectsBox) {
if (m_widgetStack->currentWidget())
m_widgetStack->currentWidget()->setFocus();
return true;
} else {
m_projectsBox->setFocus();
return true;
}
}
if (o == m_widgetStack->currentWidget()) {
if (kev->key() == Qt::Key_Return) {
hide();
return true;
}
ProjectListWidget *plw = qobject_cast<ProjectListWidget*>(m_widgetStack->currentWidget());
if (kev->key() == Qt::Key_B)
{
plw->setBuildComboPopup();
return true;
}
if (kev->key() == Qt::Key_R)
{
plw->setRunComboPopup();
return true;
}
}
}
default:
return false;
}
return false;
}
......@@ -117,9 +117,6 @@ public:
MiniProjectTargetSelector(QAction *projectAction, QWidget *parent = 0);
void setVisible(bool visible);
protected:
bool eventFilter(QObject *o, QEvent *ev);
signals:
void startupProjectChanged(ProjectExplorer::Project *project);
......
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