moved to shstk
This commit is contained in:
65
libs/widgets/clineedit.h
Normal file
65
libs/widgets/clineedit.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CLINEEDIT_H
|
||||
#define CLINEEDIT_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include "qad_widgets_export.h"
|
||||
|
||||
|
||||
class QAD_WIDGETS_EXPORT CLineEdit: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
|
||||
|
||||
public:
|
||||
explicit CLineEdit(QWidget * parent = 0);
|
||||
~CLineEdit() {delete cw;}
|
||||
|
||||
const QString & defaultText() const {return dt;}
|
||||
|
||||
protected:
|
||||
QWidget * cw;
|
||||
QString dt;
|
||||
QImage clear_im;
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void resizeEvent(QResizeEvent * );
|
||||
void changeEvent(QEvent * e);
|
||||
void cwPaintEvent();
|
||||
|
||||
private slots:
|
||||
void clearMouseRelease(QMouseEvent * e) {if (cw->rect().contains(e->pos())) clearClick();}
|
||||
void textChanged_(QString text) {cw->setVisible(text != dt);}
|
||||
|
||||
public slots:
|
||||
void clearClick() {if (!isEnabled()) return; setText(dt); emit cleared(); emit textEdited(dt);}
|
||||
void setDefaultText(const QString & t, bool set_text = false);
|
||||
|
||||
signals:
|
||||
void cleared();
|
||||
|
||||
};
|
||||
|
||||
#endif // CLINEEDIT_H
|
||||
Reference in New Issue
Block a user