mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Implement down key press in FancyLineEdit
This commit is contained in:
parent
e6180e9914
commit
eab83ec678
@ -199,6 +199,16 @@ void FancyLineEdit::resizeEvent(QResizeEvent *)
|
||||
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);
|
||||
|
@ -22,7 +22,6 @@ namespace frontend {
|
||||
|
||||
class FancyLineEditPrivate;
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
class IconButton: public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -45,7 +44,6 @@ private:
|
||||
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")
|
||||
@ -67,8 +65,8 @@ Q_SIGNALS:
|
||||
void buttonClicked(Side side);
|
||||
void leftButtonClicked();
|
||||
void rightButtonClicked();
|
||||
void downPressed();
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
public:
|
||||
explicit FancyLineEdit(QWidget *parent = 0);
|
||||
~FancyLineEdit();
|
||||
@ -99,6 +97,7 @@ private Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *e);
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
|
||||
private:
|
||||
void updateMargins();
|
||||
@ -106,12 +105,6 @@ private:
|
||||
|
||||
FancyLineEditPrivate *m_d;
|
||||
QString m_oldText;
|
||||
#else
|
||||
public:
|
||||
explicit FancyLineEdit(QWidget *parent = 0)
|
||||
: QLineEdit(parent)
|
||||
{}
|
||||
#endif // QT_VERSION >= 0x040600*/
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -155,6 +155,13 @@ GuiCitation::GuiCitation(GuiView & lv)
|
||||
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()),
|
||||
|
@ -59,6 +59,13 @@ GuiRef::GuiRef(GuiView & lv)
|
||||
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_);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "GuiSelectionManager.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
|
||||
@ -403,8 +404,7 @@ bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
|
||||
return true;
|
||||
}
|
||||
else if (keyPressed == Qt::Key_Right) {
|
||||
selectedLV->setFocus();
|
||||
selectedLV->setCurrentIndex(selectedLV->currentIndex());
|
||||
focusAndHighlight(selectedLV);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
@ -452,8 +452,7 @@ bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
|
||||
}
|
||||
}
|
||||
else if (keyPressed == Qt::Key_Left) {
|
||||
availableLV->setFocus();
|
||||
availableLV->setCurrentIndex(availableLV->currentIndex());
|
||||
focusAndHighlight(availableLV);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ PanelStack::PanelStack(QWidget * parent)
|
||||
#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
|
||||
|
@ -230,6 +230,15 @@ void setValid(QWidget * widget, bool valid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -80,6 +80,9 @@ bool ColorSorter(ColorCode lhs, ColorCode rhs);
|
||||
/// 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,
|
||||
|
Loading…
Reference in New Issue
Block a user