diff --git a/CMakeLists.txt b/CMakeLists.txt index fa72647..27bc7a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 09779d9..86924d4 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -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") diff --git a/qad/widgets/clineedit.cpp b/qad/widgets/clineedit.cpp index 861dd50..bf0845c 100644 --- a/qad/widgets/clineedit.cpp +++ b/qad/widgets/clineedit.cpp @@ -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) { diff --git a/qad/widgets/clineedit.h b/qad/widgets/clineedit.h index 121942b..dcf6b72 100644 --- a/qad/widgets/clineedit.h +++ b/qad/widgets/clineedit.h @@ -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();} diff --git a/qcd_utils/CMakeLists.txt b/qcd_utils/CMakeLists.txt index bfb2cac..e8120ee 100644 --- a/qcd_utils/CMakeLists.txt +++ b/qcd_utils/CMakeLists.txt @@ -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)