mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 03:55:04 +00:00
工具栏基本功能
This commit is contained in:
parent
d1ed7624dc
commit
adc0641893
9 changed files with 291 additions and 31 deletions
|
@ -6,10 +6,22 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>564</width>
|
||||
<width>560</width>
|
||||
<height>486</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>560</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>560</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtScrcpy</string>
|
||||
</property>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "input.h"
|
||||
#include "keycodes.h"
|
||||
|
||||
#define CONTROL_EVENT_COMMAND_BACK_OR_SCREEN_ON 0
|
||||
// ControlEvent
|
||||
class ControlEvent : public QScrcpyEvent
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
virtual void keyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize) = 0;
|
||||
|
||||
void setDeviceSocket(DeviceSocket* deviceSocket);
|
||||
protected:
|
||||
void sendControlEvent(ControlEvent* event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "toolform.h"
|
||||
#include "ui_toolform.h"
|
||||
#include "iconhelper.h"
|
||||
#include "videoform.h"
|
||||
|
||||
ToolForm::ToolForm(QWidget* adsorbWidget, AdsorbPositions adsorbPos)
|
||||
: MagneticWidget(adsorbWidget, adsorbPos)
|
||||
|
@ -10,6 +12,10 @@ ToolForm::ToolForm(QWidget* adsorbWidget, AdsorbPositions adsorbPos)
|
|||
ui->setupUi(this);
|
||||
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint);
|
||||
|
||||
m_videoForm = dynamic_cast<VideoForm*>(adsorbWidget);
|
||||
|
||||
initStyle();
|
||||
}
|
||||
|
||||
ToolForm::~ToolForm()
|
||||
|
@ -17,6 +23,20 @@ ToolForm::~ToolForm()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void ToolForm::initStyle()
|
||||
{
|
||||
IconHelper::Instance()->SetIcon(ui->fullScreenBtn, QChar(0xf0b2), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->menuBtn, QChar(0xf096), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->homeBtn, QChar(0xf1db), 15);
|
||||
//IconHelper::Instance()->SetIcon(ui->returnBtn, QChar(0xf104), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->returnBtn, QChar(0xf053), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->appSwitchBtn, QChar(0xf24d), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->powerBtn, QChar(0xf023), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->volumeUpBtn, QChar(0xf028), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->volumeDownBtn, QChar(0xf027), 15);
|
||||
IconHelper::Instance()->SetIcon(ui->turnOnBtn, QChar(0xf09c), 15);
|
||||
}
|
||||
|
||||
void ToolForm::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
|
@ -37,3 +57,66 @@ void ToolForm::mouseMoveEvent(QMouseEvent *event)
|
|||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_fullScreenBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->switchFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_returnBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postGoBack();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_homeBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postGoHome();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_menuBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postGoMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_appSwitchBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postAppSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_powerBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postPower();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_volumeUpBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postVolumeUp();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_volumeDownBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postVolumeDown();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolForm::on_turnOnBtn_clicked()
|
||||
{
|
||||
if (m_videoForm) {
|
||||
m_videoForm->postTurnOn();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define TOOLFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
#include "magneticwidget.h"
|
||||
|
||||
|
@ -9,6 +10,7 @@ namespace Ui {
|
|||
class ToolForm;
|
||||
}
|
||||
|
||||
class VideoForm;
|
||||
class ToolForm : public MagneticWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -22,9 +24,32 @@ protected:
|
|||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_fullScreenBtn_clicked();
|
||||
|
||||
void on_returnBtn_clicked();
|
||||
|
||||
void on_homeBtn_clicked();
|
||||
|
||||
void on_menuBtn_clicked();
|
||||
|
||||
void on_appSwitchBtn_clicked();
|
||||
|
||||
void on_powerBtn_clicked();
|
||||
|
||||
void on_volumeUpBtn_clicked();
|
||||
|
||||
void on_volumeDownBtn_clicked();
|
||||
|
||||
void on_turnOnBtn_clicked();
|
||||
|
||||
private:
|
||||
void initStyle();
|
||||
|
||||
private:
|
||||
Ui::ToolForm *ui;
|
||||
QPoint m_dragPosition;
|
||||
QPointer<VideoForm> m_videoForm;
|
||||
};
|
||||
|
||||
#endif // TOOLFORM_H
|
||||
|
|
|
@ -6,13 +6,91 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>80</width>
|
||||
<width>63</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
<string>Tool</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="fullScreenBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="powerBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="turnOnBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="volumeUpBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="volumeDownBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="appSwitchBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="menuBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="homeBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="returnBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "ui_videoform.h"
|
||||
#include "iconhelper.h"
|
||||
#include "toolform.h"
|
||||
#include "controlevent.h"
|
||||
|
||||
VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -101,7 +102,6 @@ VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate,QWi
|
|||
});
|
||||
|
||||
updateShowSize(size());
|
||||
initStyle();
|
||||
|
||||
bool vertical = size().height() > size().width();
|
||||
updateStyleSheet(vertical);
|
||||
|
@ -125,7 +125,7 @@ void VideoForm::initUI()
|
|||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
// 去掉标题栏
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
// 根据图片构造异形窗口
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
|
@ -149,12 +149,6 @@ void VideoForm::showToolFrom(bool show)
|
|||
m_toolForm->setVisible(show);
|
||||
}
|
||||
|
||||
void VideoForm::initStyle()
|
||||
{
|
||||
//IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13);
|
||||
//IconHelper::Instance()->SetIcon(ui->returnBtn, QChar(0xf104), 15);
|
||||
}
|
||||
|
||||
void VideoForm::updateStyleSheet(bool vertical)
|
||||
{
|
||||
if (vertical) {
|
||||
|
@ -216,13 +210,77 @@ void VideoForm::switchFullScreen()
|
|||
{
|
||||
if (isFullScreen()) {
|
||||
showNormal();
|
||||
updateStyleSheet(height() > width());
|
||||
showToolFrom(true);
|
||||
} else {
|
||||
showToolFrom(false);
|
||||
showFullScreen();
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
showFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoForm::postGoMenu()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_MENU);
|
||||
}
|
||||
|
||||
void VideoForm::postGoBack()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_BACK);
|
||||
}
|
||||
|
||||
void VideoForm::postAppSwitch()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_APP_SWITCH);
|
||||
}
|
||||
|
||||
void VideoForm::postPower()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_POWER);
|
||||
}
|
||||
|
||||
void VideoForm::postVolumeUp()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_VOLUME_UP);
|
||||
}
|
||||
|
||||
void VideoForm::postVolumeDown()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_VOLUME_DOWN);
|
||||
}
|
||||
|
||||
void VideoForm::postTurnOn()
|
||||
{
|
||||
ControlEvent* controlEvent = new ControlEvent(ControlEvent::CET_COMMAND);
|
||||
if (!controlEvent) {
|
||||
return;
|
||||
}
|
||||
controlEvent->setCommandEventData(CONTROL_EVENT_COMMAND_BACK_OR_SCREEN_ON);
|
||||
m_inputConvert.sendControlEvent(controlEvent);
|
||||
}
|
||||
|
||||
void VideoForm::postGoHome()
|
||||
{
|
||||
postKeyCodeClick(AKEYCODE_HOME);
|
||||
}
|
||||
|
||||
void VideoForm::postKeyCodeClick(AndroidKeycode keycode)
|
||||
{
|
||||
ControlEvent* controlEventDown = new ControlEvent(ControlEvent::CET_KEYCODE);
|
||||
if (!controlEventDown) {
|
||||
return;
|
||||
}
|
||||
controlEventDown->setKeycodeEventData(AKEY_EVENT_ACTION_DOWN, keycode, AMETA_NONE);
|
||||
m_inputConvert.sendControlEvent(controlEventDown);
|
||||
|
||||
ControlEvent* controlEventUp = new ControlEvent(ControlEvent::CET_KEYCODE);
|
||||
if (!controlEventUp) {
|
||||
return;
|
||||
}
|
||||
controlEventUp->setKeycodeEventData(AKEY_EVENT_ACTION_UP, keycode, AMETA_NONE);
|
||||
m_inputConvert.sendControlEvent(controlEventUp);
|
||||
}
|
||||
|
||||
void VideoForm::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (ui->videoWidget->geometry().contains(event->pos())) {
|
||||
|
@ -301,13 +359,3 @@ void VideoForm::showEvent(QShowEvent *event)
|
|||
{
|
||||
showToolFrom();
|
||||
}
|
||||
|
||||
void VideoForm::on_fullScrcenbtn_clicked()
|
||||
{
|
||||
switchFullScreen();
|
||||
}
|
||||
|
||||
void VideoForm::on_returnBtn_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -23,13 +23,23 @@ public:
|
|||
explicit VideoForm(const QString& serial, quint16 maxSize = 720, quint32 bitRate = 8000000, QWidget *parent = 0);
|
||||
~VideoForm();
|
||||
|
||||
void switchFullScreen();
|
||||
void postGoMenu();
|
||||
void postGoHome();
|
||||
void postGoBack();
|
||||
void postAppSwitch();
|
||||
void postPower();
|
||||
void postVolumeUp();
|
||||
void postVolumeDown();
|
||||
// turn the screen on if it was off, press BACK otherwise
|
||||
void postTurnOn();
|
||||
|
||||
private:
|
||||
void updateShowSize(const QSize &newSize);
|
||||
void switchFullScreen();
|
||||
void initStyle();
|
||||
void updateStyleSheet(bool vertical);
|
||||
void initUI();
|
||||
void showToolFrom(bool show = true);
|
||||
void postKeyCodeClick(AndroidKeycode keycode);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
@ -42,10 +52,6 @@ protected:
|
|||
void paintEvent(QPaintEvent *);
|
||||
void showEvent(QShowEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_fullScrcenbtn_clicked();
|
||||
void on_returnBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::videoForm *ui;
|
||||
QSize frameSize;
|
||||
|
|
12
TODO.txt
12
TODO.txt
|
@ -1,2 +1,10 @@
|
|||
手机窗口启动动画
|
||||
工具窗口
|
||||
|
||||
模拟点击改用手指
|
||||
中英文翻译
|
||||
tool tips
|
||||
工具栏基本功能
|
||||
server移除
|
||||
mp4录制
|
||||
工具栏扩展(模拟点击指定次数等)
|
||||
|
||||
中文输入
|
Loading…
Add table
Reference in a new issue