use tab not right arrow for minibuffer completion

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6721 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-05 21:10:34 +00:00
parent 08a281769e
commit 988355b92f
4 changed files with 34 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2003-04-05 John Levon <levon@movementarian.org>
* QCommandBuffer.C:
* QCommandEdit.C:
* QCommandEdit.h: use tab instead of right-arrow
for completion
2003-04-04 John Levon <levon@movementarian.org>
* panelstack.C: hide the pointless header

View File

@ -68,11 +68,16 @@ QCommandBuffer::QCommandBuffer(QtView * view, ControlCommandBuffer & control)
QPixmap qpup(toqstr(LibFileSearch("images", "up", "xpm")));
QPixmap qpdown(toqstr(LibFileSearch("images", "down", "xpm")));
(new QToolButton(qpup, qt_("Previous command"), "", this, SLOT(up()), this))->show();
(new QToolButton(qpdown, qt_("Next command"), "", this, SLOT(down()), this))->show();
QToolButton * up = new QToolButton(qpup, qt_("Previous command"), "", this, SLOT(up()), this);
up->setFocusPolicy(NoFocus);
up->show();
QToolButton * down = new QToolButton(qpdown, qt_("Next command"), "", this, SLOT(down()), this);
down->setFocusPolicy(NoFocus);
down->show();
edit_ = new QCommandEdit(this);
edit_->setMinimumSize(edit_->sizeHint());
edit_->setFocusPolicy(ClickFocus);
edit_->show();
setStretchableWidget(edit_);
@ -80,7 +85,7 @@ QCommandBuffer::QCommandBuffer(QtView * view, ControlCommandBuffer & control)
connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
connect(edit_, SIGNAL(rightPressed()), this, SLOT(complete()));
connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
}
@ -105,6 +110,7 @@ void QCommandBuffer::dispatch()
controller_.dispatch(fromqstr(edit_->text()));
view_->centralWidget()->setFocus();
edit_->setText("");
edit_->clearFocus();
}
@ -157,9 +163,10 @@ void QCommandBuffer::complete()
void QCommandBuffer::complete_selected(QString const & str)
{
edit_->setText(str + ' ');
QWidget const * widget = static_cast<QWidget const *>(sender());
const_cast<QWidget *>(widget)->hide();
edit_->setText(str + ' ');
edit_->setFocus();
}

View File

@ -12,7 +12,6 @@
#include "QCommandEdit.h"
QCommandEdit::QCommandEdit(QWidget * parent)
: QLineEdit(parent)
{
@ -29,21 +28,25 @@ void QCommandEdit::keyPressEvent(QKeyEvent * e)
case Key_Up:
emit upPressed();
break;
break;
case Key_Down:
emit downPressed();
break;
case Key_Right:
if (cursorPosition() == text().length())
emit rightPressed();
else
QLineEdit::keyPressEvent(e);
break;
default:
QLineEdit::keyPressEvent(e);
break;
}
}
void QCommandEdit::focusOutEvent(QFocusEvent * e)
{
if (e->reason() == QFocusEvent::Tab) {
emit tabPressed();
return;
}
QLineEdit::focusOutEvent(e);
}

View File

@ -29,9 +29,12 @@ signals:
void downPressed();
/// complete
void rightPressed();
void tabPressed();
protected:
virtual void keyPressEvent(QKeyEvent * e);
virtual void focusOutEvent(QFocusEvent * e);
};
#endif // QCOMMANDEDIT_H