From e3e16ce70f28e0c8bfb77464fc7259cf66dc0d8a Mon Sep 17 00:00:00 2001 From: MRXY001 Date: Thu, 24 Jun 2021 09:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9C=E7=A8=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=89=8D=E7=BC=80=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control_service/remotecontrolservie.cpp | 17 ++++++++++++----- control_service/remotecontrolservie.h | 2 +- global/usettings.cpp | 2 +- global/usettings.h | 2 +- widgets/settings/remotecontrolwidget.cpp | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/control_service/remotecontrolservie.cpp b/control_service/remotecontrolservie.cpp index dbea77f..85a6538 100644 --- a/control_service/remotecontrolservie.cpp +++ b/control_service/remotecontrolservie.cpp @@ -16,21 +16,22 @@ RemoteControlServie::RemoteControlServie(QObject *parent) : QObject(parent) } -void RemoteControlServie::execCmd(QString cmd) +bool RemoteControlServie::execCmd(QString cmd) { - if (us->remoteControlPrefix.size()) + if (us->remoteControlPrefixs.size()) { bool find = false; - foreach (auto prefix, us->remoteControlPrefix) + foreach (auto prefix, us->remoteControlPrefixs) { if (!cmd.startsWith(prefix)) - return ; + continue ; + qDebug() << cmd << prefix; cmd.remove(0, prefix.length()); find = true; break; } if (!find) - return ; + return false; } QRegularExpressionMatch match; @@ -86,6 +87,12 @@ void RemoteControlServie::execCmd(QString cmd) { emit reply(readTextFile(rt->DATA_PATH + "control/" + cmd)); } + + else + { + return false; + } + return true; } void RemoteControlServie::simulateKeys(QString seq, bool delay) diff --git a/control_service/remotecontrolservie.h b/control_service/remotecontrolservie.h index 75b7233..36b9c77 100644 --- a/control_service/remotecontrolservie.h +++ b/control_service/remotecontrolservie.h @@ -10,7 +10,7 @@ class RemoteControlServie : public QObject public: explicit RemoteControlServie(QObject *parent = nullptr); - void execCmd(QString cmd); + bool execCmd(QString cmd); void simulateKeys(QString seq, bool delay = false); diff --git a/global/usettings.cpp b/global/usettings.cpp index 6fbb73f..129d819 100644 --- a/global/usettings.cpp +++ b/global/usettings.cpp @@ -64,7 +64,7 @@ void USettings::restoreSettings() endGroup(); beginGroup("remoteControl"); - assign(remoteControlPrefix, "prefix"); + assign(remoteControlPrefixs, "prefixs"); endGroup(); beginGroup("leave"); diff --git a/global/usettings.h b/global/usettings.h index 2ac1e0d..0072634 100644 --- a/global/usettings.h +++ b/global/usettings.h @@ -111,7 +111,7 @@ class USettings : public MySettings int autoCacheFileMaxSize = 10; // 自动缓存的文件上限,单位MB // 远程控制 - QStringList remoteControlPrefix; + QStringList remoteControlPrefixs; // 离开模式 bool leaveMode = false; // 离开模式(开启回复) diff --git a/widgets/settings/remotecontrolwidget.cpp b/widgets/settings/remotecontrolwidget.cpp index c47672b..8168246 100644 --- a/widgets/settings/remotecontrolwidget.cpp +++ b/widgets/settings/remotecontrolwidget.cpp @@ -8,7 +8,7 @@ RemoteControlWidget::RemoteControlWidget(QWidget *parent) : { ui->setupUi(this); - ui->prefixEdit->setText(us->remoteControlPrefix.join(" ")); + ui->prefixEdit->setText(us->remoteControlPrefixs.join(" ")); } RemoteControlWidget::~RemoteControlWidget() @@ -18,5 +18,5 @@ RemoteControlWidget::~RemoteControlWidget() void RemoteControlWidget::on_prefixEdit_editingFinished() { - us->set("remoteControl/prefix", us->remoteControlPrefix = ui->prefixEdit->text().split(" ", QString::SkipEmptyParts)); + us->set("remoteControl/prefixs", us->remoteControlPrefixs = ui->prefixEdit->text().split(" ", QString::SkipEmptyParts)); }