diff --git a/src/gui/src/Action.cpp b/src/gui/src/Action.cpp index 5d3792ef..0fdbed18 100644 --- a/src/gui/src/Action.cpp +++ b/src/gui/src/Action.cpp @@ -24,7 +24,7 @@ const char* Action::m_ActionTypeNames[] = { "keyDown", "keyUp", "keystroke", - "switchToScreen", "switchInDirection", "lockCursorToScreen", + "switchToScreen", "switchInDirection", "lockCursorToScreen", "restartServer", "mouseDown", "mouseUp", "mousebutton" }; @@ -87,6 +87,9 @@ QString Action::text() const text += m_LockCursorModeNames[m_LockCursorMode]; break; + case restartAllConnections: + text += "restart"; + break; default: Q_ASSERT(0); break; @@ -116,6 +119,7 @@ void Action::loadSettings(QSettings& settings) setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt()); setActiveOnRelease(settings.value("activeOnRelease", false).toBool()); setHaveScreens(settings.value("hasScreens", false).toBool()); + setRestartServer(settings.value("restartServer", false).toBool()); } void Action::saveSettings(QSettings& settings) const @@ -136,6 +140,7 @@ void Action::saveSettings(QSettings& settings) const settings.setValue("lockCursorToScreen", lockCursorMode()); settings.setValue("activeOnRelease", activeOnRelease()); settings.setValue("hasScreens", haveScreens()); + settings.setValue("restartServer", restartServer()); } QTextStream& operator<<(QTextStream& outStream, const Action& action) diff --git a/src/gui/src/Action.h b/src/gui/src/Action.h index dea98df6..6917233c 100644 --- a/src/gui/src/Action.h +++ b/src/gui/src/Action.h @@ -36,9 +36,29 @@ class Action friend QTextStream& operator<<(QTextStream& outStream, const Action& action); public: - enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton }; - enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown }; - enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff }; + enum ActionType { + keyDown, + keyUp, + keystroke, + switchToScreen, + switchInDirection, + lockCursorToScreen, + restartAllConnections, + mouseDown, + mouseUp, + mousebutton, + }; + enum SwitchDirection { + switchLeft, + switchRight, + switchUp, + switchDown + }; + enum LockCursorMode { + lockCursorToggle, + lockCursonOn, + lockCursorOff + }; public: Action(); @@ -55,6 +75,7 @@ class Action int lockCursorMode() const { return m_LockCursorMode; } bool activeOnRelease() const { return m_ActiveOnRelease; } bool haveScreens() const { return m_HasScreens; } + bool restartServer() const { return m_restartServer; } protected: KeySequence& keySequence() { return m_KeySequence; } @@ -66,6 +87,7 @@ class Action void setLockCursorMode(int m) { m_LockCursorMode = m; } void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; } void setHaveScreens(bool b) { m_HasScreens = b; } + void setRestartServer( bool b) { m_restartServer = b; } private: KeySequence m_KeySequence; @@ -76,6 +98,7 @@ class Action int m_LockCursorMode; bool m_ActiveOnRelease; bool m_HasScreens; + bool m_restartServer; static const char* m_ActionTypeNames[]; static const char* m_SwitchDirectionNames[]; diff --git a/src/gui/src/ActionDialog.cpp b/src/gui/src/ActionDialog.cpp index 7518015e..d8961a2c 100644 --- a/src/gui/src/ActionDialog.cpp +++ b/src/gui/src/ActionDialog.cpp @@ -39,7 +39,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey // work around Qt Designer's lack of a QButtonGroup; we need it to get // at the button id of the checked radio button - QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen }; + QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen , m_pRadioRestartAllConnections}; for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++) m_pButtonGroupType->addButton(typeButtons[i], i); @@ -91,6 +91,7 @@ void ActionDialog::accept() m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex()); m_Action.setLockCursorMode(m_pComboLockCursorToScreen->currentIndex()); m_Action.setActiveOnRelease(m_pRadioHotkeyReleased->isChecked()); + m_Action.setRestartServer(m_pRadioRestartAllConnections->isChecked()); QDialog::accept(); } diff --git a/src/gui/src/ActionDialogBase.ui b/src/gui/src/ActionDialogBase.ui index f6dff784..c4af18cd 100644 --- a/src/gui/src/ActionDialogBase.ui +++ b/src/gui/src/ActionDialogBase.ui @@ -239,6 +239,17 @@ + + + + + + Restart server + + + + + @@ -369,6 +380,22 @@ + + m_pRadioRestartAllConnections + toggled(bool) + m_pKeySequenceWidgetHotkey + setDisabled(bool) + + + 101 + 353 + + + 68 + 126 + + + m_pRadioPress toggled(bool) @@ -561,6 +588,22 @@ + + m_pRadioRestartAllConnections + toggled(bool) + m_pGroupBoxScreens + setDisabled(bool) + + + 48 + 339 + + + 79 + 234 + + + m_pRadioSwitchToScreen toggled(bool) diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index 5e43d8a5..35e97b05 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -1241,6 +1241,26 @@ Config::parseAction(ConfigReadContext& s, action = new InputFilter::LockCursorToScreenAction(m_events, mode); } + else if (name == "restartServer") { + if (args.size() > 1) { + throw XConfigRead(s, "syntax for action: restartServer([{{restart}}])"); + } + + InputFilter::RestartServer::Mode mode = + InputFilter::RestartServer::restart; + + if (args.size() == 1) { + if (args[0] == "restart") { + mode = InputFilter::RestartServer::restart; + } + else { + throw XConfigRead(s, "syntax for action: restartServer([{restart}])"); + } + } + + action = new InputFilter::RestartServer(m_events, mode); + } + else if (name == "keyboardBroadcast") { if (args.size() > 2) { throw XConfigRead(s, "syntax for action: keyboardBroadcast([{off|on|toggle}[,screens]])"); diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index 363ded15..7118c33c 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -323,6 +323,40 @@ InputFilter::LockCursorToScreenAction::perform(const Event& event) Event::kDeliverImmediately)); } + +InputFilter::RestartServer::RestartServer( + IEventQueue* events, Mode mode) : + m_mode(mode), + m_events(events) +{ + // do nothing +} + +InputFilter::RestartServer::Mode +InputFilter::RestartServer::getMode() const +{ + return m_mode; +} + +InputFilter::Action *InputFilter::RestartServer::clone() const { + return new RestartServer(*this); +} + +String +InputFilter::RestartServer::format() const +{ + static const char* s_mode[] = { "restart" }; + + return synergy::string::sprintf("restartServer(%s)", s_mode[m_mode]); +} + +void +InputFilter::RestartServer::perform(const Event& event) +{ + //HACK Super hack we should gracefully exit + exit(0); +} + InputFilter::SwitchToScreenAction::SwitchToScreenAction( IEventQueue* events, const String& screen) : m_screen(screen), @@ -1088,3 +1122,4 @@ InputFilter::handleEvent(const Event& event, void*) // not handled so pass through m_events->addEvent(myEvent); } + diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h index 99564176..0102315a 100644 --- a/src/lib/server/InputFilter.h +++ b/src/lib/server/InputFilter.h @@ -149,6 +149,24 @@ public: Mode m_mode; IEventQueue* m_events; }; + + class RestartServer : public Action { + public: + enum Mode { restart }; + + RestartServer(IEventQueue* events, Mode = restart); + + Mode getMode() const; + + // Action overrides + virtual Action* clone() const; + virtual String format() const; + virtual void perform(const Event&); + + private: + Mode m_mode; + IEventQueue* m_events; + }; // SwitchToScreenAction class SwitchToScreenAction : public Action {