A?adido nuevo edit para la b?squeda que sustituye al antiguo junto con la etiqueta y el bot?n

Se ha eliminado la posibilidad de realizar b?squedas que no incluyan los c?mics(falta a?adir una b?squeda m?s potente)
This commit is contained in:
Luis Ángel San Martín
2013-05-13 17:39:37 +02:00
parent 65a50fb612
commit af6c6c26b5
7 changed files with 84 additions and 13 deletions

View File

@ -1245,4 +1245,51 @@ YACReaderFlowConfigWidget::YACReaderFlowConfigWidget(QWidget * parent )
layout->setContentsMargins(0,0,0,0);
setLayout(layout);
}
/////////////////////////////////////////////////////////////////////////////////////////
#include <QToolButton>
#include <QStyle>
#include <QLabel>
YACReaderLineEdit::YACReaderLineEdit(QWidget *parent)
: QLineEdit(parent)
{
clearButton = new QToolButton(this);
searchLabel = new QLabel(this);
QPixmap pixmap(":/images/clearSearch.png");
QPixmap pixmapIcon(":/images/iconSearch.png");
searchLabel->setStyleSheet("QLabel { border: none; padding: 0px; }");
searchLabel->setPixmap(pixmapIcon);
clearButton->setIcon(QIcon(pixmap));
clearButton->setIconSize(pixmap.size());
clearButton->setCursor(Qt::ArrowCursor);
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
clearButton->hide();
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 1px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 2).arg(clearButton->sizeHint().width() + frameWidth + 2));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
void YACReaderLineEdit::resizeEvent(QResizeEvent *)
{
QSize sz = clearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
clearButton->move(rect().right() - frameWidth - sz.width(),
(rect().bottom() + 1 - sz.height())/2);
QSize szl = searchLabel->sizeHint();
searchLabel->move(3,(rect().bottom() + 1 - szl.height())/2);
}
void YACReaderLineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}

View File

@ -379,6 +379,28 @@ signals:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#include <QLineEdit>
class QToolButton;
class QLabel;
class YACReaderLineEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderLineEdit(QWidget *parent = 0);
protected:
void resizeEvent(QResizeEvent *);
private slots:
void updateCloseButton(const QString &text);
private:
QToolButton *clearButton;
QLabel * searchLabel;
};
#endif