refactor: move yscroll to coreArgs
This commit is contained in:
parent
efebe9ca56
commit
b0fe79d527
11 changed files with 30 additions and 23 deletions
|
|
@ -165,6 +165,10 @@ QVariant Settings::defaultValue(const QString &key)
|
|||
return QStringLiteral("%1/%2").arg(Settings::settingsPath(), kDaemonLogFilename);
|
||||
}
|
||||
|
||||
if (key == Client::ScrollSpeed) {
|
||||
return 120;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public:
|
|||
struct Client
|
||||
{
|
||||
inline static const auto InvertScrollDirection = QStringLiteral("client/invertScrollDirection");
|
||||
inline static const auto ScrollSpeed = QStringLiteral("client/yscroll");
|
||||
inline static const auto LanguageSync = QStringLiteral("client/languageSync");
|
||||
inline static const auto RemoteHost = QStringLiteral("client/remoteHost");
|
||||
inline static const auto XdpRestoreToken = QStringLiteral("client/xdpRestoreToken");
|
||||
|
|
@ -164,6 +165,7 @@ private:
|
|||
Settings::Client::InvertScrollDirection
|
||||
, Settings::Client::LanguageSync
|
||||
, Settings::Client::RemoteHost
|
||||
, Settings::Client::ScrollSpeed
|
||||
, Settings::Client::XdpRestoreToken
|
||||
, Settings::Core::CoreMode
|
||||
, Settings::Core::Interface
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ bool ArgParser::parseClientArgs(deskflow::ClientArgs &args, int argc, const char
|
|||
continue;
|
||||
} else if (isArg(i, argc, argv, nullptr, "--camp") || isArg(i, argc, argv, nullptr, "--no-camp")) {
|
||||
// ignore -- included for backwards compatibility
|
||||
} else if (isArg(i, argc, argv, nullptr, "--yscroll", 1)) {
|
||||
// define scroll
|
||||
args.m_yscroll = atoi(argv[++i]);
|
||||
} else if (isArg(i, argc, argv, nullptr, "--sync-language")) {
|
||||
args.m_enableLangSync = true;
|
||||
} else if (isArg(i, argc, argv, nullptr, "--invert-scroll")) {
|
||||
|
|
|
|||
|
|
@ -105,14 +105,11 @@ void ClientApp::help()
|
|||
std::stringstream help;
|
||||
help << "\n\nClient Mode:\n\n"
|
||||
<< "Usage: " << kAppId << "-core client"
|
||||
<< " [--yscroll <delta>]"
|
||||
<< " [--sync-language]"
|
||||
<< " [--invert-scroll]"
|
||||
<< " <server-address>"
|
||||
<< "\n\n"
|
||||
<< "Connect to a " << kAppName << " mouse/keyboard sharing server.\n"
|
||||
<< " --yscroll <delta> defines the vertical scrolling delta,\n"
|
||||
<< " which is 120 by default.\n"
|
||||
<< " --sync-language enable language synchronization.\n"
|
||||
<< " --invert-scroll invert scroll direction on this\n"
|
||||
<< " computer.\n"
|
||||
|
|
@ -176,8 +173,8 @@ deskflow::Screen *ClientApp::createScreen()
|
|||
LOG_INFO("using legacy x windows screen");
|
||||
return new deskflow::Screen(
|
||||
new XWindowsScreen(
|
||||
qPrintable(Settings::value(Settings::Core::Display).toString()), false, args().m_yscroll, getEvents(),
|
||||
args().m_clientScrollDirection
|
||||
qPrintable(Settings::value(Settings::Core::Display).toString()), false,
|
||||
Settings::value(Settings::Client::ScrollSpeed).toInt(), getEvents(), args().m_clientScrollDirection
|
||||
),
|
||||
getEvents()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ public:
|
|||
~ClientArgs() override = default;
|
||||
|
||||
public:
|
||||
int m_yscroll = 0;
|
||||
bool m_enableLangSync = false; /// @brief Should keyboard input be in same language as on server
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -120,6 +120,10 @@ void CoreArgParser::parse()
|
|||
if (m_parser.isSet(CoreArgs::serverConfigOption)) {
|
||||
Settings::setValue(Settings::Server::ExternalConfigFile, m_parser.value(CoreArgs::serverConfigOption));
|
||||
}
|
||||
|
||||
if (m_parser.isSet(CoreArgs::yscrollOption)) {
|
||||
Settings::setValue(Settings::Client::ScrollSpeed, m_parser.value(CoreArgs::yscrollOption));
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]] void CoreArgParser::showHelpText() const
|
||||
|
|
|
|||
|
|
@ -66,8 +66,13 @@ struct CoreArgs
|
|||
inline static const auto serverConfigOption =
|
||||
QCommandLineOption("serverConfig", "Server Mode: File to load as server config", "path");
|
||||
|
||||
// Client Options
|
||||
inline static const auto yscrollOption =
|
||||
QCommandLineOption("yscroll", "Client Mode: Vertical scrolling delta (default: 120)", "value");
|
||||
|
||||
inline static const auto options = {helpOption, versionOption, configOption, interfaceOption,
|
||||
portOption, nameOption, logLevelOption, logFileOption,
|
||||
secureOption, tlsCertOption, preventSleepOption, restartOption,
|
||||
displayOption, useHooksOption, peerCheckOption, serverConfigOption};
|
||||
secureOption, tlsCertOption, preventSleepOption, restartOption,
|
||||
displayOption, useHooksOption, peerCheckOption, serverConfigOption,
|
||||
yscrollOption};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -170,17 +170,6 @@ void ArgParserTests::clientArgs()
|
|||
QVERIFY(args.m_shouldExitOk);
|
||||
}
|
||||
|
||||
void ArgParserTests::client_yScroll()
|
||||
{
|
||||
deskflow::ClientArgs clientArgs;
|
||||
const int argc = 3;
|
||||
const char *kYScrollCmd[argc] = {"stub", "--yscroll", "1"};
|
||||
|
||||
m_parser.parseClientArgs(clientArgs, argc, kYScrollCmd);
|
||||
|
||||
QCOMPARE(clientArgs.m_yscroll, 1);
|
||||
}
|
||||
|
||||
void ArgParserTests::client_setLangSync()
|
||||
{
|
||||
deskflow::ClientArgs clientArgs;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ private Q_SLOTS:
|
|||
void getArgv();
|
||||
void assembleCommand();
|
||||
void clientArgs();
|
||||
void client_yScroll();
|
||||
void client_setLangSync();
|
||||
void client_setInvertScroll();
|
||||
void client_setAddress();
|
||||
|
|
|
|||
|
|
@ -320,6 +320,16 @@ void CoreArgParserTests::server_setConfig()
|
|||
QCOMPARE("afile.conf", Settings::value(Settings::Server::ExternalConfigFile).toString());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::client_yscroll()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--yscroll", "15"};
|
||||
|
||||
CoreArgParser parser(args);
|
||||
parser.parse();
|
||||
|
||||
QCOMPARE(15, Settings::value(Settings::Client::ScrollSpeed).toInt());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::preventSleep_true()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--prevent-sleep", "true"};
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ private Q_SLOTS:
|
|||
void server_peerCheck_false();
|
||||
void server_peerCheck_true();
|
||||
void server_setConfig();
|
||||
void client_yscroll();
|
||||
|
||||
private:
|
||||
inline static const QString m_settingsPath = QStringLiteral("tmp/test");
|
||||
|
|
|
|||
Loading…
Reference in a new issue