git-svn-id: svn://db.shs.com.ru/libs@331 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -12,6 +12,7 @@ if(POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 OLD)
|
||||
endif()
|
||||
project(libs)
|
||||
include(SDKMacros.cmake)
|
||||
set(LIBPROJECT 1)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/pip/")
|
||||
if(MINGW)
|
||||
|
||||
@@ -2,9 +2,7 @@ project(qad)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
#cmake_policy(SET CMP0017 OLD)
|
||||
#find_package(Qt4 REQUIRED)
|
||||
if (LIBPROJECT)
|
||||
include(../SDKMacros.cmake)
|
||||
else()
|
||||
if (NOT LIBPROJECT)
|
||||
option(LIB "System install" 1)
|
||||
option(DEBUG "Build with -g3" 0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
|
||||
|
||||
@@ -1,24 +1,32 @@
|
||||
#include "clineedit.h"
|
||||
#include "qad_types.h"
|
||||
|
||||
|
||||
CLineEdit::CLineEdit(QWidget * parent): QLineEdit(parent) {
|
||||
cw = new QWidget(this);
|
||||
cw->setStyleSheet("background-image: url(:/icons/edit-clear-locationbar-rtl.png);");
|
||||
clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
|
||||
cw->setCursor(Qt::ArrowCursor);
|
||||
cw->setToolTip(tr("Clear"));
|
||||
cw->hide();
|
||||
cw->installEventFilter(this);
|
||||
connect(this, SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
|
||||
int is = fontHeight();
|
||||
int m0, m1, m2, m3;
|
||||
getTextMargins(&m0, &m1, &m2, &m3);
|
||||
setTextMargins(m0, m1, m2 + 21, m3);
|
||||
connect(this, SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
|
||||
setTextMargins(m0, m1, m2 + (is * 1.2), m3);
|
||||
//connect(cw, SIGNAL(mouseReleaseEvent(QMouseEvent * )), this, SLOT(clearMouseRelease(QMouseEvent * )));
|
||||
}
|
||||
|
||||
|
||||
bool CLineEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
if (e->type() == QEvent::MouseButtonRelease) {
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseButtonRelease:
|
||||
clearMouseRelease((QMouseEvent * )e);
|
||||
break;
|
||||
case QEvent::Paint:
|
||||
cwPaintEvent();
|
||||
break;
|
||||
default : break;
|
||||
}
|
||||
return QLineEdit::eventFilter(o, e);
|
||||
}
|
||||
@@ -26,7 +34,8 @@ bool CLineEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
|
||||
void CLineEdit::resizeEvent(QResizeEvent * e) {
|
||||
QLineEdit::resizeEvent(e);
|
||||
cw->setGeometry(width() - 21, (height() - 17) / 2, 16, 16);
|
||||
int is = fontHeight(), tm = (height() - is) / 2;
|
||||
cw->setGeometry(width() - is - tm, tm, is, is);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +48,13 @@ void CLineEdit::changeEvent(QEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void CLineEdit::cwPaintEvent() {
|
||||
QPainter p(cw);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p.drawImage(cw->rect(), clear_im);
|
||||
}
|
||||
|
||||
|
||||
void CLineEdit::setDefaultText(const QString & t, bool set_text) {
|
||||
dt = t;
|
||||
if (set_text) {
|
||||
|
||||
@@ -21,11 +21,13 @@ public:
|
||||
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();}
|
||||
|
||||
@@ -21,7 +21,7 @@ qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
||||
qt_target_link_libraries(${PROJECT_NAME} pip qad_utils qad_widgets cd_utils piqt)
|
||||
message(STATUS "Building ${PROJECT_NAME}")
|
||||
if(LIBPROJECT)
|
||||
sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||
#sdk_install("" "${PROJECT_NAME}" "${out_HDR}" "${out_QM}")
|
||||
else()
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
|
||||
Reference in New Issue
Block a user