mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
UI: Add opt. to enable/disable in-focus hotkey blocking
Adds an option to enable/disable blocking hotkeys when the window is in focus which is normally used in order to prevent hotkey/shortcut conflicts. This does not apply to the settings window; the hotkey behavior is unchanged with the settings window (in order to prevent hotkeys from being used while setting hotkeys for example). Closes obsproject/obs-studio#1267
This commit is contained in:
parent
a75724d8a5
commit
051c58eeb7
@ -751,6 +751,7 @@ Basic.Settings.Advanced.Network="Network"
|
||||
Basic.Settings.Advanced.Network.BindToIP="Bind to IP"
|
||||
Basic.Settings.Advanced.Network.EnableNewSocketLoop="Enable new networking code"
|
||||
Basic.Settings.Advanced.Network.EnableLowLatencyMode="Low latency mode"
|
||||
Basic.Settings.Advanced.Hotkeys.DisableHotkeysInFocus="Disable hotkeys when main window is in focus"
|
||||
|
||||
# advanced audio properties
|
||||
Basic.AdvAudio="Advanced Audio Properties"
|
||||
|
@ -144,7 +144,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>-44</y>
|
||||
<width>801</width>
|
||||
<height>741</height>
|
||||
</rect>
|
||||
@ -733,8 +733,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>818</width>
|
||||
<height>697</height>
|
||||
<width>601</width>
|
||||
<height>640</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
@ -3372,8 +3372,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>69</height>
|
||||
<width>63</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@ -3768,8 +3768,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>818</width>
|
||||
<height>697</height>
|
||||
<width>98</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="hotkeyLayout">
|
||||
@ -3816,7 +3816,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>803</width>
|
||||
<height>761</height>
|
||||
<height>793</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
@ -3844,6 +3844,12 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="processPriorityLabel">
|
||||
<property name="text">
|
||||
@ -3857,6 +3863,19 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="processPriority"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_13">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -3872,6 +3891,9 @@
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="rendererLabel">
|
||||
<property name="text">
|
||||
@ -4044,6 +4066,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer_12">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -4056,6 +4091,12 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="monitoringDeviceLabel">
|
||||
<property name="text">
|
||||
@ -4076,6 +4117,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -4091,6 +4145,9 @@
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
@ -4153,6 +4210,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -4165,6 +4235,9 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
@ -4254,6 +4327,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -4266,6 +4352,12 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="reconnectEnable">
|
||||
<property name="text">
|
||||
@ -4335,6 +4427,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -4347,9 +4452,12 @@
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="bindToIP"/>
|
||||
</item>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="text">
|
||||
@ -4360,6 +4468,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="bindToIP"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="enableNewSocketLoop">
|
||||
<property name="text">
|
||||
@ -4377,6 +4488,51 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="title">
|
||||
<string>Basic.Settings.Hotkeys</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_33">
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="disableFocusHotkeys">
|
||||
<property name="text">
|
||||
<string>Basic.Settings.Advanced.Hotkeys.DisableHotkeysInFocus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_14">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -916,6 +916,9 @@ void OBSApp::AppInit()
|
||||
EnableOSXVSync(false);
|
||||
#endif
|
||||
|
||||
enableHotkeysInFocus = !config_get_bool(globalConfig, "General",
|
||||
"DisableHotkeysInFocus");
|
||||
|
||||
move_basic_to_profiles();
|
||||
move_basic_to_scene_collections();
|
||||
|
||||
@ -942,6 +945,18 @@ static bool StartupOBS(const char *locale, profiler_name_store_t *store)
|
||||
return obs_startup(locale, path, store);
|
||||
}
|
||||
|
||||
inline void OBSApp::ResetHotkeyState(bool inFocus)
|
||||
{
|
||||
obs_hotkey_enable_background_press(
|
||||
inFocus || enableHotkeysInFocus);
|
||||
}
|
||||
|
||||
void OBSApp::EnableInFocusHotkeys(bool enable)
|
||||
{
|
||||
enableHotkeysInFocus = enable;
|
||||
ResetHotkeyState(applicationState() != Qt::ApplicationActive);
|
||||
}
|
||||
|
||||
bool OBSApp::OBSInit()
|
||||
{
|
||||
ProfileScope("OBSApp::OBSInit");
|
||||
@ -973,13 +988,12 @@ bool OBSApp::OBSInit()
|
||||
mainWindow->OBSInit();
|
||||
|
||||
connect(this, &QGuiApplication::applicationStateChanged,
|
||||
[](Qt::ApplicationState state)
|
||||
[this](Qt::ApplicationState state)
|
||||
{
|
||||
obs_hotkey_enable_background_press(
|
||||
ResetHotkeyState(
|
||||
state != Qt::ApplicationActive);
|
||||
});
|
||||
obs_hotkey_enable_background_press(
|
||||
applicationState() != Qt::ApplicationActive);
|
||||
ResetHotkeyState(applicationState() != Qt::ApplicationActive);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -73,6 +73,9 @@ private:
|
||||
os_inhibit_t *sleepInhibitor = nullptr;
|
||||
int sleepInhibitRefs = 0;
|
||||
|
||||
bool enableHotkeysInFocus = true;
|
||||
|
||||
|
||||
std::deque<obs_frontend_translate_ui_cb> translatorHooks;
|
||||
|
||||
bool InitGlobalConfig();
|
||||
@ -80,6 +83,8 @@ private:
|
||||
bool InitLocale();
|
||||
bool InitTheme();
|
||||
|
||||
inline void ResetHotkeyState(bool inFocus);
|
||||
|
||||
public:
|
||||
OBSApp(int &argc, char **argv, profiler_name_store_t *store);
|
||||
~OBSApp();
|
||||
@ -87,6 +92,8 @@ public:
|
||||
void AppInit();
|
||||
bool OBSInit();
|
||||
|
||||
void EnableInFocusHotkeys(bool enable);
|
||||
|
||||
inline QMainWindow *GetMainWindow() const {return mainWindow.data();}
|
||||
|
||||
inline config_t *GlobalConfig() const {return globalConfig;}
|
||||
|
@ -442,6 +442,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
||||
HookWidget(ui->bindToIP, COMBO_CHANGED, ADV_CHANGED);
|
||||
HookWidget(ui->enableNewSocketLoop, CHECK_CHANGED, ADV_CHANGED);
|
||||
HookWidget(ui->enableLowLatencyMode, CHECK_CHANGED, ADV_CHANGED);
|
||||
HookWidget(ui->disableFocusHotkeys, CHECK_CHANGED, ADV_CHANGED);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
delete ui->enableAutoUpdates;
|
||||
@ -702,11 +703,17 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
||||
SimpleRecordingQualityChanged();
|
||||
|
||||
UpdateAutomaticReplayBufferCheckboxes();
|
||||
|
||||
App()->EnableInFocusHotkeys(false);
|
||||
}
|
||||
|
||||
OBSBasicSettings::~OBSBasicSettings()
|
||||
{
|
||||
bool disableHotkeysInFocus = config_get_bool(App()->GlobalConfig(),
|
||||
"General", "DisableHotkeysInFocus");
|
||||
|
||||
main->EnableOutputs(true);
|
||||
App()->EnableInFocusHotkeys(!disableHotkeysInFocus);
|
||||
}
|
||||
|
||||
void OBSBasicSettings::SaveCombo(QComboBox *widget, const char *section,
|
||||
@ -2280,6 +2287,10 @@ void OBSBasicSettings::LoadAdvancedSettings()
|
||||
ui->enableLowLatencyMode->setChecked(enableLowLatencyMode);
|
||||
#endif
|
||||
|
||||
bool disableFocusHotkeys = config_get_bool(App()->GlobalConfig(),
|
||||
"General", "DisableHotkeysInFocus");
|
||||
ui->disableFocusHotkeys->setChecked(disableFocusHotkeys);
|
||||
|
||||
loading = false;
|
||||
}
|
||||
|
||||
@ -2789,6 +2800,10 @@ void OBSBasicSettings::SaveAdvancedSettings()
|
||||
SaveCheckBox(ui->enableLowLatencyMode, "Output", "LowLatencyEnable");
|
||||
#endif
|
||||
|
||||
bool disableFocusHotkeys = ui->disableFocusHotkeys->isChecked();
|
||||
config_set_bool(App()->GlobalConfig(), "General",
|
||||
"DisableHotkeysInFocus", disableFocusHotkeys);
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (WidgetChanged(ui->disableOSXVSync)) {
|
||||
bool disable = ui->disableOSXVSync->isChecked();
|
||||
|
Loading…
Reference in New Issue
Block a user