mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Forgot to add two files
This commit is contained in:
parent
aa25471517
commit
5d1bede9e5
35
apps/launcher/utils/comboboxlineedit.cpp
Normal file
35
apps/launcher/utils/comboboxlineedit.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
|
||||
#include "comboboxlineedit.hpp"
|
||||
|
||||
ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
mClearButton = new QToolButton(this);
|
||||
QPixmap pixmap(":images/clear.png");
|
||||
mClearButton->setIcon(QIcon(pixmap));
|
||||
mClearButton->setIconSize(pixmap.size());
|
||||
mClearButton->setCursor(Qt::ArrowCursor);
|
||||
mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||
mClearButton->hide();
|
||||
connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateClearButton(const QString&)));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
setObjectName(QString("ComboBoxLineEdit"));
|
||||
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||
}
|
||||
|
||||
void ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize sz = mClearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
mClearButton->move(rect().right() - frameWidth - sz.width(),
|
||||
(rect().bottom() + 1 - sz.height())/2);
|
||||
}
|
||||
|
||||
void ComboBoxLineEdit::updateClearButton(const QString& text)
|
||||
{
|
||||
mClearButton->setVisible(!text.isEmpty());
|
||||
}
|
35
apps/launcher/utils/comboboxlineedit.hpp
Normal file
35
apps/launcher/utils/comboboxlineedit.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
|
||||
**
|
||||
** Use, modification and distribution is allowed without limitation,
|
||||
** warranty, liability or support of any kind.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LINEEDIT_H
|
||||
#define LINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
class ComboBoxLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ComboBoxLineEdit(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void updateClearButton(const QString &text);
|
||||
|
||||
private:
|
||||
QToolButton *mClearButton;
|
||||
};
|
||||
|
||||
#endif // LIENEDIT_H
|
||||
|
Loading…
Reference in New Issue
Block a user