no message
parent
c9907e5b8a
commit
e4ba3226ed
44
Qss.cpp
44
Qss.cpp
|
@ -407,9 +407,9 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev )
|
||||||
int dx = x - m_pos.x();
|
int dx = x - m_pos.x();
|
||||||
int dy = y - m_pos.y();
|
int dy = y - m_pos.y();
|
||||||
|
|
||||||
if ((m_left || m_right) && qAbs(dx) < 5)
|
if ((m_left || m_right) && qAbs(dx) < 10)
|
||||||
return;
|
return;
|
||||||
if ((m_top || m_bottom) && qAbs(dy) < 5)
|
if ((m_top || m_bottom) && qAbs(dy) < 15)
|
||||||
return;
|
return;
|
||||||
if (m_left && dx > 0 && mFrameRect.width() <= m_frame->minimumWidth())
|
if (m_left && dx > 0 && mFrameRect.width() <= m_frame->minimumWidth())
|
||||||
return ;
|
return ;
|
||||||
|
@ -448,10 +448,10 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev )
|
||||||
int y = ev->y();
|
int y = ev->y();
|
||||||
|
|
||||||
QRect rc = m_frame->rect();
|
QRect rc = m_frame->rect();
|
||||||
m_left = qAbs(x - rc.left()) <= 5;
|
m_left = qAbs(x - rc.left()) <= 10;
|
||||||
m_right = qAbs(x - rc.right()) <= 5;
|
m_right = qAbs(x - rc.right()) <= 10;
|
||||||
m_top = qAbs(y - rc.top()) <= 5;
|
m_top = qAbs(y - rc.top()) <= 10;
|
||||||
m_bottom = qAbs(y - rc.bottom()) <= 5;
|
m_bottom = qAbs(y - rc.bottom()) <= 10;
|
||||||
|
|
||||||
if ((m_left && m_top) || (m_right && m_bottom))
|
if ((m_left && m_top) || (m_right && m_bottom))
|
||||||
m_frame->setCursor(Qt::SizeFDiagCursor);
|
m_frame->setCursor(Qt::SizeFDiagCursor);
|
||||||
|
@ -572,11 +572,7 @@ bool QssMainWindow::eventFilter( QObject * obj, QEvent * ev ){
|
||||||
m_frame->setCursor(Qt::ArrowCursor);
|
m_frame->setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
if(QEvent::Resize == ev->type()){
|
if(QEvent::Resize == ev->type()){
|
||||||
//qDebug()<<"resized sended"<<this->objectName();
|
|
||||||
//QRect rtTempGeometry = this->frameGeometry();
|
|
||||||
//qDebug("re geomotry size is %d %d %d %d",rtTempGeometry.x(),
|
|
||||||
// rtTempGeometry.y(),rtTempGeometry.width(),rtTempGeometry.height());
|
|
||||||
//this->setGeometry(rtTempGeometry.x(),rtTempGeometry.y(),rtTempGeometry.width(),rtTempGeometry.height());
|
|
||||||
}
|
}
|
||||||
else if (ev->type() == QEvent::MouseButtonRelease)
|
else if (ev->type() == QEvent::MouseButtonRelease)
|
||||||
{
|
{
|
||||||
|
@ -595,7 +591,6 @@ bool QssMainWindow::eventFilter( QObject * obj, QEvent * ev ){
|
||||||
if(QEvent::Resize == ev->type()){
|
if(QEvent::Resize == ev->type()){
|
||||||
QDesktopWidget desktop;
|
QDesktopWidget desktop;
|
||||||
QRect sizeHint = desktop.availableGeometry(-1);
|
QRect sizeHint = desktop.availableGeometry(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
return QMainWindow::eventFilter(obj, ev);
|
return QMainWindow::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
@ -1373,15 +1368,15 @@ void QssMessageBox::aboutQt( QWidget *parent, const QString &title /*= QString()
|
||||||
|
|
||||||
QssDockWidget::QssDockWidget(QWidget *parent)
|
QssDockWidget::QssDockWidget(QWidget *parent)
|
||||||
: QDockWidget(parent),
|
: QDockWidget(parent),
|
||||||
m_mousePressedInBorder(false),
|
m_parent(parent),
|
||||||
m_parent(parent)
|
m_mousePressedInBorder(false)
|
||||||
{
|
{
|
||||||
m_rcValid = QApplication::desktop()->availableGeometry();
|
m_rcValid = QApplication::desktop()->availableGeometry();
|
||||||
|
|
||||||
m_frame = new QFrame(parent);
|
m_frame = new QFrame(parent);
|
||||||
m_frame->setObjectName("dialog");//css
|
m_frame->setObjectName("dialog");//css
|
||||||
m_frame->setAttribute(Qt::WA_TranslucentBackground);/** padding css boder<65><72>*/
|
m_frame->setAttribute(Qt::WA_TranslucentBackground);/** padding css boder<65><72>*/
|
||||||
m_frame->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint/* | Qt::WindowMinimizeButtonHint*/);//Qt::WindowMinimizeButtonHintdialog<6F><67>
|
m_frame->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint
|
||||||
m_frame->setMouseTracking(true);
|
m_frame->setMouseTracking(true);
|
||||||
m_frame->installEventFilter(this);
|
m_frame->installEventFilter(this);
|
||||||
|
|
||||||
|
@ -1470,22 +1465,20 @@ bool QssDockWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
else if (ev->type() == QEvent::Show)
|
else if (ev->type() == QEvent::Show)
|
||||||
{
|
{
|
||||||
QRect rc = m_frame->rect(), parentRc;
|
QRect rc = m_frame->rect(), parentRc;
|
||||||
if (m_parent)/**<2A><> */
|
if (m_parent)
|
||||||
{
|
{
|
||||||
/** */
|
|
||||||
QPoint pt = m_parent->mapToGlobal(QPoint(0,0));
|
QPoint pt = m_parent->mapToGlobal(QPoint(0,0));
|
||||||
parentRc =m_parent->rect();
|
parentRc =m_parent->rect();
|
||||||
parentRc.translate(pt);
|
parentRc.translate(pt);
|
||||||
}
|
}
|
||||||
else/** */
|
else
|
||||||
parentRc = m_rcValid;
|
parentRc = m_rcValid;
|
||||||
|
|
||||||
/** m_frame */
|
|
||||||
int x = parentRc.left() + (parentRc.width() - rc.width())*0.5;x = x <= 0?1:x;
|
int x = parentRc.left() + (parentRc.width() - rc.width())*0.5;x = x <= 0?1:x;
|
||||||
int y = parentRc.top() + (parentRc.height() - rc.height())*0.5;y = y <= 0?1:y;
|
int y = parentRc.top() + (parentRc.height() - rc.height())*0.5;y = y <= 0?1:y;
|
||||||
m_frame->move(x,y);
|
m_frame->move(x,y);
|
||||||
|
|
||||||
/** */
|
|
||||||
QPropertyAnimation* aniSize = new QPropertyAnimation(m_frame,"geometry");
|
QPropertyAnimation* aniSize = new QPropertyAnimation(m_frame,"geometry");
|
||||||
aniSize->setDuration(200);
|
aniSize->setDuration(200);
|
||||||
aniSize->setKeyValueAt(0, QRect(x,y,0,0));
|
aniSize->setKeyValueAt(0, QRect(x,y,0,0));
|
||||||
|
@ -1502,9 +1495,7 @@ bool QssDockWidget::eventFilter(QObject *obj, QEvent *ev)
|
||||||
aniGroup->addAnimation(aniSize);
|
aniGroup->addAnimation(aniSize);
|
||||||
aniGroup->addAnimation(aniOpacity);
|
aniGroup->addAnimation(aniOpacity);
|
||||||
|
|
||||||
/** <20><> */
|
|
||||||
aniGroup->start(QAbstractAnimation::DeleteWhenStopped);
|
aniGroup->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (ev->type() == QEvent::Close)
|
else if (ev->type() == QEvent::Close)
|
||||||
{
|
{
|
||||||
|
@ -1557,10 +1548,7 @@ QssToastWidget::QssToastWidget(QWidget *parent)
|
||||||
|
|
||||||
QssToastWidget::~QssToastWidget()
|
QssToastWidget::~QssToastWidget()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QssToastWidget::setText(const QString& text)
|
void QssToastWidget::setText(const QString& text)
|
||||||
{
|
{
|
||||||
ui.label->setText(text);
|
ui.label->setText(text);
|
||||||
|
@ -1595,12 +1583,10 @@ void QssToastWidget::showAnimation(int timeout /*= 2000*/)
|
||||||
void QssToastWidget::showTip(const QString& text, QWidget* parent /*= nullptr*/)
|
void QssToastWidget::showTip(const QString& text, QWidget* parent /*= nullptr*/)
|
||||||
{
|
{
|
||||||
QssToastWidget* toast = new QssToastWidget(parent);
|
QssToastWidget* toast = new QssToastWidget(parent);
|
||||||
toast->setWindowFlags(toast->windowFlags() | Qt::WindowStaysOnTopHint); // 置顶
|
toast->setWindowFlags(toast->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
toast->setText(text);
|
toast->setText(text);
|
||||||
toast->setStyleSheet("font:bold;font-size:24px;color:rgb(255,255,255);");
|
toast->setStyleSheet("font:bold;font-size:24px;color:rgb(255,255,255);");
|
||||||
toast->adjustSize(); //设置完文本后调整下大小
|
toast->adjustSize();
|
||||||
|
|
||||||
// 测试显示位于主屏的70%高度位置
|
|
||||||
QScreen* pScreen = QGuiApplication::primaryScreen();
|
QScreen* pScreen = QGuiApplication::primaryScreen();
|
||||||
toast->move((pScreen->size().width() - toast->width()) / 2,
|
toast->move((pScreen->size().width() - toast->width()) / 2,
|
||||||
pScreen->size().height() * 5 / 10);
|
pScreen->size().height() * 5 / 10);
|
||||||
|
|
Loading…
Reference in New Issue