diff --git a/client/qt_gl_/yuvgl/Qss/Qss.cpp b/client/qt_gl_/yuvgl/Qss/Qss.cpp index f7ed6af..f59a056 100644 --- a/client/qt_gl_/yuvgl/Qss/Qss.cpp +++ b/client/qt_gl_/yuvgl/Qss/Qss.cpp @@ -26,7 +26,8 @@ #define QSSDIALOG_SHADOW_WIDTH 12 //QFrame#dialog,QFrame#messagebox padding #define QSSDIALOG_BODER_WIDTH 0 -QssTtitleBar::QssTtitleBar(QWidget *parent , QTitleBar_Type type/* = QTitleBar_Type_Window*/) +QssTtitleBar::QssTtitleBar(QWidget *parent , + QTitleBar_Type type/* = QTitleBar_Type_Window*/) : QWidget(parent), m_maxOrRestore(false), m_pressed(false), @@ -88,6 +89,7 @@ QssTtitleBar::QssTtitleBar(QWidget *parent , QTitleBar_Type type/* = QTitleBar_T setWindowFlags(windowFlags()| Qt::MSWindowsFixedSizeDialogHint); this->setGeometry(parent->geometry().x(),parent->geometry().y(),0,0); + m_rcNormal = parentWidget()->geometry(); } QssTtitleBar::~QssTtitleBar() @@ -128,9 +130,15 @@ void QssTtitleBar::onMaxOrRestore() { if (m_type != QTitleBar_Type_MainWindow) return ; - + emit(OnMaxOrRestore(m_maxOrRestore)); + /* if (m_maxOrRestore) { + parentWidget()->setMinimumSize(0, 0); + parentWidget()->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + setMinimumSize(0, 0); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + if (!m_rcNormal.isValid()) { QSize sizeHint = parentWidget()->sizeHint(); @@ -145,32 +153,40 @@ void QssTtitleBar::onMaxOrRestore() m_rcNormal.setHeight(sizeHint.height()); } parentWidget()->setGeometry(m_rcNormal); + parentWidget()->setFixedHeight(m_rcNormal.height()); } else { + parentWidget()->setMinimumSize(0, 0); + parentWidget()->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + setMinimumSize(0, 0); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + + QSize sizeHint = parentWidget()->sizeHint(); + QDesktopWidget desktop; QRect rc = desktop.availableGeometry(-1); QRect curRcMain = m_Main->geometry(); - QRect curRcFrame = parentWidget()->geometry(); QRect curRcCentral = m_Main->centralWidget()->geometry(); + QRect curRcFrame = parentWidget()->geometry(); + + if (rc.width() < m_rcValid.width()&& rc.height()< m_rcValid.height()) + m_rcNormal = curRcFrame; - qDebug()<<"current geometry is "<geometry(); - if (rc.width() < m_rcValid.width() && rc.height() < m_rcValid.height()) - m_rcNormal = rcFrame; qDebug()<<"parent is"<objectName()<objectName(); - parentWidget()->setGeometry(rc); - this->m_Main->setGeometry(rc); - m_Main->centralWidget()->setGeometry(rc); + rc.setRight(rc.right() - 50); + m_Main->setGeometry(rc); + //m_Main->setFixedHeight(rc.height()); curRcMain = m_Main->geometry(); - curRcFrame = parentWidget()->geometry(); - curRcCentral = m_Main->centralWidget()->geometry(); + m_Main->setFixedHeight(rc.height()); + QSizePolicy mainPolicy = m_Main->sizePolicy(); + qDebug()<centralWidget()->setFixedHeight(rc.height()); - qDebug()<<"current geometry is "<m_frame->setMinimumSize(0, 0); + this->m_frame->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + + if (!m_rcNormal.isValid()) + { + QSize sizeHint = parentWidget()->sizeHint(); + if (sizeHint.width() > m_rcValid.width()) + sizeHint.setWidth(m_rcValid.width() -100); + if (sizeHint.height() > m_rcValid.height()) + sizeHint.setHeight(m_rcValid.height() - 100); + + m_rcNormal.setLeft((m_rcValid.width() - sizeHint.width())/2); + m_rcNormal.setTop((m_rcValid.height() - sizeHint.height())/2); + m_rcNormal.setWidth(sizeHint.width()); + m_rcNormal.setHeight(sizeHint.height()); + } + this->setGeometry(m_rcNormal); + this->m_frame->setGeometry(m_rcNormal); + this->centralWidget()->setGeometry(m_rcNormal); + this->setFixedHeight(m_rcNormal.height() + this->titleBar()->height()); + this->m_frame->setFixedHeight(m_rcNormal.height() + this->titleBar()->height()); + + setMinimumSize(0, 0); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + this->m_frame->setMinimumSize(0, 0); + this->m_frame->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + + + } + else + { + setMinimumSize(0, 0); + setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + this->m_frame->setMinimumSize(0, 0); + this->m_frame->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + QSize sizeHint = parentWidget()->sizeHint(); + + QDesktopWidget desktop; + QRect rc = desktop.availableGeometry(-1); + + qDebug()<<"parent is"<objectName()<objectName(); + parentWidget()->setGeometry(rc); + rc.setRight(rc.right() - 50); + + this->setGeometry(rc); + this->setFixedHeight(rc.height()); + + } +} + QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/) : QMainWindow(parent, flags), m_mousePressedInBoundy(false), @@ -242,11 +315,12 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = //css m_frame->setObjectName("window"); - m_frame->setWindowFlags(Qt::Window | Qt::FramelessWindowHint| Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint); + m_frame->setWindowFlags(Qt::Window | + Qt::FramelessWindowHint| + Qt::WindowSystemMenuHint | + Qt::WindowMinimizeButtonHint); m_frame->setMouseTracking(true); m_frame->installEventFilter(this); - - m_titleBar = new QssTtitleBar(m_frame); m_titleBar->installEventFilter(this); m_titleBar->SetMainWindow(this); @@ -259,12 +333,19 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = vbox->setSpacing(0); vbox->addStretch(); - qDebug()<children()[0]->objectName(); installEventFilter(this); + + mFrameRect = m_frame->geometry(); + m_rcNormal = this->geometry(); + + connect(this->titleBar(),SIGNAL( OnMaxOrRestore(bool )),this,SLOT(OnMaxOrRestore(bool))); } - +QssMainWindow::~QssMainWindow() +{ + m_frame->deleteLater(); +} void QssMainWindow::show() { @@ -328,8 +409,6 @@ void QssMainWindow::showFullScreen() { m_titleBar->setMaxOrRestore(true); m_frame->showFullScreen(); - this->showFullScreen(); - this->centralWidget()->showFullScreen(); } void QssMainWindow::showNormal() @@ -365,11 +444,6 @@ int QssMainWindow::CalCursorCol(QPoint pt) void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev ) { - QObjectList t = this->children(); - foreach(auto obj,t){ - qDebug()<<"object name"<objectName(); - } - if (m_titleBar->maxOrRestore()) { return; @@ -396,12 +470,12 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev ) return; if ((m_top || m_bottom) && qAbs(dy) < 5) return; - if (m_left && dx > 0 && m_rect.width() <= m_frame->minimumWidth()) + if (m_left && dx > 0 && mFrameRect.width() <= m_frame->minimumWidth()) return ; - if (m_top && dy > 0 && m_rect.height() <= m_frame->minimumHeight()) + if (m_top && dy > 0 && mFrameRect.height() <= m_frame->minimumHeight()) return; - QRect rc = m_rect; + QRect rc = mFrameRect; if (m_left){ rc.setLeft(rc.left() + dx); rtCentralGeo.setLeft(rtCentralGeo.left() + dx); @@ -422,10 +496,8 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev ) rtCentralGeo.setBottom(rtCentralGeo.bottom() + dy); rtMainWindow.setBottom(rtMainWindow.bottom() + dy); } - QObjectList t = m_frame->children(); - foreach(auto obj,t){ - qDebug()<<"m_frame children name is "<objectName(); - } + + m_rcNormal = rtMainWindow; this->centralWidget()->raise(); this->centralWidget()->setGeometry(rtCentralGeo); @@ -433,9 +505,7 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev ) m_frame->show(); this->setGeometry(rtMainWindow); this->show(); - qDebug()<<"parent is "<parent(); - qDebug()<<"resize set geometry "<globalPos(); } @@ -465,11 +535,9 @@ void QssMainWindow::onMouseMoveEvent( QMouseEvent * ev ) void QssMainWindow::onMousePressEvent( QMouseEvent * ev ) { - qDebug("mouse press"); - m_pos = ev->globalPos(); this->show(); - m_rect = m_frame->geometry(); + mFrameRect = m_frame->geometry(); if(nullptr != centralWidget()){ m_CentralRect = centralWidget()->geometry(); } @@ -485,9 +553,9 @@ void QssMainWindow::onMousePressEvent( QMouseEvent * ev ) setCursor(Qt::ArrowCursor); } } - m_rtPreGeometry = m_rect; - qDebug("frame geometry is %d %d %d %d",m_rect.x(),m_rect.y(), - m_rect.width(),m_rect.height()); + m_rtPreGeometry = mFrameRect; + qDebug("frame geometry is %d %d %d %d",mFrameRect.x(),mFrameRect.y(), + mFrameRect.width(),mFrameRect.height()); } void QssMainWindow::onMouseReleaseEvent( QMouseEvent * ev ) @@ -568,11 +636,11 @@ bool QssMainWindow::eventFilter( QObject * obj, QEvent * ev ) m_frame->setCursor(Qt::ArrowCursor); } if(QEvent::Resize == ev->type()){ - qDebug()<<"resized sended"<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()); + //qDebug()<<"resized sended"<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) { @@ -706,12 +774,12 @@ void QssDialog::onMouseMoveEvent( QMouseEvent * ev ) return; if ((m_top || m_bottom) && qAbs(dy) < 5) return; - if (m_left && dx > 0 && m_rect.width() <= m_frame->minimumWidth()) + if (m_left && dx > 0 && mFrameRect.width() <= m_frame->minimumWidth()) return ; - if (m_top && dy > 0 && m_rect.height() <= m_frame->minimumHeight()) + if (m_top && dy > 0 && mFrameRect.height() <= m_frame->minimumHeight()) return; - QRect rc = m_rect; + QRect rc = mFrameRect; if (m_left) rc.setLeft(rc.left() + dx); if (m_right) @@ -722,7 +790,7 @@ void QssDialog::onMouseMoveEvent( QMouseEvent * ev ) rc.setBottom(rc.bottom() + dy); m_frame->setGeometry(rc); - m_rect = rc; + mFrameRect = rc; m_pos = ev->globalPos(); } else @@ -763,12 +831,12 @@ void QssDockWidget::onMouseMoveEvent( QMouseEvent * ev ) return; if ((m_top || m_bottom) && qAbs(dy) < 5) return; - if (m_left && dx > 0 && m_rect.width() <= m_frame->minimumWidth()) + if (m_left && dx > 0 && mFrameRect.width() <= m_frame->minimumWidth()) return ; - if (m_top && dy > 0 && m_rect.height() <= m_frame->minimumHeight()) + if (m_top && dy > 0 && mFrameRect.height() <= m_frame->minimumHeight()) return; - QRect rc = m_rect; + QRect rc = mFrameRect; if (m_left) rc.setLeft(rc.left() + dx); if (m_right) @@ -779,7 +847,7 @@ void QssDockWidget::onMouseMoveEvent( QMouseEvent * ev ) rc.setBottom(rc.bottom() + dy); m_frame->setGeometry(rc); - m_rect = rc; + mFrameRect = rc; m_pos = ev->globalPos(); } else @@ -809,7 +877,7 @@ void QssDockWidget::onMouseMoveEvent( QMouseEvent * ev ) void QssDialog::onMousePressEvent( QMouseEvent * ev ) { m_pos = ev->globalPos(); - m_rect = m_frame->geometry(); + mFrameRect = m_frame->geometry(); if(m_left || m_right || m_top || m_bottom) { m_mousePressedInBorder = ev->button() == Qt::LeftButton; @@ -821,7 +889,7 @@ void QssDialog::onMousePressEvent( QMouseEvent * ev ) void QssDockWidget::onMousePressEvent( QMouseEvent * ev ) { m_pos = ev->globalPos(); - m_rect = m_frame->geometry(); + mFrameRect = m_frame->geometry(); if(m_left || m_right || m_top || m_bottom) { m_mousePressedInBorder = ev->button() == Qt::LeftButton; diff --git a/client/qt_gl_/yuvgl/Qss/Qss.h b/client/qt_gl_/yuvgl/Qss/Qss.h index 0647d08..1dfb222 100644 --- a/client/qt_gl_/yuvgl/Qss/Qss.h +++ b/client/qt_gl_/yuvgl/Qss/Qss.h @@ -30,6 +30,8 @@ class QssTtitleBar : public QWidget { Q_OBJECT +signals: + void OnMaxOrRestore(bool ); public: enum QTitleBar_Button { @@ -92,12 +94,11 @@ class QssMainWindow : public QMainWindow { Q_OBJECT +public slots: + void OnMaxOrRestore(bool max); public: QssMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); - virtual ~QssMainWindow() - { - m_frame->deleteLater(); - } + virtual ~QssMainWindow(); void show(); void showMinimized(); @@ -119,17 +120,19 @@ private: void onMouseMoveEvent(QMouseEvent * ev); void onMousePressEvent(QMouseEvent * ev); void onMouseReleaseEvent(QMouseEvent * ev); +protected: + QFrame* m_frame; + QRect mFrameRect; + QRect mRect; + QRect m_CentralRect; + QssTtitleBar* m_titleBar; private: - QFrame* m_frame; - QssTtitleBar* m_titleBar; QRect m_rcValid;//桌面最大可用尺寸 QRect m_rcNormal;//还原后窗口尺寸 /** 边框调整大小相关 */ - QRect m_rect; - QRect m_CentralRect; QPoint m_pos; bool m_mousePressedInBoundy; bool m_left,m_right,m_top,m_bottom; @@ -176,7 +179,7 @@ private: QWidget* m_parent; /** 边框调整大小相关 */ - QRect m_rect; + QRect mFrameRect; QPoint m_pos; bool m_mousePressedInBorder; bool m_left,m_right,m_top,m_bottom; @@ -220,7 +223,7 @@ private: QWidget* m_parent; /** 边框调整大小相关 */ - QRect m_rect; + QRect mFrameRect; QPoint m_pos; bool m_mousePressedInBorder; bool m_left,m_right,m_top,m_bottom; diff --git a/client/qt_gl_/yuvgl/Qss/qss.qrc b/client/qt_gl_/yuvgl/Qss/qss.qrc index c553561..0c24518 100644 --- a/client/qt_gl_/yuvgl/Qss/qss.qrc +++ b/client/qt_gl_/yuvgl/Qss/qss.qrc @@ -45,6 +45,7 @@ icon/int.svg icon/objects.svg icon/string.svg + icon/最大化.svg icon/missing.svg diff --git a/client/qt_gl_/yuvgl/mainwindow.cpp b/client/qt_gl_/yuvgl/mainwindow.cpp index 2556c30..3dc31c7 100644 --- a/client/qt_gl_/yuvgl/mainwindow.cpp +++ b/client/qt_gl_/yuvgl/mainwindow.cpp @@ -1,5 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include MainWindow::MainWindow(QWidget *parent) : QssMainWindow(parent), @@ -13,6 +14,15 @@ MainWindow::MainWindow(QWidget *parent) : mAudioCapture(nullptr) { ui->setupUi(this); + this->move(50,50); + int i(0); + QDesktopWidget* desktopWidget = QApplication::desktop(); + QRect clientRect = desktopWidget->availableGeometry(); + QRect applicationRect = desktopWidget->screenGeometry(); + + qDebug()<pos()<m_frame->geometry()<centralWidget()->geometry(); + + this->centralWidget()->setStyleSheet("background:green;"); std::vector cameras = Camera::EnumAllCamera(); for(std::wstring x : cameras){ ui->comboBox->addItem(QString::fromWCharArray(x.c_str(),x.size()), @@ -22,8 +32,8 @@ MainWindow::MainWindow(QWidget *parent) : mMic = mAudioCapture->EnumSpeakers(); qDebug()<<"capture "<::iterator itr = mMic.begin();itr != mMic.end();itr++){ - ui->comboBox_2->addItem(QString::fromLocal8Bit(itr->name.c_str(),itr->name.size()), - QString::fromLocal8Bit(itr->name.c_str(),itr->name.size())); + + } //mAudioCapture->SetObserver(mAudioCoder); //mAudioCapture->InitCapture(0, 44100, 2); @@ -56,6 +66,7 @@ void MainWindow::on_pushButton_clicked(){ m_bCameraOpen = true; mPlayerWidget->show(); ui->verticalLayout->addWidget(mPlayerWidget); + qDebug()<verticalLayout->layout(); ui->verticalLayout->setStretch(0,1); ui->verticalLayout->setStretch(1,0); ui->verticalLayout->setStretch(2,9); diff --git a/client/qt_gl_/yuvgl/mainwindow.ui b/client/qt_gl_/yuvgl/mainwindow.ui index 150ac3e..5f6cc67 100644 --- a/client/qt_gl_/yuvgl/mainwindow.ui +++ b/client/qt_gl_/yuvgl/mainwindow.ui @@ -172,24 +172,6 @@ - - - - 0 - 0 - 1383 - 26 - - - - - - TopToolBarArea - - - false - -