Merge remote-tracking branch 'src/upstream' into upstream

This commit is contained in:
huheng@kylinos.cn 2022-11-09 19:31:08 +08:00
commit f2c7b4c584
7 changed files with 105 additions and 5 deletions

View File

@ -26,6 +26,8 @@ set(MOBILE_COMMON_SOURCES
publicattributes.hpp
serverstatus.h
serverstatus.cpp
tablemodelistener.cpp
tablemodelistener.h
util.h
util.cpp)

View File

@ -0,0 +1,35 @@
//
// Created by sqp on 2022/11/8.
//
#include <QDBusPendingReply>
#include "tablemodelistener.h"
#define KYLIN_STATUS_MANAGER_PATH "/"
#define KYLIN_STATUS_MANAGER_NAME "com.kylin.statusmanager.interface"
#define KYLIN_STATUS_MANAGER_INTERFACE "com.kylin.statusmanager.interface"
TableModeListener::TableModeListener(QObject *parent) : QObject(parent){
// 平板模式切换
m_modeInterface = new QDBusInterface(KYLIN_STATUS_MANAGER_NAME, KYLIN_STATUS_MANAGER_PATH,
KYLIN_STATUS_MANAGER_INTERFACE, QDBusConnection::sessionBus());
QObject::connect(m_modeInterface, SIGNAL(mode_change_signal(bool)), this, SIGNAL(sigModeChange(bool)));
}
TableModeListener::~TableModeListener() {
if (m_modeInterface){
delete m_modeInterface;
m_modeInterface = nullptr;
}
}
bool TableModeListener::getMode() {
if (m_modeInterface && m_modeInterface->isValid()) {
QDBusPendingReply<bool> resultMode = m_modeInterface->call("get_current_tabletmode");
if (resultMode.isValid()) {
return resultMode.value();
}
}
return false;
}

View File

@ -0,0 +1,28 @@
//
// Created by sqp on 2022/11/8.
//
#ifndef KYLIN_CONNECTIVITY_TABLEMODELISTENER_H
#define KYLIN_CONNECTIVITY_TABLEMODELISTENER_H
#include <QObject>
#include <QDBusInterface>
class TableModeListener : public QObject {
Q_OBJECT
public:
TableModeListener(QObject *parent = nullptr);
~TableModeListener();
bool getMode();
private:
Q_SIGNALS:
void sigModeChange(bool isTable);
private:
QDBusInterface *m_modeInterface = nullptr; //平板模式切换
};
#endif //KYLIN_CONNECTIVITY_TABLEMODELISTENER_H

View File

@ -24,7 +24,7 @@ extern "C"
#include "libavutil/imgutils.h"
}
const std::string SNDCPYPATH = "/usr/share/kylin-mobile-assistant/sndcpy ";
const std::string SNDCPYPATH = "/usr/share/kylin-connectivity/sndcpy ";
const std::string LOGPATH = "~/.log/kylin-connectivity.log";
BaseDevice::BaseDevice(DeviceParams params, QObject *parent) : QObject(parent)

View File

@ -7,6 +7,7 @@
#include <QMenu>
#include <QGSettings>
#include "loadanimation.h"
#include "tablemodelistener.h"
namespace Ui
{
@ -130,6 +131,7 @@ private:
QPointer<BaseDevice> m_device;
bool m_isLoading = false;
QTimer *m_loadTimer = nullptr;
TableModeListener *m_tableModeListener = nullptr;
};
#endif // VIDEOFORM_H

View File

@ -9,6 +9,8 @@ VideoTitle::VideoTitle(QWidget *parent) : QWidget(parent)
initUI();
// 设置菜单
initMenu();
m_tableModeListener = new TableModeListener(this);
onModeChanged(m_tableModeListener->getMode());
// 信号连接槽
connectInit();
}
@ -34,7 +36,7 @@ void VideoTitle::initUI()
m_menuBtn = new QToolButton(this);
m_menu = new QMenu();
m_minBtn = new QPushButton(this);
m_maxBtn = new QPushButton();
m_maxBtn = new QPushButton(this);
m_closeBtn = new QPushButton(this);
m_titleNameLab->setText(tr("kylin-connectivity"));
@ -105,6 +107,8 @@ 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);
}
// 设置菜单按钮
@ -122,12 +126,11 @@ void VideoTitle::initMenu()
m_scrollWidget->setText(tr("Mouse sensitivity"));
m_actionQuit->setText(tr("Quit"));
// 将Action添加到菜单中
m_actions << m_triple << m_stayOnTop << m_fullScreen << m_scrollWidget << m_actionQuit;
m_menu->addActions(m_actions);
// 为菜单按钮设置菜单
m_menuBtn->setMenu(m_menu);
}
void VideoTitle::onMinClick()
@ -204,6 +207,32 @@ void VideoTitle::onQuitTrigger()
void VideoTitle::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && (!isFullScreen)) {
onMaxClick();
if (!m_isTable){
onMaxClick();
}
}
}
void VideoTitle::onModeChanged(bool isTable) {
m_isTable = isTable;
if (m_isTable) {
m_maxBtn->hide();
// 将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);
}

View File

@ -9,6 +9,7 @@
#include <QList>
#include <QAction>
#include <QMouseEvent>
#include <tablemodelistener.h>
class VideoTitle : public QWidget
{
@ -40,6 +41,7 @@ private Q_SLOTS:
void onStayOnTopTrigger();
void onScrollTrigger();
void onQuitTrigger();
void onModeChanged(bool isTable);
public Q_SLOTS:
void onFullScreenTrigger();
@ -65,6 +67,8 @@ private:
bool isTripleShow = true;
bool isStayOnTop = false;
bool isFullScreen = false;
TableModeListener *m_tableModeListener = nullptr;
bool m_isTable = false;
};
#endif // VIDEOTITLE_H