1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 12:02:48 +01:00

Add support for returnPressed() signal to QSearchField.

This commit is contained in:
John Maguire 2012-06-28 11:34:44 +02:00
parent 20d740f385
commit 1e620321a3
3 changed files with 12 additions and 1 deletions

View File

@ -22,6 +22,7 @@ public slots:
signals:
void textChanged(const QString &text);
void editingFinished();
void returnPressed();
protected:
void resizeEvent(QResizeEvent*);

View File

@ -46,6 +46,12 @@ public:
emit qSearchField->editingFinished();
}
void returnPressed()
{
if (qSearchField)
emit qSearchField->returnPressed();
}
QPointer<QSearchField> qSearchField;
NSSearchField *nsSearchField;
};
@ -67,10 +73,12 @@ public:
}
-(void)controlTextDidEndEditing:(NSNotification*)notification {
Q_UNUSED(notification);
// No Q_ASSERT here as it is called on destruction.
if (pimpl)
pimpl->textDidEndEditing();
if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement)
pimpl->returnPressed();
}
@end

View File

@ -55,6 +55,8 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent)
this, SIGNAL(textChanged(QString)));
connect(lineEdit, SIGNAL(editingFinished()),
this, SIGNAL(editingFinished()));
connect(lineEdit, SIGNAL(returnPressed()),
this, SIGNAL(returnPressed()));
connect(lineEdit, SIGNAL(textChanged(QString)),
this, SLOT(setText(QString)));