🐞 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()
|
||||
|
@ -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()));
|
||||
|
@ -542,7 +545,8 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event)
|
|||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
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) {
|
||||
|
@ -562,7 +566,8 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event)
|
|||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
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) {
|
||||
|
@ -579,7 +584,8 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event)
|
|||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
// local check
|
||||
QPointF local = mouseEvent->localPos();
|
||||
if (local.x() < 0) {
|
||||
|
@ -607,7 +613,8 @@ bool VideoForm::eventFilter(QObject *watch, QEvent *event)
|
|||
if (!m_device) {
|
||||
return false;
|
||||
}
|
||||
mouseEvent->setLocalPos(m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
mouseEvent->setLocalPos(
|
||||
m_videoWidget->mapFrom(ui->keepRatioWidget, mouseEvent->localPos().toPoint()));
|
||||
Q_EMIT m_device->mouseEvent(mouseEvent, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
}
|
||||
return true;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
|
|
@ -9,8 +9,6 @@ VideoTitle::VideoTitle(QWidget *parent) : QWidget(parent)
|
|||
initUI();
|
||||
// 设置菜单
|
||||
initMenu();
|
||||
m_tableModeListener = new TableModeListener(this);
|
||||
onModeChanged(m_tableModeListener->getMode());
|
||||
// 信号连接槽
|
||||
connectInit();
|
||||
}
|
||||
|
@ -108,8 +106,6 @@ 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);
|
||||
}
|
||||
|
||||
// 设置菜单按钮
|
||||
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue