diff --git a/projection/device/deviceui/videoform.cpp b/projection/device/deviceui/videoform.cpp index 2698238..fca5154 100644 --- a/projection/device/deviceui/videoform.cpp +++ b/projection/device/deviceui/videoform.cpp @@ -38,23 +38,12 @@ const int ERROR_LENGTH = 1; VideoForm::VideoForm(QWidget *parent, int screenIndex) : QWidget(parent), ui(new Ui::videoForm) { m_screenIndex = screenIndex; - if (m_screenIndex != 0) { - QDesktopWidget *desktop = QApplication::desktop(); - kdk::WindowManager::setGeometry(windowHandle(), desktop->screenGeometry(m_screenIndex)); - } - ui->setupUi(this); - kdk::UkuiStyleHelper::self()->removeHeader(this); + m_titleHeight = TITLE_HEIGHT; initUI(); - this->setProperty("useStyleWindowManager", true); + m_loadTimer = new QTimer(this); // 注册快捷键 installShortcut(); - updateShowSize(size()); - - // 注册事件过滤器 - this->installEventFilter(this); - ui->keepRatioWidget->installEventFilter(this); - ui->toolform->installEventFilter(this); m_tableModeListener = new TableModeListener(this); onModeChanged(m_tableModeListener->getMode()); @@ -74,6 +63,13 @@ VideoForm::~VideoForm() void VideoForm::initUI() { + if (m_screenIndex != 0) { + QDesktopWidget *desktop = QApplication::desktop(); + kdk::WindowManager::setGeometry(windowHandle(), desktop->screenGeometry(m_screenIndex)); + } + ui->setupUi(this); + + kdk::UkuiStyleHelper::self()->removeHeader(this); setWindowIcon(QIcon::fromTheme("kylin-connectivity")); setAttribute(Qt::WA_DeleteOnClose); m_videoWidget = new QYUVOpenGLWidget(); @@ -86,18 +82,18 @@ void VideoForm::initUI() ui->keepRatioWidget->setWidthHeightRatio(m_widthHeightRatio); ui->keepRatioWidget->setParent(this); - this->setMouseTracking(true); + installEventFilter(this); + ui->keepRatioWidget->installEventFilter(this); + ui->toolform->installEventFilter(this); + + setMouseTracking(true); m_videoWidget->setMouseTracking(true); ui->keepRatioWidget->setMouseTracking(true); - m_titleHeight = TITLE_HEIGHT; - m_loadTimer = new QTimer(this); } void VideoForm::initConnect() { connect(ui->title, &VideoTitle::sigChangeNavigationStatus, this, &VideoForm::onToolFormStatusChange); - connect(ui->title, &VideoTitle::sigMaxButtonClicked, this, &VideoForm::onMaxButtonClick); - connect(ui->title, &VideoTitle::sigFullScreen, this, &VideoForm::onFullScreen); connect(ui->title, &VideoTitle::sigScroll, this, &VideoForm::onScrollTrigger); connect(m_loadTimer, &QTimer::timeout, this, [this]() { m_isLoading = true; }); connect(m_tableModeListener, &TableModeListener::sigModeChange, this, &VideoForm::onModeChanged); @@ -136,16 +132,18 @@ const QSize &VideoForm::frameSize() void VideoForm::updateRender(const AVFrame *frame) { if (m_videoWidget->isHidden()) { - this->show(); + show(); activateWindow(); setFocus(); + updateShowSize(QSize(frame->width, frame->height)); if (m_loadTimer) { m_loadTimer->start(500); } - updateShowSize(QSize(frame->width, frame->height)); if (m_isLoading) { if (m_loadingWidget) { m_loadingWidget->close(); + m_loadingWidget->deleteLater(); + m_loadingWidget = nullptr; } m_videoWidget->show(); } else { @@ -228,6 +226,8 @@ void VideoForm::moveCenter() kdk::WindowManager::setGeometry( windowHandle(), QRect((screenRect.topRight() - QRect(0, 0, size().width(), size().height()).topRight()), size())); + } else if (m_isTable && !m_isVertical) { + kdk::WindowManager::setGeometry(windowHandle(), QRect((QRect(QPoint(0, 0), size())))); } else { kdk::WindowManager::setGeometry( windowHandle(), @@ -384,7 +384,9 @@ void VideoForm::installShortcut() if (!m_device) { return; } - Q_EMIT ui->title->onFullScreenTrigger(); + if (!m_isFull) { + ui->title->fullScreen(); + } }); } @@ -395,9 +397,6 @@ void VideoForm::updateShowSize(const QSize &newSize) m_isVertical = m_widthHeightRatio < 1.0f; if (m_frameSize != newSize) { m_frameSize = newSize; - if (m_isFull) { - ui->title->onFullScreenTrigger(); - } setWindowSize(); moveCenter(); } @@ -406,7 +405,6 @@ void VideoForm::updateShowSize(const QSize &newSize) void VideoForm::setDevice(BaseDevice *device) { m_device = device; - connect(ui->title, &VideoTitle::sigCloseWindow, m_device, &BaseDevice::sigVideoClose); ui->toolform->setDevice(m_device); } @@ -431,7 +429,7 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event) case QEvent::KeyPress: { QKeyEvent *keyEvent = (QKeyEvent *)event; if (keyEvent->key() == Qt::Key_Escape && m_isFull) { - Q_EMIT ui->title->onFullScreenTrigger(); + ui->title->fullScreen(); return true; } if (!m_device) { @@ -459,72 +457,25 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event) case QEvent::Close: { Q_EMIT m_device->sigVideoClose(); return true; - } - // case QEvent::DragEnter: { - // QDragEnterEvent *dragEnterEvent = (QDragEnterEvent *)event; - // dragEnterEvent->acceptProposedAction(); - // return true; - // } - // case QEvent::Drop: { - // QDropEvent *dropEvent = (QDropEvent *)event; - // if (!m_device) { - // return false; - // } - // const QMimeData *qm = dropEvent->mimeData(); - // QList urls = qm->urls(); - // - // for (const QUrl &url : urls) { - // QString file = url.toLocalFile(); - // QFileInfo fileInfo(file); - // - // if (!fileInfo.exists()) { - // QMessageBox::warning(this, tr("kylin-connectivity"), tr("file does not - // exist"), - // QMessageBox::Ok); - // continue; - // } - // - // if (fileInfo.isFile() && fileInfo.suffix() == "apk") { - // Q_EMIT m_device->installApkRequest(file); - // continue; - // } - // Q_EMIT m_device->pushFileRequest(file, Config::getInstance().getPushFilePath() + - // fileInfo.fileName()); - // } - // - // return true; - // } - case QEvent::MouseButtonPress: { - QMouseEvent *mouseEvent = (QMouseEvent *)event; - m_cursorPos = calCursorPos(mouseEvent->pos(), calCursorX(mouseEvent->pos())); - if (mouseEvent->button() == Qt::LeftButton) { - if (m_cursorPos != CENTER) { - m_resizeFlag = true; - } - m_preGeometry = geometry(); - m_viewMousePos = mouseEvent->globalPos(); - } - return true; - } - case QEvent::MouseButtonRelease: { - m_resizeFlag = false; - return true; - } - case QEvent::MouseMove: { - QMouseEvent *mouseEvent = (QMouseEvent *)event; - if (!(m_isMax || m_isFull)) { - setCursorShape(calCursorPos(mouseEvent->pos(), calCursorX(mouseEvent->pos()))); - if (m_resizeFlag) { - windowZoom(); - } - } - return true; } case QEvent::Resize: { + if (windowState() != Qt::WindowNoState) { + return QWidget::eventFilter(watch, event); + } + if (!m_resizeAuto) { + m_resizeAuto = true; + return QWidget::eventFilter(watch, event); + } + + if (m_timerId) { + killTimer(m_timerId); + m_timerId = 0; + } + m_timerId = startTimer(400); if (m_toolForm) { kdk::WindowManager::setGeometry(m_toolForm->windowHandle(), - QRect(QPoint(0, this->height() - 40), m_toolForm->size())); - m_toolForm->setFixedWidth(this->width()); + QRect(QPoint(0, height() - 40), m_toolForm->size())); + m_toolForm->setFixedWidth(width()); } } default: @@ -657,33 +608,56 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event) return QWidget::eventFilter(watch, event); } -void VideoForm::setCursorShape(int pos) +void VideoForm::timerEvent(QTimerEvent *event) { - Qt::CursorShape cursorShape; - switch (pos) { - case WindowEdge::TOP: - cursorShape = Qt::SizeVerCursor; - break; - case WindowEdge::BUTTOM: - cursorShape = Qt::SizeVerCursor; - break; - case WindowEdge::LEFT: - cursorShape = Qt::SizeHorCursor; - break; - case WindowEdge::RIGHT: - cursorShape = Qt::SizeHorCursor; - break; - case WindowEdge::BUTTOMLEFT: - cursorShape = Qt::SizeBDiagCursor; - break; - case WindowEdge::BUTTOMRIGHT: - cursorShape = Qt::SizeFDiagCursor; - break; - default: - cursorShape = Qt::ArrowCursor; - break; + qInfo() << "Start scaling to scale..."; + m_resizeAuto = false; + killTimer(event->timerId()); + m_timerId = 0; + windowZoom(); +} + +void VideoForm::changeEvent(QEvent *event) +{ + if (QEvent::WindowStateChange == event->type()) { + if (!m_resizeAuto) { + return; + } + m_normalVertical = m_isVertical; + Qt::WindowStates state = windowState(); + qInfo() << "VideoForm state change: " << state; + switch (state) { + case Qt::WindowNoState: { + m_resizeAuto = false; + if (m_isWindeStateChanged) { + m_isWindeStateChanged = false; + windowZoom(); + } + m_isMax = false; + m_isFull = false; + ui->title->show(); + if (m_isToolFormShow) { + ui->toolform->show(); + } + ui->title->setMaxBtnMode(false); + } break; + case Qt::WindowMaximized: { + m_isMax = true; + m_isFull = false; + ui->title->show(); + if (m_isToolFormShow) { + ui->toolform->show(); + } + ui->title->setMaxBtnMode(true); + } break; + case Qt::WindowFullScreen: { + m_isFull = true; + m_isMax = false; + ui->title->hide(); + ui->toolform->hide(); + } break; + } } - this->setCursor(cursorShape); } void VideoForm::onGetInputState() @@ -739,62 +713,34 @@ QPoint VideoForm::cursorPoint() return point; } -int VideoForm::calCursorX(QPoint point) -{ - return (point.x() < frameShape ? 1 : ((point.x() > this->width() - frameShape) ? 3 : 2)); -} - -int VideoForm::calCursorPos(QPoint point, int cursorX) -{ - return ((point.y() < frameShape ? 10 : ((point.y() > this->height() - frameShape) ? 30 : 20)) + cursorX); -} - void VideoForm::windowZoom() { - QPoint currentPoint = QCursor::pos(); //获取当前的点,这个点是全局的 - QPoint moveSize = currentPoint - m_viewMousePos; //计算出移动的位置,当前点 - 鼠标左键按下的点 - QRect tempGeometry = m_preGeometry; // 该值记录窗口缩放变化 - QScreen *screen = QGuiApplication::primaryScreen(); - QRect screenRect = screen->availableGeometry(); - int desktopHeight = QApplication::desktop()->availableGeometry().height(); - int desktopWidth = (desktopHeight - m_titleHeight) * m_widthHeightRatio; - this->setMinimumSize(0, 0); - this->setMaximumSize(desktopWidth, desktopHeight); - switch (m_cursorPos) { - case WindowEdge::LEFT: - tempGeometry.setLeft(m_preGeometry.left() + moveSize.x()); - tempGeometry.setHeight((tempGeometry.width() / m_widthHeightRatio) + m_titleHeight); - break; - case WindowEdge::RIGHT: - tempGeometry.setRight(m_preGeometry.right() + moveSize.x()); - tempGeometry.setHeight((tempGeometry.width() / m_widthHeightRatio) + m_titleHeight); - break; - case WindowEdge::BUTTOMLEFT: - tempGeometry.setBottomLeft(m_preGeometry.bottomLeft() + moveSize); - tempGeometry.setHeight((tempGeometry.width() / m_widthHeightRatio) + m_titleHeight); - break; - case WindowEdge::BUTTOM: - tempGeometry.setBottom(m_preGeometry.bottom() + moveSize.y()); - tempGeometry.setWidth((tempGeometry.height() - m_titleHeight) * m_widthHeightRatio); - break; - case WindowEdge::BUTTOMRIGHT: - tempGeometry.setBottomRight(m_preGeometry.bottomRight() + moveSize); - tempGeometry.setWidth((tempGeometry.height() - m_titleHeight) * m_widthHeightRatio); - break; - default: - break; + QRect tempGeometry = geometry(); + int w = width(); + int h = height(); + if (m_oldHeight == h) { + h = (w / m_widthHeightRatio) + m_titleHeight; + } else { + w = (h - m_titleHeight) * m_widthHeightRatio; } - if (tempGeometry.height() >= screenRect.height()) { - tempGeometry.setHeight(screenRect.height()); - tempGeometry.setWidth((tempGeometry.height() - m_titleHeight) * m_widthHeightRatio - ERROR_LENGTH); - kdk::WindowManager::setGeometry(windowHandle(), tempGeometry); - } else if (tempGeometry.height() <= (screenRect.height() / 2)) { - tempGeometry.setHeight(screenRect.height() / 2); - tempGeometry.setWidth((tempGeometry.height() - m_titleHeight) * m_widthHeightRatio + ERROR_LENGTH); - kdk::WindowManager::setGeometry(windowHandle(), tempGeometry); + setScreenIndex(); + QRect screenRect = getScreenRect(); + if (h >= screenRect.height()) { + h = screenRect.height(); + w = (screenRect.height() - m_titleHeight) * m_widthHeightRatio; + } else if (h <= (screenRect.height() / 2)) { + h = screenRect.height() / 2; + w = (h - m_titleHeight) * m_widthHeightRatio; + } + tempGeometry.setWidth(w); + tempGeometry.setHeight(h); + if (m_toolForm) { + setGeometry(QRect(QPoint(0, h - TITLE_HEIGHT), m_toolForm->size())); + m_toolForm->setFixedWidth(w); } kdk::WindowManager::setGeometry(windowHandle(), tempGeometry); - setFixedSize(tempGeometry.width(), tempGeometry.height()); + setSize(w, h); + m_oldHeight = h; } void VideoForm::showToolForm(bool show) @@ -823,11 +769,34 @@ void VideoForm::onToolFormStatusChange() void VideoForm::setWindowSize() { + m_resizeAuto = false; QSize showSize = size(); setScreenIndex(); QRect screenRect = getScreenRect(); int height = screenRect.height(); int width = screenRect.width(); + int desktopHeight = QApplication::desktop()->availableGeometry().height(); + setMinimumSize((desktopHeight / 2) * m_widthHeightRatio, desktopHeight / 2); + setMaximumSize(desktopHeight * m_widthHeightRatio, desktopHeight); + if (m_isVertical != m_normalVertical) { + if (m_isMax) { + if (m_isTable) { + setSize(desktopHeight * m_widthHeightRatio, desktopHeight); + } else { + showNormal(); + } + showMaximized(); + m_isWindeStateChanged = true; + return; + } + if (m_isFull) { + showNormal(); + showFullScreen(); + m_isWindeStateChanged = true; + return; + } + } + m_resizeAuto = false; if (m_isVertical) { showSize.setHeight(height); showSize.setWidth((height - m_titleHeight) * m_widthHeightRatio); @@ -841,14 +810,13 @@ void VideoForm::setWindowSize() showSize.setWidth((height - m_titleHeight) * m_widthHeightRatio); } } - setFixedSize(showSize); + m_oldHeight = showSize.height(); + resize(showSize); } void VideoForm::onModeChanged(bool isTable) { m_isTable = isTable; - setWindowSize(); - moveCenter(); ui->title->changeMode(m_isTable); } @@ -859,75 +827,6 @@ void VideoForm::onModeRotationsChange(QString rotaion) moveCenter(); } -void VideoForm::onMaxButtonClick(bool max) -{ - m_isMax = max; - saveWindowConfig(); - setScreenIndex(); - - QRect screenRect = getScreenRect(); - int height = screenRect.height(); - int width = screenRect.width(); - - if (m_isMax) { - if (m_beforeIsVertical == m_isVertical) { - setFixedSize(m_beforeSize); - kdk::WindowManager::setGeometry(windowHandle(), QRect(m_beforePoint, size())); - } else { - setWindowSize(); - } - } else { - if (m_isVertical) { - this->setFixedSize((height - m_titleHeight) * m_widthHeightRatio, height); - kdk::WindowManager::setGeometry(windowHandle(), QRect(QPoint(m_beforePoint.x(), 0), size())); - } else { - this->setFixedSize(width, height); - } - } - m_isMax = !m_isMax; -} - -void VideoForm::onFullScreen() -{ - saveWindowConfig(); - setScreenIndex(); - - QRect screenRect = getScreenRect(); - int height = QApplication::desktop()->screenGeometry().height(); - int width = QApplication::desktop()->screenGeometry().width(); - if (m_isFull) { - KWindowSystem::clearState(this->winId(), KWindowSystem::KeepAbove); - ui->title->show(); - if (m_isToolFormShow) { - ui->toolform->show(); - } - if (m_beforeIsVertical == m_isVertical) { - setFixedSize(m_beforeSize); - kdk::WindowManager::setGeometry(windowHandle(), QRect(m_beforePoint, size())); - } else { - setWindowSize(); - } - m_isFull = false; - } else { - KWindowSystem::setState(this->winId(), KWindowSystem::KeepAbove); - ui->title->hide(); - ui->toolform->hide(); - - this->setFixedSize(width, height); - moveCenter(); - m_isFull = true; - } -} - -void VideoForm::saveWindowConfig() -{ - if (!m_isFull && !m_isMax) { - m_beforeIsVertical = m_isVertical; - m_beforePoint = this->pos(); - m_beforeSize = this->size(); - } -} - void VideoForm::onScrollTrigger() { ScrollSettingWidget *scrollWidget = new ScrollSettingWidget(this); @@ -940,4 +839,13 @@ void VideoForm::initPanelSetting() qInfo() << "init panel gsettings"; m_panelSetting = new QGSettings(UKUI_TASK_GSETTING_PATH); } +} + +void VideoForm::setSize(int width, int height) +{ + m_resizeAuto = false; + setFixedSize(width, height); + int desktopHeight = QApplication::desktop()->availableGeometry().height(); + setMinimumSize((desktopHeight / 2) * m_widthHeightRatio, desktopHeight / 2); + setMaximumSize(desktopHeight * m_widthHeightRatio, desktopHeight); } \ No newline at end of file diff --git a/projection/device/deviceui/videoform.h b/projection/device/deviceui/videoform.h index 405f96d..a7a3423 100644 --- a/projection/device/deviceui/videoform.h +++ b/projection/device/deviceui/videoform.h @@ -10,7 +10,7 @@ #include "tablemodelistener.h" namespace Ui { - class videoForm; +class videoForm; } enum WindowEdge { TOP = 12, LEFT = 21, CENTER = 22, RIGHT = 23, BUTTOMLEFT = 31, BUTTOM = 32, BUTTOMRIGHT = 33 }; @@ -51,9 +51,6 @@ public Q_SLOTS: void onModeRotationsChange(QString rotaion); - void onMaxButtonClick(bool max); - - void onFullScreen(); void onScrollTrigger(); void onGetInputState(); @@ -74,14 +71,6 @@ private: void slotActivated(QSystemTrayIcon::ActivationReason reason); - // 设置鼠标形状 - void setCursorShape(int mPos); - - // 计算鼠标光标位置 - int calCursorPos(QPoint pt, int colPos); - - int calCursorX(QPoint pt); - // 窗口缩放 void windowZoom(); @@ -93,11 +82,13 @@ private: QPoint cursorPoint(); QRect getScreenRect(); void setScreenIndex(); - void saveWindowConfig(); void initPanelSetting(); + void setSize(int width, int height); protected: bool eventFilter(QObject *watch, QEvent *event) override; + void timerEvent(QTimerEvent *event) override; + void changeEvent(QEvent *event) override; private: // ui @@ -111,19 +102,11 @@ private: QPoint m_dragPosition; float m_widthHeightRatio = 0.5f; bool m_resizeFlag = false; //窗口大小重置标志 - const int frameShape = 6; //用于鼠标区域判断 - int m_cursorPos; // 鼠标在窗口的位置 - QPoint m_viewMousePos; // 鼠标在全局的位置 - QRect m_preGeometry; // 每次窗口的坐标和宽高 int m_titleHeight; // 标题栏与导航栏高度 - bool m_isVertical = false; // 手机横竖屏 - bool m_isToolFormShow = true; // 是否展示导航栏 - bool m_isMax = false; // 窗口最大化 - bool m_isFull = false; // 窗口全屏 - QPoint m_beforePoint; - QSize m_beforeSize; - bool m_beforeIsVertical; + bool m_isVertical = false; // 手机横竖屏 + bool m_normalVertical = false; // 窗口状态改变之前的横竖屏状态 + bool m_isToolFormShow = true; // 是否展示导航栏 int m_inputX = 0; int m_inputY = 0; int m_screenIndex = 0; @@ -134,6 +117,12 @@ private: QTimer *m_loadTimer = nullptr; TableModeListener *m_tableModeListener = nullptr; bool m_isTable = false; + bool m_isMax = false; + bool m_isFull = false; + int m_timerId = 0; + int m_oldHeight = 0; + int m_resizeAuto = false; + bool m_isWindeStateChanged = false; }; #endif // VIDEOFORM_H diff --git a/projection/uibase/keepratiowidget.cpp b/projection/uibase/keepratiowidget.cpp index e2b9aac..9f9a357 100644 --- a/projection/uibase/keepratiowidget.cpp +++ b/projection/uibase/keepratiowidget.cpp @@ -3,9 +3,13 @@ #include "keepratiowidget.h" -KeepRatioWidget::KeepRatioWidget(QWidget *parent) : QWidget(parent) {} +KeepRatioWidget::KeepRatioWidget(QWidget *parent) : QWidget(parent) +{ +} -KeepRatioWidget::~KeepRatioWidget() {} +KeepRatioWidget::~KeepRatioWidget() +{ +} void KeepRatioWidget::setWidget(QWidget *w) { @@ -74,5 +78,6 @@ void KeepRatioWidget::adjustSubWidget() height = curSize.height(); width = curSize.width(); } + m_subWidget->setGeometry(pos.x(), pos.y(), width, height); } diff --git a/projection/uibase/videotitle.cpp b/projection/uibase/videotitle.cpp index 0b124de..e59e2ca 100644 --- a/projection/uibase/videotitle.cpp +++ b/projection/uibase/videotitle.cpp @@ -136,20 +136,16 @@ void VideoTitle::onMinClick() void VideoTitle::onMaxClick() { - Q_EMIT sigMaxButtonClicked(isMax); // 当前窗口是否最大化,最大化:点击后还原,更换图标。窗口化:点击后最大化,更换图标 - if (isMax) { - isMax = false; - m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic")); + if (window()->isMaximized()) { + window()->showNormal(); } else { - isMax = true; - m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic")); + window()->showMaximized(); } } void VideoTitle::onCloseClick() { - // Q_EMIT sigCloseWindow(); window()->close(); } @@ -180,12 +176,15 @@ void VideoTitle::onStayOnTopTrigger() void VideoTitle::onFullScreenTrigger() { - Q_EMIT sigFullScreen(); - if (isFullScreen) { - isFullScreen = false; + if (window()->isFullScreen()) { + window()->showNormal(); + if (m_oldState == Qt::WindowState::WindowMaximized) { + window()->showMaximized(); + } m_fullScreen->setText(tr("FullScreen")); } else { - isFullScreen = true; + m_oldState = window()->windowState(); + window()->showFullScreen(); m_fullScreen->setText(tr("Cancel FullScreen")); } } @@ -202,13 +201,28 @@ void VideoTitle::onQuitTrigger() void VideoTitle::mouseDoubleClickEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton && (!isFullScreen)) { - if (!m_isTable) { - onMaxClick(); - } + Q_UNUSED(event) + if (window()->isMaximized()) { + window()->showNormal(); + } else { + window()->showMaximized(); } } +void VideoTitle::setMaxBtnMode(bool isMax) +{ + if (!isMax) { + m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic")); + } else { + m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic")); + } +} + +void VideoTitle::fullScreen() +{ + onFullScreenTrigger(); +} + void VideoTitle::changeMode(bool isTable) { m_isTable = isTable; @@ -217,18 +231,12 @@ void VideoTitle::changeMode(bool isTable) // 将Action添加到菜单中 m_menu->removeAction(m_stayOnTop); m_menu->removeAction(m_fullScreen); - if (!isMax) { - onMaxClick(); - } } else { m_maxBtn->show(); // 将Action添加到菜单中 m_actions.clear(); m_actions << m_triple << m_stayOnTop << m_fullScreen << m_scrollWidget << m_actionQuit; m_menu->addActions(m_actions); - if (isMax) { - onMaxClick(); - } } // 为菜单按钮设置菜单 m_menuBtn->setMenu(m_menu); diff --git a/projection/uibase/videotitle.h b/projection/uibase/videotitle.h index 3524e0f..f7fb60f 100644 --- a/projection/uibase/videotitle.h +++ b/projection/uibase/videotitle.h @@ -19,6 +19,8 @@ public: ~VideoTitle(); void changeMode(bool isTable); + void setMaxBtnMode(bool isMax); + void fullScreen(); private: void initUI(); @@ -30,9 +32,6 @@ private: Q_SIGNALS: void sigChangeNavigationStatus(); - void sigMaxButtonClicked(bool isMax); - void sigFullScreen(); - void sigCloseWindow(); void sigScroll(); private Q_SLOTS: @@ -43,8 +42,6 @@ private Q_SLOTS: void onStayOnTopTrigger(); void onScrollTrigger(); void onQuitTrigger(); - -public Q_SLOTS: void onFullScreenTrigger(); protected: @@ -64,12 +61,10 @@ private: QAction *m_fullScreen = nullptr; // 置顶 QAction *m_scrollWidget = nullptr; // 鼠标灵敏度 QAction *m_actionQuit = nullptr; // 退出 - bool isMax = false; bool isTripleShow = true; bool isStayOnTop = false; - bool isFullScreen = false; - TableModeListener *m_tableModeListener = nullptr; bool m_isTable = false; + Qt::WindowStates m_oldState = Qt::WindowState::WindowNoState; }; #endif // VIDEOTITLE_H