Merge pull request #389 from barry-ran/dev

Dev
This commit is contained in:
Barry 2021-04-17 18:23:01 +08:00 committed by GitHub
commit fc6314b8f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 830 additions and 222 deletions

View file

@ -186,7 +186,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright (C) 2019 Rankun
Copyright (C) 2019-2025 Rankun
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -179,7 +179,6 @@ macos {
APP_CONFIG.files = $$files($$PWD/../config/config.ini)
APP_CONFIG.path = Contents/MacOS/config
QMAKE_BUNDLE_DATA += APP_CONFIG
# mac application icon
ICON = $$PWD/res/QtScrcpy.icns
QMAKE_INFO_PLIST = $$PWD/res/Info_Mac.plist

View file

@ -33,7 +33,7 @@ Device::Device(DeviceParams params, QObject *parent) : QObject(parent), m_params
m_decoder = new Decoder(m_vb, this);
m_fileHandler = new FileHandler(this);
m_controller = new Controller(params.gameScript, this);
m_videoForm = new VideoForm(Config::getInstance().getFramelessWindow(), Config::getInstance().getSkin());
m_videoForm = new VideoForm(params.framelessWindow, Config::getInstance().getSkin());
m_videoForm->setDevice(this);
}
@ -382,7 +382,7 @@ bool Device::saveFrame(const AVFrame *frame)
// save
QString absFilePath;
QString fileDir(Config::getInstance().getRecordPath());
QString fileDir(m_params.recordPath);
if (fileDir.isEmpty()) {
qWarning() << "please select record save path!!!";
return false;

View file

@ -26,6 +26,7 @@ public:
struct DeviceParams
{
QString recordFileName = ""; // 视频录制文件名
QString recordPath = ""; // 视频保存路径
QString serial = ""; // 设备序列号
quint16 localPort = 27183; // reverse时本地监听端口
quint16 maxSize = 720; // 视频分辨率
@ -37,7 +38,8 @@ public:
QString gameScript = ""; // 游戏映射脚本
bool renderExpiredFrames = false; // 是否渲染延迟视频帧
int lockVideoOrientation = -1; // 是否锁定视频方向
int stayAwake = false; // 是否保持唤醒
bool stayAwake = false; // 是否保持唤醒
bool framelessWindow = false; // 是否无边框窗口
};
enum GroupControlState
{

View file

@ -1,4 +1,4 @@
#include <QDebug>
#include <QDebug>
#include <QFile>
#include <QFileDialog>
#include <QKeyEvent>
@ -43,8 +43,10 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
if (args.contains("devices")) {
QStringList devices = m_adb.getDevicesSerialFromStdOut();
ui->serialBox->clear();
ui->connectedPhoneList->clear();
for (auto &item : devices) {
ui->serialBox->addItem(item);
ui->connectedPhoneList->addItem(item+"-"+Config::getInstance().getNickName(item));
}
} else if (args.contains("show") && args.contains("wlan0")) {
QString ip = m_adb.getDeviceIPFromStdOut();
@ -74,10 +76,25 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
outLog(log, newLine);
}
});
m_hideIcon = new QSystemTrayIcon();
m_hideIcon->setIcon(QIcon(":/image/tray/logo.png"));
m_menu = new QMenu();
m_quit = new QAction();
m_showWindow = new QAction();;
m_showWindow->setText(tr("show"));
m_quit->setText(tr("quit"));
m_menu->addAction(m_showWindow);
m_menu->addAction(m_quit);
m_hideIcon->setContextMenu(m_menu);
connect(m_showWindow, &QAction::triggered, this, &Dialog::slotShow);
connect(m_quit, SIGNAL(triggered()), this, SLOT(close()));
connect(m_hideIcon, &QSystemTrayIcon::activated,this,&Dialog::slotActivated);
}
Dialog::~Dialog()
{
updateBootConfig(false);
m_deviceManage.disconnectAllDevice();
delete ui;
}
@ -95,7 +112,6 @@ void Dialog::initUI()
ui->bitRateBox->addItem("50000000");
ui->bitRateBox->addItem("100000000");
ui->bitRateBox->addItem("200000000");
ui->bitRateBox->setCurrentIndex(Config::getInstance().getBitRateIndex());
ui->maxSizeBox->addItem("640");
ui->maxSizeBox->addItem("720");
@ -103,11 +119,9 @@ void Dialog::initUI()
ui->maxSizeBox->addItem("1280");
ui->maxSizeBox->addItem("1920");
ui->maxSizeBox->addItem(tr("original"));
ui->maxSizeBox->setCurrentIndex(Config::getInstance().getMaxSizeIndex());
ui->formatBox->addItem("mp4");
ui->formatBox->addItem("mkv");
ui->formatBox->setCurrentIndex(Config::getInstance().getRecordFormatIndex());
ui->lockOrientationBox->addItem(tr("no lock"));
ui->lockOrientationBox->addItem("0");
@ -116,20 +130,64 @@ void Dialog::initUI()
ui->lockOrientationBox->addItem("270");
ui->lockOrientationBox->setCurrentIndex(0);
ui->recordPathEdt->setText(Config::getInstance().getRecordPath());
ui->framelessCheck->setChecked(Config::getInstance().getFramelessWindow());
updateBootConfig(true);
on_useSingleModeCheck_clicked();
on_updateDevice_clicked();
#ifdef Q_OS_OSX
// mac need more width
setFixedWidth(520);
setFixedWidth(550);
#endif
#ifdef Q_OS_LINUX
// linux need more width
setFixedWidth(480);
setFixedWidth(520);
#endif
}
void Dialog::updateBootConfig(bool toView)
{
if (toView) {
UserBootConfig config = Config::getInstance().getUserBootConfig();
ui->bitRateBox->setCurrentIndex(config.bitRateIndex);
ui->maxSizeBox->setCurrentIndex(config.maxSizeIndex);
ui->formatBox->setCurrentIndex(config.recordFormatIndex);
ui->recordPathEdt->setText(config.recordPath);
ui->lockOrientationBox->setCurrentIndex(config.lockOrientationIndex);
ui->framelessCheck->setChecked(config.framelessWindow);
ui->recordScreenCheck->setChecked(config.recordScreen);
ui->notDisplayCheck->setChecked(config.recordBackground);
ui->useReverseCheck->setChecked(config.reverseConnect);
ui->fpsCheck->setChecked(config.showFPS);
ui->alwaysTopCheck->setChecked(config.windowOnTop);
ui->closeScreenCheck->setChecked(config.autoOffScreen);
ui->stayAwakeCheck->setChecked(config.keepAlive);
ui->useSingleModeCheck->setChecked(config.simpleMode);
} else {
UserBootConfig config;
config.bitRateIndex = ui->bitRateBox->currentIndex();
config.maxSizeIndex = ui->maxSizeBox->currentIndex();
config.recordFormatIndex = ui->formatBox->currentIndex();
config.recordPath = ui->recordPathEdt->text();
config.lockOrientationIndex = ui->lockOrientationBox->currentIndex();
config.recordScreen = ui->recordScreenCheck->isChecked();
config.recordBackground = ui->notDisplayCheck->isChecked();
config.reverseConnect = ui->useReverseCheck->isChecked();
config.showFPS = ui->fpsCheck->isChecked();
config.windowOnTop = ui->alwaysTopCheck->isChecked();
config.autoOffScreen = ui->closeScreenCheck->isChecked();
config.framelessWindow = ui->framelessCheck->isChecked();
config.keepAlive = ui->stayAwakeCheck->isChecked();
config.simpleMode = ui->useSingleModeCheck->isChecked();
Config::getInstance().setUserBootConfig(config);
}
}
void Dialog::execAdbCmd()
{
if (checkAdbRun()) {
@ -140,6 +198,15 @@ void Dialog::execAdbCmd()
m_adb.execute(ui->serialBox->currentText().trimmed(), cmd.split(" ", Qt::SkipEmptyParts));
}
void Dialog::delayMs(int ms)
{
QTime dieTime = QTime::currentTime().addMSecs(ms);
while (QTime::currentTime() < dieTime) {
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
}
QString Dialog::getGameScript(const QString &fileName)
{
QFile loadFile(KeyMap::getKeyMapPath() + "/" + fileName);
@ -153,6 +220,48 @@ QString Dialog::getGameScript(const QString &fileName)
return ret;
}
void Dialog::slotShow()
{
this->show();
m_hideIcon->hide();
}
void Dialog::slotActivated(QSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
case QSystemTrayIcon::Trigger:
this->show();
m_hideIcon->hide();
break;
default:
break;
}
}
void Dialog::closeEvent(QCloseEvent *event)
{
int res = QMessageBox::question(this,tr("warning"),tr("Quit or set tray?"),tr("Quit"),tr("Set tray"),tr("Cancel"));
if(res == 0)
{
event->accept();
}
else if(res == 1)
{
this->hide();
m_hideIcon->show();
m_hideIcon->showMessage(tr("Notice"),
tr("Hidden here!"),
QSystemTrayIcon::Information,
3000);
event->ignore();
}
else
{
event->ignore();
}
}
void Dialog::on_updateDevice_clicked()
{
if (checkAdbRun()) {
@ -195,6 +304,8 @@ void Dialog::on_startServerBtn_clicked()
params.renderExpiredFrames = Config::getInstance().getRenderExpiredFrames();
params.lockVideoOrientation = ui->lockOrientationBox->currentIndex() - 1;
params.stayAwake = ui->stayAwakeCheck->isChecked();
params.framelessWindow = ui->framelessCheck->isChecked();
params.recordPath = ui->recordPathEdt->text().trimmed();
m_deviceManage.connectDevice(params);
@ -341,7 +452,6 @@ void Dialog::on_selectRecordPathBtn_clicked()
void Dialog::on_recordPathEdt_textChanged(const QString &arg1)
{
Config::getInstance().setRecordPath(arg1);
ui->recordPathEdt->setToolTip(arg1.trimmed());
ui->notDisplayCheck->setCheckable(!arg1.trimmed().isEmpty());
}
@ -402,23 +512,118 @@ void Dialog::on_recordScreenCheck_clicked(bool checked)
}
}
void Dialog::on_bitRateBox_activated(int index)
void Dialog::on_usbConnectBtn_clicked()
{
Config::getInstance().setBitRateIndex(index);
on_stopAllServerBtn_clicked();
delayMs(200);
on_updateDevice_clicked();
delayMs(200);
int firstUsbDevice = findDeviceFromeSerialBox(false);
if (-1 == firstUsbDevice) {
qWarning() << "No use device is found!";
return;
}
ui->serialBox->setCurrentIndex(firstUsbDevice);
on_startServerBtn_clicked();
}
void Dialog::on_maxSizeBox_activated(int index)
{
Config::getInstance().setMaxSizeIndex(index);
int Dialog::findDeviceFromeSerialBox(bool wifi) {
QRegExp regIP("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\:([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])\\b");
for (int i = 0; i < ui->serialBox->count(); ++i)
{
bool isWifi = regIP.exactMatch(ui->serialBox->itemText(i));
bool found = wifi ? isWifi : !isWifi;
if(found)
{
return i;
}
}
return -1;
}
void Dialog::on_formatBox_activated(int index)
void Dialog::on_wifiConnectBtn_clicked()
{
Config::getInstance().setRecordFormatIndex(index);
on_stopAllServerBtn_clicked();
delayMs(200);
on_updateDevice_clicked();
delayMs(200);
int firstUsbDevice = findDeviceFromeSerialBox(false);
if (-1 == firstUsbDevice) {
qWarning() << "No use device is found!";
return;
}
ui->serialBox->setCurrentIndex(firstUsbDevice);
on_getIPBtn_clicked();
delayMs(200);
on_startAdbdBtn_clicked();
delayMs(1000);
on_wirelessConnectBtn_clicked();
delayMs(2000);
on_updateDevice_clicked();
delayMs(200);
int firstWifiDevice = findDeviceFromeSerialBox(true);
if (-1 == firstWifiDevice) {
qWarning() << "No wifi device is found!";
return;
}
ui->serialBox->setCurrentIndex(firstWifiDevice);
on_startServerBtn_clicked();
}
void Dialog::on_framelessCheck_stateChanged(int arg1)
void Dialog::on_connectedPhoneList_itemDoubleClicked(QListWidgetItem *item)
{
Q_UNUSED(arg1)
Config::getInstance().setFramelessWindow(ui->framelessCheck->isChecked());
Q_UNUSED(item);
ui->serialBox->setCurrentIndex(ui->connectedPhoneList->currentRow());
on_startServerBtn_clicked();
}
void Dialog::on_updateNameBtn_clicked()
{
if(ui->serialBox->count()!=0) {
if(ui->userNameEdt->text().isEmpty()) {
Config::getInstance().setNickName(ui->serialBox->currentText(), "Phone");
} else {
Config::getInstance().setNickName(ui->serialBox->currentText(), ui->userNameEdt->text());
}
on_updateDevice_clicked();
qDebug()<<"Update OK!";
} else {
qWarning()<<"No device is connected!";
}
}
void Dialog::on_useSingleModeCheck_clicked()
{
if(ui->useSingleModeCheck->isChecked())
{
ui->configGroupBox->hide();
ui->adbGroupBox->hide();
ui->wirelessGroupBox->hide();
ui->usbGroupBox->hide();
}
else
{
ui->configGroupBox->show();
ui->adbGroupBox->show();
ui->wirelessGroupBox->show();
ui->usbGroupBox->show();
}
}
void Dialog::on_serialBox_currentIndexChanged(const QString &arg1)
{
ui->userNameEdt->setText(Config::getInstance().getNickName(arg1));
}

View file

@ -1,8 +1,13 @@
#ifndef DIALOG_H
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QPointer>
#include <QMessageBox>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QListWidget>
#include "adbprocess.h"
#include "devicemanage.h"
@ -58,24 +63,40 @@ private slots:
void on_recordScreenCheck_clicked(bool checked);
void on_bitRateBox_activated(int index);
void on_usbConnectBtn_clicked();
void on_maxSizeBox_activated(int index);
void on_wifiConnectBtn_clicked();
void on_formatBox_activated(int index);
void on_connectedPhoneList_itemDoubleClicked(QListWidgetItem *item);
void on_framelessCheck_stateChanged(int arg1);
void on_updateNameBtn_clicked();
void on_useSingleModeCheck_clicked();
void on_serialBox_currentIndexChanged(const QString &arg1);
private:
bool checkAdbRun();
void initUI();
void updateBootConfig(bool toView = true);
void execAdbCmd();
void delayMs(int ms);
QString getGameScript(const QString &fileName);
void slotShow();
void slotActivated(QSystemTrayIcon::ActivationReason reason);
int findDeviceFromeSerialBox(bool wifi);
protected:
void closeEvent(QCloseEvent *event);
private:
Ui::Dialog *ui;
AdbProcess m_adb;
DeviceManage m_deviceManage;
QSystemTrayIcon *m_hideIcon;
QMenu *m_menu;
QAction *m_showWindow;
QAction *m_quit;
};
#endif // DIALOG_H

View file

@ -6,19 +6,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>517</height>
<width>500</width>
<height>745</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>420</width>
<width>500</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>420</width>
<width>500</width>
<height>16777215</height>
</size>
</property>
@ -26,6 +26,63 @@
<string notr="true">QtScrcpy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="useSingleModeCheck">
<property name="text">
<string>Use Simple Mode</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="simpleGroupBox">
<property name="title">
<string>Simple Mode</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="wifiConnectBtn">
<property name="text">
<string>WIFI Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="usbConnectBtn">
<property name="text">
<string>USB Connect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Double click to connect:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="connectedPhoneList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="configGroupBox">
<property name="title">
@ -350,21 +407,43 @@
<string>USB line</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_9">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>device name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="userNameEdt">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="updateNameBtn">
<property name="text">
<string>update name</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="usbWidget1" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
@ -382,6 +461,12 @@
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>device serial:</string>
</property>

View file

@ -1,4 +1,4 @@
#include <QApplication>
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QSurfaceFormat>

Binary file not shown.

View file

@ -16,22 +16,22 @@
<translation type="vanished">file transfer failed</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="181"/>
<location filename="../../device/device.cpp" line="184"/>
<source>install apk</source>
<translation>install apk</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="183"/>
<location filename="../../device/device.cpp" line="186"/>
<source>file transfer</source>
<translation>file transfer</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="187"/>
<location filename="../../device/device.cpp" line="190"/>
<source>wait current %1 to complete</source>
<translation>wait current %1 to complete</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="190"/>
<location filename="../../device/device.cpp" line="193"/>
<source>%1 complete, save in %2</source>
<translation>%1 complete, save in %2</translation>
</message>
@ -41,7 +41,7 @@
<translation type="vanished">%1 complete\n save in %2</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="193"/>
<location filename="../../device/device.cpp" line="196"/>
<source>%1 failed</source>
<translation>%1 failed</translation>
</message>
@ -49,93 +49,134 @@
<context>
<name>Dialog</name>
<message>
<location filename="../../dialog.ui" line="477"/>
<location filename="../../dialog.ui" line="562"/>
<source>Wireless</source>
<translation>Wireless</translation>
</message>
<message>
<location filename="../../dialog.ui" line="561"/>
<location filename="../../dialog.ui" line="646"/>
<source>wireless connect</source>
<translation>wireless connect</translation>
</message>
<message>
<location filename="../../dialog.ui" line="577"/>
<location filename="../../dialog.ui" line="662"/>
<source>wireless disconnect</source>
<translation>wireless disconnect</translation>
</message>
<message>
<location filename="../../dialog.ui" line="32"/>
<location filename="../../dialog.ui" line="89"/>
<source>Start Config</source>
<translation>Start Config</translation>
</message>
<message>
<location filename="../../dialog.ui" line="168"/>
<location filename="../../dialog.ui" line="225"/>
<source>record save path:</source>
<translation>record save path:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="185"/>
<location filename="../../dialog.cpp" line="338"/>
<location filename="../../dialog.ui" line="242"/>
<location filename="../../dialog.cpp" line="449"/>
<source>select path</source>
<translation>select path</translation>
</message>
<message>
<location filename="../../dialog.ui" line="99"/>
<location filename="../../dialog.ui" line="156"/>
<source>record format</source>
<translation>record format:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="323"/>
<location filename="../../dialog.ui" line="380"/>
<source>record screen</source>
<translation>record screen</translation>
</message>
<message>
<location filename="../../dialog.ui" line="268"/>
<location filename="../../dialog.ui" line="325"/>
<source>frameless</source>
<translation>frameless</translation>
</message>
<message>
<location filename="../../dialog.ui" line="127"/>
<location filename="../../dialog.ui" line="32"/>
<source>Use Simple Mode</source>
<translatorcomment>Use Simple Mode</translatorcomment>
<translation>Use Simple Mode</translation>
</message>
<message>
<location filename="../../dialog.ui" line="42"/>
<source>Simple Mode</source>
<translatorcomment>Simple Mode</translatorcomment>
<translation>Simple Mode</translation>
</message>
<message>
<location filename="../../dialog.ui" line="53"/>
<source>WIFI Connect</source>
<translatorcomment>WIFI Connect</translatorcomment>
<translation>WIFI Connect</translation>
</message>
<message>
<location filename="../../dialog.ui" line="60"/>
<source>USB Connect</source>
<translatorcomment>USB Connect</translatorcomment>
<translation>USB Connect</translation>
</message>
<message>
<location filename="../../dialog.ui" line="69"/>
<source>Double click to connect:</source>
<translation>Double click to connect:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="184"/>
<source>lock orientation:</source>
<translation>lock orientation:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="330"/>
<location filename="../../dialog.ui" line="387"/>
<source>show fps</source>
<translation>show fps</translation>
</message>
<message>
<location filename="../../dialog.ui" line="337"/>
<location filename="../../dialog.ui" line="394"/>
<source>stay awake</source>
<translation>stay awake</translation>
</message>
<message>
<location filename="../../dialog.ui" line="434"/>
<location filename="../../dialog.ui" line="421"/>
<source>device name:</source>
<translatorcomment>device name:</translatorcomment>
<translation>device name:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="438"/>
<source>update name</source>
<translatorcomment>update name</translatorcomment>
<translation>update name</translation>
</message>
<message>
<location filename="../../dialog.ui" line="519"/>
<source>stop all server</source>
<translation>stop all server</translation>
</message>
<message>
<location filename="../../dialog.ui" line="611"/>
<location filename="../../dialog.ui" line="696"/>
<source>adb command:</source>
<translation>adb command:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="647"/>
<location filename="../../dialog.ui" line="732"/>
<source>terminate</source>
<translation>terminate</translation>
</message>
<message>
<location filename="../../dialog.ui" line="634"/>
<location filename="../../dialog.ui" line="719"/>
<source>execute</source>
<translation>execute</translation>
</message>
<message>
<location filename="../../dialog.ui" line="660"/>
<location filename="../../dialog.ui" line="745"/>
<source>clear</source>
<translation>clear</translation>
</message>
<message>
<location filename="../../dialog.ui" line="313"/>
<location filename="../../dialog.ui" line="370"/>
<source>reverse connection</source>
<translation>reverse connection</translation>
</message>
@ -144,57 +185,57 @@
<translation type="vanished">auto enable</translation>
</message>
<message>
<location filename="../../dialog.ui" line="297"/>
<location filename="../../dialog.ui" line="354"/>
<source>background record</source>
<translation>background record</translation>
</message>
<message>
<location filename="../../dialog.ui" line="261"/>
<location filename="../../dialog.ui" line="318"/>
<source>screen-off</source>
<translation>screen-off</translation>
</message>
<message>
<location filename="../../dialog.ui" line="230"/>
<location filename="../../dialog.ui" line="287"/>
<source>apply</source>
<translation>apply</translation>
</message>
<message>
<location filename="../../dialog.ui" line="85"/>
<location filename="../../dialog.ui" line="142"/>
<source>max size:</source>
<translation>max size:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="281"/>
<location filename="../../dialog.ui" line="338"/>
<source>always on top</source>
<translation>always on top</translation>
</message>
<message>
<location filename="../../dialog.ui" line="223"/>
<location filename="../../dialog.ui" line="280"/>
<source>refresh script</source>
<translation>refresh script</translation>
</message>
<message>
<location filename="../../dialog.ui" line="451"/>
<location filename="../../dialog.ui" line="536"/>
<source>get device IP</source>
<translation>get device IP</translation>
</message>
<message>
<location filename="../../dialog.ui" line="350"/>
<location filename="../../dialog.ui" line="407"/>
<source>USB line</source>
<translation>USB line</translation>
</message>
<message>
<location filename="../../dialog.ui" line="406"/>
<location filename="../../dialog.ui" line="491"/>
<source>stop server</source>
<translation>stop server</translation>
</message>
<message>
<location filename="../../dialog.ui" line="396"/>
<location filename="../../dialog.ui" line="481"/>
<source>start server</source>
<translation>start server</translation>
</message>
<message>
<location filename="../../dialog.ui" line="386"/>
<location filename="../../dialog.ui" line="471"/>
<source>device serial:</source>
<translation>device serial:</translation>
</message>
@ -203,30 +244,110 @@
<translation type="vanished">Config</translation>
</message>
<message>
<location filename="../../dialog.ui" line="68"/>
<location filename="../../dialog.ui" line="125"/>
<source>bit rate:</source>
<translation>bit rate:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="461"/>
<location filename="../../dialog.ui" line="546"/>
<source>start adbd</source>
<translation>start adbd</translation>
</message>
<message>
<location filename="../../dialog.ui" line="441"/>
<location filename="../../dialog.ui" line="526"/>
<source>refresh devices</source>
<translation>refresh devices</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="105"/>
<location filename="../../dialog.cpp" line="85"/>
<source>show</source>
<translatorcomment>show</translatorcomment>
<translation>show</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="86"/>
<source>quit</source>
<translatorcomment>quit</translatorcomment>
<translation>quit</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="121"/>
<source>original</source>
<translation>original</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="112"/>
<location filename="../../dialog.cpp" line="126"/>
<source>no lock</source>
<translation>no lock</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>warning</source>
<translatorcomment>Warning</translatorcomment>
<translation>Warning</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Quit or set tray?</source>
<translatorcomment>Quit or set tray?</translatorcomment>
<translation>Quit or set tray?</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Quit</source>
<translatorcomment>Quit</translatorcomment>
<translation>Quit</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Set tray</source>
<translatorcomment>Set tray</translatorcomment>
<translation>Set tray</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Cancel</source>
<translatorcomment>Cancel</translatorcomment>
<translation>Cancel</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="253"/>
<source>Notice</source>
<translatorcomment>Notice</translatorcomment>
<translation>Notice</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="254"/>
<source>Hidden here!</source>
<translatorcomment>Hidden here!</translatorcomment>
<translation>Hidden here!</translation>
</message>
</context>
<context>
<name>InputConvertGame</name>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>current keymap mode: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>custom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>normal</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KeyMap</name>
<message>
<location filename="../../device/controller/inputconvert/keymap/keymap.cpp" line="307"/>
<source>Script updated, current keymap mode:normal, Press ~ key to switch keymap mode</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
@ -241,7 +362,7 @@ You can download it at the following address:</source>
<translation type="vanished">This software is completely open source and free.\nStrictly used for illegal purposes, or at your own risk.\nYou can download it at the following address:</translation>
</message>
<message>
<location filename="../../main.cpp" line="108"/>
<location filename="../../main.cpp" line="109"/>
<source>This software is completely open source and free. Strictly used for illegal purposes, or at your own risk. You can download it at the following address:</source>
<translation>This software is completely open source and free. Strictly used for illegal purposes, or at your own risk. You can download it at the following address:</translation>
</message>
@ -337,7 +458,7 @@ You can download it at the following address:</source>
<translation type="vanished">file transfer failed</translation>
</message>
<message>
<location filename="../../device/ui/videoform.cpp" line="710"/>
<location filename="../../device/ui/videoform.cpp" line="749"/>
<source>file does not exist</source>
<translation>file does not exist</translation>
</message>

Binary file not shown.

View file

@ -16,22 +16,22 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../device/device.cpp" line="181"/>
<location filename="../../device/device.cpp" line="184"/>
<source>install apk</source>
<translation>apk</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="183"/>
<location filename="../../device/device.cpp" line="186"/>
<source>file transfer</source>
<translation></translation>
</message>
<message>
<location filename="../../device/device.cpp" line="187"/>
<location filename="../../device/device.cpp" line="190"/>
<source>wait current %1 to complete</source>
<translation>%1</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="190"/>
<location filename="../../device/device.cpp" line="193"/>
<source>%1 complete, save in %2</source>
<translation>%1,%2</translation>
</message>
@ -41,7 +41,7 @@
<translation type="vanished">%1\n %2</translation>
</message>
<message>
<location filename="../../device/device.cpp" line="193"/>
<location filename="../../device/device.cpp" line="196"/>
<source>%1 failed</source>
<translation>%1 </translation>
</message>
@ -49,93 +49,134 @@
<context>
<name>Dialog</name>
<message>
<location filename="../../dialog.ui" line="477"/>
<location filename="../../dialog.ui" line="562"/>
<source>Wireless</source>
<translation>线</translation>
</message>
<message>
<location filename="../../dialog.ui" line="561"/>
<location filename="../../dialog.ui" line="646"/>
<source>wireless connect</source>
<translation>线</translation>
</message>
<message>
<location filename="../../dialog.ui" line="577"/>
<location filename="../../dialog.ui" line="662"/>
<source>wireless disconnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../../dialog.ui" line="32"/>
<location filename="../../dialog.ui" line="89"/>
<source>Start Config</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="168"/>
<location filename="../../dialog.ui" line="225"/>
<source>record save path:</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="185"/>
<location filename="../../dialog.cpp" line="338"/>
<location filename="../../dialog.ui" line="242"/>
<location filename="../../dialog.cpp" line="449"/>
<source>select path</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="99"/>
<location filename="../../dialog.ui" line="156"/>
<source>record format</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="323"/>
<location filename="../../dialog.ui" line="380"/>
<source>record screen</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="268"/>
<location filename="../../dialog.ui" line="325"/>
<source>frameless</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="127"/>
<location filename="../../dialog.ui" line="32"/>
<source>Use Simple Mode</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="42"/>
<source>Simple Mode</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="53"/>
<source>WIFI Connect</source>
<translatorcomment>WIFI连接</translatorcomment>
<translation>WIFI连接</translation>
</message>
<message>
<location filename="../../dialog.ui" line="60"/>
<source>USB Connect</source>
<translatorcomment>USB连接</translatorcomment>
<translation>USB连接</translation>
</message>
<message>
<location filename="../../dialog.ui" line="69"/>
<source>Double click to connect:</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="184"/>
<source>lock orientation:</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="330"/>
<location filename="../../dialog.ui" line="387"/>
<source>show fps</source>
<translation>fps</translation>
</message>
<message>
<location filename="../../dialog.ui" line="337"/>
<location filename="../../dialog.ui" line="394"/>
<source>stay awake</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="434"/>
<location filename="../../dialog.ui" line="421"/>
<source>device name:</source>
<translatorcomment>:</translatorcomment>
<translation>:</translation>
</message>
<message>
<location filename="../../dialog.ui" line="438"/>
<source>update name</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="519"/>
<source>stop all server</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="611"/>
<location filename="../../dialog.ui" line="696"/>
<source>adb command:</source>
<translation>adb命令</translation>
</message>
<message>
<location filename="../../dialog.ui" line="647"/>
<location filename="../../dialog.ui" line="732"/>
<source>terminate</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="634"/>
<location filename="../../dialog.ui" line="719"/>
<source>execute</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="660"/>
<location filename="../../dialog.ui" line="745"/>
<source>clear</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="313"/>
<location filename="../../dialog.ui" line="370"/>
<source>reverse connection</source>
<translation></translation>
</message>
@ -144,57 +185,57 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../dialog.ui" line="297"/>
<location filename="../../dialog.ui" line="354"/>
<source>background record</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="261"/>
<location filename="../../dialog.ui" line="318"/>
<source>screen-off</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="230"/>
<location filename="../../dialog.ui" line="287"/>
<source>apply</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="85"/>
<location filename="../../dialog.ui" line="142"/>
<source>max size:</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="281"/>
<location filename="../../dialog.ui" line="338"/>
<source>always on top</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="223"/>
<location filename="../../dialog.ui" line="280"/>
<source>refresh script</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="451"/>
<location filename="../../dialog.ui" line="536"/>
<source>get device IP</source>
<translation>IP</translation>
</message>
<message>
<location filename="../../dialog.ui" line="350"/>
<location filename="../../dialog.ui" line="407"/>
<source>USB line</source>
<translation>USB线</translation>
</message>
<message>
<location filename="../../dialog.ui" line="406"/>
<location filename="../../dialog.ui" line="491"/>
<source>stop server</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="396"/>
<location filename="../../dialog.ui" line="481"/>
<source>start server</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="386"/>
<location filename="../../dialog.ui" line="471"/>
<source>device serial:</source>
<translation></translation>
</message>
@ -203,30 +244,110 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../dialog.ui" line="68"/>
<location filename="../../dialog.ui" line="125"/>
<source>bit rate:</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.ui" line="461"/>
<location filename="../../dialog.ui" line="546"/>
<source>start adbd</source>
<translation>adbd</translation>
</message>
<message>
<location filename="../../dialog.ui" line="441"/>
<location filename="../../dialog.ui" line="526"/>
<source>refresh devices</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="105"/>
<location filename="../../dialog.cpp" line="85"/>
<source>show</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="86"/>
<source>quit</source>
<translatorcomment>退</translatorcomment>
<translation>退</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="121"/>
<source>original</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="112"/>
<location filename="../../dialog.cpp" line="126"/>
<source>no lock</source>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>warning</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Quit or set tray?</source>
<translatorcomment>退</translatorcomment>
<translation>退</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Quit</source>
<translatorcomment>退</translatorcomment>
<translation>退</translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Set tray</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="243"/>
<source>Cancel</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="253"/>
<source>Notice</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../../dialog.cpp" line="254"/>
<source>Hidden here!</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
</context>
<context>
<name>InputConvertGame</name>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>current keymap mode: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>custom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../device/controller/inputconvert/inputconvertgame.cpp" line="507"/>
<source>normal</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KeyMap</name>
<message>
<location filename="../../device/controller/inputconvert/keymap/keymap.cpp" line="307"/>
<source>Script updated, current keymap mode:normal, Press ~ key to switch keymap mode</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
@ -241,7 +362,7 @@ You can download it at the following address:</source>
<translation type="vanished">.\n严禁用于非法用途.\n你可以在下面地址下载:</translation>
</message>
<message>
<location filename="../../main.cpp" line="108"/>
<location filename="../../main.cpp" line="109"/>
<source>This software is completely open source and free. Strictly used for illegal purposes, or at your own risk. You can download it at the following address:</source>
<translation>:</translation>
</message>
@ -337,7 +458,7 @@ You can download it at the following address:</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../device/ui/videoform.cpp" line="710"/>
<location filename="../../device/ui/videoform.cpp" line="749"/>
<source>file does not exist</source>
<translation></translation>
</message>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -2,7 +2,7 @@
<qresource prefix="/">
<file>font/fontawesome-webfont.ttf</file>
<file>image/videoform/phone-h.png</file>
<file>image/videoform/phone-v.png</file>
<file>image/videoform/phone-v.png</file>
<file>qss/psblack.css</file>
<file>qss/psblack/add_bottom.png</file>
<file>qss/psblack/add_left.png</file>
@ -24,5 +24,6 @@
<file>qss/psblack/radiobutton_unchecked_disable.png</file>
<file>i18n/QtScrcpy_en.qm</file>
<file>i18n/QtScrcpy_zh.qm</file>
<file>image/tray/logo.png</file>
</qresource>
</RCC>

View file

@ -9,6 +9,7 @@ MagneticWidget::MagneticWidget(QWidget *adsorbWidget, AdsorbPositions adsorbPos)
Q_ASSERT(m_adsorbWidget);
setParent(m_adsorbWidget);
setWindowFlags(windowFlags() | Qt::Tool);
m_adsorbWidgetSize = m_adsorbWidget->size();
m_adsorbWidget->installEventFilter(this);
}
@ -30,6 +31,10 @@ bool MagneticWidget::eventFilter(QObject *watched, QEvent *event)
if (watched != m_adsorbWidget || !event) {
return false;
}
// 始终记录adsorbWidget最新size
if (QEvent::Resize == event->type()) {
m_adsorbWidgetSize = m_adsorbWidget->size();
}
if (m_adsorbed && QEvent::Move == event->type()) {
move(m_adsorbWidget->pos() - m_relativePos);
}
@ -48,7 +53,7 @@ bool MagneticWidget::eventFilter(QObject *watched, QEvent *event)
pos.setY(pos.y() - m_relativePos.y());
break;
case AP_OUTSIDE_RIGHT:
pos.setX(pos.x() + m_adsorbWidget->width());
pos.setX(pos.x() + m_adsorbWidgetSize.width());
pos.setY(pos.y() - m_relativePos.y());
break;
case AP_OUTSIDE_TOP:
@ -165,8 +170,8 @@ void MagneticWidget::moveEvent(QMoveEvent *event)
void MagneticWidget::getGeometry(QRect &relativeWidgetRect, QRect &targetWidgetRect)
{
relativeWidgetRect.setTopLeft(m_adsorbWidget->pos());
relativeWidgetRect.setWidth(m_adsorbWidget->width());
relativeWidgetRect.setHeight(m_adsorbWidget->height());
relativeWidgetRect.setWidth(m_adsorbWidgetSize.width());
relativeWidgetRect.setHeight(m_adsorbWidgetSize.height());
targetWidgetRect.setTopLeft(pos());
targetWidgetRect.setWidth(width());

View file

@ -46,6 +46,9 @@ private:
QPoint m_relativePos;
bool m_adsorbed = false;
QPointer<QWidget> m_adsorbWidget;
// 单独记录adsorbWidgetSize因为Widget setGeometry的时候会先收到Move事件后收到Resize事件
// 但是收到Move事件时Widget的size()已经是setGeometry指定的size了
QSize m_adsorbWidgetSize;
AdsorbPosition m_curAdsorbPosition;
};

View file

@ -1,6 +1,7 @@
#include <QCoreApplication>
#include <QCoreApplication>
#include <QFileInfo>
#include <QSettings>
#include <QDebug>
#include "config.h"
@ -43,7 +44,7 @@
#define COMMON_CODEC_NAME_KEY "CodecName"
#define COMMON_CODEC_NAME_DEF "-"
// user data
// user config
#define COMMON_RECORD_KEY "RecordPath"
#define COMMON_RECORD_DEF ""
@ -56,16 +57,44 @@
#define COMMON_RECORD_FORMAT_INDEX_KEY "RecordFormatIndex"
#define COMMON_RECORD_FORMAT_INDEX_DEF 0
#define COMMON_LOCK_ORIENTATION_INDEX_KEY "LockDirectionIndex"
#define COMMON_LOCK_ORIENTATION_INDEX_DEF 0
#define COMMON_RECORD_SCREEN_KEY "RecordScreen"
#define COMMON_RECORD_SCREEN_DEF false
#define COMMON_RECORD_BACKGROUD_KEY "RecordBackGround"
#define COMMON_RECORD_BACKGROUD_DEF false
#define COMMON_REVERSE_CONNECT_KEY "ReverseConnect"
#define COMMON_REVERSE_CONNECT_DEF true
#define COMMON_SHOW_FPS_KEY "ShowFPS"
#define COMMON_SHOW_FPS_DEF false
#define COMMON_WINDOW_ON_TOP_KEY "WindowOnTop"
#define COMMON_WINDOW_ON_TOP_DEF false
#define COMMON_AUTO_OFF_SCREEN_KEY "AutoOffScreen"
#define COMMON_AUTO_OFF_SCREEN_DEF false
#define COMMON_FRAMELESS_WINDOW_KEY "FramelessWindow"
#define COMMON_FRAMELESS_WINDOW_DEF false
#define COMMON_KEEP_ALIVE_KEY "KeepAlive"
#define COMMON_KEEP_ALIVE_DEF false
#define COMMON_SIMPLE_MODE_KEY "SimpleMode"
#define COMMON_SIMPLE_MODE_DEF false
// device config
#define SERIAL_WINDOW_RECT_KEY_X "WindowRectX"
#define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY"
#define SERIAL_WINDOW_RECT_KEY_W "WindowRectW"
#define SERIAL_WINDOW_RECT_KEY_H "WindowRectH"
#define SERIAL_WINDOW_RECT_KEY_DEF -1
#define COMMON_FRAMELESS_WINDOW_KEY "FramelessWindow"
#define COMMON_FRAMELESS_WINDOW_DEF false
// 最大尺寸 录制格式
#define SERIAL_NICK_NAME_KEY "NickName"
#define SERIAL_NICK_NAME_DEF "Phone"
QString Config::s_configPath = "";
@ -76,6 +105,8 @@ Config::Config(QObject *parent) : QObject(parent)
m_userData = new QSettings(getConfigPath() + "/userdata.ini", QSettings::IniFormat);
m_userData->setIniCodec("UTF-8");
qDebug()<<m_userData->childGroups();
}
Config &Config::getInstance()
@ -97,68 +128,47 @@ const QString &Config::getConfigPath()
return s_configPath;
}
QString Config::getRecordPath()
void Config::setUserBootConfig(const UserBootConfig &config)
{
QString record;
m_userData->beginGroup(GROUP_COMMON);
record = m_userData->value(COMMON_RECORD_KEY, COMMON_RECORD_DEF).toString();
m_userData->setValue(COMMON_RECORD_KEY, config.recordPath);
m_userData->setValue(COMMON_BITRATE_INDEX_KEY, config.bitRateIndex);
m_userData->setValue(COMMON_MAX_SIZE_INDEX_KEY, config.maxSizeIndex);
m_userData->setValue(COMMON_RECORD_FORMAT_INDEX_KEY, config.recordFormatIndex);
m_userData->setValue(COMMON_FRAMELESS_WINDOW_KEY, config.framelessWindow);
m_userData->setValue(COMMON_LOCK_ORIENTATION_INDEX_KEY, config.lockOrientationIndex);
m_userData->setValue(COMMON_RECORD_SCREEN_KEY, config.recordScreen);
m_userData->setValue(COMMON_RECORD_BACKGROUD_KEY, config.recordBackground);
m_userData->setValue(COMMON_REVERSE_CONNECT_KEY, config.reverseConnect);
m_userData->setValue(COMMON_SHOW_FPS_KEY, config.showFPS);
m_userData->setValue(COMMON_WINDOW_ON_TOP_KEY, config.windowOnTop);
m_userData->setValue(COMMON_AUTO_OFF_SCREEN_KEY, config.autoOffScreen);
m_userData->setValue(COMMON_KEEP_ALIVE_KEY, config.keepAlive);
m_userData->setValue(COMMON_SIMPLE_MODE_KEY, config.simpleMode);
m_userData->endGroup();
return record;
m_userData->sync();
}
void Config::setRecordPath(const QString &path)
UserBootConfig Config::getUserBootConfig()
{
UserBootConfig config;
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_RECORD_KEY, path);
m_userData->endGroup();
}
int Config::getBitRateIndex()
{
int bitRateIndex;
m_userData->beginGroup(GROUP_COMMON);
bitRateIndex = m_userData->value(COMMON_BITRATE_INDEX_KEY, COMMON_BITRATE_INDEX_DEF).toInt();
m_userData->endGroup();
return bitRateIndex;
}
void Config::setBitRateIndex(int bitRateIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_BITRATE_INDEX_KEY, bitRateIndex);
m_userData->endGroup();
}
int Config::getMaxSizeIndex()
{
int maxSizeIndex;
m_userData->beginGroup(GROUP_COMMON);
maxSizeIndex = m_userData->value(COMMON_MAX_SIZE_INDEX_KEY, COMMON_MAX_SIZE_INDEX_DEF).toInt();
m_userData->endGroup();
return maxSizeIndex;
}
void Config::setMaxSizeIndex(int maxSizeIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_MAX_SIZE_INDEX_KEY, maxSizeIndex);
m_userData->endGroup();
}
int Config::getRecordFormatIndex()
{
int recordFormatIndex;
m_userData->beginGroup(GROUP_COMMON);
recordFormatIndex = m_userData->value(COMMON_RECORD_FORMAT_INDEX_KEY, COMMON_RECORD_FORMAT_INDEX_DEF).toInt();
m_userData->endGroup();
return recordFormatIndex;
}
void Config::setRecordFormatIndex(int recordFormatIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_RECORD_FORMAT_INDEX_KEY, recordFormatIndex);
config.recordPath = m_userData->value(COMMON_RECORD_KEY, COMMON_RECORD_DEF).toString();
config.bitRateIndex = m_userData->value(COMMON_BITRATE_INDEX_KEY, COMMON_BITRATE_INDEX_DEF).toInt();
config.maxSizeIndex = m_userData->value(COMMON_MAX_SIZE_INDEX_KEY, COMMON_MAX_SIZE_INDEX_DEF).toInt();
config.recordFormatIndex = m_userData->value(COMMON_RECORD_FORMAT_INDEX_KEY, COMMON_RECORD_FORMAT_INDEX_DEF).toInt();
config.lockOrientationIndex = m_userData->value(COMMON_LOCK_ORIENTATION_INDEX_KEY, COMMON_LOCK_ORIENTATION_INDEX_DEF).toInt();
config.framelessWindow = m_userData->value(COMMON_FRAMELESS_WINDOW_KEY, COMMON_FRAMELESS_WINDOW_DEF).toBool();
config.recordScreen = m_userData->value(COMMON_RECORD_SCREEN_KEY, COMMON_RECORD_SCREEN_DEF).toBool();
config.recordBackground = m_userData->value(COMMON_RECORD_BACKGROUD_KEY, COMMON_RECORD_BACKGROUD_DEF).toBool();
config.reverseConnect = m_userData->value(COMMON_REVERSE_CONNECT_KEY, COMMON_REVERSE_CONNECT_DEF).toBool();
config.showFPS = m_userData->value(COMMON_SHOW_FPS_KEY, COMMON_SHOW_FPS_DEF).toBool();
config.windowOnTop = m_userData->value(COMMON_WINDOW_ON_TOP_KEY, COMMON_WINDOW_ON_TOP_DEF).toBool();
config.autoOffScreen = m_userData->value(COMMON_AUTO_OFF_SCREEN_KEY, COMMON_AUTO_OFF_SCREEN_DEF).toBool();
config.keepAlive = m_userData->value(COMMON_KEEP_ALIVE_KEY, COMMON_KEEP_ALIVE_DEF).toBool();
config.simpleMode = m_userData->value(COMMON_SIMPLE_MODE_KEY, COMMON_SIMPLE_MODE_DEF).toBool();
m_userData->endGroup();
return config;
}
void Config::setRect(const QString &serial, const QRect &rc)
@ -184,20 +194,21 @@ QRect Config::getRect(const QString &serial)
return rc;
}
void Config::setFramelessWindow(bool frameless)
void Config::setNickName(const QString &serial, const QString &name)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_FRAMELESS_WINDOW_KEY, frameless);
m_userData->beginGroup(serial);
m_userData->setValue(SERIAL_NICK_NAME_KEY, name);
m_userData->endGroup();
m_userData->sync();
}
bool Config::getFramelessWindow()
QString Config::getNickName(const QString &serial)
{
bool framelessWindow = false;
m_userData->beginGroup(GROUP_COMMON);
framelessWindow = m_userData->value(COMMON_FRAMELESS_WINDOW_KEY, COMMON_FRAMELESS_WINDOW_DEF).toBool();
QString name;
m_userData->beginGroup(serial);
name = m_userData->value(SERIAL_NICK_NAME_KEY, SERIAL_NICK_NAME_DEF).toString();
m_userData->endGroup();
return framelessWindow;
return name;
}
QString Config::getServerVersion()
@ -301,6 +312,16 @@ QString Config::getCodecName()
return codecName;
}
QStringList Config::getConnectedGroups()
{
return m_userData->childGroups();
}
void Config::deleteGroup(const QString &serial)
{
m_userData->remove(serial);
}
QString Config::getTitle()
{
QString title;

View file

@ -1,16 +1,36 @@
#ifndef CONFIG_H
#ifndef CONFIG_H
#define CONFIG_H
#include <QObject>
#include <QPointer>
#include <QRect>
struct UserBootConfig
{
QString recordPath = "";
int bitRateIndex = 0;
int maxSizeIndex = 0;
int recordFormatIndex = 0;
int lockOrientationIndex = 0;
bool recordScreen = false;
bool recordBackground = false;
bool reverseConnect = true;
bool showFPS = false;
bool windowOnTop = false;
bool autoOffScreen = false;
bool framelessWindow = false;
bool keepAlive = false;
bool simpleMode = false;
};
class QSettings;
class Config : public QObject
{
Q_OBJECT
public:
static Config &getInstance();
// config
QString getTitle();
QString getServerVersion();
@ -24,20 +44,19 @@ public:
QString getLogLevel();
QString getCodecOptions();
QString getCodecName();
QStringList getConnectedGroups();
// user data
QString getRecordPath();
void setRecordPath(const QString &path);
int getBitRateIndex();
void setBitRateIndex(int bitRateIndex);
int getMaxSizeIndex();
void setMaxSizeIndex(int maxSizeIndex);
int getRecordFormatIndex();
void setRecordFormatIndex(int recordFormatIndex);
// user data:common
void setUserBootConfig(const UserBootConfig &config);
UserBootConfig getUserBootConfig();
// user data:device
void setNickName(const QString &serial, const QString &name);
QString getNickName(const QString &serial);
void setRect(const QString &serial, const QRect &rc);
QRect getRect(const QString &serial);
bool getFramelessWindow();
void setFramelessWindow(bool frameless);
void deleteGroup(const QString &serial);
private:
explicit Config(QObject *parent = nullptr);

View file

@ -124,7 +124,9 @@ you can [build it by yourself](##Build)(just ubuntu test)
## Run
### Simple Mode
Connect to your Android device on your computer, then run the program and click `USB connect` or `WiFi connect`
### Not Simple Mode
Connect to your Android device on your computer, then run the program and click the button below to connect to the Android device.
![run](screenshot/run.png)
@ -260,7 +262,7 @@ All the dependencies are provided and it is easy to compile.
## Licence
Since it is based on scrcpy, respect its Licence
Copyright (C) 2020 Barry
Copyright (C) 2025 Rankun
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View file

@ -128,7 +128,9 @@ Mac OS平台你可以直接使用我编译好的可执行程序:
目前只在ubuntu上测试过
## 运行
### 精简模式
在你的电脑上接入Android设备然后运行程序点击`一键USB连接`或者`一键WIFI连接`
### 非精简模式
在你的电脑上接入Android设备然后运行程序按顺序点击如下按钮即可连接到Android设备
![运行](screenshot/run.png)
@ -256,7 +258,7 @@ Mac OS平台你可以直接使用我编译好的可执行程序:
## Licence
由于是复刻的scrcpy尊重它的Licence
Copyright (C) 2020 Barry
Copyright (C) 2025 Rankun
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.