调整代码结构
This commit is contained in:
parent
c3f5824968
commit
034d688796
|
|
@ -61,8 +61,8 @@ void dpConfigurationDialog::initialize()
|
||||||
connect(ui->btnReomve_type, SIGNAL(clicked()), this, SLOT(onBtnClicked_remove_type()));
|
connect(ui->btnReomve_type, SIGNAL(clicked()), this, SLOT(onBtnClicked_remove_type()));
|
||||||
connect(ui->btnReomve_source, SIGNAL(clicked()), this, SLOT(onBtnClicked_remove_source()));
|
connect(ui->btnReomve_source, SIGNAL(clicked()), this, SLOT(onBtnClicked_remove_source()));
|
||||||
|
|
||||||
connect(ui->typeSourceList, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onItemClicked_typeSource(const QModelIndex&)));
|
connect(ui->typeSourceList, &QListView::clicked, this, &dpConfigurationDialog::onItemClicked_typeSource);
|
||||||
connect(ui->dataSourceList, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onItemClicked_dataSource(const QModelIndex&)));
|
connect(ui->dataSourceList, &QListView::clicked, this, &dpConfigurationDialog::onItemClicked_dataSource);
|
||||||
|
|
||||||
///数据类型
|
///数据类型
|
||||||
//typeSourceList
|
//typeSourceList
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ dpLineChart::~dpLineChart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void dpLineChart::initQCP()
|
void dpLineChart::initQCP()
|
||||||
{
|
{
|
||||||
//m_pCustomPlot->axisRect()->setupFullAxesBox();
|
//m_pCustomPlot->axisRect()->setupFullAxesBox();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QBasicTimer>
|
||||||
|
|
||||||
class QPropertyAnimation;
|
class QPropertyAnimation;
|
||||||
class CustomBorderContainer : public QObject
|
class CustomBorderContainer : public QObject
|
||||||
|
|
@ -45,10 +46,10 @@ public:
|
||||||
|
|
||||||
void setMinWindowSize(int, int); //设置窗口能缩放的最小尺寸
|
void setMinWindowSize(int, int); //设置窗口能缩放的最小尺寸
|
||||||
void setBorderSize(int); //设置边框尺寸
|
void setBorderSize(int); //设置边框尺寸
|
||||||
|
void updateBorder(); //重绘border
|
||||||
void showBorderDraw();
|
void showBorderDraw();
|
||||||
void hideBorderDraw();
|
void hideBorderDraw();
|
||||||
void setAutoAdjustDistance(int);
|
void setAutoAdjustDistance(int);
|
||||||
void updateBorder(); //重绘border
|
|
||||||
void setOperationOption(OperationOptions);
|
void setOperationOption(OperationOptions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -65,14 +66,18 @@ private:
|
||||||
void mouseMoveEvent(QMouseEvent*);
|
void mouseMoveEvent(QMouseEvent*);
|
||||||
void mouseReleaseEvent(QMouseEvent*);
|
void mouseReleaseEvent(QMouseEvent*);
|
||||||
void paintEvent(QPaintEvent*);
|
void paintEvent(QPaintEvent*);
|
||||||
|
void timerEvent(QTimerEvent*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
borderType m_type;
|
borderType m_type;
|
||||||
QPoint m_ptMouseLast;
|
QPoint m_ptMouseLast;
|
||||||
|
QPoint m_mouseMoveLengt;
|
||||||
bool m_bMousIsPress;
|
bool m_bMousIsPress;
|
||||||
bool m_bShowPainterDraw;
|
bool m_bShowPainterDraw;
|
||||||
QString m_strOperation;
|
QString m_strOperation;
|
||||||
CustomBorderContainer* m_pContainer;
|
CustomBorderContainer* m_pContainer;
|
||||||
|
|
||||||
|
QBasicTimer m_repaintTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
void iniBorder();
|
void iniBorder();
|
||||||
|
|
@ -84,8 +89,9 @@ private:
|
||||||
void scaleByLeftBottomBorder(const QPoint&);
|
void scaleByLeftBottomBorder(const QPoint&);
|
||||||
void scaleByRightTopBorder(const QPoint&);
|
void scaleByRightTopBorder(const QPoint&);
|
||||||
void scaleByRightBottomBorder(const QPoint&);
|
void scaleByRightBottomBorder(const QPoint&);
|
||||||
void moveByMoveBordr(const QPoint&);
|
void moveByMoveBorder(const QPoint&);
|
||||||
void autoAdjustGeometry(const QString&);
|
void autoAdjustGeometry(const QString&);
|
||||||
|
void updateContentWidget();
|
||||||
|
|
||||||
QWidget* m_pWidget;
|
QWidget* m_pWidget;
|
||||||
int m_nMinWindowSize_width;
|
int m_nMinWindowSize_width;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent*);
|
bool event(QEvent*);
|
||||||
/*void keyPressEvent(QKeyEvent*);
|
/*void paintEvent(QPaintEvent*);
|
||||||
|
void keyPressEvent(QKeyEvent*);
|
||||||
void mousePressEvent(QMouseEvent*);
|
void mousePressEvent(QMouseEvent*);
|
||||||
void enterEvent(QEnterEvent*);
|
void enterEvent(QEnterEvent*);
|
||||||
void leaveEvent(QEvent*);
|
void leaveEvent(QEvent*);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
CustomBorderContainer::CustomBorder::CustomBorder(QWidget* parent, borderType type, CustomBorderContainer* container)
|
CustomBorderContainer::CustomBorder::CustomBorder(QWidget* parent, borderType type, CustomBorderContainer* container) : QLabel(parent)
|
||||||
{
|
{
|
||||||
setParent(parent);
|
//setParent(parent);
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_pContainer = container;
|
m_pContainer = container;
|
||||||
m_bMousIsPress = false;
|
m_bMousIsPress = false;
|
||||||
|
|
@ -103,6 +103,7 @@ void CustomBorderContainer::CustomBorder::mouseMoveEvent(QMouseEvent* event)
|
||||||
if(m_bMousIsPress)
|
if(m_bMousIsPress)
|
||||||
{
|
{
|
||||||
QPoint moveLength = event->globalPosition().toPoint() - m_ptMouseLast;
|
QPoint moveLength = event->globalPosition().toPoint() - m_ptMouseLast;
|
||||||
|
m_mouseMoveLengt = moveLength;
|
||||||
switch(m_type)
|
switch(m_type)
|
||||||
{
|
{
|
||||||
case border_left:
|
case border_left:
|
||||||
|
|
@ -130,13 +131,19 @@ void CustomBorderContainer::CustomBorder::mouseMoveEvent(QMouseEvent* event)
|
||||||
m_pContainer->scaleByRightBottomBorder(moveLength);
|
m_pContainer->scaleByRightBottomBorder(moveLength);
|
||||||
break;
|
break;
|
||||||
case border_move:
|
case border_move:
|
||||||
m_pContainer->moveByMoveBordr(moveLength);
|
m_pContainer->moveByMoveBorder(moveLength);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_ptMouseLast = event->globalPosition().toPoint();
|
m_ptMouseLast = event->globalPosition().toPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(!m_repaintTimer.isActive())
|
||||||
|
// {
|
||||||
|
// m_repaintTimer.start(16, this);
|
||||||
|
// }
|
||||||
|
|
||||||
QLabel::mouseMoveEvent(event);
|
QLabel::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
void CustomBorderContainer::CustomBorder::mouseReleaseEvent(QMouseEvent* event)
|
void CustomBorderContainer::CustomBorder::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
|
@ -146,7 +153,19 @@ void CustomBorderContainer::CustomBorder::mouseReleaseEvent(QMouseEvent* event)
|
||||||
//if(container->m_opOptions & OperationOption::WidgetAutoAdjustGeometry)
|
//if(container->m_opOptions & OperationOption::WidgetAutoAdjustGeometry)
|
||||||
if(m_pContainer->m_opOptions.testFlag(OperationOption::WidgetAutoAdjustGeometry))
|
if(m_pContainer->m_opOptions.testFlag(OperationOption::WidgetAutoAdjustGeometry))
|
||||||
m_pContainer->autoAdjustGeometry(m_strOperation);
|
m_pContainer->autoAdjustGeometry(m_strOperation);
|
||||||
QLabel::mousePressEvent(event);
|
else
|
||||||
|
m_pContainer->updateBorder();
|
||||||
|
|
||||||
|
QLabel::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomBorderContainer::CustomBorder::timerEvent(QTimerEvent* event)
|
||||||
|
{
|
||||||
|
if(event->timerId() == m_repaintTimer.timerId())
|
||||||
|
{
|
||||||
|
m_repaintTimer.stop();
|
||||||
|
m_pContainer->updateContentWidget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomBorderContainer::CustomBorder::showPainterDraw(bool bShow)
|
void CustomBorderContainer::CustomBorder::showPainterDraw(bool bShow)
|
||||||
|
|
@ -158,7 +177,7 @@ CustomBorderContainer::CustomBorderContainer(QWidget *parent, int minWindowWidth
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_pWidget = parent;
|
m_pWidget = parent;
|
||||||
setParent(parent);
|
//setParent(parent);
|
||||||
m_nMinWindowSize_width = minWindowWidth;
|
m_nMinWindowSize_width = minWindowWidth;
|
||||||
m_nMinWindowSize_height = minWindowHeight;
|
m_nMinWindowSize_height = minWindowHeight;
|
||||||
m_nBorderSize = borderSize;
|
m_nBorderSize = borderSize;
|
||||||
|
|
@ -240,6 +259,96 @@ void CustomBorderContainer::setAutoAdjustDistance(int nDistance)
|
||||||
m_nAutoAdjustDistance = nDistance;
|
m_nAutoAdjustDistance = nDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomBorderContainer::setOperationOption(OperationOptions options)
|
||||||
|
{
|
||||||
|
m_opOptions = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomBorderContainer::scaleByLeftBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
//不能采用宽度判断:if(m_widget->width()<minWindowWidth),因为一旦进入找个判断条件,就无法再更新宽度,无法重新缩放,因此采用鼠标点位置的实时计算来判断
|
||||||
|
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)) //左边界动态调整x坐标和width,判断这两个值的实时关系
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y(), m_pWidget->width() - moveLength.x(), m_pWidget->height());
|
||||||
|
//updateBorder();因为moveBorder会显示出来,所以只对它实时刷新
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByRightBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)) //有边界动态调整width,判断width和x坐标的关系
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width() + moveLength.x(), m_pWidget->height());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByTopBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width(), m_pWidget->height() - moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByBottomBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width(), m_pWidget->height() + moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByLeftTopBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)
|
||||||
|
|| (m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width() - moveLength.x(), m_pWidget->height() - moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByLeftBottomBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)
|
||||||
|
|| (m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y(), m_pWidget->width() - moveLength.x(), m_pWidget->height() + moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByRightTopBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)
|
||||||
|
|| (m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width() + moveLength.x(), m_pWidget->height() - moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
void CustomBorderContainer::scaleByRightBottomBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)
|
||||||
|
|| (m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width() + moveLength.x(), m_pWidget->height() + moveLength.y());
|
||||||
|
//updateBorder();
|
||||||
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomBorderContainer::moveByMoveBorder(const QPoint& moveLength)
|
||||||
|
{
|
||||||
|
//m_pWidget->setUpdatesEnabled(false);
|
||||||
|
m_pWidget->move(moveLength + m_pWidget->pos());
|
||||||
|
//m_pWidget->setUpdatesEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
void CustomBorderContainer::updateBorder()
|
void CustomBorderContainer::updateBorder()
|
||||||
{
|
{
|
||||||
m_pBorder_Left->setGeometry(0, m_nBorderSize, m_nBorderSize, m_pWidget->height() - m_nBorderSize * 2);
|
m_pBorder_Left->setGeometry(0, m_nBorderSize, m_nBorderSize, m_pWidget->height() - m_nBorderSize * 2);
|
||||||
|
|
@ -253,86 +362,9 @@ void CustomBorderContainer::updateBorder()
|
||||||
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
m_pBorder_Move->setGeometry(m_nBorderSize, m_nBorderSize, m_pWidget->width() - m_nBorderSize * 2, m_nBorderSize * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomBorderContainer::setOperationOption(OperationOptions options)
|
void CustomBorderContainer::updateContentWidget()
|
||||||
{
|
{
|
||||||
m_opOptions = options;
|
m_pWidget->update();
|
||||||
}
|
|
||||||
|
|
||||||
void CustomBorderContainer::scaleByLeftBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
//不能采用宽度判断:if(m_widget->width()<minWindowWidth),因为一旦进入找个判断条件,就无法再更新宽度,无法重新缩放,因此采用鼠标点位置的实时计算来判断
|
|
||||||
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)) //左边界动态调整x坐标和width,判断这两个值的实时关系
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y(), m_pWidget->width() - moveLength.x(), m_pWidget->height());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByRightBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)) //有边界动态调整width,判断width和x坐标的关系
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width() + moveLength.x(), m_pWidget->height());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByTopBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width(), m_pWidget->height() - moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByBottomBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width(), m_pWidget->height() + moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByLeftTopBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)
|
|
||||||
|| (m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width() - moveLength.x(), m_pWidget->height() - moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByLeftBottomBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().x() + moveLength.x()) > (m_pWidget->pos().x() + m_pWidget->width() - m_nMinWindowSize_width)
|
|
||||||
|| (m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x() + moveLength.x(), m_pWidget->pos().y(), m_pWidget->width() - moveLength.x(), m_pWidget->height() + moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByRightTopBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)
|
|
||||||
|| (m_pWidget->pos().y() + moveLength.y()) > (m_pWidget->pos().y() + m_pWidget->height() - m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y() + moveLength.y(), m_pWidget->width() + moveLength.x(), m_pWidget->height() - moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
void CustomBorderContainer::scaleByRightBottomBorder(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
if((m_pWidget->pos().x() + m_pWidget->width() + moveLength.x()) < (m_pWidget->pos().x() + m_nMinWindowSize_width)
|
|
||||||
|| (m_pWidget->pos().y() + m_pWidget->height() + moveLength.y()) < (m_pWidget->pos().y() + m_nMinWindowSize_height))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_pWidget->setGeometry(m_pWidget->pos().x(), m_pWidget->pos().y(), m_pWidget->width() + moveLength.x(), m_pWidget->height() + moveLength.y());
|
|
||||||
updateBorder();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomBorderContainer::moveByMoveBordr(const QPoint& moveLength)
|
|
||||||
{
|
|
||||||
//m_pWidget->setUpdatesEnabled(false);
|
|
||||||
m_pWidget->move(moveLength + m_pWidget->pos());
|
|
||||||
//m_pWidget->setUpdatesEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomBorderContainer::autoAdjustGeometry(const QString& strOperation)
|
void CustomBorderContainer::autoAdjustGeometry(const QString& strOperation)
|
||||||
|
|
@ -349,7 +381,7 @@ void CustomBorderContainer::autoAdjustGeometry(const QString& strOperation)
|
||||||
{
|
{
|
||||||
int nDistance_X_Left2Left = m_pWidget->geometry().left();
|
int nDistance_X_Left2Left = m_pWidget->geometry().left();
|
||||||
int nDistance_X_Right2Right = m_pWidget->geometry().right() - parentWiget->width();
|
int nDistance_X_Right2Right = m_pWidget->geometry().right() - parentWiget->width();
|
||||||
int nDistance_X = m_nAutoAdjustDistance + 1;
|
int nDistance_X;
|
||||||
if(nDistance_X_Left2Left == 0)
|
if(nDistance_X_Left2Left == 0)
|
||||||
nDistance_X = nDistance_X_Right2Right;
|
nDistance_X = nDistance_X_Right2Right;
|
||||||
else if(nDistance_X_Right2Right == 0)
|
else if(nDistance_X_Right2Right == 0)
|
||||||
|
|
@ -361,7 +393,7 @@ void CustomBorderContainer::autoAdjustGeometry(const QString& strOperation)
|
||||||
|
|
||||||
int nDistance_Y_Top2Top = m_pWidget->geometry().top();
|
int nDistance_Y_Top2Top = m_pWidget->geometry().top();
|
||||||
int nDistance_Y_Bottom2Bottom = m_pWidget->geometry().bottom() - parentWiget->height();
|
int nDistance_Y_Bottom2Bottom = m_pWidget->geometry().bottom() - parentWiget->height();
|
||||||
int nDistance_Y = m_nAutoAdjustDistance + 1;
|
int nDistance_Y;
|
||||||
if(nDistance_Y_Top2Top == 0)
|
if(nDistance_Y_Top2Top == 0)
|
||||||
nDistance_Y = nDistance_Y_Bottom2Bottom;
|
nDistance_Y = nDistance_Y_Bottom2Bottom;
|
||||||
else if(nDistance_Y_Bottom2Bottom == 0)
|
else if(nDistance_Y_Bottom2Bottom == 0)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ Dashboard::Dashboard(const QString& strName, QObject *parent)
|
||||||
|
|
||||||
Dashboard::~Dashboard()
|
Dashboard::~Dashboard()
|
||||||
{
|
{
|
||||||
//在这里m_pDisplayArea和m_pTabButton不需要进行手动析构,因为QObject建立起的父子结构会自动析构,自动析构时不会将其置为nullptr,所以if判断无效,会引起'SIGSEGV'(存储器段错误)报错
|
//m_pDisplayArea和m_pTab不需要手动析构,因为QObject建立起的父子结构会自动析构,自动析构时不会将其置为nullptr,所以if判断无效,会引起'SIGSEGV'(存储器段错误)报错
|
||||||
if(m_pTabMenu)
|
if(m_pTabMenu)
|
||||||
{
|
{
|
||||||
delete m_pTabMenu;
|
delete m_pTabMenu;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ DataPanel::DataPanel(QWidget *parent, DataPanelType type)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);
|
setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);
|
||||||
|
//setAttribute(Qt::WA_StaticContents, false); // 禁用静态内容优化
|
||||||
|
//setAttribute(Qt::WA_PaintOnScreen, false); // 默认使用双缓冲
|
||||||
|
|
||||||
m_strName = "";
|
m_strName = "";
|
||||||
m_bMouseEnter = false;
|
m_bMouseEnter = false;
|
||||||
|
|
@ -38,12 +40,17 @@ DataPanel::DataPanel(QWidget *parent, DataPanelType type)
|
||||||
m_pContentWidget = nullptr;
|
m_pContentWidget = nullptr;
|
||||||
m_pScrollArea = nullptr;
|
m_pScrollArea = nullptr;
|
||||||
|
|
||||||
|
/*setStyleSheet("QDialog{\n"
|
||||||
|
" border:2px solid rgb(76,88,105);\n"
|
||||||
|
" background-color:rgba(24,32,38,250);\n"
|
||||||
|
"}\n");*/
|
||||||
|
|
||||||
QWidget* centralWidget = new QWidget(this);
|
QWidget* centralWidget = new QWidget(this);
|
||||||
centralWidget->setObjectName("centralWidget");
|
centralWidget->setObjectName("centralWidget");
|
||||||
centralWidget->setStyleSheet("QWidget #centralWidget{\n"
|
/*centralWidget->setStyleSheet("QWidget #centralWidget{\n"
|
||||||
" border:2px solid rgb(76,88,105);\n"
|
" border:2px solid rgb(76,88,105);\n"
|
||||||
" background-color:rgba(24,32,38,250);\n"
|
" background-color:rgba(24,32,38,250);\n"
|
||||||
"}\n");
|
"}\n");*/
|
||||||
QBoxLayout* centralLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
QBoxLayout* centralLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||||||
centralLayout->setContentsMargins(0, 0, 0, 0);
|
centralLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
centralLayout->addWidget(centralWidget);
|
centralLayout->addWidget(centralWidget);
|
||||||
|
|
@ -67,6 +74,7 @@ DataPanel::DataPanel(QWidget *parent, DataPanelType type)
|
||||||
connect(m_pToolWidget->ui->btnFullScree, SIGNAL(clicked()), this, SLOT(onToolBtnClicked_fullScreen()));
|
connect(m_pToolWidget->ui->btnFullScree, SIGNAL(clicked()), this, SLOT(onToolBtnClicked_fullScreen()));
|
||||||
connect(m_pToolWidget->ui->btnMenu, SIGNAL(clicked()), this, SLOT(onToolBtnClicked_menu()));
|
connect(m_pToolWidget->ui->btnMenu, SIGNAL(clicked()), this, SLOT(onToolBtnClicked_menu()));
|
||||||
m_pToolWidget->raise();
|
m_pToolWidget->raise();
|
||||||
|
m_pToolWidget->hide();
|
||||||
|
|
||||||
m_pToolMenu = new CustomMenu(this);
|
m_pToolMenu = new CustomMenu(this);
|
||||||
connect(m_pToolMenu, SIGNAL(aboutToHide()), this, SLOT(onAboutToHide_toolMenu()));
|
connect(m_pToolMenu, SIGNAL(aboutToHide()), this, SLOT(onAboutToHide_toolMenu()));
|
||||||
|
|
@ -97,7 +105,7 @@ bool DataPanel::event(QEvent* event)
|
||||||
}
|
}
|
||||||
else if(event->type() == QEvent::Show)
|
else if(event->type() == QEvent::Show)
|
||||||
{
|
{
|
||||||
m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3);
|
//m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3);
|
||||||
m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5);
|
m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5);
|
||||||
}
|
}
|
||||||
else if(event->type() == QEvent::Resize || event->type() == QEvent::Move)
|
else if(event->type() == QEvent::Resize || event->type() == QEvent::Move)
|
||||||
|
|
@ -114,6 +122,7 @@ bool DataPanel::event(QEvent* event)
|
||||||
else if(event->type() == QEvent::Enter)
|
else if(event->type() == QEvent::Enter)
|
||||||
{
|
{
|
||||||
//qDebug() << "Enter";
|
//qDebug() << "Enter";
|
||||||
|
m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3);
|
||||||
m_pToolWidget->show();
|
m_pToolWidget->show();
|
||||||
QString strCurState = m_pToolWidget->ui->btnFullScree->property("currentState").toString();
|
QString strCurState = m_pToolWidget->ui->btnFullScree->property("currentState").toString();
|
||||||
if(strCurState == "enterFullScreen")
|
if(strCurState == "enterFullScreen")
|
||||||
|
|
@ -128,11 +137,49 @@ bool DataPanel::event(QEvent* event)
|
||||||
m_pCustomBorderContainer->hideBorderDraw();
|
m_pCustomBorderContainer->hideBorderDraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(event->type() == QEvent::Paint)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
// 绘制背景
|
||||||
|
painter.fillRect(rect(), QColor(24, 32, 38, 250)); // 原样式表背景色
|
||||||
|
// 绘制边框
|
||||||
|
QPen pen(QColor(76, 88, 105), 2); // 原样式表边框颜色和宽度
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawRect(rect().adjusted(1, 1, -1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
return QDialog::event(event);
|
return QDialog::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void DataPanel::keyPressEvent(QKeyEvent* e)
|
/*void DataPanel::paintEvent(QPaintEvent* event)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
// 绘制背景
|
||||||
|
painter.fillRect(rect(), QColor(24, 32, 38, 250)); // 原样式表背景色
|
||||||
|
// 绘制边框
|
||||||
|
QPen pen(QColor(76, 88, 105), 2); // 原样式表边框颜色和宽度
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawRect(rect().adjusted(1, 1, -1, -1));
|
||||||
|
|
||||||
|
// 双缓冲绘制
|
||||||
|
QPainter painter(this);
|
||||||
|
QPixmap buffer(size());
|
||||||
|
buffer.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter bufferPainter(&buffer);
|
||||||
|
bufferPainter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
// 绘制带边框的背景
|
||||||
|
bufferPainter.setPen(QPen(QColor(76,88,105),2));
|
||||||
|
bufferPainter.setBrush(QColor(24,32,38,250));
|
||||||
|
bufferPainter.drawRoundedRect(rect().adjusted(1, 1, -1, -1), 0, 0);
|
||||||
|
|
||||||
|
painter.drawPixmap(0, 0, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataPanel::keyPressEvent(QKeyEvent* e)
|
||||||
{
|
{
|
||||||
if(e->key() == Qt::Key_Escape)
|
if(e->key() == Qt::Key_Escape)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ void TimeLineWidget::mouseMoveEvent(QMouseEvent* e)
|
||||||
d_ptr->m_ptMousePress = e->pos();
|
d_ptr->m_ptMousePress = e->pos();
|
||||||
d_ptr->m_timeMousePress = d_ptr->m_timeLineItem->time();
|
d_ptr->m_timeMousePress = d_ptr->m_timeLineItem->time();
|
||||||
|
|
||||||
|
setDisplayState(historical);
|
||||||
emit viewHistoricalData(dateTime);
|
emit viewHistoricalData(dateTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue