yolobs-studio/UI/window-basic-settings.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

410 lines
11 KiB
C++
Raw Permalink Normal View History

2016-02-23 23:16:51 +00:00
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
Philippe Groarke <philippe.groarke@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include <util/util.hpp>
#include <QDialog>
2019-07-27 12:47:10 +00:00
#include <QPointer>
2016-02-23 23:16:51 +00:00
#include <memory>
#include <string>
#include <libff/ff-util.h>
2019-07-27 12:47:10 +00:00
#include <obs.hpp>
#include "auth-base.hpp"
2016-02-23 23:16:51 +00:00
class OBSBasic;
class QAbstractButton;
2020-12-22 17:32:50 +00:00
class QRadioButton;
2016-02-23 23:16:51 +00:00
class QComboBox;
class QCheckBox;
class QLabel;
class OBSPropertiesView;
class OBSHotkeyWidget;
#include "ui_OBSBasicSettings.h"
2019-09-22 21:19:10 +00:00
#define VOLUME_METER_DECAY_FAST 23.53
#define VOLUME_METER_DECAY_MEDIUM 11.76
#define VOLUME_METER_DECAY_SLOW 8.57
2018-02-19 19:54:37 +00:00
2016-02-23 23:16:51 +00:00
class SilentUpdateCheckBox : public QCheckBox {
Q_OBJECT
public slots:
void setCheckedSilently(bool checked)
{
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);
}
};
2019-09-22 21:19:10 +00:00
class OBSFFDeleter {
2016-02-23 23:16:51 +00:00
public:
void operator()(const ff_format_desc *format)
{
ff_format_desc_free(format);
}
void operator()(const ff_codec_desc *codec)
{
ff_codec_desc_free(codec);
}
};
2019-09-22 21:19:10 +00:00
using OBSFFCodecDesc = std::unique_ptr<const ff_codec_desc, OBSFFDeleter>;
using OBSFFFormatDesc = std::unique_ptr<const ff_format_desc, OBSFFDeleter>;
2016-02-23 23:16:51 +00:00
class OBSBasicSettings : public QDialog {
Q_OBJECT
2019-09-22 21:19:10 +00:00
Q_PROPERTY(QIcon generalIcon READ GetGeneralIcon WRITE SetGeneralIcon
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 advancedIcon READ GetAdvancedIcon WRITE SetAdvancedIcon
DESIGNABLE true)
2016-02-23 23:16:51 +00:00
private:
OBSBasic *main;
std::unique_ptr<Ui::OBSBasicSettings> ui;
2019-07-27 12:47:10 +00:00
std::shared_ptr<Auth> auth;
2016-02-23 23:16:51 +00:00
bool generalChanged = false;
bool stream1Changed = false;
bool outputsChanged = false;
bool audioChanged = false;
bool videoChanged = false;
bool hotkeysChanged = false;
bool advancedChanged = false;
2019-09-22 21:19:10 +00:00
int pageIndex = 0;
2016-02-23 23:16:51 +00:00
bool loading = true;
2020-03-25 08:07:22 +00:00
bool forceAuthReload = false;
2016-02-23 23:16:51 +00:00
std::string savedTheme;
2020-03-25 08:07:22 +00:00
int sampleRateIndex = 0;
int channelIndex = 0;
2016-02-23 23:16:51 +00:00
int lastSimpleRecQualityIdx = 0;
2020-12-22 17:32:50 +00:00
int lastServiceIdx = -1;
int lastIgnoreRecommended = -1;
2018-02-19 19:54:37 +00:00
int lastChannelSetupIdx = 0;
2016-02-23 23:16:51 +00:00
OBSFFFormatDesc formats;
OBSPropertiesView *streamProperties = nullptr;
OBSPropertiesView *streamEncoderProps = nullptr;
OBSPropertiesView *recordEncoderProps = nullptr;
QPointer<QLabel> advOutRecWarning;
QPointer<QLabel> simpleOutRecWarning;
2016-05-24 19:53:01 +00:00
QString curPreset;
QString curQSVPreset;
QString curNVENCPreset;
2017-04-19 19:54:15 +00:00
QString curAMDPreset;
2016-05-24 19:53:01 +00:00
QString curAdvStreamEncoder;
QString curAdvRecordEncoder;
2016-02-23 23:16:51 +00:00
using AudioSource_t =
2019-09-22 21:19:10 +00:00
std::tuple<OBSWeakSource, QPointer<QCheckBox>,
QPointer<QSpinBox>, QPointer<QCheckBox>,
QPointer<QSpinBox>>;
2016-02-23 23:16:51 +00:00
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;
2020-12-22 17:32:50 +00:00
QPointer<QCheckBox> simpleVodTrack;
QPointer<QCheckBox> vodTrackCheckbox;
QPointer<QWidget> vodTrackContainer;
QPointer<QRadioButton> vodTrack[MAX_AUDIO_MIXES];
2016-02-23 23:16:51 +00:00
void SaveCombo(QComboBox *widget, const char *section,
2019-09-22 21:19:10 +00:00
const char *value);
2016-02-23 23:16:51 +00:00
void SaveComboData(QComboBox *widget, const char *section,
2019-09-22 21:19:10 +00:00
const char *value);
2016-02-23 23:16:51 +00:00
void SaveCheckBox(QAbstractButton *widget, const char *section,
2019-09-22 21:19:10 +00:00
const char *value, bool invert = false);
2016-02-23 23:16:51 +00:00
void SaveEdit(QLineEdit *widget, const char *section,
2019-09-22 21:19:10 +00:00
const char *value);
2016-02-23 23:16:51 +00:00
void SaveSpinBox(QSpinBox *widget, const char *section,
2019-09-22 21:19:10 +00:00
const char *value);
2016-02-23 23:16:51 +00:00
void SaveFormat(QComboBox *combo);
void SaveEncoder(QComboBox *combo, const char *section,
2019-09-22 21:19:10 +00:00
const char *value);
2016-02-23 23:16:51 +00:00
2020-12-22 17:32:50 +00:00
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);
2016-02-23 23:16:51 +00:00
inline bool Changed() const
{
return generalChanged || outputsChanged || stream1Changed ||
2019-09-22 21:19:10 +00:00
audioChanged || videoChanged || advancedChanged ||
hotkeysChanged;
2016-02-23 23:16:51 +00:00
}
inline void EnableApplyButton(bool en)
{
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(en);
}
inline void ClearChanged()
{
generalChanged = false;
stream1Changed = false;
outputsChanged = false;
2019-09-22 21:19:10 +00:00
audioChanged = false;
videoChanged = false;
2016-02-23 23:16:51 +00:00
hotkeysChanged = false;
2019-09-22 21:19:10 +00:00
advancedChanged = false;
2016-02-23 23:16:51 +00:00
EnableApplyButton(false);
}
#ifdef _WIN32
bool aeroWasDisabled = false;
QCheckBox *toggleAero = nullptr;
void ToggleDisableAero(bool checked);
#endif
void HookWidget(QWidget *widget, const char *signal, const char *slot);
bool QueryChanges();
void LoadEncoderTypes();
void LoadColorRanges();
void LoadFormats();
void ReloadCodecs(const ff_format_desc *formatDesc);
void LoadGeneralSettings();
void LoadStream1Settings();
void LoadOutputSettings();
void LoadAudioSettings();
void LoadVideoSettings();
2019-09-22 21:19:10 +00:00
void
LoadHotkeySettings(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
2016-02-23 23:16:51 +00:00
void LoadAdvancedSettings();
void LoadSettings(bool changedOnly);
OBSPropertiesView *CreateEncoderPropertyView(const char *encoder,
2019-09-22 21:19:10 +00:00
const char *path,
bool changed = false);
2016-02-23 23:16:51 +00:00
/* general */
void LoadLanguageList();
void LoadThemeList();
2019-07-27 12:47:10 +00:00
/* stream */
void InitStreamPage();
inline bool IsCustomService() const;
void LoadServices(bool showAll);
void OnOAuthStreamKeyConnected();
void OnAuthConnected();
QString lastService;
2020-03-25 08:07:22 +00:00
int prevLangIndex;
bool prevBrowserAccel;
2019-07-27 12:47:10 +00:00
private slots:
void UpdateServerList();
void UpdateKeyLink();
2020-12-22 17:32:50 +00:00
void UpdateVodTrackSetting();
void UpdateServiceRecommendations();
void RecreateOutputResolutionWidget();
void UpdateResFPSLimits();
void UpdateMoreInfoLink();
void DisplayEnforceWarning(bool checked);
2019-07-27 12:47:10 +00:00
void on_show_clicked();
void on_authPwShow_clicked();
void on_connectAccount_clicked();
void on_disconnectAccount_clicked();
void on_useStreamKey_clicked();
void on_useAuth_toggled();
2019-09-22 21:19:10 +00:00
private:
2016-02-23 23:16:51 +00:00
/* output */
void LoadSimpleOutputSettings();
void LoadAdvOutputStreamingSettings();
void LoadAdvOutputStreamingEncoderProperties();
void LoadAdvOutputRecordingSettings();
void LoadAdvOutputRecordingEncoderProperties();
void LoadAdvOutputFFmpegSettings();
void LoadAdvOutputAudioSettings();
2019-09-22 21:19:10 +00:00
void SetAdvOutputFFmpegEnablement(ff_codec_type encoderType,
bool enabled,
bool enableEncode = false);
2016-02-23 23:16:51 +00:00
/* audio */
void LoadListValues(QComboBox *widget, obs_property_t *prop, int index);
void LoadAudioDevices();
void LoadAudioSources();
/* video */
void LoadRendererList();
2020-12-22 17:32:50 +00:00
void ResetDownscales(uint32_t cx, uint32_t cy,
bool ignoreAllSignals = false);
2016-02-23 23:16:51 +00:00
void LoadDownscaleFilters();
void LoadResolutionLists();
void LoadFPSData();
void SaveGeneralSettings();
void SaveStream1Settings();
void SaveOutputSettings();
void SaveAudioSettings();
void SaveVideoSettings();
void SaveHotkeySettings();
void SaveAdvancedSettings();
void SaveSettings();
void UpdateSimpleOutStreamDelayEstimate();
void UpdateAdvOutStreamDelayEstimate();
void FillSimpleRecordingValues();
2016-05-24 19:53:01 +00:00
void FillSimpleStreamingValues();
2017-04-19 19:54:15 +00:00
void FillAudioMonitoringDevices();
2016-02-23 23:16:51 +00:00
void RecalcOutputResPixels(const char *resText);
2020-10-01 20:15:25 +00:00
bool AskIfCanCloseSettings();
2019-09-22 21:19:10 +00:00
QIcon generalIcon;
QIcon streamIcon;
QIcon outputIcon;
QIcon audioIcon;
QIcon videoIcon;
QIcon hotkeysIcon;
QIcon advancedIcon;
QIcon GetGeneralIcon() const;
QIcon GetStreamIcon() const;
QIcon GetOutputIcon() const;
QIcon GetAudioIcon() const;
QIcon GetVideoIcon() const;
QIcon GetHotkeysIcon() const;
QIcon GetAdvancedIcon() const;
2020-03-25 08:07:22 +00:00
int CurrentFLVTrack();
2020-12-22 17:32:50 +00:00
OBSService GetStream1Service();
2016-02-23 23:16:51 +00:00
private slots:
void on_theme_activated(int idx);
void on_listWidget_itemSelectionChanged();
void on_buttonBox_clicked(QAbstractButton *button);
2019-07-27 12:47:10 +00:00
void on_service_currentIndexChanged(int idx);
2016-02-23 23:16:51 +00:00
void on_simpleOutputBrowse_clicked();
void on_advOutRecPathBrowse_clicked();
void on_advOutFFPathBrowse_clicked();
void on_advOutEncoder_currentIndexChanged(int idx);
void on_advOutRecEncoder_currentIndexChanged(int idx);
2017-04-19 19:54:15 +00:00
void on_advOutFFIgnoreCompat_stateChanged(int state);
2016-02-23 23:16:51 +00:00
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(const QString &text);
2016-05-24 19:53:01 +00:00
void on_filenameFormatting_textEdited(const QString &text);
2016-02-23 23:16:51 +00:00
void on_outputResolution_editTextChanged(const QString &text);
void on_baseResolution_editTextChanged(const QString &text);
void on_disableOSXVSync_clicked();
void GeneralChanged();
void AudioChanged();
void AudioChangedRestart();
void ReloadAudioSources();
2018-02-19 19:54:37 +00:00
void SurroundWarning(int idx);
void SpeakerLayoutChanged(int idx);
2016-02-23 23:16:51 +00:00
void OutputsChanged();
void Stream1Changed();
void VideoChanged();
void VideoChangedResolution();
void VideoChangedRestart();
void HotkeysChanged();
2019-09-22 21:19:10 +00:00
void ReloadHotkeys(obs_hotkey_id ignoreKey = OBS_INVALID_HOTKEY_ID);
2016-02-23 23:16:51 +00:00
void AdvancedChanged();
void AdvancedChangedRestart();
void UpdateStreamDelayEstimate();
2017-04-19 19:54:15 +00:00
void UpdateAutomaticReplayBufferCheckboxes();
2016-02-23 23:16:51 +00:00
void AdvOutRecCheckWarnings();
void SimpleRecordingQualityChanged();
void SimpleRecordingEncoderChanged();
void SimpleRecordingQualityLosslessWarning(int idx);
2017-04-19 19:54:15 +00:00
void SimpleReplayBufferChanged();
2018-02-19 19:54:37 +00:00
void AdvReplayBufferChanged();
2017-04-19 19:54:15 +00:00
2016-05-24 19:53:01 +00:00
void SimpleStreamingEncoderChanged();
2019-07-27 12:47:10 +00:00
OBSService SpawnTempService();
void SetGeneralIcon(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 SetAdvancedIcon(const QIcon &icon);
2016-02-23 23:16:51 +00:00
protected:
2020-10-01 20:15:25 +00:00
virtual void closeEvent(QCloseEvent *event) override;
void reject() override;
2016-02-23 23:16:51 +00:00
public:
OBSBasicSettings(QWidget *parent);
2017-06-29 19:01:10 +00:00
~OBSBasicSettings();
2016-02-23 23:16:51 +00:00
};