|
@@ -164,7 +164,7 @@ void TimeWidget::setEditLineEnable(bool enable)
|
|
|
{
|
|
{
|
|
|
if(m_pTimePopupWidget != nullptr && m_pTimePopupWidget->isVisible())
|
|
if(m_pTimePopupWidget != nullptr && m_pTimePopupWidget->isVisible())
|
|
|
{
|
|
{
|
|
|
- m_isBanPopupShow = true;
|
|
|
|
|
|
|
+ // m_isBanPopupShow = true;
|
|
|
ShowPopupArea(false);
|
|
ShowPopupArea(false);
|
|
|
UpdateProperty(this, "hover", false);
|
|
UpdateProperty(this, "hover", false);
|
|
|
}
|
|
}
|
|
@@ -204,11 +204,7 @@ void TimeWidget::setQSS()
|
|
|
/* 点击了时间图标 */
|
|
/* 点击了时间图标 */
|
|
|
void TimeWidget::do_pBtn_tip_Clicked()
|
|
void TimeWidget::do_pBtn_tip_Clicked()
|
|
|
{
|
|
{
|
|
|
- if(m_pTimePopupWidget == nullptr)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if(m_pTimePopupWidget->isVisible())
|
|
|
|
|
|
|
+ if((m_pTimePopupWidget != nullptr) && (m_pTimePopupWidget->isVisible()))
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -224,6 +220,16 @@ void TimeWidget::do_pBtn_tip_Clicked()
|
|
|
*/
|
|
*/
|
|
|
bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
|
{
|
|
{
|
|
|
|
|
+ /* 判断是否被禁用了 */
|
|
|
|
|
+ if(!this->isEnabled())
|
|
|
|
|
+ {
|
|
|
|
|
+ return QWidget::eventFilter(obj, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ /* 判断是否是鼠标点击事件 */
|
|
|
|
|
+ if(e == nullptr || obj == nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ return QWidget::eventFilter(obj, e);
|
|
|
|
|
+ }
|
|
|
if (obj == ui->dateTimeEdit)
|
|
if (obj == ui->dateTimeEdit)
|
|
|
{
|
|
{
|
|
|
if(e->type() == QEvent::Wheel && m_isDisableWheel)
|
|
if(e->type() == QEvent::Wheel && m_isDisableWheel)
|
|
@@ -234,15 +240,13 @@ bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
|
if (e->type() == QEvent::FocusIn && m_type == EditLine)
|
|
if (e->type() == QEvent::FocusIn && m_type == EditLine)
|
|
|
{
|
|
{
|
|
|
/* 如果Popup正在关闭 */
|
|
/* 如果Popup正在关闭 */
|
|
|
-
|
|
|
|
|
- if(m_isBanPopupShow == true)
|
|
|
|
|
- {
|
|
|
|
|
- m_isBanPopupShow = false;
|
|
|
|
|
- /* 这里需要再次失去焦点,否则下次点击编辑栏无法弹出Popup */
|
|
|
|
|
- ui->dateTimeEdit->clearFocus();
|
|
|
|
|
- return QWidget::eventFilter(obj, e);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // if(m_isBanPopupShow == true)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // m_isBanPopupShow = false;
|
|
|
|
|
+ // /* 这里需要再次失去焦点,否则下次点击编辑栏无法弹出Popup */
|
|
|
|
|
+ // ui->dateTimeEdit->clearFocus();
|
|
|
|
|
+ // return QWidget::eventFilter(obj, e);
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
//qInfo() << "dateTimeEdit focusIn";
|
|
//qInfo() << "dateTimeEdit focusIn";
|
|
|
ShowPopupArea(true);
|
|
ShowPopupArea(true);
|
|
@@ -274,13 +278,12 @@ bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
|
UpdateProperty(this, "hover", false);
|
|
UpdateProperty(this, "hover", false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /* 判断是不是显示区外面,是的话就隐藏 */
|
|
|
|
|
- QMouseEvent* pMouse = reinterpret_cast<QMouseEvent*>(e);
|
|
|
|
|
- if (nullptr != pMouse)
|
|
|
|
|
|
|
+ /* 鼠标点击事件,判断是不是显示区外面,是的话就隐藏,是内部就显示弹窗 */
|
|
|
|
|
+ if(e->type() == QEvent::MouseButtonPress)
|
|
|
{
|
|
{
|
|
|
- if (pMouse->type() == QEvent::MouseButtonPress)
|
|
|
|
|
|
|
+ QMouseEvent* pMouse = reinterpret_cast<QMouseEvent*>(e);
|
|
|
|
|
+ if (nullptr != pMouse)
|
|
|
{
|
|
{
|
|
|
- //qInfo() << "focusOut";
|
|
|
|
|
QPoint gtl = this->mapToGlobal(rect().topLeft());
|
|
QPoint gtl = this->mapToGlobal(rect().topLeft());
|
|
|
QRect rc(gtl.x(), gtl.y(), width(), height()); // 全局位置判断
|
|
QRect rc(gtl.x(), gtl.y(), width(), height()); // 全局位置判断
|
|
|
if (!rc.contains(pMouse->globalPos()))
|
|
if (!rc.contains(pMouse->globalPos()))
|
|
@@ -296,10 +299,10 @@ bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
|
}
|
|
}
|
|
|
/* 如果焦点不在编辑栏,Popup窗口隐藏后,编辑栏会重新获取焦点,将会再次跳出Popup窗口
|
|
/* 如果焦点不在编辑栏,Popup窗口隐藏后,编辑栏会重新获取焦点,将会再次跳出Popup窗口
|
|
|
因此在其没有焦点的时候设置 m_isBanPopupShow ,防止Popup隐藏后编辑栏再次获取焦点再次弹出Popup */
|
|
因此在其没有焦点的时候设置 m_isBanPopupShow ,防止Popup隐藏后编辑栏再次获取焦点再次弹出Popup */
|
|
|
- if(!ui->dateTimeEdit->hasFocus())
|
|
|
|
|
- {
|
|
|
|
|
- m_isBanPopupShow = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if(!ui->dateTimeEdit->hasFocus())
|
|
|
|
|
+ // {
|
|
|
|
|
+ // m_isBanPopupShow = true;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
ShowPopupArea(false);
|
|
ShowPopupArea(false);
|
|
|
UpdateProperty(this, "hover", false);
|
|
UpdateProperty(this, "hover", false);
|
|
@@ -309,8 +312,19 @@ bool TimeWidget::eventFilter(QObject* obj, QEvent* e)
|
|
|
this->close();
|
|
this->close();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ /* 鼠标点击在了编辑栏内部 */
|
|
|
|
|
+ if(m_wdgTimeArea != nullptr && m_wdgTimeArea->isVisible())
|
|
|
|
|
+ {
|
|
|
|
|
+ return QWidget::eventFilter(obj, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ ShowPopupArea(true);
|
|
|
|
|
+ UpdateProperty(this, "hover", true);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return QWidget::eventFilter(obj, e);
|
|
return QWidget::eventFilter(obj, e);
|
|
|
}
|
|
}
|
|
@@ -328,6 +342,7 @@ void TimeWidget::moveEvent(QMoveEvent *event)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/* 这个用来实时修改编辑栏的时间 */
|
|
/* 这个用来实时修改编辑栏的时间 */
|
|
|
void TimeWidget::do_dateTimeChanged(const QTime& dt)
|
|
void TimeWidget::do_dateTimeChanged(const QTime& dt)
|
|
|
{
|
|
{
|
|
@@ -358,7 +373,7 @@ void TimeWidget::do_closePopup(bool isOk)
|
|
|
{
|
|
{
|
|
|
ui->dateTimeEdit->setTime(m_formerDateTime.time());
|
|
ui->dateTimeEdit->setTime(m_formerDateTime.time());
|
|
|
}
|
|
}
|
|
|
- m_isBanPopupShow = true;
|
|
|
|
|
|
|
+ // m_isBanPopupShow = true;
|
|
|
ShowPopupArea(false);
|
|
ShowPopupArea(false);
|
|
|
UpdateProperty(this, "hover", false);
|
|
UpdateProperty(this, "hover", false);
|
|
|
if(m_type == Dialog)
|
|
if(m_type == Dialog)
|
|
@@ -521,7 +536,7 @@ void TimeWidget::Init()
|
|
|
ui->dateTimeEdit->setTime(t);
|
|
ui->dateTimeEdit->setTime(t);
|
|
|
ui->lbl_tip->hide();
|
|
ui->lbl_tip->hide();
|
|
|
/* 使用这个阻止show的时候获取焦点自动弹出Popup */
|
|
/* 使用这个阻止show的时候获取焦点自动弹出Popup */
|
|
|
- m_isBanPopupShow = true;
|
|
|
|
|
|
|
+ // m_isBanPopupShow = true;
|
|
|
ui->dateTimeEdit->show();
|
|
ui->dateTimeEdit->show();
|
|
|
m_formerDateTime.setTime(t);
|
|
m_formerDateTime.setTime(t);
|
|
|
|
|
|