|
@@ -8,6 +8,7 @@
|
|
|
#include <QApplication>
|
|
|
#include <QDesktopWidget>
|
|
|
#include <QPainter>
|
|
|
+#include <QMouseEvent>
|
|
|
|
|
|
#include "common/combobox/customcombobox.h"
|
|
|
#include "LHQLogAPI.h"
|
|
@@ -15,7 +16,7 @@
|
|
|
#include "common/SelectTime/timewidget.h"
|
|
|
#include "common/date/calendardtedit.h"
|
|
|
#include "ItemData.h"
|
|
|
-#include "oneshadow.h"
|
|
|
+#include "OneShadowEffect.h"
|
|
|
|
|
|
// #include "lhstylemanager.h"
|
|
|
|
|
@@ -42,7 +43,8 @@ AddSpecialItem::AddSpecialItem(QWidget *parent) :
|
|
|
// LH_WRITE_ERROR(QString("打开文件失败:%1").arg(file.fileName()));
|
|
|
// }
|
|
|
/* 创建弹窗阴影 */
|
|
|
- m_shadow = new OneShadow(ui->widget_background->size(), 16);
|
|
|
+ OneShadowEffect *pShadowEffect = new OneShadowEffect(this);
|
|
|
+ ui->widget_background->setGraphicsEffect(pShadowEffect);
|
|
|
|
|
|
ui->label_timeWarn->hide();
|
|
|
ui->label_devWarn->hide();
|
|
@@ -313,17 +315,52 @@ bool AddSpecialItem::eventFilter(QObject *watched, QEvent *event)
|
|
|
}
|
|
|
|
|
|
/* 绘画事件 */
|
|
|
-void AddSpecialItem::paintEvent(QPaintEvent *event)
|
|
|
+// void AddSpecialItem::paintEvent(QPaintEvent *event)
|
|
|
+// {
|
|
|
+// QPainter painter(this);
|
|
|
+// painter.setRenderHint(QPainter::Antialiasing);
|
|
|
+// /* 移动到方框下面 */
|
|
|
+// QPoint pos = ui->widget_background->pos();
|
|
|
+// pos.setX(pos.x() - 16);
|
|
|
+// pos.setY(pos.y() - 16);
|
|
|
+// painter.drawImage(pos, m_shadow->image());
|
|
|
+// }
|
|
|
+
|
|
|
+/* 鼠标点击事件 */
|
|
|
+void AddSpecialItem::mousePressEvent(QMouseEvent *event)
|
|
|
{
|
|
|
- QPainter painter(this);
|
|
|
- painter.setRenderHint(QPainter::Antialiasing);
|
|
|
- /* 移动到方框下面 */
|
|
|
- QPoint pos = ui->widget_background->pos();
|
|
|
- pos.setX(pos.x() - 16);
|
|
|
- pos.setY(pos.y() - 16);
|
|
|
- painter.drawImage(pos, m_shadow->image());
|
|
|
+ m_lastPos = event->globalPos();
|
|
|
+ event->accept();
|
|
|
}
|
|
|
|
|
|
+/* 鼠标移动事件 */
|
|
|
+void AddSpecialItem::mouseMoveEvent(QMouseEvent *event)
|
|
|
+{
|
|
|
+ // QRect rect = this->geometry();
|
|
|
+ auto point = ui->widget_Top->mapToGlobal(QPoint(0, 0));
|
|
|
+ QRect rect(point, ui->widget_Top->size());
|
|
|
+ // LH_WRITE_LOG(QString("rect: %1, %2, %3, %4").arg(rect.left()).arg(rect.top()).arg(rect.right()).arg(rect.bottom()));
|
|
|
+ // LH_WRITE_LOG(QString("lastPos: %1, %2").arg(m_lastPos.x()).arg(m_lastPos.y()));
|
|
|
+ // rect.setBottom(rect.top()+50);
|
|
|
+ if(!rect.contains(m_lastPos))
|
|
|
+ {
|
|
|
+ event->accept();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ int dx = event->globalX() - m_lastPos.x();
|
|
|
+ int dy = event->globalY() - m_lastPos.y();
|
|
|
+ // move(x()+dx, y()+dy);
|
|
|
+ ui->widget_background->move(ui->widget_background->x() + dx, ui->widget_background->y() + dy);
|
|
|
+ // m_shadow->move(ui->widget_background->pos());
|
|
|
+ m_lastPos = event->globalPos();
|
|
|
+ event->accept();
|
|
|
+}
|
|
|
+
|
|
|
+/* 鼠标释放事件 */
|
|
|
+void AddSpecialItem::mouseReleaseEvent(QMouseEvent *event)
|
|
|
+{
|
|
|
+ event->accept();
|
|
|
+}
|
|
|
|
|
|
|