00001 /****************************************************************************************************** 00002 * (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #include "DlgEditPointGraphLineEdit.h" 00008 #include "Logger.h" 00009 #include <QWidget> 00010 00011 DlgEditPointGraphLineEdit::DlgEditPointGraphLineEdit (QWidget *widget) : 00012 QLineEdit (widget), 00013 m_hover (false) 00014 { 00015 LOG4CPP_INFO_S ((*mainCat)) << "DlgEditPointGraphLineEdit::DlgEditPointGraphLineEdit"; 00016 } 00017 00018 DlgEditPointGraphLineEdit::~DlgEditPointGraphLineEdit() 00019 { 00020 LOG4CPP_INFO_S ((*mainCat)) << "DlgEditPointGraphLineEdit::~DlgEditPointGraphLineEdit"; 00021 } 00022 00023 void DlgEditPointGraphLineEdit::enterEvent(QEvent *) 00024 { 00025 m_hover = true; 00026 updateBackground (); 00027 } 00028 00029 void DlgEditPointGraphLineEdit::leaveEvent (QEvent *) 00030 { 00031 m_hover = false; 00032 updateBackground (); 00033 } 00034 00035 void DlgEditPointGraphLineEdit::updateBackground () 00036 { 00037 QString color = (m_hover || !text().isEmpty() ? QString ("white") : QString ("#d3d3d3")); 00038 QString style = QString ("QLineEdit { background-color: %1; }").arg (color); 00039 setStyleSheet (style); 00040 }