Skip to content

Commit

Permalink
修复远程控制前缀的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
iwxyi committed Jun 24, 2021
1 parent 34eb213 commit e3e16ce
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
17 changes: 12 additions & 5 deletions control_service/remotecontrolservie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion control_service/remotecontrolservie.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion global/usettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void USettings::restoreSettings()
endGroup();

beginGroup("remoteControl");
assign(remoteControlPrefix, "prefix");
assign(remoteControlPrefixs, "prefixs");
endGroup();

beginGroup("leave");
Expand Down
2 changes: 1 addition & 1 deletion global/usettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class USettings : public MySettings
int autoCacheFileMaxSize = 10; // 自动缓存的文件上限,单位MB

// 远程控制
QStringList remoteControlPrefix;
QStringList remoteControlPrefixs;

// 离开模式
bool leaveMode = false; // 离开模式(开启回复)
Expand Down
4 changes: 2 additions & 2 deletions widgets/settings/remotecontrolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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));
}

0 comments on commit e3e16ce

Please sign in to comment.