+}
+
+void InputLine::setCustomFont(const QFont &font) {
+ setFont(font);
+}
+
+QSize InputLine::sizeHint() const {
+ // use the style to determine a decent size
+ QFontMetrics fm(font());
+ int h = fm.lineSpacing() + 2 * frameWidth();
+ QStyleOptionFrameV2 opt;
+ opt.initFrom(this);
+ opt.rect = QRect(0, 0, 100, h);
+ opt.lineWidth = lineWidth();
+ opt.midLineWidth = midLineWidth();
+ opt.state |= QStyle::State_Sunken;
+ QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h).expandedTo(QApplication::globalStrut()), this);
+ return s;
+}
+
+QSize InputLine::minimumSizeHint() const {
+ return sizeHint();
+}
+
+bool InputLine::eventFilter(QObject *watched, QEvent *event) {
+ if(event->type() != QEvent::KeyPress)
+ return false;
+
+ // keys from BufferView should be sent to (and focus) the input line
+ BufferView *view = qobject_cast<BufferView *>(watched);
+ if(view) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ if(keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier)) ) { // normal key press
+ QChar c = keyEvent->text().at(0);
+ if(c.isLetterOrNumber() || c.isSpace() || c.isPunct() || c.isSymbol()) {
+ setFocus();
+ keyPressEvent(keyEvent);
+ return true;
+ } else
+ return false;
+ }
+ }
+ return false;