diff --git a/QtScrcpy/QtScrcpy.pro b/QtScrcpy/QtScrcpy.pro index 0afdc4e..e61704c 100644 --- a/QtScrcpy/QtScrcpy.pro +++ b/QtScrcpy/QtScrcpy.pro @@ -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 diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index e5f6827..b7ea3c1 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -74,6 +74,20 @@ 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() @@ -119,14 +133,18 @@ void Dialog::initUI() ui->recordPathEdt->setText(Config::getInstance().getRecordPath()); ui->framelessCheck->setChecked(Config::getInstance().getFramelessWindow()); + on_useSingleModeCheck_clicked(); + + updateConnectedList(); + #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 } @@ -140,6 +158,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 +180,77 @@ 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::updateConnectedList() +{ + ui->connectedPhoneList->clear(); + QStringList list = Config::getInstance().getConnectedGroups(); + + 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 < list.length(); ++i) + { + QString phone = QString(list[i]); + if(phone != "common" /*&& regIP.exactMatch(phone)*/) + { + ui->connectedPhoneList->addItem(phone+"-"+Config::getInstance().getUserName(phone)); + } + } +} + +void Dialog::updateUser() +{ + +} + +void Dialog::loadUser() +{ + +} + +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()) { @@ -166,6 +264,21 @@ void Dialog::on_startServerBtn_clicked() { outLog("start server...", false); + UserBootConfig config; + + 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.windowFrameless = ui->framelessCheck->isChecked(); + config.keepAlive = ui->stayAwakeCheck->isChecked(); + + Config::getInstance().setUserBootConfig(ui->serialBox->currentText(),config); + + updateConnectedList(); + QString absFilePath; if (ui->recordScreenCheck->isChecked()) { QString fileDir(ui->recordPathEdt->text().trimmed()); @@ -422,3 +535,120 @@ void Dialog::on_framelessCheck_stateChanged(int arg1) Q_UNUSED(arg1) Config::getInstance().setFramelessWindow(ui->framelessCheck->isChecked()); } + +void Dialog::on_usbConnectBtn_clicked() +{ + on_stopAllServerBtn_clicked(); + delayMs(200); + on_updateDevice_clicked(); + delayMs(200); + if(ui->serialBox->count()==0) + { + qWarning() << "No device is found!"; + return; + } + + 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) + { + if(!regIP.exactMatch(ui->serialBox->itemText(i))) + { + ui->serialBox->setCurrentIndex(i); + on_startServerBtn_clicked(); + break; + } + } + + updateConnectedList(); +} + +void Dialog::on_wifiConnectBtn_clicked() +{ + on_stopAllServerBtn_clicked(); + delayMs(200); + + on_updateDevice_clicked(); + delayMs(200); + if(ui->serialBox->count()==0) + { + qWarning() << "No device is found!"; + return; + } + + on_getIPBtn_clicked(); + delayMs(200); + + on_startAdbdBtn_clicked(); + delayMs(1000); + + on_wirelessConnectBtn_clicked(); + delayMs(2000); + + ui->serialBox->clear(); + + ui->serialBox->addItem(ui->deviceIpEdt->text()+":5555"); + + on_startServerBtn_clicked(); + delayMs(200); + + updateConnectedList(); +} + +void Dialog::on_connectedPhoneList_itemDoubleClicked(QListWidgetItem *item) +{ + ui->serialBox->clear(); + ui->serialBox->addItem(item->text().split("-")[0]); + ui->serialBox->setCurrentIndex(0); + + UserBootConfig config = Config::getInstance().getUserBootConfig(ui->serialBox->currentText()); + + 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->framelessCheck->setChecked(config.windowFrameless); + ui->stayAwakeCheck->setChecked(config.keepAlive); + ui->userNameEdt->setText(Config::getInstance().getUserName(ui->serialBox->currentText())); + + on_startServerBtn_clicked(); +} + +void Dialog::on_updateNameBtn_clicked() +{ + if(ui->serialBox->count()!=0) + { + if(ui->userNameEdt->text().isEmpty()) + Config::getInstance().setUserName(ui->serialBox->currentText(),"PHONE"); + else + Config::getInstance().setUserName(ui->serialBox->currentText(),ui->userNameEdt->text()); + + updateConnectedList(); + + 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(); + } +} diff --git a/QtScrcpy/dialog.h b/QtScrcpy/dialog.h index 20eae6f..bae8044 100644 --- a/QtScrcpy/dialog.h +++ b/QtScrcpy/dialog.h @@ -1,8 +1,13 @@ -#ifndef DIALOG_H +#ifndef DIALOG_H #define DIALOG_H #include #include +#include +#include +#include +#include + #include "adbprocess.h" #include "devicemanage.h" @@ -66,16 +71,39 @@ private slots: void on_framelessCheck_stateChanged(int arg1); + void on_usbConnectBtn_clicked(); + + void on_wifiConnectBtn_clicked(); + + void on_connectedPhoneList_itemDoubleClicked(QListWidgetItem *item); + + void on_updateNameBtn_clicked(); + + void on_useSingleModeCheck_clicked(); + private: bool checkAdbRun(); void initUI(); void execAdbCmd(); + void delayMs(int ms); QString getGameScript(const QString &fileName); + void slotShow(); + void slotActivated(QSystemTrayIcon::ActivationReason reason); + void updateConnectedList(); + void updateUser(); + void loadUser(); + +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 diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index ae80cab..ed900ab 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -6,19 +6,19 @@ 0 0 - 420 - 517 + 500 + 745 - 420 + 500 0 - 420 + 500 16777215 @@ -26,6 +26,56 @@ QtScrcpy + + + + Use Simple Mode + + + true + + + + + + + Simple Mode + + + false + + + + + + + + WIFI Connect + + + + + + + USB Connect + + + + + + + + + + 16777215 + 16777215 + + + + + + + @@ -350,21 +400,43 @@ USB line - - 3 - - - 5 - - - 5 - - - 5 - - - 5 - + + + + + + + 110 + 0 + + + + device name: + + + + + + + + 16777215 + 16777215 + + + + + + + + update name + + + false + + + + + @@ -382,6 +454,12 @@ + + + 110 + 0 + + device serial: diff --git a/QtScrcpy/main.cpp b/QtScrcpy/main.cpp index bac0c2c..50178f0 100644 --- a/QtScrcpy/main.cpp +++ b/QtScrcpy/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) qInfo( "%s", - QObject::tr("This software is completely open source and free. Use for illegal purposes is strictly prohibited, or at your own risk. You can download it at the " + QObject::tr("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:") .toUtf8() .data()); diff --git a/QtScrcpy/res/i18n/QtScrcpy_en.qm b/QtScrcpy/res/i18n/QtScrcpy_en.qm index 87eb16a..99b69d0 100644 Binary files a/QtScrcpy/res/i18n/QtScrcpy_en.qm and b/QtScrcpy/res/i18n/QtScrcpy_en.qm differ diff --git a/QtScrcpy/res/i18n/QtScrcpy_en.ts b/QtScrcpy/res/i18n/QtScrcpy_en.ts index 9d74059..e2ae0fe 100644 --- a/QtScrcpy/res/i18n/QtScrcpy_en.ts +++ b/QtScrcpy/res/i18n/QtScrcpy_en.ts @@ -49,93 +49,129 @@ Dialog - + Wireless Wireless - + wireless connect wireless connect - + wireless disconnect wireless disconnect - + Start Config Start Config - + record save path: record save path: - - + + select path select path - + record format: record format: - + record screen record screen - + frameless frameless - + + Use Simple Mode + Use Simple Mode + Use Simple Mode + + + + Simple Mode + Simple Mode + Simple Mode + + + + WIFI Connect + WIFI Connect + WIFI Connect + + + + USB Connect + USB Connect + USB Connect + + + lock orientation: lock orientation: - + show fps show fps - + stay awake stay awake - + + device name: + device name: + device name: + + + + update name + update name + update name + + + stop all server stop all server - + adb command: adb command: - + terminate terminate - + execute execute - + clear clear - + reverse connection reverse connection @@ -144,57 +180,57 @@ auto enable - + background record background record - + screen-off screen-off - + apply apply - + max size: max size: - + always on top always on top - + refresh script refresh script - + get device IP get device IP - + USB line USB line - + stop server stop server - + start server start server - + device serial: device serial: @@ -203,47 +239,101 @@ Config - + bit rate: bit rate: - + start adbd start adbd - + refresh devices refresh devices - + + show + show + show + + + + quit + quit + quit + + + original original - + no lock no lock + + + warning + Warning + Warning + + + + Quit or set tray? + Quit or set tray? + Quit or set tray? + + + + Quit + Quit + Quit + + + + Set tray + Set tray + Set tray + + + + Cancel + Cancel + Cancel + + + + Notice + Notice + Notice + + + + Hidden here! + Hidden here! + Hidden here! + InputConvertGame current keymap mode: %1 - current keymap mode: %1 + custom - custom + normal - normal + @@ -251,7 +341,7 @@ Script updated, current keymap mode:normal, Press ~ key to switch keymap mode - Script updated, current keymap mode:normal, Press ~ key to switch keymap mode + @@ -266,14 +356,10 @@ Strictly used for illegal purposes, or at your own risk. You can download it at the following address: 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: - - 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: - 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: - - This software is completely open source and free. Use for illegal purposes is strictly prohibited, or at your own risk. You can download it at the following address: - This software is completely open source and free. Use for illegal purposes is strictly prohibited, or at your own risk. You can download it at the following address: + 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: + 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: diff --git a/QtScrcpy/res/i18n/QtScrcpy_zh.qm b/QtScrcpy/res/i18n/QtScrcpy_zh.qm index dfe62bf..16fef0d 100644 Binary files a/QtScrcpy/res/i18n/QtScrcpy_zh.qm and b/QtScrcpy/res/i18n/QtScrcpy_zh.qm differ diff --git a/QtScrcpy/res/i18n/QtScrcpy_zh.ts b/QtScrcpy/res/i18n/QtScrcpy_zh.ts index eee9e68..9315d44 100644 --- a/QtScrcpy/res/i18n/QtScrcpy_zh.ts +++ b/QtScrcpy/res/i18n/QtScrcpy_zh.ts @@ -49,93 +49,129 @@ Dialog - + Wireless 无线 - + wireless connect 无线连接 - + wireless disconnect 无线断开 - + Start Config 启动配置 - + record save path: 录像保存路径: - - + + select path 选择路径 - + record format: 录制格式: - + record screen 录制屏幕 - + frameless 无边框 - + + Use Simple Mode + 启用一键模式 + 启用一键模式 + + + + Simple Mode + 一键模式 + 一键模式 + + + + WIFI Connect + 一键WIFI连接 + 一键WIFI连接 + + + + USB Connect + 一键USB连接 + 一键USB连接 + + + lock orientation: 锁定方向: - + show fps 显示fps - + stay awake 保持唤醒 - + + device name: + 设备名称: + 设备名称: + + + + update name + 更新设置名称 + 更新设置名称 + + + stop all server 停止所有服务 - + adb command: adb命令: - + terminate 终止 - + execute 执行 - + clear 清理 - + reverse connection 反向连接 @@ -144,57 +180,57 @@ 自动启用脚本 - + background record 后台录制 - + screen-off 自动息屏 - + apply 应用脚本 - + max size: 最大尺寸: - + always on top 窗口置顶 - + refresh script 刷新脚本 - + get device IP 获取设备IP - + USB line USB线 - + stop server 停止服务 - + start server 启动服务 - + device serial: 设备序列号: @@ -203,47 +239,101 @@ 配置 - + bit rate: 比特率: - + start adbd 启动adbd - + refresh devices 刷新设备列表 - + + show + 显示 + 显示 + + + + quit + 退出 + 退出 + + + original 原始 - + no lock 不锁定 + + + warning + 警告 + 警告 + + + + Quit or set tray? + 退出还是最小化到托盘? + 退出还是最小化到托盘? + + + + Quit + 退出 + 退出 + + + + Set tray + 最小化到系统托盘 + 最小化到系统托盘 + + + + Cancel + 取消 + 取消 + + + + Notice + 提示 + 提示 + + + + Hidden here! + 安卓录屏程序隐藏在这! + 安卓录屏程序隐藏在这! + InputConvertGame current keymap mode: %1 - 当前按键映射模式: %1 + custom - 自定义 + normal - 正常 + @@ -251,7 +341,7 @@ Script updated, current keymap mode:normal, Press ~ key to switch keymap mode - 脚本已更新,当前按键映射模式:正常,按~键切换按键映射模式 + @@ -266,14 +356,10 @@ Strictly used for illegal purposes, or at your own risk. You can download it at the following address: 本软件完全开源免费.\n严禁用于非法用途,否则后果自负.\n你可以在下面地址下载: - - 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: - 本软件完全开源免费,严禁用于非法用途,否则后果自负,你可以在下面地址下载: - - This software is completely open source and free. Use for illegal purposes is strictly prohibited, or at your own risk. You can download it at the following address: - 该软件是完全开源和免费的。 严禁将其用于非法目的,否则后果自负。 您可以从以下地址下载它: + 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: + 本软件完全开源免费,严禁用于非法用途,否则后果自负,你可以在下面地址下载: diff --git a/QtScrcpy/res/image/tray/logo.png b/QtScrcpy/res/image/tray/logo.png new file mode 100644 index 0000000..8fbaafe Binary files /dev/null and b/QtScrcpy/res/image/tray/logo.png differ diff --git a/QtScrcpy/res/res.qrc b/QtScrcpy/res/res.qrc index 840268d..d2f53a4 100644 --- a/QtScrcpy/res/res.qrc +++ b/QtScrcpy/res/res.qrc @@ -2,7 +2,7 @@ font/fontawesome-webfont.ttf image/videoform/phone-h.png - image/videoform/phone-v.png + image/videoform/phone-v.png qss/psblack.css qss/psblack/add_bottom.png qss/psblack/add_left.png @@ -24,5 +24,6 @@ qss/psblack/radiobutton_unchecked_disable.png i18n/QtScrcpy_en.qm i18n/QtScrcpy_zh.qm + image/tray/logo.png diff --git a/QtScrcpy/util/config.cpp b/QtScrcpy/util/config.cpp index 8966a7d..b9393ad 100644 --- a/QtScrcpy/util/config.cpp +++ b/QtScrcpy/util/config.cpp @@ -1,6 +1,7 @@ -#include +#include #include #include +#include #include "config.h" @@ -62,6 +63,16 @@ #define SERIAL_WINDOW_RECT_KEY_H "WindowRectH" #define SERIAL_WINDOW_RECT_KEY_DEF -1 +#define USER_NAME "PHONE" +#define USER_RECORD_SCREEN "RecordScreen" +#define USER_RECORD_BACKGROUD "RecordBackGround" +#define USER_REVERSE_CONNECT "ReverseConnect" +#define USER_SHOW_FPS "ShowFPS" +#define USER_WINDOW_ON_TOP "WindowOnTop" +#define USER_AUTO_OFF_SCREEN "AutoOffScreen" +#define USER_WINDOW_FRAMELESS "WindowFrameless" +#define USER_KEEP_ALIVE "KeepAlive" + #define COMMON_FRAMELESS_WINDOW_KEY "FramelessWindow" #define COMMON_FRAMELESS_WINDOW_DEF false @@ -76,6 +87,8 @@ Config::Config(QObject *parent) : QObject(parent) m_userData = new QSettings(getConfigPath() + "/userdata.ini", QSettings::IniFormat); m_userData->setIniCodec("UTF-8"); + + qDebug()<childGroups(); } Config &Config::getInstance() @@ -113,6 +126,37 @@ void Config::setRecordPath(const QString &path) m_userData->endGroup(); } +void Config::setUserBootConfig(const QString &serial, const UserBootConfig &config) +{ + m_userData->beginGroup(serial); + m_userData->setValue(USER_RECORD_SCREEN, config.recordScreen); + m_userData->setValue(USER_RECORD_BACKGROUD, config.recordBackground); + m_userData->setValue(USER_REVERSE_CONNECT, config.reverseConnect); + m_userData->setValue(USER_SHOW_FPS, config.showFPS); + m_userData->setValue(USER_WINDOW_ON_TOP, config.windowOnTop); + m_userData->setValue(USER_AUTO_OFF_SCREEN, config.autoOffScreen); + m_userData->setValue(USER_WINDOW_FRAMELESS, config.windowFrameless); + m_userData->setValue(USER_KEEP_ALIVE, config.keepAlive); + m_userData->endGroup(); + m_userData->sync(); +} + +UserBootConfig Config::getUserBootConfig(const QString &serial) +{ + UserBootConfig config; + m_userData->beginGroup(serial); + config.recordScreen = m_userData->value(USER_RECORD_SCREEN, false).toBool(); + config.recordBackground = m_userData->value(USER_RECORD_BACKGROUD, false).toBool(); + config.reverseConnect = m_userData->value(USER_REVERSE_CONNECT, true).toBool(); + config.showFPS = m_userData->value(USER_SHOW_FPS, false).toBool(); + config.windowOnTop = m_userData->value(USER_WINDOW_ON_TOP, false).toBool(); + config.autoOffScreen = m_userData->value(USER_AUTO_OFF_SCREEN, false).toBool(); + config.windowFrameless = m_userData->value(USER_WINDOW_FRAMELESS, false).toBool(); + config.keepAlive = m_userData->value(USER_KEEP_ALIVE, false).toBool(); + m_userData->endGroup(); + return config; +} + int Config::getBitRateIndex() { int bitRateIndex; @@ -191,6 +235,23 @@ void Config::setFramelessWindow(bool frameless) m_userData->endGroup(); } +void Config::setUserName(const QString &serial, const QString &name) +{ + m_userData->beginGroup(serial); + m_userData->setValue(USER_NAME, name); + m_userData->endGroup(); + m_userData->sync(); +} + +QString Config::getUserName(const QString &serial) +{ + QString name; + m_userData->beginGroup(serial); + name = m_userData->value(USER_NAME,"PHONE").toString(); + m_userData->endGroup(); + return name; +} + bool Config::getFramelessWindow() { bool framelessWindow = false; @@ -301,6 +362,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; diff --git a/QtScrcpy/util/config.h b/QtScrcpy/util/config.h index e0e7f51..af3104d 100644 --- a/QtScrcpy/util/config.h +++ b/QtScrcpy/util/config.h @@ -1,15 +1,27 @@ -#ifndef CONFIG_H +#ifndef CONFIG_H #define CONFIG_H #include #include #include +struct UserBootConfig +{ + bool recordScreen = false; + bool recordBackground = false; + bool reverseConnect = true; + bool showFPS = false; + bool windowOnTop = false; + bool autoOffScreen = false; + bool windowFrameless = false; + bool keepAlive = false; +}; class QSettings; class Config : public QObject { Q_OBJECT public: + static Config &getInstance(); // config QString getTitle(); @@ -24,6 +36,8 @@ public: QString getLogLevel(); QString getCodecOptions(); QString getCodecName(); + QStringList getConnectedGroups(); + void deleteGroup(const QString &serial); // user data QString getRecordPath(); @@ -38,6 +52,10 @@ public: QRect getRect(const QString &serial); bool getFramelessWindow(); void setFramelessWindow(bool frameless); + void setUserName(const QString &serial, const QString &name); + QString getUserName(const QString &serial); + void setUserBootConfig(const QString &serial, const UserBootConfig &config); + UserBootConfig getUserBootConfig(const QString &serial); private: explicit Config(QObject *parent = nullptr);