frontend: Split Settings implementation into single files per C++ class
This commit is contained in:
parent
9876882e0b
commit
1ff68267a3
@ -18,33 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <util/util.hpp>
|
#include <QCheckBox>
|
||||||
#include <QDialog>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
#include "auth-base.hpp"
|
|
||||||
#include "ffmpeg-utils.hpp"
|
|
||||||
#include "obs-app-theming.hpp"
|
|
||||||
|
|
||||||
class OBSBasic;
|
|
||||||
class QAbstractButton;
|
|
||||||
class QRadioButton;
|
|
||||||
class QComboBox;
|
|
||||||
class QCheckBox;
|
|
||||||
class QLabel;
|
|
||||||
class QButtonGroup;
|
|
||||||
class OBSPropertiesView;
|
|
||||||
class OBSHotkeyWidget;
|
|
||||||
|
|
||||||
#include "ui_OBSBasicSettings.h"
|
|
||||||
|
|
||||||
#define VOLUME_METER_DECAY_FAST 23.53
|
|
||||||
#define VOLUME_METER_DECAY_MEDIUM 11.76
|
|
||||||
#define VOLUME_METER_DECAY_SLOW 8.57
|
|
||||||
|
|
||||||
class SilentUpdateCheckBox : public QCheckBox {
|
class SilentUpdateCheckBox : public QCheckBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -57,433 +31,3 @@ public slots:
|
|||||||
blockSignals(blocked);
|
blockSignals(blocked);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SilentUpdateSpinBox : public QSpinBox {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setValueSilently(int val)
|
|
||||||
{
|
|
||||||
bool blocked = blockSignals(true);
|
|
||||||
setValue(val);
|
|
||||||
blockSignals(blocked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string DeserializeConfigText(const char *value);
|
|
||||||
|
|
||||||
class OBSBasicSettings : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QIcon generalIcon READ GetGeneralIcon WRITE SetGeneralIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon appearanceIcon READ GetAppearanceIcon WRITE SetAppearanceIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon streamIcon READ GetStreamIcon WRITE SetStreamIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon outputIcon READ GetOutputIcon WRITE SetOutputIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon audioIcon READ GetAudioIcon WRITE SetAudioIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon videoIcon READ GetVideoIcon WRITE SetVideoIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon hotkeysIcon READ GetHotkeysIcon WRITE SetHotkeysIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon accessibilityIcon READ GetAccessibilityIcon WRITE SetAccessibilityIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon advancedIcon READ GetAdvancedIcon WRITE SetAdvancedIcon DESIGNABLE true)
|
|
||||||
|
|
||||||
enum Pages { GENERAL, APPEARANCE, STREAM, OUTPUT, AUDIO, VIDEO, HOTKEYS, ACCESSIBILITY, ADVANCED, NUM_PAGES };
|
|
||||||
|
|
||||||
private:
|
|
||||||
OBSBasic *main;
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::OBSBasicSettings> ui;
|
|
||||||
|
|
||||||
std::shared_ptr<Auth> auth;
|
|
||||||
|
|
||||||
bool generalChanged = false;
|
|
||||||
bool stream1Changed = false;
|
|
||||||
bool outputsChanged = false;
|
|
||||||
bool audioChanged = false;
|
|
||||||
bool videoChanged = false;
|
|
||||||
bool hotkeysChanged = false;
|
|
||||||
bool a11yChanged = false;
|
|
||||||
bool appearanceChanged = false;
|
|
||||||
bool advancedChanged = false;
|
|
||||||
int pageIndex = 0;
|
|
||||||
bool loading = true;
|
|
||||||
bool forceAuthReload = false;
|
|
||||||
bool forceUpdateCheck = false;
|
|
||||||
int sampleRateIndex = 0;
|
|
||||||
int channelIndex = 0;
|
|
||||||
bool llBufferingEnabled = false;
|
|
||||||
bool hotkeysLoaded = false;
|
|
||||||
|
|
||||||
int lastSimpleRecQualityIdx = 0;
|
|
||||||
int lastServiceIdx = -1;
|
|
||||||
int lastIgnoreRecommended = -1;
|
|
||||||
int lastChannelSetupIdx = 0;
|
|
||||||
|
|
||||||
static constexpr uint32_t ENCODER_HIDE_FLAGS = (OBS_ENCODER_CAP_DEPRECATED | OBS_ENCODER_CAP_INTERNAL);
|
|
||||||
|
|
||||||
OBSTheme *savedTheme = nullptr;
|
|
||||||
|
|
||||||
std::vector<FFmpegFormat> formats;
|
|
||||||
|
|
||||||
OBSPropertiesView *streamProperties = nullptr;
|
|
||||||
OBSPropertiesView *streamEncoderProps = nullptr;
|
|
||||||
OBSPropertiesView *recordEncoderProps = nullptr;
|
|
||||||
|
|
||||||
QPointer<QLabel> advOutRecWarning;
|
|
||||||
QPointer<QLabel> simpleOutRecWarning;
|
|
||||||
|
|
||||||
QString curPreset;
|
|
||||||
QString curQSVPreset;
|
|
||||||
QString curNVENCPreset;
|
|
||||||
QString curAMDPreset;
|
|
||||||
QString curAMDAV1Preset;
|
|
||||||
|
|
||||||
QString curAdvStreamEncoder;
|
|
||||||
QString curAdvRecordEncoder;
|
|
||||||
|
|
||||||
using AudioSource_t = std::tuple<OBSWeakSource, QPointer<QCheckBox>, QPointer<QSpinBox>, QPointer<QCheckBox>,
|
|
||||||
QPointer<QSpinBox>>;
|
|
||||||
std::vector<AudioSource_t> audioSources;
|
|
||||||
std::vector<OBSSignal> audioSourceSignals;
|
|
||||||
OBSSignal sourceCreated;
|
|
||||||
OBSSignal channelChanged;
|
|
||||||
|
|
||||||
std::vector<std::pair<bool, QPointer<OBSHotkeyWidget>>> hotkeys;
|
|
||||||
OBSSignal hotkeyRegistered;
|
|
||||||
OBSSignal hotkeyUnregistered;
|
|
||||||
|
|
||||||
uint32_t outputCX = 0;
|
|
||||||
uint32_t outputCY = 0;
|
|
||||||
|
|
||||||
QPointer<QCheckBox> simpleVodTrack;
|
|
||||||
|
|
||||||
QPointer<QCheckBox> vodTrackCheckbox;
|
|
||||||
QPointer<QWidget> vodTrackContainer;
|
|
||||||
QPointer<QRadioButton> vodTrack[MAX_AUDIO_MIXES];
|
|
||||||
|
|
||||||
QIcon hotkeyConflictIcon;
|
|
||||||
|
|
||||||
void SaveCombo(QComboBox *widget, const char *section, const char *value);
|
|
||||||
void SaveComboData(QComboBox *widget, const char *section, const char *value);
|
|
||||||
void SaveCheckBox(QAbstractButton *widget, const char *section, const char *value, bool invert = false);
|
|
||||||
void SaveGroupBox(QGroupBox *widget, const char *section, const char *value);
|
|
||||||
void SaveEdit(QLineEdit *widget, const char *section, const char *value);
|
|
||||||
void SaveSpinBox(QSpinBox *widget, const char *section, const char *value);
|
|
||||||
void SaveText(QPlainTextEdit *widget, const char *section, const char *value);
|
|
||||||
void SaveFormat(QComboBox *combo);
|
|
||||||
void SaveEncoder(QComboBox *combo, const char *section, const char *value);
|
|
||||||
|
|
||||||
bool ResFPSValid(obs_service_resolution *res_list, size_t res_count, int max_fps);
|
|
||||||
void ClosestResFPS(obs_service_resolution *res_list, size_t res_count, int max_fps, int &new_cx, int &new_cy,
|
|
||||||
int &new_fps);
|
|
||||||
|
|
||||||
inline bool Changed() const
|
|
||||||
{
|
|
||||||
return generalChanged || appearanceChanged || outputsChanged || stream1Changed || audioChanged ||
|
|
||||||
videoChanged || advancedChanged || hotkeysChanged || a11yChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void EnableApplyButton(bool en) { ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(en); }
|
|
||||||
|
|
||||||
inline void ClearChanged()
|
|
||||||
{
|
|
||||||
generalChanged = false;
|
|
||||||
stream1Changed = false;
|
|
||||||
outputsChanged = false;
|
|
||||||
audioChanged = false;
|
|
||||||
videoChanged = false;
|
|
||||||
hotkeysChanged = false;
|
|
||||||
a11yChanged = false;
|
|
||||||
advancedChanged = false;
|
|
||||||
appearanceChanged = false;
|
|
||||||
EnableApplyButton(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Widget, typename WidgetParent, typename... SignalArgs, typename... SlotArgs>
|
|
||||||
void HookWidget(Widget *widget, void (WidgetParent::*signal)(SignalArgs...),
|
|
||||||
void (OBSBasicSettings::*slot)(SlotArgs...))
|
|
||||||
{
|
|
||||||
QObject::connect(widget, signal, this, slot);
|
|
||||||
widget->setProperty("changed", QVariant(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QueryChanges();
|
|
||||||
bool QueryAllowedToClose();
|
|
||||||
|
|
||||||
void ResetEncoders(bool streamOnly = false);
|
|
||||||
void LoadColorRanges();
|
|
||||||
void LoadColorSpaces();
|
|
||||||
void LoadColorFormats();
|
|
||||||
void LoadFormats();
|
|
||||||
void ReloadCodecs(const FFmpegFormat &format);
|
|
||||||
|
|
||||||
void UpdateColorFormatSpaceWarning();
|
|
||||||
|
|
||||||
void LoadGeneralSettings();
|
|
||||||
void LoadStream1Settings();
|
|
||||||
void LoadOutputSettings();
|
|
||||||
void LoadAudioSettings();
|
|
||||||
void LoadVideoSettings();
|
|
||||||
void LoadHotkeySettings(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
|
|
||||||
void LoadA11ySettings(bool presetChange = false);
|
|
||||||
void LoadAppearanceSettings(bool reload = false);
|
|
||||||
void LoadAdvancedSettings();
|
|
||||||
void LoadSettings(bool changedOnly);
|
|
||||||
|
|
||||||
OBSPropertiesView *CreateEncoderPropertyView(const char *encoder, const char *path, bool changed = false);
|
|
||||||
|
|
||||||
/* general */
|
|
||||||
void LoadLanguageList();
|
|
||||||
void LoadThemeList(bool firstLoad);
|
|
||||||
void LoadBranchesList();
|
|
||||||
|
|
||||||
/* stream */
|
|
||||||
void InitStreamPage();
|
|
||||||
bool IsCustomService() const;
|
|
||||||
inline bool IsWHIP() const;
|
|
||||||
void LoadServices(bool showAll);
|
|
||||||
void OnOAuthStreamKeyConnected();
|
|
||||||
void OnAuthConnected();
|
|
||||||
QString lastService;
|
|
||||||
QString protocol;
|
|
||||||
QString lastCustomServer;
|
|
||||||
int prevLangIndex;
|
|
||||||
bool prevBrowserAccel;
|
|
||||||
|
|
||||||
void ServiceChanged(bool resetFields = false);
|
|
||||||
QString FindProtocol();
|
|
||||||
void UpdateServerList();
|
|
||||||
void UpdateKeyLink();
|
|
||||||
void UpdateVodTrackSetting();
|
|
||||||
void UpdateServiceRecommendations();
|
|
||||||
void UpdateMoreInfoLink();
|
|
||||||
void UpdateAdvNetworkGroup();
|
|
||||||
|
|
||||||
/* Appearance */
|
|
||||||
void InitAppearancePage();
|
|
||||||
|
|
||||||
bool IsCustomServer();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void UpdateMultitrackVideo();
|
|
||||||
void RecreateOutputResolutionWidget();
|
|
||||||
bool UpdateResFPSLimits();
|
|
||||||
void DisplayEnforceWarning(bool checked);
|
|
||||||
void on_show_clicked();
|
|
||||||
void on_authPwShow_clicked();
|
|
||||||
void on_connectAccount_clicked();
|
|
||||||
void on_disconnectAccount_clicked();
|
|
||||||
void on_useStreamKey_clicked();
|
|
||||||
void on_useAuth_toggled();
|
|
||||||
void on_server_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_hotkeyFilterReset_clicked();
|
|
||||||
void on_hotkeyFilterSearch_textChanged(const QString text);
|
|
||||||
void on_hotkeyFilterInput_KeyChanged(obs_key_combination_t combo);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/* output */
|
|
||||||
void LoadSimpleOutputSettings();
|
|
||||||
void LoadAdvOutputStreamingSettings();
|
|
||||||
void LoadAdvOutputStreamingEncoderProperties();
|
|
||||||
void LoadAdvOutputRecordingSettings();
|
|
||||||
void LoadAdvOutputRecordingEncoderProperties();
|
|
||||||
void LoadAdvOutputFFmpegSettings();
|
|
||||||
void LoadAdvOutputAudioSettings();
|
|
||||||
void SetAdvOutputFFmpegEnablement(FFmpegCodecType encoderType, bool enabled, bool enableEncode = false);
|
|
||||||
|
|
||||||
/* audio */
|
|
||||||
void LoadListValues(QComboBox *widget, obs_property_t *prop, int index);
|
|
||||||
void LoadAudioDevices();
|
|
||||||
void LoadAudioSources();
|
|
||||||
|
|
||||||
/* video */
|
|
||||||
void LoadRendererList();
|
|
||||||
void ResetDownscales(uint32_t cx, uint32_t cy, bool ignoreAllSignals = false);
|
|
||||||
void LoadDownscaleFilters();
|
|
||||||
void LoadResolutionLists();
|
|
||||||
void LoadFPSData();
|
|
||||||
|
|
||||||
/* a11y */
|
|
||||||
void UpdateA11yColors();
|
|
||||||
void SetDefaultColors();
|
|
||||||
void ResetDefaultColors();
|
|
||||||
QColor GetColor(uint32_t colorVal, QString label);
|
|
||||||
uint32_t preset = 0;
|
|
||||||
uint32_t selectRed = 0x0000FF;
|
|
||||||
uint32_t selectGreen = 0x00FF00;
|
|
||||||
uint32_t selectBlue = 0xFF7F00;
|
|
||||||
uint32_t mixerGreen = 0x267f26;
|
|
||||||
uint32_t mixerYellow = 0x267f7f;
|
|
||||||
uint32_t mixerRed = 0x26267f;
|
|
||||||
uint32_t mixerGreenActive = 0x4cff4c;
|
|
||||||
uint32_t mixerYellowActive = 0x4cffff;
|
|
||||||
uint32_t mixerRedActive = 0x4c4cff;
|
|
||||||
|
|
||||||
void SaveGeneralSettings();
|
|
||||||
void SaveStream1Settings();
|
|
||||||
void SaveOutputSettings();
|
|
||||||
void SaveAudioSettings();
|
|
||||||
void SaveVideoSettings();
|
|
||||||
void SaveHotkeySettings();
|
|
||||||
void SaveA11ySettings();
|
|
||||||
void SaveAppearanceSettings();
|
|
||||||
void SaveAdvancedSettings();
|
|
||||||
void SaveSettings();
|
|
||||||
|
|
||||||
void SearchHotkeys(const QString &text, obs_key_combination_t filterCombo);
|
|
||||||
|
|
||||||
void UpdateSimpleOutStreamDelayEstimate();
|
|
||||||
void UpdateAdvOutStreamDelayEstimate();
|
|
||||||
|
|
||||||
void FillSimpleRecordingValues();
|
|
||||||
void FillAudioMonitoringDevices();
|
|
||||||
|
|
||||||
void RecalcOutputResPixels(const char *resText);
|
|
||||||
|
|
||||||
bool AskIfCanCloseSettings();
|
|
||||||
|
|
||||||
void UpdateYouTubeAppDockSettings();
|
|
||||||
|
|
||||||
QIcon generalIcon;
|
|
||||||
QIcon appearanceIcon;
|
|
||||||
QIcon streamIcon;
|
|
||||||
QIcon outputIcon;
|
|
||||||
QIcon audioIcon;
|
|
||||||
QIcon videoIcon;
|
|
||||||
QIcon hotkeysIcon;
|
|
||||||
QIcon accessibilityIcon;
|
|
||||||
QIcon advancedIcon;
|
|
||||||
|
|
||||||
QIcon GetGeneralIcon() const;
|
|
||||||
QIcon GetAppearanceIcon() const;
|
|
||||||
QIcon GetStreamIcon() const;
|
|
||||||
QIcon GetOutputIcon() const;
|
|
||||||
QIcon GetAudioIcon() const;
|
|
||||||
QIcon GetVideoIcon() const;
|
|
||||||
QIcon GetHotkeysIcon() const;
|
|
||||||
QIcon GetAccessibilityIcon() const;
|
|
||||||
QIcon GetAdvancedIcon() const;
|
|
||||||
|
|
||||||
int CurrentFLVTrack();
|
|
||||||
int SimpleOutGetSelectedAudioTracks();
|
|
||||||
int AdvOutGetSelectedAudioTracks();
|
|
||||||
int AdvOutGetStreamingSelectedAudioTracks();
|
|
||||||
|
|
||||||
OBSService GetStream1Service();
|
|
||||||
|
|
||||||
bool ServiceAndVCodecCompatible();
|
|
||||||
bool ServiceAndACodecCompatible();
|
|
||||||
bool ServiceSupportsCodecCheck();
|
|
||||||
|
|
||||||
inline bool AllowsMultiTrack(const char *protocol);
|
|
||||||
void SwapMultiTrack(const char *protocol);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_theme_activated(int idx);
|
|
||||||
void on_themeVariant_activated(int idx);
|
|
||||||
|
|
||||||
void on_listWidget_itemSelectionChanged();
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
|
||||||
|
|
||||||
void on_service_currentIndexChanged(int idx);
|
|
||||||
void on_customServer_textChanged(const QString &text);
|
|
||||||
void on_simpleOutputBrowse_clicked();
|
|
||||||
void on_advOutRecPathBrowse_clicked();
|
|
||||||
void on_advOutFFPathBrowse_clicked();
|
|
||||||
void on_advOutEncoder_currentIndexChanged();
|
|
||||||
void on_advOutRecEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFIgnoreCompat_stateChanged(int state);
|
|
||||||
void on_advOutFFFormat_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFAEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFVEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFType_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void on_colorFormat_currentIndexChanged(int idx);
|
|
||||||
void on_colorSpace_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void on_filenameFormatting_textEdited(const QString &text);
|
|
||||||
void on_outputResolution_editTextChanged(const QString &text);
|
|
||||||
void on_baseResolution_editTextChanged(const QString &text);
|
|
||||||
|
|
||||||
void on_disableOSXVSync_clicked();
|
|
||||||
|
|
||||||
void on_choose1_clicked();
|
|
||||||
void on_choose2_clicked();
|
|
||||||
void on_choose3_clicked();
|
|
||||||
void on_choose4_clicked();
|
|
||||||
void on_choose5_clicked();
|
|
||||||
void on_choose6_clicked();
|
|
||||||
void on_choose7_clicked();
|
|
||||||
void on_choose8_clicked();
|
|
||||||
void on_choose9_clicked();
|
|
||||||
void on_colorPreset_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void GeneralChanged();
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
||||||
void HideOBSWindowWarning(Qt::CheckState state);
|
|
||||||
#else
|
|
||||||
void HideOBSWindowWarning(int state);
|
|
||||||
#endif
|
|
||||||
void AudioChanged();
|
|
||||||
void AudioChangedRestart();
|
|
||||||
void ReloadAudioSources();
|
|
||||||
void SurroundWarning(int idx);
|
|
||||||
void SpeakerLayoutChanged(int idx);
|
|
||||||
void LowLatencyBufferingChanged(bool checked);
|
|
||||||
void UpdateAudioWarnings();
|
|
||||||
void OutputsChanged();
|
|
||||||
void Stream1Changed();
|
|
||||||
void VideoChanged();
|
|
||||||
void VideoChangedResolution();
|
|
||||||
void HotkeysChanged();
|
|
||||||
bool ScanDuplicateHotkeys(QFormLayout *layout);
|
|
||||||
void ReloadHotkeys(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
|
|
||||||
void A11yChanged();
|
|
||||||
void AppearanceChanged();
|
|
||||||
void AdvancedChanged();
|
|
||||||
void AdvancedChangedRestart();
|
|
||||||
|
|
||||||
void UpdateStreamDelayEstimate();
|
|
||||||
|
|
||||||
void UpdateAutomaticReplayBufferCheckboxes();
|
|
||||||
|
|
||||||
void AdvOutSplitFileChanged();
|
|
||||||
void AdvOutRecCheckWarnings();
|
|
||||||
void AdvOutRecCheckCodecs();
|
|
||||||
|
|
||||||
void SimpleRecordingQualityChanged();
|
|
||||||
void SimpleRecordingEncoderChanged();
|
|
||||||
void SimpleRecordingQualityLosslessWarning(int idx);
|
|
||||||
|
|
||||||
void SimpleReplayBufferChanged();
|
|
||||||
void AdvReplayBufferChanged();
|
|
||||||
|
|
||||||
void SimpleStreamingEncoderChanged();
|
|
||||||
|
|
||||||
OBSService SpawnTempService();
|
|
||||||
|
|
||||||
void SetGeneralIcon(const QIcon &icon);
|
|
||||||
void SetAppearanceIcon(const QIcon &icon);
|
|
||||||
void SetStreamIcon(const QIcon &icon);
|
|
||||||
void SetOutputIcon(const QIcon &icon);
|
|
||||||
void SetAudioIcon(const QIcon &icon);
|
|
||||||
void SetVideoIcon(const QIcon &icon);
|
|
||||||
void SetHotkeysIcon(const QIcon &icon);
|
|
||||||
void SetAccessibilityIcon(const QIcon &icon);
|
|
||||||
void SetAdvancedIcon(const QIcon &icon);
|
|
||||||
|
|
||||||
void UseStreamKeyAdvClicked();
|
|
||||||
|
|
||||||
void SimpleStreamAudioEncoderChanged();
|
|
||||||
void AdvAudioEncodersChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
|
||||||
virtual void showEvent(QShowEvent *event) override;
|
|
||||||
void reject() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSBasicSettings(QWidget *parent);
|
|
||||||
~OBSBasicSettings();
|
|
||||||
|
|
||||||
inline const QIcon &GetHotkeyConflictIcon() const { return hotkeyConflictIcon; }
|
|
||||||
};
|
|
||||||
|
@ -18,45 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <util/util.hpp>
|
#include <QSpinBox>
|
||||||
#include <QDialog>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
#include "auth-base.hpp"
|
|
||||||
#include "ffmpeg-utils.hpp"
|
|
||||||
#include "obs-app-theming.hpp"
|
|
||||||
|
|
||||||
class OBSBasic;
|
|
||||||
class QAbstractButton;
|
|
||||||
class QRadioButton;
|
|
||||||
class QComboBox;
|
|
||||||
class QCheckBox;
|
|
||||||
class QLabel;
|
|
||||||
class QButtonGroup;
|
|
||||||
class OBSPropertiesView;
|
|
||||||
class OBSHotkeyWidget;
|
|
||||||
|
|
||||||
#include "ui_OBSBasicSettings.h"
|
|
||||||
|
|
||||||
#define VOLUME_METER_DECAY_FAST 23.53
|
|
||||||
#define VOLUME_METER_DECAY_MEDIUM 11.76
|
|
||||||
#define VOLUME_METER_DECAY_SLOW 8.57
|
|
||||||
|
|
||||||
class SilentUpdateCheckBox : public QCheckBox {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setCheckedSilently(bool checked)
|
|
||||||
{
|
|
||||||
bool blocked = blockSignals(true);
|
|
||||||
setChecked(checked);
|
|
||||||
blockSignals(blocked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SilentUpdateSpinBox : public QSpinBox {
|
class SilentUpdateSpinBox : public QSpinBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -69,421 +31,3 @@ public slots:
|
|||||||
blockSignals(blocked);
|
blockSignals(blocked);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string DeserializeConfigText(const char *value);
|
|
||||||
|
|
||||||
class OBSBasicSettings : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QIcon generalIcon READ GetGeneralIcon WRITE SetGeneralIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon appearanceIcon READ GetAppearanceIcon WRITE SetAppearanceIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon streamIcon READ GetStreamIcon WRITE SetStreamIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon outputIcon READ GetOutputIcon WRITE SetOutputIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon audioIcon READ GetAudioIcon WRITE SetAudioIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon videoIcon READ GetVideoIcon WRITE SetVideoIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon hotkeysIcon READ GetHotkeysIcon WRITE SetHotkeysIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon accessibilityIcon READ GetAccessibilityIcon WRITE SetAccessibilityIcon DESIGNABLE true)
|
|
||||||
Q_PROPERTY(QIcon advancedIcon READ GetAdvancedIcon WRITE SetAdvancedIcon DESIGNABLE true)
|
|
||||||
|
|
||||||
enum Pages { GENERAL, APPEARANCE, STREAM, OUTPUT, AUDIO, VIDEO, HOTKEYS, ACCESSIBILITY, ADVANCED, NUM_PAGES };
|
|
||||||
|
|
||||||
private:
|
|
||||||
OBSBasic *main;
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::OBSBasicSettings> ui;
|
|
||||||
|
|
||||||
std::shared_ptr<Auth> auth;
|
|
||||||
|
|
||||||
bool generalChanged = false;
|
|
||||||
bool stream1Changed = false;
|
|
||||||
bool outputsChanged = false;
|
|
||||||
bool audioChanged = false;
|
|
||||||
bool videoChanged = false;
|
|
||||||
bool hotkeysChanged = false;
|
|
||||||
bool a11yChanged = false;
|
|
||||||
bool appearanceChanged = false;
|
|
||||||
bool advancedChanged = false;
|
|
||||||
int pageIndex = 0;
|
|
||||||
bool loading = true;
|
|
||||||
bool forceAuthReload = false;
|
|
||||||
bool forceUpdateCheck = false;
|
|
||||||
int sampleRateIndex = 0;
|
|
||||||
int channelIndex = 0;
|
|
||||||
bool llBufferingEnabled = false;
|
|
||||||
bool hotkeysLoaded = false;
|
|
||||||
|
|
||||||
int lastSimpleRecQualityIdx = 0;
|
|
||||||
int lastServiceIdx = -1;
|
|
||||||
int lastIgnoreRecommended = -1;
|
|
||||||
int lastChannelSetupIdx = 0;
|
|
||||||
|
|
||||||
static constexpr uint32_t ENCODER_HIDE_FLAGS = (OBS_ENCODER_CAP_DEPRECATED | OBS_ENCODER_CAP_INTERNAL);
|
|
||||||
|
|
||||||
OBSTheme *savedTheme = nullptr;
|
|
||||||
|
|
||||||
std::vector<FFmpegFormat> formats;
|
|
||||||
|
|
||||||
OBSPropertiesView *streamProperties = nullptr;
|
|
||||||
OBSPropertiesView *streamEncoderProps = nullptr;
|
|
||||||
OBSPropertiesView *recordEncoderProps = nullptr;
|
|
||||||
|
|
||||||
QPointer<QLabel> advOutRecWarning;
|
|
||||||
QPointer<QLabel> simpleOutRecWarning;
|
|
||||||
|
|
||||||
QString curPreset;
|
|
||||||
QString curQSVPreset;
|
|
||||||
QString curNVENCPreset;
|
|
||||||
QString curAMDPreset;
|
|
||||||
QString curAMDAV1Preset;
|
|
||||||
|
|
||||||
QString curAdvStreamEncoder;
|
|
||||||
QString curAdvRecordEncoder;
|
|
||||||
|
|
||||||
using AudioSource_t = std::tuple<OBSWeakSource, QPointer<QCheckBox>, QPointer<QSpinBox>, QPointer<QCheckBox>,
|
|
||||||
QPointer<QSpinBox>>;
|
|
||||||
std::vector<AudioSource_t> audioSources;
|
|
||||||
std::vector<OBSSignal> audioSourceSignals;
|
|
||||||
OBSSignal sourceCreated;
|
|
||||||
OBSSignal channelChanged;
|
|
||||||
|
|
||||||
std::vector<std::pair<bool, QPointer<OBSHotkeyWidget>>> hotkeys;
|
|
||||||
OBSSignal hotkeyRegistered;
|
|
||||||
OBSSignal hotkeyUnregistered;
|
|
||||||
|
|
||||||
uint32_t outputCX = 0;
|
|
||||||
uint32_t outputCY = 0;
|
|
||||||
|
|
||||||
QPointer<QCheckBox> simpleVodTrack;
|
|
||||||
|
|
||||||
QPointer<QCheckBox> vodTrackCheckbox;
|
|
||||||
QPointer<QWidget> vodTrackContainer;
|
|
||||||
QPointer<QRadioButton> vodTrack[MAX_AUDIO_MIXES];
|
|
||||||
|
|
||||||
QIcon hotkeyConflictIcon;
|
|
||||||
|
|
||||||
void SaveCombo(QComboBox *widget, const char *section, const char *value);
|
|
||||||
void SaveComboData(QComboBox *widget, const char *section, const char *value);
|
|
||||||
void SaveCheckBox(QAbstractButton *widget, const char *section, const char *value, bool invert = false);
|
|
||||||
void SaveGroupBox(QGroupBox *widget, const char *section, const char *value);
|
|
||||||
void SaveEdit(QLineEdit *widget, const char *section, const char *value);
|
|
||||||
void SaveSpinBox(QSpinBox *widget, const char *section, const char *value);
|
|
||||||
void SaveText(QPlainTextEdit *widget, const char *section, const char *value);
|
|
||||||
void SaveFormat(QComboBox *combo);
|
|
||||||
void SaveEncoder(QComboBox *combo, const char *section, const char *value);
|
|
||||||
|
|
||||||
bool ResFPSValid(obs_service_resolution *res_list, size_t res_count, int max_fps);
|
|
||||||
void ClosestResFPS(obs_service_resolution *res_list, size_t res_count, int max_fps, int &new_cx, int &new_cy,
|
|
||||||
int &new_fps);
|
|
||||||
|
|
||||||
inline bool Changed() const
|
|
||||||
{
|
|
||||||
return generalChanged || appearanceChanged || outputsChanged || stream1Changed || audioChanged ||
|
|
||||||
videoChanged || advancedChanged || hotkeysChanged || a11yChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void EnableApplyButton(bool en) { ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(en); }
|
|
||||||
|
|
||||||
inline void ClearChanged()
|
|
||||||
{
|
|
||||||
generalChanged = false;
|
|
||||||
stream1Changed = false;
|
|
||||||
outputsChanged = false;
|
|
||||||
audioChanged = false;
|
|
||||||
videoChanged = false;
|
|
||||||
hotkeysChanged = false;
|
|
||||||
a11yChanged = false;
|
|
||||||
advancedChanged = false;
|
|
||||||
appearanceChanged = false;
|
|
||||||
EnableApplyButton(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Widget, typename WidgetParent, typename... SignalArgs, typename... SlotArgs>
|
|
||||||
void HookWidget(Widget *widget, void (WidgetParent::*signal)(SignalArgs...),
|
|
||||||
void (OBSBasicSettings::*slot)(SlotArgs...))
|
|
||||||
{
|
|
||||||
QObject::connect(widget, signal, this, slot);
|
|
||||||
widget->setProperty("changed", QVariant(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QueryChanges();
|
|
||||||
bool QueryAllowedToClose();
|
|
||||||
|
|
||||||
void ResetEncoders(bool streamOnly = false);
|
|
||||||
void LoadColorRanges();
|
|
||||||
void LoadColorSpaces();
|
|
||||||
void LoadColorFormats();
|
|
||||||
void LoadFormats();
|
|
||||||
void ReloadCodecs(const FFmpegFormat &format);
|
|
||||||
|
|
||||||
void UpdateColorFormatSpaceWarning();
|
|
||||||
|
|
||||||
void LoadGeneralSettings();
|
|
||||||
void LoadStream1Settings();
|
|
||||||
void LoadOutputSettings();
|
|
||||||
void LoadAudioSettings();
|
|
||||||
void LoadVideoSettings();
|
|
||||||
void LoadHotkeySettings(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
|
|
||||||
void LoadA11ySettings(bool presetChange = false);
|
|
||||||
void LoadAppearanceSettings(bool reload = false);
|
|
||||||
void LoadAdvancedSettings();
|
|
||||||
void LoadSettings(bool changedOnly);
|
|
||||||
|
|
||||||
OBSPropertiesView *CreateEncoderPropertyView(const char *encoder, const char *path, bool changed = false);
|
|
||||||
|
|
||||||
/* general */
|
|
||||||
void LoadLanguageList();
|
|
||||||
void LoadThemeList(bool firstLoad);
|
|
||||||
void LoadBranchesList();
|
|
||||||
|
|
||||||
/* stream */
|
|
||||||
void InitStreamPage();
|
|
||||||
bool IsCustomService() const;
|
|
||||||
inline bool IsWHIP() const;
|
|
||||||
void LoadServices(bool showAll);
|
|
||||||
void OnOAuthStreamKeyConnected();
|
|
||||||
void OnAuthConnected();
|
|
||||||
QString lastService;
|
|
||||||
QString protocol;
|
|
||||||
QString lastCustomServer;
|
|
||||||
int prevLangIndex;
|
|
||||||
bool prevBrowserAccel;
|
|
||||||
|
|
||||||
void ServiceChanged(bool resetFields = false);
|
|
||||||
QString FindProtocol();
|
|
||||||
void UpdateServerList();
|
|
||||||
void UpdateKeyLink();
|
|
||||||
void UpdateVodTrackSetting();
|
|
||||||
void UpdateServiceRecommendations();
|
|
||||||
void UpdateMoreInfoLink();
|
|
||||||
void UpdateAdvNetworkGroup();
|
|
||||||
|
|
||||||
/* Appearance */
|
|
||||||
void InitAppearancePage();
|
|
||||||
|
|
||||||
bool IsCustomServer();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void UpdateMultitrackVideo();
|
|
||||||
void RecreateOutputResolutionWidget();
|
|
||||||
bool UpdateResFPSLimits();
|
|
||||||
void DisplayEnforceWarning(bool checked);
|
|
||||||
void on_show_clicked();
|
|
||||||
void on_authPwShow_clicked();
|
|
||||||
void on_connectAccount_clicked();
|
|
||||||
void on_disconnectAccount_clicked();
|
|
||||||
void on_useStreamKey_clicked();
|
|
||||||
void on_useAuth_toggled();
|
|
||||||
void on_server_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_hotkeyFilterReset_clicked();
|
|
||||||
void on_hotkeyFilterSearch_textChanged(const QString text);
|
|
||||||
void on_hotkeyFilterInput_KeyChanged(obs_key_combination_t combo);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/* output */
|
|
||||||
void LoadSimpleOutputSettings();
|
|
||||||
void LoadAdvOutputStreamingSettings();
|
|
||||||
void LoadAdvOutputStreamingEncoderProperties();
|
|
||||||
void LoadAdvOutputRecordingSettings();
|
|
||||||
void LoadAdvOutputRecordingEncoderProperties();
|
|
||||||
void LoadAdvOutputFFmpegSettings();
|
|
||||||
void LoadAdvOutputAudioSettings();
|
|
||||||
void SetAdvOutputFFmpegEnablement(FFmpegCodecType encoderType, bool enabled, bool enableEncode = false);
|
|
||||||
|
|
||||||
/* audio */
|
|
||||||
void LoadListValues(QComboBox *widget, obs_property_t *prop, int index);
|
|
||||||
void LoadAudioDevices();
|
|
||||||
void LoadAudioSources();
|
|
||||||
|
|
||||||
/* video */
|
|
||||||
void LoadRendererList();
|
|
||||||
void ResetDownscales(uint32_t cx, uint32_t cy, bool ignoreAllSignals = false);
|
|
||||||
void LoadDownscaleFilters();
|
|
||||||
void LoadResolutionLists();
|
|
||||||
void LoadFPSData();
|
|
||||||
|
|
||||||
/* a11y */
|
|
||||||
void UpdateA11yColors();
|
|
||||||
void SetDefaultColors();
|
|
||||||
void ResetDefaultColors();
|
|
||||||
QColor GetColor(uint32_t colorVal, QString label);
|
|
||||||
uint32_t preset = 0;
|
|
||||||
uint32_t selectRed = 0x0000FF;
|
|
||||||
uint32_t selectGreen = 0x00FF00;
|
|
||||||
uint32_t selectBlue = 0xFF7F00;
|
|
||||||
uint32_t mixerGreen = 0x267f26;
|
|
||||||
uint32_t mixerYellow = 0x267f7f;
|
|
||||||
uint32_t mixerRed = 0x26267f;
|
|
||||||
uint32_t mixerGreenActive = 0x4cff4c;
|
|
||||||
uint32_t mixerYellowActive = 0x4cffff;
|
|
||||||
uint32_t mixerRedActive = 0x4c4cff;
|
|
||||||
|
|
||||||
void SaveGeneralSettings();
|
|
||||||
void SaveStream1Settings();
|
|
||||||
void SaveOutputSettings();
|
|
||||||
void SaveAudioSettings();
|
|
||||||
void SaveVideoSettings();
|
|
||||||
void SaveHotkeySettings();
|
|
||||||
void SaveA11ySettings();
|
|
||||||
void SaveAppearanceSettings();
|
|
||||||
void SaveAdvancedSettings();
|
|
||||||
void SaveSettings();
|
|
||||||
|
|
||||||
void SearchHotkeys(const QString &text, obs_key_combination_t filterCombo);
|
|
||||||
|
|
||||||
void UpdateSimpleOutStreamDelayEstimate();
|
|
||||||
void UpdateAdvOutStreamDelayEstimate();
|
|
||||||
|
|
||||||
void FillSimpleRecordingValues();
|
|
||||||
void FillAudioMonitoringDevices();
|
|
||||||
|
|
||||||
void RecalcOutputResPixels(const char *resText);
|
|
||||||
|
|
||||||
bool AskIfCanCloseSettings();
|
|
||||||
|
|
||||||
void UpdateYouTubeAppDockSettings();
|
|
||||||
|
|
||||||
QIcon generalIcon;
|
|
||||||
QIcon appearanceIcon;
|
|
||||||
QIcon streamIcon;
|
|
||||||
QIcon outputIcon;
|
|
||||||
QIcon audioIcon;
|
|
||||||
QIcon videoIcon;
|
|
||||||
QIcon hotkeysIcon;
|
|
||||||
QIcon accessibilityIcon;
|
|
||||||
QIcon advancedIcon;
|
|
||||||
|
|
||||||
QIcon GetGeneralIcon() const;
|
|
||||||
QIcon GetAppearanceIcon() const;
|
|
||||||
QIcon GetStreamIcon() const;
|
|
||||||
QIcon GetOutputIcon() const;
|
|
||||||
QIcon GetAudioIcon() const;
|
|
||||||
QIcon GetVideoIcon() const;
|
|
||||||
QIcon GetHotkeysIcon() const;
|
|
||||||
QIcon GetAccessibilityIcon() const;
|
|
||||||
QIcon GetAdvancedIcon() const;
|
|
||||||
|
|
||||||
int CurrentFLVTrack();
|
|
||||||
int SimpleOutGetSelectedAudioTracks();
|
|
||||||
int AdvOutGetSelectedAudioTracks();
|
|
||||||
int AdvOutGetStreamingSelectedAudioTracks();
|
|
||||||
|
|
||||||
OBSService GetStream1Service();
|
|
||||||
|
|
||||||
bool ServiceAndVCodecCompatible();
|
|
||||||
bool ServiceAndACodecCompatible();
|
|
||||||
bool ServiceSupportsCodecCheck();
|
|
||||||
|
|
||||||
inline bool AllowsMultiTrack(const char *protocol);
|
|
||||||
void SwapMultiTrack(const char *protocol);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_theme_activated(int idx);
|
|
||||||
void on_themeVariant_activated(int idx);
|
|
||||||
|
|
||||||
void on_listWidget_itemSelectionChanged();
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
|
||||||
|
|
||||||
void on_service_currentIndexChanged(int idx);
|
|
||||||
void on_customServer_textChanged(const QString &text);
|
|
||||||
void on_simpleOutputBrowse_clicked();
|
|
||||||
void on_advOutRecPathBrowse_clicked();
|
|
||||||
void on_advOutFFPathBrowse_clicked();
|
|
||||||
void on_advOutEncoder_currentIndexChanged();
|
|
||||||
void on_advOutRecEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFIgnoreCompat_stateChanged(int state);
|
|
||||||
void on_advOutFFFormat_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFAEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFVEncoder_currentIndexChanged(int idx);
|
|
||||||
void on_advOutFFType_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void on_colorFormat_currentIndexChanged(int idx);
|
|
||||||
void on_colorSpace_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void on_filenameFormatting_textEdited(const QString &text);
|
|
||||||
void on_outputResolution_editTextChanged(const QString &text);
|
|
||||||
void on_baseResolution_editTextChanged(const QString &text);
|
|
||||||
|
|
||||||
void on_disableOSXVSync_clicked();
|
|
||||||
|
|
||||||
void on_choose1_clicked();
|
|
||||||
void on_choose2_clicked();
|
|
||||||
void on_choose3_clicked();
|
|
||||||
void on_choose4_clicked();
|
|
||||||
void on_choose5_clicked();
|
|
||||||
void on_choose6_clicked();
|
|
||||||
void on_choose7_clicked();
|
|
||||||
void on_choose8_clicked();
|
|
||||||
void on_choose9_clicked();
|
|
||||||
void on_colorPreset_currentIndexChanged(int idx);
|
|
||||||
|
|
||||||
void GeneralChanged();
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
||||||
void HideOBSWindowWarning(Qt::CheckState state);
|
|
||||||
#else
|
|
||||||
void HideOBSWindowWarning(int state);
|
|
||||||
#endif
|
|
||||||
void AudioChanged();
|
|
||||||
void AudioChangedRestart();
|
|
||||||
void ReloadAudioSources();
|
|
||||||
void SurroundWarning(int idx);
|
|
||||||
void SpeakerLayoutChanged(int idx);
|
|
||||||
void LowLatencyBufferingChanged(bool checked);
|
|
||||||
void UpdateAudioWarnings();
|
|
||||||
void OutputsChanged();
|
|
||||||
void Stream1Changed();
|
|
||||||
void VideoChanged();
|
|
||||||
void VideoChangedResolution();
|
|
||||||
void HotkeysChanged();
|
|
||||||
bool ScanDuplicateHotkeys(QFormLayout *layout);
|
|
||||||
void ReloadHotkeys(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
|
|
||||||
void A11yChanged();
|
|
||||||
void AppearanceChanged();
|
|
||||||
void AdvancedChanged();
|
|
||||||
void AdvancedChangedRestart();
|
|
||||||
|
|
||||||
void UpdateStreamDelayEstimate();
|
|
||||||
|
|
||||||
void UpdateAutomaticReplayBufferCheckboxes();
|
|
||||||
|
|
||||||
void AdvOutSplitFileChanged();
|
|
||||||
void AdvOutRecCheckWarnings();
|
|
||||||
void AdvOutRecCheckCodecs();
|
|
||||||
|
|
||||||
void SimpleRecordingQualityChanged();
|
|
||||||
void SimpleRecordingEncoderChanged();
|
|
||||||
void SimpleRecordingQualityLosslessWarning(int idx);
|
|
||||||
|
|
||||||
void SimpleReplayBufferChanged();
|
|
||||||
void AdvReplayBufferChanged();
|
|
||||||
|
|
||||||
void SimpleStreamingEncoderChanged();
|
|
||||||
|
|
||||||
OBSService SpawnTempService();
|
|
||||||
|
|
||||||
void SetGeneralIcon(const QIcon &icon);
|
|
||||||
void SetAppearanceIcon(const QIcon &icon);
|
|
||||||
void SetStreamIcon(const QIcon &icon);
|
|
||||||
void SetOutputIcon(const QIcon &icon);
|
|
||||||
void SetAudioIcon(const QIcon &icon);
|
|
||||||
void SetVideoIcon(const QIcon &icon);
|
|
||||||
void SetHotkeysIcon(const QIcon &icon);
|
|
||||||
void SetAccessibilityIcon(const QIcon &icon);
|
|
||||||
void SetAdvancedIcon(const QIcon &icon);
|
|
||||||
|
|
||||||
void UseStreamKeyAdvClicked();
|
|
||||||
|
|
||||||
void SimpleStreamAudioEncoderChanged();
|
|
||||||
void AdvAudioEncodersChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
|
||||||
virtual void showEvent(QShowEvent *event) override;
|
|
||||||
void reject() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSBasicSettings(QWidget *parent);
|
|
||||||
~OBSBasicSettings();
|
|
||||||
|
|
||||||
inline const QIcon &GetHotkeyConflictIcon() const { return hotkeyConflictIcon; }
|
|
||||||
};
|
|
||||||
|
@ -14,75 +14,47 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <obs.hpp>
|
#include "OBSBasicSettings.hpp"
|
||||||
#include <util/util.hpp>
|
#include "OBSHotkeyLabel.hpp"
|
||||||
#include <util/lexer.h>
|
#include "OBSHotkeyWidget.hpp"
|
||||||
#include <graphics/math-defs.h>
|
|
||||||
#include <initializer_list>
|
#include <components/Multiview.hpp>
|
||||||
#include <sstream>
|
#include <components/OBSSourceLabel.hpp>
|
||||||
#include <unordered_map>
|
#include <components/SilentUpdateCheckBox.hpp>
|
||||||
#include <unordered_set>
|
#include <components/SilentUpdateSpinBox.hpp>
|
||||||
#include <QCompleter>
|
#ifdef YOUTUBE_ENABLED
|
||||||
#include <QGuiApplication>
|
#include <docks/YouTubeAppDock.hpp>
|
||||||
#include <QLineEdit>
|
#endif
|
||||||
#include <QMessageBox>
|
#include <utility/audio-encoders.hpp>
|
||||||
#include <QCloseEvent>
|
#include <utility/BaseLexer.hpp>
|
||||||
#include <QDirIterator>
|
#include <utility/FFmpegCodec.hpp>
|
||||||
#include <QVariant>
|
#include <utility/FFmpegFormat.hpp>
|
||||||
#include <QTreeView>
|
#include <utility/SettingsEventFilter.hpp>
|
||||||
#include <QScreen>
|
#ifdef YOUTUBE_ENABLED
|
||||||
#include <QStandardItemModel>
|
#include <utility/YoutubeApiWrappers.hpp>
|
||||||
#include <QSpacerItem>
|
#endif
|
||||||
|
#include <widgets/OBSBasic.hpp>
|
||||||
|
#include <widgets/OBSProjector.hpp>
|
||||||
|
|
||||||
|
#include <properties-view.hpp>
|
||||||
#include <qt-wrappers.hpp>
|
#include <qt-wrappers.hpp>
|
||||||
|
|
||||||
#include "audio-encoders.hpp"
|
#include <QCompleter>
|
||||||
#include "hotkey-edit.hpp"
|
#include <QStandardItemModel>
|
||||||
#include "source-label.hpp"
|
|
||||||
#include "obs-app.hpp"
|
|
||||||
#include "platform.hpp"
|
|
||||||
#include "properties-view.hpp"
|
|
||||||
#include "window-basic-main.hpp"
|
|
||||||
#include "moc_window-basic-settings.cpp"
|
|
||||||
#include "window-basic-main-outputs.hpp"
|
|
||||||
#include "window-projector.hpp"
|
|
||||||
|
|
||||||
#ifdef YOUTUBE_ENABLED
|
#include <sstream>
|
||||||
#include "youtube-api-wrappers.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <util/platform.h>
|
#include "moc_OBSBasicSettings.cpp"
|
||||||
#include <util/dstr.hpp>
|
|
||||||
#include "ui-config.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class SettingsEventFilter : public QObject {
|
extern const char *get_simple_output_encoder(const char *encoder);
|
||||||
QScopedPointer<OBSEventFilter> shortcutFilter;
|
|
||||||
|
|
||||||
public:
|
extern bool restart;
|
||||||
inline SettingsEventFilter() : shortcutFilter((OBSEventFilter *)CreateShortcutFilter()) {}
|
extern bool opt_allow_opengl;
|
||||||
|
extern bool cef_js_avail;
|
||||||
protected:
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override
|
|
||||||
{
|
|
||||||
int key;
|
|
||||||
|
|
||||||
switch (event->type()) {
|
|
||||||
case QEvent::KeyPress:
|
|
||||||
case QEvent::KeyRelease:
|
|
||||||
key = static_cast<QKeyEvent *>(event)->key();
|
|
||||||
if (key == Qt::Key_Escape) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shortcutFilter->filter(obj, event);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline bool ResTooHigh(uint32_t cx, uint32_t cy)
|
static inline bool ResTooHigh(uint32_t cx, uint32_t cy)
|
||||||
{
|
{
|
||||||
|
@ -18,57 +18,22 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <util/util.hpp>
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
#include "auth-base.hpp"
|
|
||||||
#include "ffmpeg-utils.hpp"
|
|
||||||
#include "obs-app-theming.hpp"
|
|
||||||
|
|
||||||
class OBSBasic;
|
|
||||||
class QAbstractButton;
|
|
||||||
class QRadioButton;
|
|
||||||
class QComboBox;
|
|
||||||
class QCheckBox;
|
|
||||||
class QLabel;
|
|
||||||
class QButtonGroup;
|
|
||||||
class OBSPropertiesView;
|
|
||||||
class OBSHotkeyWidget;
|
|
||||||
|
|
||||||
#include "ui_OBSBasicSettings.h"
|
#include "ui_OBSBasicSettings.h"
|
||||||
|
|
||||||
|
#include <utility/FFmpegShared.hpp>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#define VOLUME_METER_DECAY_FAST 23.53
|
#define VOLUME_METER_DECAY_FAST 23.53
|
||||||
#define VOLUME_METER_DECAY_MEDIUM 11.76
|
#define VOLUME_METER_DECAY_MEDIUM 11.76
|
||||||
#define VOLUME_METER_DECAY_SLOW 8.57
|
#define VOLUME_METER_DECAY_SLOW 8.57
|
||||||
|
|
||||||
class SilentUpdateCheckBox : public QCheckBox {
|
class Auth;
|
||||||
Q_OBJECT
|
class OBSBasic;
|
||||||
|
class OBSHotkeyWidget;
|
||||||
public slots:
|
class OBSPropertiesView;
|
||||||
void setCheckedSilently(bool checked)
|
struct FFmpegFormat;
|
||||||
{
|
struct OBSTheme;
|
||||||
bool blocked = blockSignals(true);
|
|
||||||
setChecked(checked);
|
|
||||||
blockSignals(blocked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SilentUpdateSpinBox : public QSpinBox {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setValueSilently(int val)
|
|
||||||
{
|
|
||||||
bool blocked = blockSignals(true);
|
|
||||||
setValue(val);
|
|
||||||
blockSignals(blocked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string DeserializeConfigText(const char *value);
|
std::string DeserializeConfigText(const char *value);
|
||||||
|
|
||||||
|
@ -15,16 +15,17 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "window-basic-settings.hpp"
|
#include "OBSHotkeyEdit.hpp"
|
||||||
#include "moc_hotkey-edit.cpp"
|
#include "OBSBasicSettings.hpp"
|
||||||
|
|
||||||
|
#include <OBSApp.hpp>
|
||||||
|
|
||||||
#include <util/dstr.hpp>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QAction>
|
|
||||||
#include <qt-wrappers.hpp>
|
#include <qt-wrappers.hpp>
|
||||||
|
#include <util/dstr.hpp>
|
||||||
|
|
||||||
#include "obs-app.hpp"
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
#include "moc_OBSHotkeyEdit.cpp"
|
||||||
|
|
||||||
void OBSHotkeyEdit::keyPressEvent(QKeyEvent *event)
|
void OBSHotkeyEdit::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
@ -214,257 +215,3 @@ void OBSHotkeyEdit::ReloadKeyLayout()
|
|||||||
{
|
{
|
||||||
RenderKey();
|
RenderKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSHotkeyWidget::SetKeyCombinations(const std::vector<obs_key_combination_t> &combos)
|
|
||||||
{
|
|
||||||
if (combos.empty())
|
|
||||||
AddEdit({0, OBS_KEY_NONE});
|
|
||||||
|
|
||||||
for (auto combo : combos)
|
|
||||||
AddEdit(combo);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OBSHotkeyWidget::Changed() const
|
|
||||||
{
|
|
||||||
return changed || std::any_of(begin(edits), end(edits), [](OBSHotkeyEdit *edit) { return edit->changed; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Apply()
|
|
||||||
{
|
|
||||||
for (auto &edit : edits) {
|
|
||||||
edit->original = edit->key;
|
|
||||||
edit->changed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
changed = false;
|
|
||||||
|
|
||||||
for (auto &revertButton : revertButtons)
|
|
||||||
revertButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::GetCombinations(std::vector<obs_key_combination_t> &combinations) const
|
|
||||||
{
|
|
||||||
combinations.clear();
|
|
||||||
for (auto &edit : edits)
|
|
||||||
if (!obs_key_combination_is_empty(edit->key))
|
|
||||||
combinations.emplace_back(edit->key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Save()
|
|
||||||
{
|
|
||||||
std::vector<obs_key_combination_t> combinations;
|
|
||||||
Save(combinations);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Save(std::vector<obs_key_combination_t> &combinations)
|
|
||||||
{
|
|
||||||
GetCombinations(combinations);
|
|
||||||
Apply();
|
|
||||||
|
|
||||||
auto AtomicUpdate = [&]() {
|
|
||||||
ignoreChangedBindings = true;
|
|
||||||
|
|
||||||
obs_hotkey_load_bindings(id, combinations.data(), combinations.size());
|
|
||||||
|
|
||||||
ignoreChangedBindings = false;
|
|
||||||
};
|
|
||||||
using AtomicUpdate_t = decltype(&AtomicUpdate);
|
|
||||||
|
|
||||||
obs_hotkey_update_atomic([](void *d) { (*static_cast<AtomicUpdate_t>(d))(); },
|
|
||||||
static_cast<void *>(&AtomicUpdate));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::AddEdit(obs_key_combination combo, int idx)
|
|
||||||
{
|
|
||||||
auto edit = new OBSHotkeyEdit(parentWidget(), combo, settings);
|
|
||||||
edit->setToolTip(toolTip);
|
|
||||||
|
|
||||||
auto revert = new QPushButton;
|
|
||||||
revert->setProperty("class", "icon-revert");
|
|
||||||
revert->setToolTip(QTStr("Revert"));
|
|
||||||
revert->setEnabled(false);
|
|
||||||
|
|
||||||
auto clear = new QPushButton;
|
|
||||||
clear->setProperty("class", "icon-clear");
|
|
||||||
clear->setToolTip(QTStr("Clear"));
|
|
||||||
clear->setEnabled(!obs_key_combination_is_empty(combo));
|
|
||||||
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [=](obs_key_combination_t new_combo) {
|
|
||||||
clear->setEnabled(!obs_key_combination_is_empty(new_combo));
|
|
||||||
revert->setEnabled(edit->original != new_combo);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto add = new QPushButton;
|
|
||||||
add->setProperty("class", "icon-plus");
|
|
||||||
add->setToolTip(QTStr("Add"));
|
|
||||||
|
|
||||||
auto remove = new QPushButton;
|
|
||||||
remove->setProperty("class", "icon-trash");
|
|
||||||
remove->setToolTip(QTStr("Remove"));
|
|
||||||
remove->setEnabled(removeButtons.size() > 0);
|
|
||||||
|
|
||||||
auto CurrentIndex = [&, remove] {
|
|
||||||
auto res = std::find(begin(removeButtons), end(removeButtons), remove);
|
|
||||||
return std::distance(begin(removeButtons), res);
|
|
||||||
};
|
|
||||||
|
|
||||||
QObject::connect(add, &QPushButton::clicked, [&, CurrentIndex] {
|
|
||||||
AddEdit({0, OBS_KEY_NONE}, CurrentIndex() + 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(remove, &QPushButton::clicked, [&, CurrentIndex] { RemoveEdit(CurrentIndex()); });
|
|
||||||
|
|
||||||
QHBoxLayout *subLayout = new QHBoxLayout;
|
|
||||||
subLayout->setContentsMargins(0, 2, 0, 2);
|
|
||||||
subLayout->addWidget(edit);
|
|
||||||
subLayout->addWidget(revert);
|
|
||||||
subLayout->addWidget(clear);
|
|
||||||
subLayout->addWidget(add);
|
|
||||||
subLayout->addWidget(remove);
|
|
||||||
|
|
||||||
if (removeButtons.size() == 1)
|
|
||||||
removeButtons.front()->setEnabled(true);
|
|
||||||
|
|
||||||
if (idx != -1) {
|
|
||||||
revertButtons.insert(begin(revertButtons) + idx, revert);
|
|
||||||
removeButtons.insert(begin(removeButtons) + idx, remove);
|
|
||||||
edits.insert(begin(edits) + idx, edit);
|
|
||||||
} else {
|
|
||||||
revertButtons.emplace_back(revert);
|
|
||||||
removeButtons.emplace_back(remove);
|
|
||||||
edits.emplace_back(edit);
|
|
||||||
}
|
|
||||||
|
|
||||||
layout()->insertLayout(idx, subLayout);
|
|
||||||
|
|
||||||
QObject::connect(revert, &QPushButton::clicked, edit, &OBSHotkeyEdit::ResetKey);
|
|
||||||
QObject::connect(clear, &QPushButton::clicked, edit, &OBSHotkeyEdit::ClearKey);
|
|
||||||
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [&](obs_key_combination) { emit KeyChanged(); });
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::SearchKey, [=](obs_key_combination combo) { emit SearchKey(combo); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::RemoveEdit(size_t idx, bool signal)
|
|
||||||
{
|
|
||||||
auto &edit = *(begin(edits) + idx);
|
|
||||||
if (!obs_key_combination_is_empty(edit->original) && signal) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
revertButtons.erase(begin(revertButtons) + idx);
|
|
||||||
removeButtons.erase(begin(removeButtons) + idx);
|
|
||||||
edits.erase(begin(edits) + idx);
|
|
||||||
|
|
||||||
auto item = layout()->takeAt(static_cast<int>(idx));
|
|
||||||
QLayoutItem *child = nullptr;
|
|
||||||
while ((child = item->layout()->takeAt(0))) {
|
|
||||||
delete child->widget();
|
|
||||||
delete child;
|
|
||||||
}
|
|
||||||
delete item;
|
|
||||||
|
|
||||||
if (removeButtons.size() == 1)
|
|
||||||
removeButtons.front()->setEnabled(false);
|
|
||||||
|
|
||||||
emit KeyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::BindingsChanged(void *data, calldata_t *param)
|
|
||||||
{
|
|
||||||
auto widget = static_cast<OBSHotkeyWidget *>(data);
|
|
||||||
auto key = static_cast<obs_hotkey_t *>(calldata_ptr(param, "key"));
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(widget, "HandleChangedBindings", Q_ARG(obs_hotkey_id, obs_hotkey_get_id(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::HandleChangedBindings(obs_hotkey_id id_)
|
|
||||||
{
|
|
||||||
if (ignoreChangedBindings || id != id_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::vector<obs_key_combination_t> bindings;
|
|
||||||
auto LoadBindings = [&](obs_hotkey_binding_t *binding) {
|
|
||||||
if (obs_hotkey_binding_get_hotkey_id(binding) != id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto get_combo = obs_hotkey_binding_get_key_combination;
|
|
||||||
bindings.push_back(get_combo(binding));
|
|
||||||
};
|
|
||||||
using LoadBindings_t = decltype(&LoadBindings);
|
|
||||||
|
|
||||||
obs_enum_hotkey_bindings(
|
|
||||||
[](void *data, size_t, obs_hotkey_binding_t *binding) {
|
|
||||||
auto LoadBindings = *static_cast<LoadBindings_t>(data);
|
|
||||||
LoadBindings(binding);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
static_cast<void *>(&LoadBindings));
|
|
||||||
|
|
||||||
while (edits.size() > 0)
|
|
||||||
RemoveEdit(edits.size() - 1, false);
|
|
||||||
|
|
||||||
SetKeyCombinations(bindings);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void updateStyle(QWidget *widget)
|
|
||||||
{
|
|
||||||
auto style = widget->style();
|
|
||||||
style->unpolish(widget);
|
|
||||||
style->polish(widget);
|
|
||||||
widget->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::enterEvent(QEnterEvent *event)
|
|
||||||
{
|
|
||||||
if (!label)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
label->highlightPair(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
if (!label)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
label->highlightPair(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::highlightPair(bool highlight)
|
|
||||||
{
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pairPartner->setProperty("class", highlight ? "text-bright" : "");
|
|
||||||
updateStyle(pairPartner);
|
|
||||||
setProperty("class", highlight ? "text-bright" : "");
|
|
||||||
updateStyle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::enterEvent(QEnterEvent *event)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
highlightPair(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
highlightPair(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::setToolTip(const QString &toolTip)
|
|
||||||
{
|
|
||||||
QLabel::setToolTip(toolTip);
|
|
||||||
if (widget)
|
|
||||||
widget->setToolTip(toolTip);
|
|
||||||
}
|
|
||||||
|
@ -17,16 +17,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
#include <obs.hpp>
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class OBSBasicSettings;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
static inline bool operator!=(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
static inline bool operator!=(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
||||||
{
|
{
|
||||||
return c1.modifiers != c2.modifiers || c1.key != c2.key;
|
return c1.modifiers != c2.modifiers || c1.key != c2.key;
|
||||||
@ -37,21 +34,6 @@ static inline bool operator==(const obs_key_combination_t &c1, const obs_key_com
|
|||||||
return !(c1 != c2);
|
return !(c1 != c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
class OBSBasicSettings;
|
|
||||||
class OBSHotkeyWidget;
|
|
||||||
|
|
||||||
class OBSHotkeyLabel : public QLabel {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
QPointer<OBSHotkeyLabel> pairPartner;
|
|
||||||
QPointer<OBSHotkeyWidget> widget;
|
|
||||||
void highlightPair(bool highlight);
|
|
||||||
void enterEvent(QEnterEvent *event) override;
|
|
||||||
void leaveEvent(QEvent *event) override;
|
|
||||||
void setToolTip(const QString &toolTip);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OBSHotkeyEdit : public QLineEdit {
|
class OBSHotkeyEdit : public QLineEdit {
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
@ -118,73 +100,3 @@ signals:
|
|||||||
void KeyChanged(obs_key_combination_t);
|
void KeyChanged(obs_key_combination_t);
|
||||||
void SearchKey(obs_key_combination_t);
|
void SearchKey(obs_key_combination_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
class OBSHotkeyWidget : public QWidget {
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSHotkeyWidget(QWidget *parent, obs_hotkey_id id, std::string name, OBSBasicSettings *settings,
|
|
||||||
const std::vector<obs_key_combination_t> &combos = {})
|
|
||||||
: QWidget(parent),
|
|
||||||
id(id),
|
|
||||||
name(name),
|
|
||||||
bindingsChanged(obs_get_signal_handler(), "hotkey_bindings_changed",
|
|
||||||
&OBSHotkeyWidget::BindingsChanged, this),
|
|
||||||
settings(settings)
|
|
||||||
{
|
|
||||||
auto layout = new QVBoxLayout;
|
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
SetKeyCombinations(combos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetKeyCombinations(const std::vector<obs_key_combination_t> &);
|
|
||||||
|
|
||||||
obs_hotkey_id id;
|
|
||||||
std::string name;
|
|
||||||
|
|
||||||
bool changed = false;
|
|
||||||
bool Changed() const;
|
|
||||||
|
|
||||||
QPointer<OBSHotkeyLabel> label;
|
|
||||||
std::vector<QPointer<OBSHotkeyEdit>> edits;
|
|
||||||
|
|
||||||
QString toolTip;
|
|
||||||
void setToolTip(const QString &toolTip_)
|
|
||||||
{
|
|
||||||
toolTip = toolTip_;
|
|
||||||
for (auto &edit : edits)
|
|
||||||
edit->setToolTip(toolTip_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Apply();
|
|
||||||
void GetCombinations(std::vector<obs_key_combination_t> &) const;
|
|
||||||
void Save();
|
|
||||||
void Save(std::vector<obs_key_combination_t> &combinations);
|
|
||||||
|
|
||||||
void enterEvent(QEnterEvent *event) override;
|
|
||||||
void leaveEvent(QEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void AddEdit(obs_key_combination combo, int idx = -1);
|
|
||||||
void RemoveEdit(size_t idx, bool signal = true);
|
|
||||||
|
|
||||||
static void BindingsChanged(void *data, calldata_t *param);
|
|
||||||
|
|
||||||
std::vector<QPointer<QPushButton>> removeButtons;
|
|
||||||
std::vector<QPointer<QPushButton>> revertButtons;
|
|
||||||
OBSSignal bindingsChanged;
|
|
||||||
bool ignoreChangedBindings = false;
|
|
||||||
OBSBasicSettings *settings;
|
|
||||||
|
|
||||||
QVBoxLayout *layout() const { return dynamic_cast<QVBoxLayout *>(QWidget::layout()); }
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void HandleChangedBindings(obs_hotkey_id id_);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void KeyChanged();
|
|
||||||
void SearchKey(obs_key_combination_t);
|
|
||||||
};
|
|
||||||
|
@ -15,396 +15,13 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "window-basic-settings.hpp"
|
#include "OBSHotkeyLabel.hpp"
|
||||||
#include "moc_hotkey-edit.cpp"
|
#include "OBSHotkeyWidget.hpp"
|
||||||
|
|
||||||
#include <util/dstr.hpp>
|
#include <QEnterEvent>
|
||||||
#include <QPointer>
|
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QAction>
|
|
||||||
#include <qt-wrappers.hpp>
|
|
||||||
|
|
||||||
#include "obs-app.hpp"
|
#include "moc_OBSHotkeyLabel.cpp"
|
||||||
|
|
||||||
void OBSHotkeyEdit::keyPressEvent(QKeyEvent *event)
|
|
||||||
{
|
|
||||||
if (event->isAutoRepeat())
|
|
||||||
return;
|
|
||||||
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
switch (event->key()) {
|
|
||||||
case Qt::Key_Shift:
|
|
||||||
case Qt::Key_Control:
|
|
||||||
case Qt::Key_Alt:
|
|
||||||
case Qt::Key_Meta:
|
|
||||||
new_key.key = OBS_KEY_NONE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
case Qt::Key_CapsLock:
|
|
||||||
// kVK_CapsLock == 57
|
|
||||||
new_key.key = obs_key_from_virtual_key(57);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
new_key.key = obs_key_from_virtual_key(event->nativeVirtualKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant OBSHotkeyEdit::inputMethodQuery(Qt::InputMethodQuery query) const
|
|
||||||
{
|
|
||||||
if (query == Qt::ImEnabled) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return QLineEdit::inputMethodQuery(query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void OBSHotkeyEdit::keyReleaseEvent(QKeyEvent *event)
|
|
||||||
{
|
|
||||||
if (event->isAutoRepeat())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event->key() != Qt::Key_CapsLock)
|
|
||||||
return;
|
|
||||||
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
// kVK_CapsLock == 57
|
|
||||||
new_key.key = obs_key_from_virtual_key(57);
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
switch (event->button()) {
|
|
||||||
case Qt::NoButton:
|
|
||||||
case Qt::LeftButton:
|
|
||||||
case Qt::RightButton:
|
|
||||||
case Qt::AllButtons:
|
|
||||||
case Qt::MouseButtonMask:
|
|
||||||
return;
|
|
||||||
|
|
||||||
case Qt::MiddleButton:
|
|
||||||
new_key.key = OBS_KEY_MOUSE3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#define MAP_BUTTON(i, j) \
|
|
||||||
case Qt::ExtraButton##i: \
|
|
||||||
new_key.key = OBS_KEY_MOUSE##j; \
|
|
||||||
break;
|
|
||||||
MAP_BUTTON(1, 4)
|
|
||||||
MAP_BUTTON(2, 5)
|
|
||||||
MAP_BUTTON(3, 6)
|
|
||||||
MAP_BUTTON(4, 7)
|
|
||||||
MAP_BUTTON(5, 8)
|
|
||||||
MAP_BUTTON(6, 9)
|
|
||||||
MAP_BUTTON(7, 10)
|
|
||||||
MAP_BUTTON(8, 11)
|
|
||||||
MAP_BUTTON(9, 12)
|
|
||||||
MAP_BUTTON(10, 13)
|
|
||||||
MAP_BUTTON(11, 14)
|
|
||||||
MAP_BUTTON(12, 15)
|
|
||||||
MAP_BUTTON(13, 16)
|
|
||||||
MAP_BUTTON(14, 17)
|
|
||||||
MAP_BUTTON(15, 18)
|
|
||||||
MAP_BUTTON(16, 19)
|
|
||||||
MAP_BUTTON(17, 20)
|
|
||||||
MAP_BUTTON(18, 21)
|
|
||||||
MAP_BUTTON(19, 22)
|
|
||||||
MAP_BUTTON(20, 23)
|
|
||||||
MAP_BUTTON(21, 24)
|
|
||||||
MAP_BUTTON(22, 25)
|
|
||||||
MAP_BUTTON(23, 26)
|
|
||||||
MAP_BUTTON(24, 27)
|
|
||||||
#undef MAP_BUTTON
|
|
||||||
}
|
|
||||||
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::HandleNewKey(obs_key_combination_t new_key)
|
|
||||||
{
|
|
||||||
if (new_key == key || obs_key_combination_is_empty(new_key))
|
|
||||||
return;
|
|
||||||
|
|
||||||
key = new_key;
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::RenderKey()
|
|
||||||
{
|
|
||||||
DStr str;
|
|
||||||
obs_key_combination_to_str(key, str);
|
|
||||||
|
|
||||||
setText(QT_UTF8(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ResetKey()
|
|
||||||
{
|
|
||||||
key = original;
|
|
||||||
|
|
||||||
changed = false;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ClearKey()
|
|
||||||
{
|
|
||||||
key = {0, OBS_KEY_NONE};
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::UpdateDuplicationState()
|
|
||||||
{
|
|
||||||
if (!dupeIcon && !hasDuplicate)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!dupeIcon)
|
|
||||||
CreateDupeIcon();
|
|
||||||
|
|
||||||
if (dupeIcon->isVisible() != hasDuplicate) {
|
|
||||||
dupeIcon->setVisible(hasDuplicate);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::InitSignalHandler()
|
|
||||||
{
|
|
||||||
layoutChanged = {obs_get_signal_handler(), "hotkey_layout_change",
|
|
||||||
[](void *this_, calldata_t *) {
|
|
||||||
auto edit = static_cast<OBSHotkeyEdit *>(this_);
|
|
||||||
QMetaObject::invokeMethod(edit, "ReloadKeyLayout");
|
|
||||||
},
|
|
||||||
this};
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::CreateDupeIcon()
|
|
||||||
{
|
|
||||||
dupeIcon = addAction(settings->GetHotkeyConflictIcon(), ActionPosition::TrailingPosition);
|
|
||||||
dupeIcon->setToolTip(QTStr("Basic.Settings.Hotkeys.DuplicateWarning"));
|
|
||||||
QObject::connect(dupeIcon, &QAction::triggered, [=] { emit SearchKey(key); });
|
|
||||||
dupeIcon->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ReloadKeyLayout()
|
|
||||||
{
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::SetKeyCombinations(const std::vector<obs_key_combination_t> &combos)
|
|
||||||
{
|
|
||||||
if (combos.empty())
|
|
||||||
AddEdit({0, OBS_KEY_NONE});
|
|
||||||
|
|
||||||
for (auto combo : combos)
|
|
||||||
AddEdit(combo);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OBSHotkeyWidget::Changed() const
|
|
||||||
{
|
|
||||||
return changed || std::any_of(begin(edits), end(edits), [](OBSHotkeyEdit *edit) { return edit->changed; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Apply()
|
|
||||||
{
|
|
||||||
for (auto &edit : edits) {
|
|
||||||
edit->original = edit->key;
|
|
||||||
edit->changed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
changed = false;
|
|
||||||
|
|
||||||
for (auto &revertButton : revertButtons)
|
|
||||||
revertButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::GetCombinations(std::vector<obs_key_combination_t> &combinations) const
|
|
||||||
{
|
|
||||||
combinations.clear();
|
|
||||||
for (auto &edit : edits)
|
|
||||||
if (!obs_key_combination_is_empty(edit->key))
|
|
||||||
combinations.emplace_back(edit->key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Save()
|
|
||||||
{
|
|
||||||
std::vector<obs_key_combination_t> combinations;
|
|
||||||
Save(combinations);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::Save(std::vector<obs_key_combination_t> &combinations)
|
|
||||||
{
|
|
||||||
GetCombinations(combinations);
|
|
||||||
Apply();
|
|
||||||
|
|
||||||
auto AtomicUpdate = [&]() {
|
|
||||||
ignoreChangedBindings = true;
|
|
||||||
|
|
||||||
obs_hotkey_load_bindings(id, combinations.data(), combinations.size());
|
|
||||||
|
|
||||||
ignoreChangedBindings = false;
|
|
||||||
};
|
|
||||||
using AtomicUpdate_t = decltype(&AtomicUpdate);
|
|
||||||
|
|
||||||
obs_hotkey_update_atomic([](void *d) { (*static_cast<AtomicUpdate_t>(d))(); },
|
|
||||||
static_cast<void *>(&AtomicUpdate));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::AddEdit(obs_key_combination combo, int idx)
|
|
||||||
{
|
|
||||||
auto edit = new OBSHotkeyEdit(parentWidget(), combo, settings);
|
|
||||||
edit->setToolTip(toolTip);
|
|
||||||
|
|
||||||
auto revert = new QPushButton;
|
|
||||||
revert->setProperty("class", "icon-revert");
|
|
||||||
revert->setToolTip(QTStr("Revert"));
|
|
||||||
revert->setEnabled(false);
|
|
||||||
|
|
||||||
auto clear = new QPushButton;
|
|
||||||
clear->setProperty("class", "icon-clear");
|
|
||||||
clear->setToolTip(QTStr("Clear"));
|
|
||||||
clear->setEnabled(!obs_key_combination_is_empty(combo));
|
|
||||||
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [=](obs_key_combination_t new_combo) {
|
|
||||||
clear->setEnabled(!obs_key_combination_is_empty(new_combo));
|
|
||||||
revert->setEnabled(edit->original != new_combo);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto add = new QPushButton;
|
|
||||||
add->setProperty("class", "icon-plus");
|
|
||||||
add->setToolTip(QTStr("Add"));
|
|
||||||
|
|
||||||
auto remove = new QPushButton;
|
|
||||||
remove->setProperty("class", "icon-trash");
|
|
||||||
remove->setToolTip(QTStr("Remove"));
|
|
||||||
remove->setEnabled(removeButtons.size() > 0);
|
|
||||||
|
|
||||||
auto CurrentIndex = [&, remove] {
|
|
||||||
auto res = std::find(begin(removeButtons), end(removeButtons), remove);
|
|
||||||
return std::distance(begin(removeButtons), res);
|
|
||||||
};
|
|
||||||
|
|
||||||
QObject::connect(add, &QPushButton::clicked, [&, CurrentIndex] {
|
|
||||||
AddEdit({0, OBS_KEY_NONE}, CurrentIndex() + 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(remove, &QPushButton::clicked, [&, CurrentIndex] { RemoveEdit(CurrentIndex()); });
|
|
||||||
|
|
||||||
QHBoxLayout *subLayout = new QHBoxLayout;
|
|
||||||
subLayout->setContentsMargins(0, 2, 0, 2);
|
|
||||||
subLayout->addWidget(edit);
|
|
||||||
subLayout->addWidget(revert);
|
|
||||||
subLayout->addWidget(clear);
|
|
||||||
subLayout->addWidget(add);
|
|
||||||
subLayout->addWidget(remove);
|
|
||||||
|
|
||||||
if (removeButtons.size() == 1)
|
|
||||||
removeButtons.front()->setEnabled(true);
|
|
||||||
|
|
||||||
if (idx != -1) {
|
|
||||||
revertButtons.insert(begin(revertButtons) + idx, revert);
|
|
||||||
removeButtons.insert(begin(removeButtons) + idx, remove);
|
|
||||||
edits.insert(begin(edits) + idx, edit);
|
|
||||||
} else {
|
|
||||||
revertButtons.emplace_back(revert);
|
|
||||||
removeButtons.emplace_back(remove);
|
|
||||||
edits.emplace_back(edit);
|
|
||||||
}
|
|
||||||
|
|
||||||
layout()->insertLayout(idx, subLayout);
|
|
||||||
|
|
||||||
QObject::connect(revert, &QPushButton::clicked, edit, &OBSHotkeyEdit::ResetKey);
|
|
||||||
QObject::connect(clear, &QPushButton::clicked, edit, &OBSHotkeyEdit::ClearKey);
|
|
||||||
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::KeyChanged, [&](obs_key_combination) { emit KeyChanged(); });
|
|
||||||
QObject::connect(edit, &OBSHotkeyEdit::SearchKey, [=](obs_key_combination combo) { emit SearchKey(combo); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::RemoveEdit(size_t idx, bool signal)
|
|
||||||
{
|
|
||||||
auto &edit = *(begin(edits) + idx);
|
|
||||||
if (!obs_key_combination_is_empty(edit->original) && signal) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
revertButtons.erase(begin(revertButtons) + idx);
|
|
||||||
removeButtons.erase(begin(removeButtons) + idx);
|
|
||||||
edits.erase(begin(edits) + idx);
|
|
||||||
|
|
||||||
auto item = layout()->takeAt(static_cast<int>(idx));
|
|
||||||
QLayoutItem *child = nullptr;
|
|
||||||
while ((child = item->layout()->takeAt(0))) {
|
|
||||||
delete child->widget();
|
|
||||||
delete child;
|
|
||||||
}
|
|
||||||
delete item;
|
|
||||||
|
|
||||||
if (removeButtons.size() == 1)
|
|
||||||
removeButtons.front()->setEnabled(false);
|
|
||||||
|
|
||||||
emit KeyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::BindingsChanged(void *data, calldata_t *param)
|
|
||||||
{
|
|
||||||
auto widget = static_cast<OBSHotkeyWidget *>(data);
|
|
||||||
auto key = static_cast<obs_hotkey_t *>(calldata_ptr(param, "key"));
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(widget, "HandleChangedBindings", Q_ARG(obs_hotkey_id, obs_hotkey_get_id(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::HandleChangedBindings(obs_hotkey_id id_)
|
|
||||||
{
|
|
||||||
if (ignoreChangedBindings || id != id_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::vector<obs_key_combination_t> bindings;
|
|
||||||
auto LoadBindings = [&](obs_hotkey_binding_t *binding) {
|
|
||||||
if (obs_hotkey_binding_get_hotkey_id(binding) != id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto get_combo = obs_hotkey_binding_get_key_combination;
|
|
||||||
bindings.push_back(get_combo(binding));
|
|
||||||
};
|
|
||||||
using LoadBindings_t = decltype(&LoadBindings);
|
|
||||||
|
|
||||||
obs_enum_hotkey_bindings(
|
|
||||||
[](void *data, size_t, obs_hotkey_binding_t *binding) {
|
|
||||||
auto LoadBindings = *static_cast<LoadBindings_t>(data);
|
|
||||||
LoadBindings(binding);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
static_cast<void *>(&LoadBindings));
|
|
||||||
|
|
||||||
while (edits.size() > 0)
|
|
||||||
RemoveEdit(edits.size() - 1, false);
|
|
||||||
|
|
||||||
SetKeyCombinations(bindings);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void updateStyle(QWidget *widget)
|
static inline void updateStyle(QWidget *widget)
|
||||||
{
|
{
|
||||||
@ -414,24 +31,6 @@ static inline void updateStyle(QWidget *widget)
|
|||||||
widget->update();
|
widget->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSHotkeyWidget::enterEvent(QEnterEvent *event)
|
|
||||||
{
|
|
||||||
if (!label)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
label->highlightPair(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
if (!label)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
label->highlightPair(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::highlightPair(bool highlight)
|
void OBSHotkeyLabel::highlightPair(bool highlight)
|
||||||
{
|
{
|
||||||
if (!pairPartner)
|
if (!pairPartner)
|
||||||
|
@ -17,27 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
static inline bool operator!=(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
|
||||||
{
|
|
||||||
return c1.modifiers != c2.modifiers || c1.key != c2.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool operator==(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
|
||||||
{
|
|
||||||
return !(c1 != c2);
|
|
||||||
}
|
|
||||||
|
|
||||||
class OBSBasicSettings;
|
|
||||||
class OBSHotkeyWidget;
|
class OBSHotkeyWidget;
|
||||||
|
|
||||||
class OBSHotkeyLabel : public QLabel {
|
class OBSHotkeyLabel : public QLabel {
|
||||||
@ -51,140 +33,3 @@ public:
|
|||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
void setToolTip(const QString &toolTip);
|
void setToolTip(const QString &toolTip);
|
||||||
};
|
};
|
||||||
|
|
||||||
class OBSHotkeyEdit : public QLineEdit {
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSHotkeyEdit(QWidget *parent, obs_key_combination_t original, OBSBasicSettings *settings)
|
|
||||||
: QLineEdit(parent),
|
|
||||||
original(original),
|
|
||||||
settings(settings)
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// disable the input cursor on OSX, focus should be clear
|
|
||||||
// enough with the default focus frame
|
|
||||||
setReadOnly(true);
|
|
||||||
#endif
|
|
||||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
|
||||||
InitSignalHandler();
|
|
||||||
ResetKey();
|
|
||||||
}
|
|
||||||
OBSHotkeyEdit(QWidget *parent = nullptr) : QLineEdit(parent), original({}), settings(nullptr)
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// disable the input cursor on OSX, focus should be clear
|
|
||||||
// enough with the default focus frame
|
|
||||||
setReadOnly(true);
|
|
||||||
#endif
|
|
||||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
|
||||||
InitSignalHandler();
|
|
||||||
ResetKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
obs_key_combination_t original;
|
|
||||||
obs_key_combination_t key;
|
|
||||||
OBSBasicSettings *settings;
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
void UpdateDuplicationState();
|
|
||||||
bool hasDuplicate = false;
|
|
||||||
QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
OBSSignal layoutChanged;
|
|
||||||
QAction *dupeIcon = nullptr;
|
|
||||||
|
|
||||||
void InitSignalHandler();
|
|
||||||
void CreateDupeIcon();
|
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void keyReleaseEvent(QKeyEvent *event) override;
|
|
||||||
#endif
|
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
|
|
||||||
void RenderKey();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void HandleNewKey(obs_key_combination_t new_key);
|
|
||||||
void ReloadKeyLayout();
|
|
||||||
void ResetKey();
|
|
||||||
void ClearKey();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void KeyChanged(obs_key_combination_t);
|
|
||||||
void SearchKey(obs_key_combination_t);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OBSHotkeyWidget : public QWidget {
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSHotkeyWidget(QWidget *parent, obs_hotkey_id id, std::string name, OBSBasicSettings *settings,
|
|
||||||
const std::vector<obs_key_combination_t> &combos = {})
|
|
||||||
: QWidget(parent),
|
|
||||||
id(id),
|
|
||||||
name(name),
|
|
||||||
bindingsChanged(obs_get_signal_handler(), "hotkey_bindings_changed",
|
|
||||||
&OBSHotkeyWidget::BindingsChanged, this),
|
|
||||||
settings(settings)
|
|
||||||
{
|
|
||||||
auto layout = new QVBoxLayout;
|
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
SetKeyCombinations(combos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetKeyCombinations(const std::vector<obs_key_combination_t> &);
|
|
||||||
|
|
||||||
obs_hotkey_id id;
|
|
||||||
std::string name;
|
|
||||||
|
|
||||||
bool changed = false;
|
|
||||||
bool Changed() const;
|
|
||||||
|
|
||||||
QPointer<OBSHotkeyLabel> label;
|
|
||||||
std::vector<QPointer<OBSHotkeyEdit>> edits;
|
|
||||||
|
|
||||||
QString toolTip;
|
|
||||||
void setToolTip(const QString &toolTip_)
|
|
||||||
{
|
|
||||||
toolTip = toolTip_;
|
|
||||||
for (auto &edit : edits)
|
|
||||||
edit->setToolTip(toolTip_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Apply();
|
|
||||||
void GetCombinations(std::vector<obs_key_combination_t> &) const;
|
|
||||||
void Save();
|
|
||||||
void Save(std::vector<obs_key_combination_t> &combinations);
|
|
||||||
|
|
||||||
void enterEvent(QEnterEvent *event) override;
|
|
||||||
void leaveEvent(QEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void AddEdit(obs_key_combination combo, int idx = -1);
|
|
||||||
void RemoveEdit(size_t idx, bool signal = true);
|
|
||||||
|
|
||||||
static void BindingsChanged(void *data, calldata_t *param);
|
|
||||||
|
|
||||||
std::vector<QPointer<QPushButton>> removeButtons;
|
|
||||||
std::vector<QPointer<QPushButton>> revertButtons;
|
|
||||||
OBSSignal bindingsChanged;
|
|
||||||
bool ignoreChangedBindings = false;
|
|
||||||
OBSBasicSettings *settings;
|
|
||||||
|
|
||||||
QVBoxLayout *layout() const { return dynamic_cast<QVBoxLayout *>(QWidget::layout()); }
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void HandleChangedBindings(obs_hotkey_id id_);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void KeyChanged();
|
|
||||||
void SearchKey(obs_key_combination_t);
|
|
||||||
};
|
|
||||||
|
@ -13,207 +13,16 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "window-basic-settings.hpp"
|
#include "OBSHotkeyWidget.hpp"
|
||||||
#include "moc_hotkey-edit.cpp"
|
#include "OBSHotkeyLabel.hpp"
|
||||||
|
|
||||||
#include <util/dstr.hpp>
|
#include <OBSApp.hpp>
|
||||||
#include <QPointer>
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QAction>
|
|
||||||
#include <qt-wrappers.hpp>
|
|
||||||
|
|
||||||
#include "obs-app.hpp"
|
#include <QEnterEvent>
|
||||||
|
|
||||||
void OBSHotkeyEdit::keyPressEvent(QKeyEvent *event)
|
#include "moc_OBSHotkeyWidget.cpp"
|
||||||
{
|
|
||||||
if (event->isAutoRepeat())
|
|
||||||
return;
|
|
||||||
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
switch (event->key()) {
|
|
||||||
case Qt::Key_Shift:
|
|
||||||
case Qt::Key_Control:
|
|
||||||
case Qt::Key_Alt:
|
|
||||||
case Qt::Key_Meta:
|
|
||||||
new_key.key = OBS_KEY_NONE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
case Qt::Key_CapsLock:
|
|
||||||
// kVK_CapsLock == 57
|
|
||||||
new_key.key = obs_key_from_virtual_key(57);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
new_key.key = obs_key_from_virtual_key(event->nativeVirtualKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant OBSHotkeyEdit::inputMethodQuery(Qt::InputMethodQuery query) const
|
|
||||||
{
|
|
||||||
if (query == Qt::ImEnabled) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return QLineEdit::inputMethodQuery(query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void OBSHotkeyEdit::keyReleaseEvent(QKeyEvent *event)
|
|
||||||
{
|
|
||||||
if (event->isAutoRepeat())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event->key() != Qt::Key_CapsLock)
|
|
||||||
return;
|
|
||||||
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
// kVK_CapsLock == 57
|
|
||||||
new_key.key = obs_key_from_virtual_key(57);
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
obs_key_combination_t new_key;
|
|
||||||
|
|
||||||
switch (event->button()) {
|
|
||||||
case Qt::NoButton:
|
|
||||||
case Qt::LeftButton:
|
|
||||||
case Qt::RightButton:
|
|
||||||
case Qt::AllButtons:
|
|
||||||
case Qt::MouseButtonMask:
|
|
||||||
return;
|
|
||||||
|
|
||||||
case Qt::MiddleButton:
|
|
||||||
new_key.key = OBS_KEY_MOUSE3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#define MAP_BUTTON(i, j) \
|
|
||||||
case Qt::ExtraButton##i: \
|
|
||||||
new_key.key = OBS_KEY_MOUSE##j; \
|
|
||||||
break;
|
|
||||||
MAP_BUTTON(1, 4)
|
|
||||||
MAP_BUTTON(2, 5)
|
|
||||||
MAP_BUTTON(3, 6)
|
|
||||||
MAP_BUTTON(4, 7)
|
|
||||||
MAP_BUTTON(5, 8)
|
|
||||||
MAP_BUTTON(6, 9)
|
|
||||||
MAP_BUTTON(7, 10)
|
|
||||||
MAP_BUTTON(8, 11)
|
|
||||||
MAP_BUTTON(9, 12)
|
|
||||||
MAP_BUTTON(10, 13)
|
|
||||||
MAP_BUTTON(11, 14)
|
|
||||||
MAP_BUTTON(12, 15)
|
|
||||||
MAP_BUTTON(13, 16)
|
|
||||||
MAP_BUTTON(14, 17)
|
|
||||||
MAP_BUTTON(15, 18)
|
|
||||||
MAP_BUTTON(16, 19)
|
|
||||||
MAP_BUTTON(17, 20)
|
|
||||||
MAP_BUTTON(18, 21)
|
|
||||||
MAP_BUTTON(19, 22)
|
|
||||||
MAP_BUTTON(20, 23)
|
|
||||||
MAP_BUTTON(21, 24)
|
|
||||||
MAP_BUTTON(22, 25)
|
|
||||||
MAP_BUTTON(23, 26)
|
|
||||||
MAP_BUTTON(24, 27)
|
|
||||||
#undef MAP_BUTTON
|
|
||||||
}
|
|
||||||
|
|
||||||
new_key.modifiers = TranslateQtKeyboardEventModifiers(event->modifiers());
|
|
||||||
|
|
||||||
HandleNewKey(new_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::HandleNewKey(obs_key_combination_t new_key)
|
|
||||||
{
|
|
||||||
if (new_key == key || obs_key_combination_is_empty(new_key))
|
|
||||||
return;
|
|
||||||
|
|
||||||
key = new_key;
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::RenderKey()
|
|
||||||
{
|
|
||||||
DStr str;
|
|
||||||
obs_key_combination_to_str(key, str);
|
|
||||||
|
|
||||||
setText(QT_UTF8(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ResetKey()
|
|
||||||
{
|
|
||||||
key = original;
|
|
||||||
|
|
||||||
changed = false;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ClearKey()
|
|
||||||
{
|
|
||||||
key = {0, OBS_KEY_NONE};
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
emit KeyChanged(key);
|
|
||||||
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::UpdateDuplicationState()
|
|
||||||
{
|
|
||||||
if (!dupeIcon && !hasDuplicate)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!dupeIcon)
|
|
||||||
CreateDupeIcon();
|
|
||||||
|
|
||||||
if (dupeIcon->isVisible() != hasDuplicate) {
|
|
||||||
dupeIcon->setVisible(hasDuplicate);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::InitSignalHandler()
|
|
||||||
{
|
|
||||||
layoutChanged = {obs_get_signal_handler(), "hotkey_layout_change",
|
|
||||||
[](void *this_, calldata_t *) {
|
|
||||||
auto edit = static_cast<OBSHotkeyEdit *>(this_);
|
|
||||||
QMetaObject::invokeMethod(edit, "ReloadKeyLayout");
|
|
||||||
},
|
|
||||||
this};
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::CreateDupeIcon()
|
|
||||||
{
|
|
||||||
dupeIcon = addAction(settings->GetHotkeyConflictIcon(), ActionPosition::TrailingPosition);
|
|
||||||
dupeIcon->setToolTip(QTStr("Basic.Settings.Hotkeys.DuplicateWarning"));
|
|
||||||
QObject::connect(dupeIcon, &QAction::triggered, [=] { emit SearchKey(key); });
|
|
||||||
dupeIcon->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyEdit::ReloadKeyLayout()
|
|
||||||
{
|
|
||||||
RenderKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::SetKeyCombinations(const std::vector<obs_key_combination_t> &combos)
|
void OBSHotkeyWidget::SetKeyCombinations(const std::vector<obs_key_combination_t> &combos)
|
||||||
{
|
{
|
||||||
@ -406,14 +215,6 @@ void OBSHotkeyWidget::HandleChangedBindings(obs_hotkey_id id_)
|
|||||||
SetKeyCombinations(bindings);
|
SetKeyCombinations(bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void updateStyle(QWidget *widget)
|
|
||||||
{
|
|
||||||
auto style = widget->style();
|
|
||||||
style->unpolish(widget);
|
|
||||||
style->polish(widget);
|
|
||||||
widget->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyWidget::enterEvent(QEnterEvent *event)
|
void OBSHotkeyWidget::enterEvent(QEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (!label)
|
if (!label)
|
||||||
@ -431,40 +232,3 @@ void OBSHotkeyWidget::leaveEvent(QEvent *event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
label->highlightPair(false);
|
label->highlightPair(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSHotkeyLabel::highlightPair(bool highlight)
|
|
||||||
{
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pairPartner->setProperty("class", highlight ? "text-bright" : "");
|
|
||||||
updateStyle(pairPartner);
|
|
||||||
setProperty("class", highlight ? "text-bright" : "");
|
|
||||||
updateStyle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::enterEvent(QEnterEvent *event)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
highlightPair(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
if (!pairPartner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event->accept();
|
|
||||||
highlightPair(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OBSHotkeyLabel::setToolTip(const QString &toolTip)
|
|
||||||
{
|
|
||||||
QLabel::setToolTip(toolTip);
|
|
||||||
if (widget)
|
|
||||||
widget->setToolTip(toolTip);
|
|
||||||
}
|
|
||||||
|
@ -17,107 +17,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include "OBSHotkeyEdit.hpp"
|
||||||
#include <QKeyEvent>
|
|
||||||
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
#include <obs.hpp>
|
|
||||||
|
|
||||||
static inline bool operator!=(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
|
||||||
{
|
|
||||||
return c1.modifiers != c2.modifiers || c1.key != c2.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool operator==(const obs_key_combination_t &c1, const obs_key_combination_t &c2)
|
|
||||||
{
|
|
||||||
return !(c1 != c2);
|
|
||||||
}
|
|
||||||
|
|
||||||
class OBSBasicSettings;
|
class OBSBasicSettings;
|
||||||
class OBSHotkeyWidget;
|
class OBSHotkeyLabel;
|
||||||
|
|
||||||
class OBSHotkeyLabel : public QLabel {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
QPointer<OBSHotkeyLabel> pairPartner;
|
|
||||||
QPointer<OBSHotkeyWidget> widget;
|
|
||||||
void highlightPair(bool highlight);
|
|
||||||
void enterEvent(QEnterEvent *event) override;
|
|
||||||
void leaveEvent(QEvent *event) override;
|
|
||||||
void setToolTip(const QString &toolTip);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OBSHotkeyEdit : public QLineEdit {
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
OBSHotkeyEdit(QWidget *parent, obs_key_combination_t original, OBSBasicSettings *settings)
|
|
||||||
: QLineEdit(parent),
|
|
||||||
original(original),
|
|
||||||
settings(settings)
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// disable the input cursor on OSX, focus should be clear
|
|
||||||
// enough with the default focus frame
|
|
||||||
setReadOnly(true);
|
|
||||||
#endif
|
|
||||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
|
||||||
InitSignalHandler();
|
|
||||||
ResetKey();
|
|
||||||
}
|
|
||||||
OBSHotkeyEdit(QWidget *parent = nullptr) : QLineEdit(parent), original({}), settings(nullptr)
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// disable the input cursor on OSX, focus should be clear
|
|
||||||
// enough with the default focus frame
|
|
||||||
setReadOnly(true);
|
|
||||||
#endif
|
|
||||||
setAttribute(Qt::WA_InputMethodEnabled, false);
|
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, true);
|
|
||||||
InitSignalHandler();
|
|
||||||
ResetKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
obs_key_combination_t original;
|
|
||||||
obs_key_combination_t key;
|
|
||||||
OBSBasicSettings *settings;
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
void UpdateDuplicationState();
|
|
||||||
bool hasDuplicate = false;
|
|
||||||
QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
OBSSignal layoutChanged;
|
|
||||||
QAction *dupeIcon = nullptr;
|
|
||||||
|
|
||||||
void InitSignalHandler();
|
|
||||||
void CreateDupeIcon();
|
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void keyReleaseEvent(QKeyEvent *event) override;
|
|
||||||
#endif
|
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
|
|
||||||
void RenderKey();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void HandleNewKey(obs_key_combination_t new_key);
|
|
||||||
void ReloadKeyLayout();
|
|
||||||
void ResetKey();
|
|
||||||
void ClearKey();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void KeyChanged(obs_key_combination_t);
|
|
||||||
void SearchKey(obs_key_combination_t);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OBSHotkeyWidget : public QWidget {
|
class OBSHotkeyWidget : public QWidget {
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user