🐞 fix(投屏模块): 修改响应平板模式切换
This commit is contained in:
parent
463f04feda
commit
bb94b31c19
|
@ -23,13 +23,12 @@
|
|||
#include "ui_videoform.h"
|
||||
#include "generatetools.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include "libavutil/frame.h"
|
||||
}
|
||||
|
||||
#ifndef UKUI_TASK_GSETTING_PATH
|
||||
#define UKUI_TASK_GSETTING_PATH "org.ukui.panel.settings"
|
||||
# define UKUI_TASK_GSETTING_PATH "org.ukui.panel.settings"
|
||||
#endif
|
||||
|
||||
const int TITLE_HEIGHT = 40;
|
||||
|
@ -57,6 +56,10 @@ VideoForm::VideoForm(QWidget *parent, int screenIndex) : QWidget(parent), ui(new
|
|||
ui->keepRatioWidget->installEventFilter(this);
|
||||
ui->toolform->installEventFilter(this);
|
||||
|
||||
m_tableModeListener = new TableModeListener(this);
|
||||
onModeChanged(m_tableModeListener->getMode());
|
||||
onModeRotationsChange(m_tableModeListener->getRotations());
|
||||
|
||||
initConnect();
|
||||
initPanelSetting();
|
||||
}
|
||||
|
@ -96,9 +99,9 @@ void VideoForm::initConnect()
|
|||
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_loadTimer, &QTimer::timeout, this, [this]() { m_isLoading = true; });
|
||||
connect(m_tableModeListener, &TableModeListener::sigModeChange, this, &VideoForm::onModeChanged);
|
||||
connect(m_tableModeListener, &TableModeListener::sigRotationsChange, this, &VideoForm::onModeRotationsChange);
|
||||
}
|
||||
|
||||
void VideoForm::deleteUI()
|
||||
|
@ -168,24 +171,24 @@ QRect VideoForm::getScreenRect()
|
|||
int panelHeight = 0;
|
||||
int panelWidth = 0;
|
||||
switch (panelPosition) {
|
||||
case 0: { // 下
|
||||
panelHeight = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 1: { // 上
|
||||
panelHeight = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 2: { // 左
|
||||
panelWidth = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 3: { // 右
|
||||
panelWidth = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case 0: { // 下
|
||||
panelHeight = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 1: { // 上
|
||||
panelHeight = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 2: { // 左
|
||||
panelWidth = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
case 3: { // 右
|
||||
panelWidth = m_panelSetting->get("panelsize").toInt();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
screenRect.setHeight(screenRect.height() - panelHeight);
|
||||
screenRect.setWidth(screenRect.width() - panelWidth);
|
||||
|
@ -218,7 +221,7 @@ void VideoForm::moveCenter()
|
|||
return;
|
||||
}
|
||||
// 垂直窗口在最右侧,横屏时窗口居中
|
||||
if (m_isVertical) {
|
||||
if (!m_isTable && m_isVertical) {
|
||||
kdk::WindowManager::setGeometry(
|
||||
windowHandle(),
|
||||
QRect((screenRect.topRight() - QRect(0, 0, size().width(), size().height()).topRight()), size()));
|
||||
|
@ -408,238 +411,242 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event)
|
|||
{
|
||||
if (watch == this) {
|
||||
switch (event->type()) {
|
||||
case QEvent::InputMethod: {
|
||||
this->changeInputBoxPos();
|
||||
QInputMethodEvent *inputMethodEvent = (QInputMethodEvent *)event;
|
||||
if (!hasFocus()) { //失去焦点时,输入法事件优先于FocusOut事件被处理
|
||||
inputMethodEvent->setCommitString(""); //将失去焦点后提交的字符串设置为空
|
||||
} else {
|
||||
QString commitText = inputMethodEvent->commitString();
|
||||
if (!commitText.isEmpty()) {
|
||||
qDebug() << "commitText = " << commitText;
|
||||
Q_EMIT m_device->sigInputChinese(commitText);
|
||||
case QEvent::InputMethod: {
|
||||
this->changeInputBoxPos();
|
||||
QInputMethodEvent *inputMethodEvent = (QInputMethodEvent *)event;
|
||||
if (!hasFocus()) { //失去焦点时,输入法事件优先于FocusOut事件被处理
|
||||
inputMethodEvent->setCommitString(""); //将失去焦点后提交的字符串设置为空
|
||||
} else {
|
||||
QString commitText = inputMethodEvent->commitString();
|
||||
if (!commitText.isEmpty()) {
|
||||
qDebug() << "commitText = " << commitText;
|
||||
Q_EMIT m_device->sigInputChinese(commitText);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::KeyPress: {
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (keyEvent->key() == Qt::Key_Escape && m_isFull) {
|
||||
Q_EMIT ui->title->onFullScreenTrigger();
|
||||
return true;
|
||||
}
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
Q_EMIT m_device->keyEvent(keyEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
case QEvent::KeyRelease: {
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_EMIT m_device->keyEvent(keyEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
case QEvent::Paint: {
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
return true;
|
||||
}
|
||||
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<QUrl> 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) {
|
||||
resizeFlag = true;
|
||||
case QEvent::KeyPress: {
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (keyEvent->key() == Qt::Key_Escape && m_isFull) {
|
||||
Q_EMIT ui->title->onFullScreenTrigger();
|
||||
return true;
|
||||
}
|
||||
m_preGeometry = geometry();
|
||||
m_viewMousePos = mouseEvent->globalPos();
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
Q_EMIT m_device->keyEvent(keyEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
resizeFlag = false;
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (!(m_isMax || m_isFull)) {
|
||||
setCursorShape(calCursorPos(mouseEvent->pos(), calCursorX(mouseEvent->pos())));
|
||||
windowZoom();
|
||||
case QEvent::KeyRelease: {
|
||||
QKeyEvent *keyEvent = (QKeyEvent *)event;
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_EMIT m_device->keyEvent(keyEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::Resize: {
|
||||
if (m_toolForm) {
|
||||
kdk::WindowManager::setGeometry(m_toolForm->windowHandle(),
|
||||
QRect(QPoint(0, this->height() - 40), m_toolForm->size()));
|
||||
m_toolForm->setFixedWidth(this->width());
|
||||
case QEvent::Paint: {
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
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<QUrl> 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) {
|
||||
resizeFlag = true;
|
||||
}
|
||||
m_preGeometry = geometry();
|
||||
m_viewMousePos = mouseEvent->globalPos();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
resizeFlag = false;
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (!(m_isMax || m_isFull)) {
|
||||
setCursorShape(calCursorPos(mouseEvent->pos(), calCursorX(mouseEvent->pos())));
|
||||
windowZoom();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::Resize: {
|
||||
if (m_toolForm) {
|
||||
kdk::WindowManager::setGeometry(m_toolForm->windowHandle(),
|
||||
QRect(QPoint(0, this->height() - 40), m_toolForm->size()));
|
||||
m_toolForm->setFixedWidth(this->width());
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (watch == ui->keepRatioWidget) {
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (mouseEvent->button() == Qt::MiddleButton) {
|
||||
if (m_device && !m_device->isCurrentCustomKeymap()) {
|
||||
return false;
|
||||
case QEvent::MouseButtonPress: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (mouseEvent->button() == Qt::MiddleButton) {
|
||||
if (m_device && !m_device->isCurrentCustomKeymap()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mouseEvent->button() == Qt::RightButton) {
|
||||
if (m_device && !m_device->isCurrentCustomKeymap()) {
|
||||
return false;
|
||||
if (mouseEvent->button() == Qt::RightButton) {
|
||||
if (m_device && !m_device->isCurrentCustomKeymap()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else {
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
m_dragPosition = mouseEvent->globalPos() - frameGeometry().topLeft();
|
||||
mouseEvent->accept();
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else {
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
m_dragPosition = mouseEvent->globalPos() - frameGeometry().topLeft();
|
||||
mouseEvent->accept();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::Enter: {
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else if (!m_dragPosition.isNull()) {
|
||||
if (mouseEvent->buttons() & Qt::LeftButton) {
|
||||
kdk::WindowManager::setGeometry(windowHandle(),
|
||||
QRect((mouseEvent->globalPos() - m_dragPosition), size()));
|
||||
mouseEvent->accept();
|
||||
}
|
||||
case QEvent::Enter: {
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_dragPosition.isNull()) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
case QEvent::MouseMove: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else if (!m_dragPosition.isNull()) {
|
||||
if (mouseEvent->buttons() & Qt::LeftButton) {
|
||||
kdk::WindowManager::setGeometry(windowHandle(),
|
||||
QRect((mouseEvent->globalPos() - m_dragPosition), size()));
|
||||
mouseEvent->accept();
|
||||
}
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
// local check
|
||||
QPointF local = mouseEvent->localPos();
|
||||
if (local.x() < 0) {
|
||||
local.setX(0);
|
||||
}
|
||||
if (local.x() > m_videoWidget->width()) {
|
||||
local.setX(m_videoWidget->width());
|
||||
}
|
||||
if (local.y() < 0) {
|
||||
local.setY(0);
|
||||
}
|
||||
if (local.y() > m_videoWidget->height()) {
|
||||
local.setY(m_videoWidget->height());
|
||||
}
|
||||
mouseEvent->setLocalPos(local);
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else {
|
||||
m_dragPosition = QPoint(0, 0);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::MouseButtonDblClick: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
case QEvent::MouseButtonRelease: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_dragPosition.isNull()) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
// local check
|
||||
QPointF local = mouseEvent->localPos();
|
||||
if (local.x() < 0) {
|
||||
local.setX(0);
|
||||
}
|
||||
if (local.x() > m_videoWidget->width()) {
|
||||
local.setX(m_videoWidget->width());
|
||||
}
|
||||
if (local.y() < 0) {
|
||||
local.setY(0);
|
||||
}
|
||||
if (local.y() > m_videoWidget->height()) {
|
||||
local.setY(m_videoWidget->height());
|
||||
}
|
||||
mouseEvent->setLocalPos(local);
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
} else {
|
||||
m_dragPosition = QPoint(0, 0);
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case QEvent::Wheel: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
case QEvent::MouseButtonDblClick: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
}
|
||||
QPoint globalPos = mouseEvent->globalPos();
|
||||
QPointF pos = m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->pos());
|
||||
QWheelEvent *wheelEvent1 = (QWheelEvent *)event;
|
||||
QWheelEvent wheelEvent(pos, globalPos, wheelEvent1->pixelDelta(), wheelEvent1->angleDelta(),
|
||||
wheelEvent1->buttons(), wheelEvent1->modifiers(), wheelEvent1->phase(),
|
||||
wheelEvent1->inverted());
|
||||
Q_EMIT m_device->wheelEvent(&wheelEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case QEvent::Wheel: {
|
||||
QMouseEvent *mouseEvent = (QMouseEvent *)event;
|
||||
if (m_videoWidget->geometry().contains(mouseEvent->pos())) {
|
||||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
QPoint globalPos = mouseEvent->globalPos();
|
||||
QPointF pos = m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->pos());
|
||||
QWheelEvent *wheelEvent1 = (QWheelEvent *)event;
|
||||
QWheelEvent wheelEvent(pos, globalPos, wheelEvent1->pixelDelta(), wheelEvent1->angleDelta(),
|
||||
wheelEvent1->buttons(), wheelEvent1->modifiers(), wheelEvent1->phase(),
|
||||
wheelEvent1->inverted());
|
||||
Q_EMIT m_device->wheelEvent(&wheelEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (watch == ui->toolform) {
|
||||
switch (event->type()) {
|
||||
case QEvent::Enter: {
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case QEvent::Enter: {
|
||||
this->setCursor(Qt::ArrowCursor);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(watch, event);
|
||||
|
@ -649,27 +656,27 @@ void VideoForm::setCursorShape(int pos)
|
|||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
this->setCursor(cursorShape);
|
||||
}
|
||||
|
@ -701,7 +708,7 @@ void VideoForm::changeInputBoxPos()
|
|||
if (testAttribute(Qt::WA_InputMethodEnabled)) {
|
||||
QTransform t;
|
||||
QPoint p = cursorPoint();
|
||||
t.translate(p.x() - this->width() / 2, p.y() - this->height()); //平移x,y
|
||||
t.translate(p.x() - this->width() / 2, p.y() - this->height()); //平移x,y
|
||||
QGuiApplication::inputMethod()->setInputItemTransform(t);
|
||||
QGuiApplication::inputMethod()->setInputItemRectangle(this->rect());
|
||||
QGuiApplication::inputMethod()->update(Qt::ImQueryInput);
|
||||
|
@ -739,9 +746,9 @@ int VideoForm::calCursorPos(QPoint point, int cursorX)
|
|||
|
||||
void VideoForm::windowZoom()
|
||||
{
|
||||
QPoint currentPoint = QCursor::pos(); //获取当前的点,这个点是全局的
|
||||
QPoint moveSize = currentPoint - m_viewMousePos; //计算出移动的位置,当前点 - 鼠标左键按下的点
|
||||
QRect tempGeometry = m_preGeometry; // 该值记录窗口缩放变化
|
||||
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();
|
||||
|
@ -750,28 +757,28 @@ void VideoForm::windowZoom()
|
|||
this->setMaximumSize(desktopWidth, desktopHeight);
|
||||
if (resizeFlag) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
if (tempGeometry.height() >= screenRect.height()) {
|
||||
tempGeometry.setHeight(screenRect.height());
|
||||
|
@ -836,6 +843,23 @@ void VideoForm::setWindowSize()
|
|||
setFixedSize(showSize);
|
||||
}
|
||||
|
||||
void VideoForm::onModeChanged(bool isTable)
|
||||
{
|
||||
m_isTable = isTable;
|
||||
ui->title->changeMode(m_isTable);
|
||||
}
|
||||
|
||||
void VideoForm::onModeRotationsChange(QString rotaion)
|
||||
{
|
||||
if (rotaion == NORMAL) {
|
||||
m_isNormal = true;
|
||||
} else {
|
||||
m_isNormal = false;
|
||||
}
|
||||
setWindowSize();
|
||||
moveCenter();
|
||||
}
|
||||
|
||||
void VideoForm::onMaxButtonClick(bool max)
|
||||
{
|
||||
m_isMax = max;
|
||||
|
@ -846,7 +870,6 @@ void VideoForm::onMaxButtonClick(bool max)
|
|||
int height = screenRect.height();
|
||||
int width = screenRect.width();
|
||||
|
||||
|
||||
if (m_isMax) {
|
||||
if (m_beforeIsVertical == m_isVertical) {
|
||||
setFixedSize(m_beforeSize);
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
#include "loadanimation.h"
|
||||
#include "tablemodelistener.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class videoForm;
|
||||
namespace Ui {
|
||||
class videoForm;
|
||||
}
|
||||
|
||||
enum WindowEdge { TOP = 12, LEFT = 21, CENTER = 22, RIGHT = 23, BUTTOMLEFT = 31, BUTTOM = 32, BUTTOMRIGHT = 33 };
|
||||
|
@ -48,6 +47,10 @@ public:
|
|||
public Q_SLOTS:
|
||||
void onToolFormStatusChange();
|
||||
|
||||
void onModeChanged(bool isTable);
|
||||
|
||||
void onModeRotationsChange(QString rotaion);
|
||||
|
||||
void onMaxButtonClick(bool max);
|
||||
|
||||
void onFullScreen();
|
||||
|
@ -107,17 +110,17 @@ private:
|
|||
QSize m_frameSize;
|
||||
QPoint m_dragPosition;
|
||||
float m_widthHeightRatio = 0.5f;
|
||||
bool resizeFlag = false; //窗口大小重置标志
|
||||
const int frameShape = 6; //用于鼠标区域判断
|
||||
int m_cursorPos; // 鼠标在窗口的位置
|
||||
QPoint m_viewMousePos; // 鼠标在全局的位置
|
||||
QRect m_preGeometry; // 每次窗口的坐标和宽高
|
||||
int m_titleHeight; // 标题栏与导航栏高度
|
||||
bool 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; // 窗口全屏
|
||||
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;
|
||||
|
@ -130,6 +133,8 @@ private:
|
|||
bool m_isLoading = false;
|
||||
QTimer *m_loadTimer = nullptr;
|
||||
TableModeListener *m_tableModeListener = nullptr;
|
||||
bool m_isTable = false;
|
||||
bool m_isNormal = true;
|
||||
};
|
||||
|
||||
#endif // VIDEOFORM_H
|
||||
#endif // VIDEOFORM_H
|
||||
|
|
|
@ -9,8 +9,6 @@ VideoTitle::VideoTitle(QWidget *parent) : QWidget(parent)
|
|||
initUI();
|
||||
// 设置菜单
|
||||
initMenu();
|
||||
m_tableModeListener = new TableModeListener(this);
|
||||
onModeChanged(m_tableModeListener->getMode());
|
||||
// 信号连接槽
|
||||
connectInit();
|
||||
}
|
||||
|
@ -108,19 +106,17 @@ void VideoTitle::connectInit()
|
|||
connect(m_fullScreen, &QAction::triggered, this, &VideoTitle::onFullScreenTrigger);
|
||||
connect(m_scrollWidget, &QAction::triggered, this, &VideoTitle::onScrollTrigger);
|
||||
connect(m_actionQuit, &QAction::triggered, this, &VideoTitle::onQuitTrigger);
|
||||
|
||||
connect(m_tableModeListener, &TableModeListener::sigModeChange, this, &VideoTitle::onModeChanged);
|
||||
}
|
||||
|
||||
// 设置菜单按钮
|
||||
void VideoTitle::initMenu()
|
||||
{
|
||||
// 创建Action
|
||||
m_triple = new QAction(m_menu); // 三联按钮
|
||||
m_stayOnTop = new QAction(m_menu); // 置顶
|
||||
m_fullScreen = new QAction(m_menu); // 全屏
|
||||
m_scrollWidget = new QAction(m_menu); // 全屏
|
||||
m_actionQuit = new QAction(m_menu); // 退出
|
||||
m_triple = new QAction(m_menu); // 三联按钮
|
||||
m_stayOnTop = new QAction(m_menu); // 置顶
|
||||
m_fullScreen = new QAction(m_menu); // 全屏
|
||||
m_scrollWidget = new QAction(m_menu); // 全屏
|
||||
m_actionQuit = new QAction(m_menu); // 退出
|
||||
m_triple->setText(tr("Hide Navigation Button"));
|
||||
m_stayOnTop->setText(tr("Stay on top"));
|
||||
m_fullScreen->setText(tr("FullScreen"));
|
||||
|
@ -213,7 +209,7 @@ void VideoTitle::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void VideoTitle::onModeChanged(bool isTable)
|
||||
void VideoTitle::changeMode(bool isTable)
|
||||
{
|
||||
m_isTable = isTable;
|
||||
if (m_isTable) {
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
VideoTitle(QWidget *parent = nullptr);
|
||||
~VideoTitle();
|
||||
|
||||
void changeMode(bool isTable);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
// 绑定槽函数
|
||||
|
@ -41,7 +43,6 @@ private Q_SLOTS:
|
|||
void onStayOnTopTrigger();
|
||||
void onScrollTrigger();
|
||||
void onQuitTrigger();
|
||||
void onModeChanged(bool isTable);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onFullScreenTrigger();
|
||||
|
@ -52,17 +53,17 @@ protected:
|
|||
private:
|
||||
QPushButton *m_titleIconLab = nullptr;
|
||||
QLabel *m_titleNameLab = nullptr;
|
||||
QToolButton *m_menuBtn = nullptr; // 菜单按钮
|
||||
QMenu *m_menu = nullptr; // 菜单
|
||||
QList<QAction *> m_actions; // action组
|
||||
QPushButton *m_minBtn = nullptr; // 最小化按钮
|
||||
QPushButton *m_maxBtn = nullptr; // 最大化按钮
|
||||
QPushButton *m_closeBtn = nullptr; // 关闭按钮
|
||||
QAction *m_triple = nullptr; // 三联按钮
|
||||
QAction *m_stayOnTop = nullptr; // 置顶
|
||||
QAction *m_fullScreen = nullptr; // 置顶
|
||||
QAction *m_scrollWidget = nullptr; // 鼠标灵敏度
|
||||
QAction *m_actionQuit = nullptr; // 退出
|
||||
QToolButton *m_menuBtn = nullptr; // 菜单按钮
|
||||
QMenu *m_menu = nullptr; // 菜单
|
||||
QList<QAction *> m_actions; // action组
|
||||
QPushButton *m_minBtn = nullptr; // 最小化按钮
|
||||
QPushButton *m_maxBtn = nullptr; // 最大化按钮
|
||||
QPushButton *m_closeBtn = nullptr; // 关闭按钮
|
||||
QAction *m_triple = nullptr; // 三联按钮
|
||||
QAction *m_stayOnTop = nullptr; // 置顶
|
||||
QAction *m_fullScreen = nullptr; // 置顶
|
||||
QAction *m_scrollWidget = nullptr; // 鼠标灵敏度
|
||||
QAction *m_actionQuit = nullptr; // 退出
|
||||
bool isMax = false;
|
||||
bool isTripleShow = true;
|
||||
bool isStayOnTop = false;
|
||||
|
@ -71,4 +72,4 @@ private:
|
|||
bool m_isTable = false;
|
||||
};
|
||||
|
||||
#endif // VIDEOTITLE_H
|
||||
#endif // VIDEOTITLE_H
|
||||
|
|
Loading…
Reference in New Issue