refactor: move languageSync to coreArgs
This commit is contained in:
committed by
Chris Rizzitello
parent
b0fe79d527
commit
2cb36777f9
@ -36,8 +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, "--sync-language")) {
|
||||
args.m_enableLangSync = true;
|
||||
} else if (isArg(i, argc, argv, nullptr, "--invert-scroll")) {
|
||||
args.m_clientScrollDirection = deskflow::ClientScrollDirection::Inverted;
|
||||
} else {
|
||||
|
||||
@ -149,8 +149,8 @@ deskflow::Screen *ClientApp::createScreen()
|
||||
#if WINAPI_MSWINDOWS
|
||||
return new deskflow::Screen(
|
||||
new MSWindowsScreen(
|
||||
false, Settings::value(Settings::Core::UseHooks).toBool(), getEvents(), args().m_enableLangSync,
|
||||
args().m_clientScrollDirection
|
||||
false, Settings::value(Settings::Core::UseHooks).toBool(), getEvents(),
|
||||
Settings::value(Settings::Client::LanguageSync).toBool(), args().m_clientScrollDirection
|
||||
),
|
||||
getEvents()
|
||||
);
|
||||
@ -183,7 +183,10 @@ deskflow::Screen *ClientApp::createScreen()
|
||||
|
||||
#if WINAPI_CARBON
|
||||
return new deskflow::Screen(
|
||||
new OSXScreen(getEvents(), false, args().m_enableLangSync, args().m_clientScrollDirection), getEvents()
|
||||
new OSXScreen(
|
||||
getEvents(), false, Settings::value(Settings::Client::LanguageSync).toBool(), args().m_clientScrollDirection
|
||||
),
|
||||
getEvents()
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -25,8 +25,6 @@ public:
|
||||
~ClientArgs() override = default;
|
||||
|
||||
public:
|
||||
bool m_enableLangSync = false; /// @brief Should keyboard input be in same language as on server
|
||||
|
||||
/**
|
||||
* @brief m_clientScrollDirection
|
||||
* This option is responcible for scroll direction on client side.
|
||||
|
||||
@ -124,6 +124,13 @@ void CoreArgParser::parse()
|
||||
if (m_parser.isSet(CoreArgs::yscrollOption)) {
|
||||
Settings::setValue(Settings::Client::ScrollSpeed, m_parser.value(CoreArgs::yscrollOption));
|
||||
}
|
||||
|
||||
if (m_parser.isSet(CoreArgs::languageSyncOption)) {
|
||||
bool value =
|
||||
((m_parser.value(CoreArgs::languageSyncOption).toLower() == "true") ||
|
||||
(m_parser.value(CoreArgs::languageSyncOption) == "1"));
|
||||
Settings::setValue(Settings::Client::LanguageSync, value);
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]] void CoreArgParser::showHelpText() const
|
||||
|
||||
@ -70,9 +70,12 @@ struct CoreArgs
|
||||
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,
|
||||
yscrollOption};
|
||||
inline static const auto languageSyncOption =
|
||||
QCommandLineOption("languageSync", "Client Mode: Sync language with client (default: false)", "value");
|
||||
|
||||
inline static const auto options = {helpOption, versionOption, configOption, interfaceOption,
|
||||
portOption, nameOption, logLevelOption, logFileOption,
|
||||
secureOption, tlsCertOption, preventSleepOption, restartOption,
|
||||
displayOption, useHooksOption, peerCheckOption, serverConfigOption,
|
||||
yscrollOption, languageSyncOption};
|
||||
};
|
||||
|
||||
@ -479,10 +479,6 @@ bool CoreProcess::addClientArgs(QStringList &args)
|
||||
args << "--log" << Settings::value(Settings::Log::File).toString();
|
||||
}
|
||||
|
||||
if (Settings::value(Settings::Client::LanguageSync).toBool()) {
|
||||
args << "--sync-language";
|
||||
}
|
||||
|
||||
if (Settings::value(Settings::Client::InvertScrollDirection).toBool()) {
|
||||
args << "--invert-scroll";
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
#include "platform/EiKeyState.h"
|
||||
|
||||
#include "base/Log.h"
|
||||
#include "common/Settings.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
#include "deskflow/ClientApp.h"
|
||||
#include "platform/XWindowsUtil.h"
|
||||
|
||||
#include <cstddef>
|
||||
@ -20,7 +20,9 @@
|
||||
namespace deskflow {
|
||||
|
||||
EiKeyState::EiKeyState(EiScreen *screen, IEventQueue *events)
|
||||
: KeyState(events, AppUtil::instance().getKeyboardLayoutList(), ClientApp::instance().args().m_enableLangSync),
|
||||
: KeyState(
|
||||
events, AppUtil::instance().getKeyboardLayoutList(), Settings::value(Settings::Client::LanguageSync).toBool()
|
||||
),
|
||||
m_screen{screen}
|
||||
{
|
||||
m_xkb = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
|
||||
@ -12,12 +12,12 @@
|
||||
#include <QDBusPendingReply>
|
||||
#endif
|
||||
|
||||
#include "common/Settings.h" // Must Include before XWindowsKeyState due to its use of Xorg headers
|
||||
|
||||
#include "platform/XWindowsKeyState.h"
|
||||
|
||||
#include "base/Log.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
#include "deskflow/ClientApp.h"
|
||||
#include "deskflow/ClientArgs.h"
|
||||
#include "platform/XWindowsUtil.h"
|
||||
|
||||
#include <X11/X.h>
|
||||
@ -35,7 +35,9 @@
|
||||
static const size_t ModifiersFromXDefaultSize = 32;
|
||||
|
||||
XWindowsKeyState::XWindowsKeyState(Display *display, bool useXKB, IEventQueue *events)
|
||||
: KeyState(events, AppUtil::instance().getKeyboardLayoutList(), ClientApp::instance().args().m_enableLangSync),
|
||||
: KeyState(
|
||||
events, AppUtil::instance().getKeyboardLayoutList(), Settings::value(Settings::Client::LanguageSync).toBool()
|
||||
),
|
||||
m_display(display),
|
||||
m_modifierFromX(ModifiersFromXDefaultSize)
|
||||
{
|
||||
@ -44,7 +46,8 @@ XWindowsKeyState::XWindowsKeyState(Display *display, bool useXKB, IEventQueue *e
|
||||
|
||||
XWindowsKeyState::XWindowsKeyState(Display *display, bool useXKB, IEventQueue *events, deskflow::KeyMap &keyMap)
|
||||
: KeyState(
|
||||
events, keyMap, AppUtil::instance().getKeyboardLayoutList(), ClientApp::instance().args().m_enableLangSync
|
||||
events, keyMap, AppUtil::instance().getKeyboardLayoutList(),
|
||||
Settings::value(Settings::Client::LanguageSync).toBool()
|
||||
),
|
||||
m_display(display),
|
||||
m_modifierFromX(ModifiersFromXDefaultSize)
|
||||
|
||||
@ -170,18 +170,6 @@ void ArgParserTests::clientArgs()
|
||||
QVERIFY(args.m_shouldExitOk);
|
||||
}
|
||||
|
||||
void ArgParserTests::client_setLangSync()
|
||||
{
|
||||
deskflow::ClientArgs clientArgs;
|
||||
clientArgs.m_enableLangSync = false;
|
||||
const int argc = 2;
|
||||
std::array<const char *, argc> kLangCmd = {"stub", "--sync-language"};
|
||||
|
||||
m_parser.parseClientArgs(clientArgs, argc, kLangCmd.data());
|
||||
|
||||
QVERIFY(clientArgs.m_enableLangSync);
|
||||
}
|
||||
|
||||
void ArgParserTests::client_setInvertScroll()
|
||||
{
|
||||
deskflow::ClientArgs clientArgs;
|
||||
|
||||
@ -22,7 +22,6 @@ private Q_SLOTS:
|
||||
void getArgv();
|
||||
void assembleCommand();
|
||||
void clientArgs();
|
||||
void client_setLangSync();
|
||||
void client_setInvertScroll();
|
||||
void client_setAddress();
|
||||
void client_badArgs();
|
||||
|
||||
@ -330,6 +330,46 @@ void CoreArgParserTests::client_yscroll()
|
||||
QCOMPARE(15, Settings::value(Settings::Client::ScrollSpeed).toInt());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::client_languageSync_true()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--languageSync", "true"};
|
||||
|
||||
CoreArgParser parser(args);
|
||||
parser.parse();
|
||||
|
||||
QVERIFY(Settings::value(Settings::Client::LanguageSync).toBool());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::client_languageSync_false()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--languageSync", "false"};
|
||||
|
||||
CoreArgParser parser(args);
|
||||
parser.parse();
|
||||
|
||||
QVERIFY(!Settings::value(Settings::Client::LanguageSync).toBool());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::client_languageSync_1()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--languageSync", "1"};
|
||||
|
||||
CoreArgParser parser(args);
|
||||
parser.parse();
|
||||
|
||||
QVERIFY(Settings::value(Settings::Client::LanguageSync).toBool());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::client_languageSync_0()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--languageSync", "0"};
|
||||
|
||||
CoreArgParser parser(args);
|
||||
parser.parse();
|
||||
|
||||
QVERIFY(!Settings::value(Settings::Client::LanguageSync).toBool());
|
||||
}
|
||||
|
||||
void CoreArgParserTests::preventSleep_true()
|
||||
{
|
||||
QStringList args = {"stub", "client", "--prevent-sleep", "true"};
|
||||
|
||||
@ -46,6 +46,10 @@ private Q_SLOTS:
|
||||
void server_peerCheck_true();
|
||||
void server_setConfig();
|
||||
void client_yscroll();
|
||||
void client_languageSync_true();
|
||||
void client_languageSync_false();
|
||||
void client_languageSync_1();
|
||||
void client_languageSync_0();
|
||||
|
||||
private:
|
||||
inline static const QString m_settingsPath = QStringLiteral("tmp/test");
|
||||
|
||||
Reference in New Issue
Block a user