diff --git a/Qss.cpp b/Qss.cpp index 805d09d..cd22a66 100644 --- a/Qss.cpp +++ b/Qss.cpp @@ -35,6 +35,18 @@ #define QSSDIALOG_SHADOW_WIDTH 12 #define QSSDIALOG_BODER_WIDTH 0 +enum { + TOPLEFT = 11, + TOP = 12, + TOPRIGHT = 13, + LEFT = 21, + CENTER = 22, + RIGHT = 23, + BUTTOMLEFT = 31, + BUTTOM = 32, + BUTTOMRIGHT = 33 +}; + static void rangeObjectList(QObject*obj,int indent){ QObjectList child = obj->children(); QString tmp(""); @@ -107,6 +119,7 @@ QssTtitleBar::QssTtitleBar(QWidget *parent , }else{ connect(m_closeBtn, SIGNAL(clicked()), parent, SLOT(close())); } + connect(m_minBtn, SIGNAL(clicked()), parent, SLOT(showMinimized())); connect(m_maxBtn, SIGNAL(clicked()), this, SLOT(onMaxOrRestore())); connect(m_restoreBtn, SIGNAL(clicked()), this, SLOT(onMaxOrRestore())); @@ -120,7 +133,7 @@ QssTtitleBar::QssTtitleBar(QWidget *parent , QFile file(":/qss/css/QssTitleBar.css"); if (!file.open(QIODevice::ReadOnly)){ - qDebug()<<"error bar"; + qDebug()<<"error open QssTitleBar"; } QTextStream in(&file); QString css = in.readAll(); @@ -226,8 +239,7 @@ bool QssTtitleBar::eventFilter( QObject * obj, QEvent * ev ) return QWidget::eventFilter(obj, ev); } -void QssMainWindow::OnMaxOrRestore(bool max) -{ +void QssMainWindow::OnMaxOrRestore(bool max) { if (max) { setMinimumSize(0, 0); @@ -333,23 +345,22 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = vbox->setSpacing(0); vbox->addWidget(this); - mFrameRect = m_frame->geometry(); m_rcNormal = m_frame->geometry(); m_rcNormalCentral = this->geometry(); connect(this->titleBar(),SIGNAL( OnMaxOrRestore(bool )),this,SLOT(OnMaxOrRestore(bool))); QFile file(":/qss/css/QssMainWindow.css"); if (!file.open(QIODevice::ReadOnly)){ - qDebug()<<"error bar"; + qDebug()<<"error QssMainWindow.css"; } QTextStream in(&file); QString css = in.readAll(); - qDebug()<setStyleSheet(css); - mShadowMask = new QWidget(this); mShadowMask->setStyleSheet("QWidget{background-color:rgba(1,1,1,0.3);}"); mShadowMask->hide(); + m_frame->setLayout(vbox); + this->setFixedHeight(m_rcNormal.height() - m_titleBar->height()); return; @@ -416,17 +427,7 @@ void QssMainWindow::showMinimized() } -enum { - TOPLEFT = 11, - TOP = 12, - TOPRIGHT = 13, - LEFT = 21, - CENTER = 22, - RIGHT = 23, - BUTTOMLEFT = 31, - BUTTOM = 32, - BUTTOMRIGHT = 33 -}; + void QssMainWindow::setCursorShape(int CalPos) { @@ -511,8 +512,7 @@ int QssMainWindow::CalCursorCol(QPoint pt) } -void QssMainWindow::onMouseMoveEvent(QMouseEvent * ev) -{ +void QssMainWindow::onMouseMoveEvent(QMouseEvent * ev) { if (m_titleBar->maxOrRestore()) { return; @@ -521,12 +521,9 @@ void QssMainWindow::onMouseMoveEvent(QMouseEvent * ev) { setCursorShape(CalCursorPos(ev->pos(),CalCursorCol(ev->pos()))); } - QPoint ptCurrentPos = QCursor::pos(); QRect rtCentralGeo = this->centralWidget()->geometry(); - QRect rtMainWindow = this->geometry(); setCursor(Qt::ArrowCursor); - if (m_mousePressedInBoundy) - { + if (m_mousePressedInBoundy) { int x = ev->globalPos().x(); int y = ev->globalPos().y(); @@ -542,34 +539,45 @@ void QssMainWindow::onMouseMoveEvent(QMouseEvent * ev) if (m_top && dy > 0 && mFrameRect.height() <= m_frame->minimumHeight()) return; - QRect rc = mFrameRect; + QRect layout = this->m_frame->layout()->geometry(); + QRect frame = this->m_frame->geometry(); + + QRect rc = m_rcNormalCentral; if (m_left){ rc.setLeft(rc.left() + dx); - rtMainWindow.setLeft(rtMainWindow.left() + dx); + frame.setLeft(frame.left() + dx); + layout.setLeft(layout.left() + dx); + } if (m_right){ rc.setRight(rc.right() + dx); - rtCentralGeo.setRight(rtCentralGeo.right() + dx); - rtMainWindow.setRight(rtMainWindow.right() + dx); + layout.setRight(layout.right() + dx); + frame.setRight(frame.right() + dx); + } if (m_top){ rc.setTop(rc.top() + dy); - rtCentralGeo.setTop(rtCentralGeo.top() + dy); - rtMainWindow.setTop(rtMainWindow.top() + dy); + layout.setTop(layout.top() + dy); + frame.setTop(frame.top() + dy); + } if (m_bottom){ rc.setBottom(rc.bottom() + dy); - rtCentralGeo.setBottom(rtCentralGeo.bottom() + dy); - rtMainWindow.setBottom(rtMainWindow.bottom() + dy); + layout.setBottom(layout.bottom() + dy); + frame.setBottom(frame.bottom() + dy); } - m_frame->setGeometry(rc); - m_frame->show(); + setMinimumSize(0, 0); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + this->m_frame->setMinimumSize(0, 0); + this->m_frame->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + this->parentWidget()->setGeometry(frame); + + // this->setGeometry(m_rcNormalCentral); mFrameRect = rc; m_CentralRect = rtCentralGeo; m_pos = ev->globalPos(); } - else - { + else { int x = ev->x(); int y = ev->y(); @@ -738,6 +746,8 @@ void QssMainWindow::showEvent(QShowEvent *ev) } bool QssMainWindow::eventFilter(QObject * obj, QEvent * ev){ + + qDebug()<type()<type() == QEvent::Hide){ qDebug()<<"hide"; } @@ -748,6 +758,11 @@ bool QssMainWindow::eventFilter(QObject * obj, QEvent * ev){ if (obj == m_frame) { if (ev->type() == QEvent::Paint){ + if(m_frame->isHidden()){ + qDebug()<<"hidden"; + m_frame->show(); + } +// m_frame->showMaximized(); } if (ev->type() == QEvent::MouseMove) @@ -781,13 +796,17 @@ bool QssMainWindow::eventFilter(QObject * obj, QEvent * ev){ } else if (ev->type() == QEvent::Show) { - QRect rc = m_frame->rect(); - QRect parentRc = m_rcValid; + m_titleBar->show(); + this->showNormal(); + this->centralWidget()->showNormal(); - /** m_frame */ - 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; - m_frame->move(x, y); +// QRect rc = m_frame->rect(); +// QRect parentRc = m_rcValid; + +// /** m_frame */ +// 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; +// m_frame->move(x, y); } else if (ev->type() == QEvent::Close) { @@ -803,7 +822,7 @@ bool QssMainWindow::eventFilter(QObject * obj, QEvent * ev){ else if (ev->type() == QEvent::Hide) { if(m_tray_on){ - m_frame->hide(); +// m_frame->hide(); return true; }else{ close(); @@ -1715,6 +1734,7 @@ void QssDockWidget::setWindowTitle(QString title) bool QssDockWidget::eventFilter(QObject *obj, QEvent *ev) { + qDebug()<objectName(); if (obj == m_frame) { if (ev->type() == QEvent::MouseMove) @@ -1830,7 +1850,7 @@ bool QssDockWidget::eventFilter(QObject *obj, QEvent *ev) } else if (ev->type() == QEvent::Hide) { - m_frame->hide(); +// m_frame->hide(); return true; } }