优化代码
parent
311096b8ae
commit
c9907e5b8a
13
Qss.cpp
13
Qss.cpp
|
@ -241,7 +241,6 @@ void QssMainWindow::OnMaxOrRestore(bool max)
|
||||||
this->setFixedHeight(rc.height());
|
this->setFixedHeight(rc.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEFINE_RESIZE(MainWindow)
|
|
||||||
QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/,float scale)
|
QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/,float scale)
|
||||||
: QMainWindow(parent, flags),
|
: QMainWindow(parent, flags),
|
||||||
ICallDPIChanged(),
|
ICallDPIChanged(),
|
||||||
|
@ -258,6 +257,7 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
|
||||||
Qt::FramelessWindowHint|
|
Qt::FramelessWindowHint|
|
||||||
Qt::WindowSystemMenuHint |
|
Qt::WindowSystemMenuHint |
|
||||||
Qt::WindowMinimizeButtonHint);
|
Qt::WindowMinimizeButtonHint);
|
||||||
|
m_frame->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||||
m_frame->setMouseTracking(true);
|
m_frame->setMouseTracking(true);
|
||||||
m_frame->installEventFilter(this);
|
m_frame->installEventFilter(this);
|
||||||
m_titleBar = new QssTtitleBar(m_frame);
|
m_titleBar = new QssTtitleBar(m_frame);
|
||||||
|
@ -265,7 +265,7 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
|
||||||
m_titleBar->SetMainWindow(this);
|
m_titleBar->SetMainWindow(this);
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(m_frame);
|
QVBoxLayout* vbox = new QVBoxLayout(m_frame);
|
||||||
vbox->addWidget(m_titleBar);
|
vbox->addWidget(m_titleBar);
|
||||||
vbox->setMargin(2);
|
vbox->setMargin(1);
|
||||||
vbox->setSpacing(0);
|
vbox->setSpacing(0);
|
||||||
vbox->addWidget(this);
|
vbox->addWidget(this);
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
@ -419,7 +419,6 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev )
|
||||||
QRect rc = mFrameRect;
|
QRect rc = mFrameRect;
|
||||||
if (m_left){
|
if (m_left){
|
||||||
rc.setLeft(rc.left() + dx);
|
rc.setLeft(rc.left() + dx);
|
||||||
rtCentralGeo.setLeft(rtCentralGeo.left() + dx);
|
|
||||||
rtMainWindow.setLeft(rtMainWindow.left() + dx);
|
rtMainWindow.setLeft(rtMainWindow.left() + dx);
|
||||||
}
|
}
|
||||||
if (m_right){
|
if (m_right){
|
||||||
|
@ -437,12 +436,8 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev )
|
||||||
rtCentralGeo.setBottom(rtCentralGeo.bottom() + dy);
|
rtCentralGeo.setBottom(rtCentralGeo.bottom() + dy);
|
||||||
rtMainWindow.setBottom(rtMainWindow.bottom() + dy);
|
rtMainWindow.setBottom(rtMainWindow.bottom() + dy);
|
||||||
}
|
}
|
||||||
this->centralWidget()->raise();
|
|
||||||
this->centralWidget()->setGeometry(rtCentralGeo);
|
|
||||||
m_frame->setGeometry(rc);
|
m_frame->setGeometry(rc);
|
||||||
m_frame->show();
|
m_frame->show();
|
||||||
this->setGeometry(rtMainWindow);
|
|
||||||
this->show();
|
|
||||||
mFrameRect = rc;
|
mFrameRect = rc;
|
||||||
m_CentralRect = rtCentralGeo;
|
m_CentralRect = rtCentralGeo;
|
||||||
m_pos = ev->globalPos();
|
m_pos = ev->globalPos();
|
||||||
|
@ -506,8 +501,7 @@ void QssMainWindow::showEvent(QShowEvent *ev)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QssMainWindow::eventFilter( QObject * obj, QEvent * ev )
|
bool QssMainWindow::eventFilter( QObject * obj, QEvent * ev ){
|
||||||
{
|
|
||||||
if (obj == m_frame)
|
if (obj == m_frame)
|
||||||
{
|
{
|
||||||
if (ev->type() == QEvent::MouseMove)
|
if (ev->type() == QEvent::MouseMove)
|
||||||
|
@ -1013,7 +1007,6 @@ bool QssDialog::eventFilter( QObject * obj, QEvent * ev )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDialog::eventFilter(obj, ev);
|
return QDialog::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
Qss.h
1
Qss.h
|
@ -227,7 +227,6 @@ public:
|
||||||
inline QssTtitleBar* titleBar(){return m_titleBar;}
|
inline QssTtitleBar* titleBar(){return m_titleBar;}
|
||||||
inline QFrame* frame(){return m_frame;}
|
inline QFrame* frame(){return m_frame;}
|
||||||
int CalCursorCol(QPoint pt); //计算鼠标X的位置
|
int CalCursorCol(QPoint pt); //计算鼠标X的位置
|
||||||
DECLARE_RESIZE();
|
|
||||||
virtual bool eventFilter(QObject * obj, QEvent * ev);
|
virtual bool eventFilter(QObject * obj, QEvent * ev);
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
|
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue