mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-04 19:06:45 +08:00
Added toggleScreen function, using hot key to loop through all screens.
Comparing to switchToScreen, it is more handy since the user only need to hit one hotkey.
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
const char* Action::m_ActionTypeNames[] =
|
||||
{
|
||||
"keyDown", "keyUp", "keystroke",
|
||||
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
||||
"switchToScreen", "toggleScreen",
|
||||
"switchInDirection", "lockCursorToScreen",
|
||||
"mouseDown", "mouseUp", "mousebutton"
|
||||
};
|
||||
|
||||
@@ -45,7 +46,13 @@ Action::Action() :
|
||||
|
||||
QString Action::text() const
|
||||
{
|
||||
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "(";
|
||||
/* This function is used to save to config file which is for barriers to
|
||||
* read. However the server config parse does not support functions with ()
|
||||
* in the end but now argument inside. If you need a function with no
|
||||
* argument, it can not have () in the end.
|
||||
*/
|
||||
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ?
|
||||
type() + int(mouseDown) : type()]);
|
||||
|
||||
switch (type())
|
||||
{
|
||||
@@ -53,6 +60,7 @@ QString Action::text() const
|
||||
case keyUp:
|
||||
case keystroke:
|
||||
{
|
||||
text += "(";
|
||||
text += keySequence().toString();
|
||||
|
||||
if (!keySequence().isMouseButton())
|
||||
@@ -72,19 +80,29 @@ QString Action::text() const
|
||||
else
|
||||
text += ",*";
|
||||
}
|
||||
text += ")";
|
||||
}
|
||||
break;
|
||||
|
||||
case switchToScreen:
|
||||
text += "(";
|
||||
text += switchScreenName();
|
||||
text += ")";
|
||||
break;
|
||||
|
||||
case toggleScreen:
|
||||
break;
|
||||
|
||||
case switchInDirection:
|
||||
text += "(";
|
||||
text += m_SwitchDirectionNames[m_SwitchDirection];
|
||||
text += ")";
|
||||
break;
|
||||
|
||||
case lockCursorToScreen:
|
||||
text += "(";
|
||||
text += m_LockCursorModeNames[m_LockCursorMode];
|
||||
text += ")";
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -92,7 +110,6 @@ QString Action::text() const
|
||||
break;
|
||||
}
|
||||
|
||||
text += ")";
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ class Action
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
||||
|
||||
public:
|
||||
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||
enum ActionType { keyDown, keyUp, keystroke,
|
||||
switchToScreen, toggleScreen, switchInDirection,
|
||||
lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
||||
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
||||
|
||||
|
||||
@@ -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_pRadioToggleScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
||||
m_pButtonGroupType->addButton(typeButtons[i], i);
|
||||
|
||||
@@ -142,6 +142,17 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_pRadioToggleScreen">
|
||||
<property name="text">
|
||||
<string>Toggle screen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user