updateButtonPositions();
}
+
+void FancyLineEdit::keyPressEvent(QKeyEvent * e)
+{
+ if (e->type() == QEvent::KeyPress && e->key() == Qt::Key_Down)
+ Q_EMIT downPressed();
+ else
+ QLineEdit::keyPressEvent(e);
+}
+
+
void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
{
m_d->m_iconbutton[side]->setPixmap(buttonPixmap);
class FancyLineEditPrivate;
-#if QT_VERSION >= 0x040600
class IconButton: public QAbstractButton
{
Q_OBJECT
bool m_autoHide;
QPixmap m_pixmap;
};
-#endif
/* A line edit with an embedded pixmap on one side that is connected to
* a menu. Additionally, it can display a grayed hintText (like "Type Here to")
void buttonClicked(Side side);
void leftButtonClicked();
void rightButtonClicked();
+ void downPressed();
-#if QT_VERSION >= 0x040600
public:
explicit FancyLineEdit(QWidget *parent = 0);
~FancyLineEdit();
protected:
virtual void resizeEvent(QResizeEvent *e);
+ virtual void keyPressEvent(QKeyEvent *e);
private:
void updateMargins();
FancyLineEditPrivate *m_d;
QString m_oldText;
-#else
-public:
- explicit FancyLineEdit(QWidget *parent = 0)
- : QLineEdit(parent)
- {}
-#endif // QT_VERSION >= 0x040600*/
};
}
this, SLOT(filterChanged(QString)));
connect(filter_, SIGNAL(returnPressed()),
this, SLOT(filterPressed()));
+#if (QT_VERSION < 0x050000)
+ connect(filter_, SIGNAL(downPressed()),
+ availableLV, SLOT(setFocus()));
+#else
+ connect(filter_, &FancyLineEdit::downPressed,
+ availableLV, [=](){ focusAndHighlight(availableLV); });
+#endif
connect(regexp_, SIGNAL(triggered()),
this, SLOT(regexChanged()));
connect(casesense_, SIGNAL(triggered()),
filter_->setAutoHideButton(FancyLineEdit::Right, true);
filter_->setPlaceholderText(qt_("All available labels"));
filter_->setToolTip(qt_("Enter string to filter the list of available labels"));
+#if (QT_VERSION < 0x050000)
+ connect(filter_, SIGNAL(downPressed()),
+ refsTW, SLOT(setFocus()));
+#else
+ connect(filter_, &FancyLineEdit::downPressed,
+ refsTW, [=](){ focusAndHighlight(refsTW); });
+#endif
filterBarL->addWidget(filter_, 0);
findKeysLA->setBuddy(filter_);
#include <config.h>
#include "GuiSelectionManager.h"
+#include "qt_helpers.h"
#include "support/debug.h"
return true;
}
else if (keyPressed == Qt::Key_Right) {
- selectedLV->setFocus();
- selectedLV->setCurrentIndex(selectedLV->currentIndex());
+ focusAndHighlight(selectedLV);
event->accept();
return true;
}
}
}
else if (keyPressed == Qt::Key_Left) {
- availableLV->setFocus();
- availableLV->setCurrentIndex(availableLV->currentIndex());
+ focusAndHighlight(availableLV);
event->accept();
return true;
}
#endif
connect(search_, SIGNAL(rightButtonClicked()), this, SLOT(resetSearch()));
connect(search_, SIGNAL(textEdited(QString)), this, SLOT(filterChanged(QString)));
+ connect(search_, SIGNAL(downPressed()),
+ list_, SLOT(setFocus()));
// Create the output layout, horizontal plus a VBox on the left with the search
// box and the tree
}
}
+
+void focusAndHighlight(QAbstractItemView * w)
+{
+ w->setFocus();
+ w->setCurrentIndex(w->currentIndex());
+ w->scrollTo(w->currentIndex());
+}
+
+
/// wrapper to hide the change of method name to setSectionResizeMode
void setSectionResizeMode(QHeaderView * view,
int logicalIndex, QHeaderView::ResizeMode mode) {
/// colors a widget red if invalid
void setValid(QWidget * widget, bool valid);
+// set focus and highlight the current item if there is no selection already
+void focusAndHighlight(QAbstractItemView * w);
+
/// Qt5 changed setSectionMode to setSectionResizeMode
/// These wrappers work for Qt4 and Qt5
void setSectionResizeMode(QHeaderView * view,