#6518 Added server restart action and hotkey capability
This commit is contained in:
parent
363355bca3
commit
29ab86b734
|
@ -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)
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -239,6 +239,17 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_pRadioRestartAllConnections">
|
||||
<property name="text">
|
||||
<string>Restart server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -369,6 +380,22 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_pRadioRestartAllConnections</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>101</x>
|
||||
<y>353</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>68</x>
|
||||
<y>126</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_pRadioPress</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
@ -561,6 +588,22 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_pRadioRestartAllConnections</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_pGroupBoxScreens</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>48</x>
|
||||
<y>339</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>79</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_pRadioSwitchToScreen</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
|
|
@ -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]])");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,6 +150,24 @@ public:
|
|||
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 {
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue