mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-04 10:33:30 +00:00
UI: Add HotkeyBlocker class
This adds a HotkeyBlocker class that is similar to SignalBlocker. It is used when selection dialogs are opened and because they are modal, hotkeys shouldn't be able to be used.
This commit is contained in:
parent
e958964bee
commit
40a40e080e
|
@ -581,6 +581,7 @@ void ColorSourceToolbar::on_choose_clicked()
|
|||
options |= QColorDialog::DontUseNativeDialog;
|
||||
#endif
|
||||
|
||||
HotkeyBlocker hb;
|
||||
QColor newColor = QColorDialog::getColor(color, this, desc, options);
|
||||
if (!newColor.isValid()) {
|
||||
return;
|
||||
|
@ -654,6 +655,7 @@ void TextSourceToolbar::on_selectFont_clicked()
|
|||
options = QFontDialog::DontUseNativeDialog;
|
||||
#endif
|
||||
|
||||
HotkeyBlocker hb;
|
||||
font = QFontDialog::getFont(
|
||||
&success, font, this,
|
||||
QTStr("Basic.PropertiesWindow.SelectFont.WindowTitle"),
|
||||
|
@ -707,6 +709,7 @@ void TextSourceToolbar::on_selectColor_clicked()
|
|||
options |= QColorDialog::DontUseNativeDialog;
|
||||
#endif
|
||||
|
||||
HotkeyBlocker hb;
|
||||
QColor newColor = QColorDialog::getColor(color, this, desc, options);
|
||||
if (!newColor.isValid()) {
|
||||
return;
|
||||
|
|
|
@ -289,3 +289,10 @@ extern bool restart_safe;
|
|||
extern "C" void install_dll_blocklist_hook(void);
|
||||
extern "C" void log_blocked_dlls(void);
|
||||
#endif
|
||||
|
||||
class HotkeyBlocker {
|
||||
public:
|
||||
inline explicit HotkeyBlocker() { App()->DisableHotkeys(); }
|
||||
|
||||
inline ~HotkeyBlocker() { App()->UpdateHotkeyFocusSetting(); }
|
||||
};
|
||||
|
|
|
@ -1898,6 +1898,7 @@ bool WidgetInfo::ColorChangedInternal(const char *setting, bool supportAlpha)
|
|||
options |= QColorDialog::DontUseNativeDialog;
|
||||
#endif
|
||||
|
||||
HotkeyBlocker hb;
|
||||
color = QColorDialog::getColor(color, view, QT_UTF8(desc), options);
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -1952,6 +1953,8 @@ bool WidgetInfo::FontChanged(const char *setting)
|
|||
options = QFontDialog::DontUseNativeDialog;
|
||||
#endif
|
||||
|
||||
HotkeyBlocker hb;
|
||||
|
||||
if (!font_obj) {
|
||||
QFont initial;
|
||||
font = QFontDialog::getFont(
|
||||
|
|
|
@ -373,6 +373,7 @@ void setThemeID(QWidget *widget, const QString &themeID)
|
|||
|
||||
QString SelectDirectory(QWidget *parent, QString title, QString path)
|
||||
{
|
||||
HotkeyBlocker hb;
|
||||
QString dir = QFileDialog::getExistingDirectory(
|
||||
parent, title, path,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
@ -383,6 +384,7 @@ QString SelectDirectory(QWidget *parent, QString title, QString path)
|
|||
QString SaveFile(QWidget *parent, QString title, QString path,
|
||||
QString extensions)
|
||||
{
|
||||
HotkeyBlocker hb;
|
||||
QString file =
|
||||
QFileDialog::getSaveFileName(parent, title, path, extensions);
|
||||
|
||||
|
@ -392,6 +394,7 @@ QString SaveFile(QWidget *parent, QString title, QString path,
|
|||
QString OpenFile(QWidget *parent, QString title, QString path,
|
||||
QString extensions)
|
||||
{
|
||||
HotkeyBlocker hb;
|
||||
QString file =
|
||||
QFileDialog::getOpenFileName(parent, title, path, extensions);
|
||||
|
||||
|
@ -401,6 +404,7 @@ QString OpenFile(QWidget *parent, QString title, QString path,
|
|||
QStringList OpenFiles(QWidget *parent, QString title, QString path,
|
||||
QString extensions)
|
||||
{
|
||||
HotkeyBlocker hb;
|
||||
QStringList files =
|
||||
QFileDialog::getOpenFileNames(parent, title, path, extensions);
|
||||
|
||||
|
|
Loading…
Reference in a new issue