window-basic-settings.hpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. Philippe Groarke <[email protected]>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ******************************************************************************/
  15. #pragma once
  16. #include <util/util.hpp>
  17. #include <QDialog>
  18. #include <memory>
  19. #include <string>
  20. #include <libff/ff-util.h>
  21. #include <obs.h>
  22. class OBSBasic;
  23. class QAbstractButton;
  24. class QComboBox;
  25. class QCheckBox;
  26. class QLabel;
  27. class OBSPropertiesView;
  28. class OBSHotkeyWidget;
  29. #include "ui_OBSBasicSettings.h"
  30. class SilentUpdateCheckBox : public QCheckBox {
  31. Q_OBJECT
  32. public slots:
  33. void setCheckedSilently(bool checked)
  34. {
  35. bool blocked = blockSignals(true);
  36. setChecked(checked);
  37. blockSignals(blocked);
  38. }
  39. };
  40. class SilentUpdateSpinBox : public QSpinBox {
  41. Q_OBJECT
  42. public slots:
  43. void setValueSilently(int val)
  44. {
  45. bool blocked = blockSignals(true);
  46. setValue(val);
  47. blockSignals(blocked);
  48. }
  49. };
  50. class OBSFFDeleter
  51. {
  52. public:
  53. void operator()(const ff_format_desc *format)
  54. {
  55. ff_format_desc_free(format);
  56. }
  57. void operator()(const ff_codec_desc *codec)
  58. {
  59. ff_codec_desc_free(codec);
  60. }
  61. };
  62. using OBSFFCodecDesc = std::unique_ptr<const ff_codec_desc,
  63. OBSFFDeleter>;
  64. using OBSFFFormatDesc = std::unique_ptr<const ff_format_desc,
  65. OBSFFDeleter>;
  66. class OBSBasicSettings : public QDialog {
  67. Q_OBJECT
  68. private:
  69. OBSBasic *main;
  70. std::unique_ptr<Ui::OBSBasicSettings> ui;
  71. bool generalChanged = false;
  72. bool stream1Changed = false;
  73. bool outputsChanged = false;
  74. bool audioChanged = false;
  75. bool videoChanged = false;
  76. bool hotkeysChanged = false;
  77. bool advancedChanged = false;
  78. int pageIndex = 0;
  79. bool loading = true;
  80. std::string savedTheme;
  81. int lastSimpleRecQualityIdx = 0;
  82. int lastChannelSetupIdx = 0;
  83. OBSFFFormatDesc formats;
  84. OBSPropertiesView *streamProperties = nullptr;
  85. OBSPropertiesView *streamEncoderProps = nullptr;
  86. OBSPropertiesView *recordEncoderProps = nullptr;
  87. QPointer<QLabel> advOutRecWarning;
  88. QPointer<QLabel> simpleOutRecWarning;
  89. QString curPreset;
  90. QString curQSVPreset;
  91. QString curNVENCPreset;
  92. QString curAMDPreset;
  93. QString curAdvStreamEncoder;
  94. QString curAdvRecordEncoder;
  95. using AudioSource_t =
  96. std::tuple<OBSWeakSource,
  97. QPointer<QCheckBox>, QPointer<QSpinBox>,
  98. QPointer<QCheckBox>, QPointer<QSpinBox>>;
  99. std::vector<AudioSource_t> audioSources;
  100. std::vector<OBSSignal> audioSourceSignals;
  101. OBSSignal sourceCreated;
  102. OBSSignal channelChanged;
  103. std::vector<std::pair<bool, QPointer<OBSHotkeyWidget>>> hotkeys;
  104. OBSSignal hotkeyRegistered;
  105. OBSSignal hotkeyUnregistered;
  106. uint32_t outputCX = 0;
  107. uint32_t outputCY = 0;
  108. void SaveCombo(QComboBox *widget, const char *section,
  109. const char *value);
  110. void SaveComboData(QComboBox *widget, const char *section,
  111. const char *value);
  112. void SaveCheckBox(QAbstractButton *widget, const char *section,
  113. const char *value, bool invert = false);
  114. void SaveEdit(QLineEdit *widget, const char *section,
  115. const char *value);
  116. void SaveSpinBox(QSpinBox *widget, const char *section,
  117. const char *value);
  118. void SaveFormat(QComboBox *combo);
  119. void SaveEncoder(QComboBox *combo, const char *section,
  120. const char *value);
  121. inline bool Changed() const
  122. {
  123. return generalChanged || outputsChanged || stream1Changed ||
  124. audioChanged || videoChanged || advancedChanged ||
  125. hotkeysChanged;
  126. }
  127. inline void EnableApplyButton(bool en)
  128. {
  129. ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(en);
  130. }
  131. inline void ClearChanged()
  132. {
  133. generalChanged = false;
  134. stream1Changed = false;
  135. outputsChanged = false;
  136. audioChanged = false;
  137. videoChanged = false;
  138. hotkeysChanged = false;
  139. advancedChanged= false;
  140. EnableApplyButton(false);
  141. }
  142. #ifdef _WIN32
  143. bool aeroWasDisabled = false;
  144. QCheckBox *toggleAero = nullptr;
  145. void ToggleDisableAero(bool checked);
  146. #endif
  147. void HookWidget(QWidget *widget, const char *signal, const char *slot);
  148. bool QueryChanges();
  149. void LoadServiceTypes();
  150. void LoadEncoderTypes();
  151. void LoadColorRanges();
  152. void LoadFormats();
  153. void ReloadCodecs(const ff_format_desc *formatDesc);
  154. void LoadGeneralSettings();
  155. void LoadStream1Settings();
  156. void LoadOutputSettings();
  157. void LoadAudioSettings();
  158. void LoadVideoSettings();
  159. void LoadHotkeySettings(obs_hotkey_id ignoreKey=OBS_INVALID_HOTKEY_ID);
  160. void LoadAdvancedSettings();
  161. void LoadSettings(bool changedOnly);
  162. OBSPropertiesView *CreateEncoderPropertyView(const char *encoder,
  163. const char *path, bool changed = false);
  164. /* general */
  165. void LoadLanguageList();
  166. void LoadThemeList();
  167. /* output */
  168. void LoadSimpleOutputSettings();
  169. void LoadAdvOutputStreamingSettings();
  170. void LoadAdvOutputStreamingEncoderProperties();
  171. void LoadAdvOutputRecordingSettings();
  172. void LoadAdvOutputRecordingEncoderProperties();
  173. void LoadAdvOutputFFmpegSettings();
  174. void LoadAdvOutputAudioSettings();
  175. void SetAdvOutputFFmpegEnablement(
  176. ff_codec_type encoderType, bool enabled,
  177. bool enableEncode = false);
  178. /* audio */
  179. void LoadListValues(QComboBox *widget, obs_property_t *prop, int index);
  180. void LoadAudioDevices();
  181. void LoadAudioSources();
  182. /* video */
  183. void LoadRendererList();
  184. void ResetDownscales(uint32_t cx, uint32_t cy);
  185. void LoadDownscaleFilters();
  186. void LoadResolutionLists();
  187. void LoadFPSData();
  188. void SaveGeneralSettings();
  189. void SaveStream1Settings();
  190. void SaveOutputSettings();
  191. void SaveAudioSettings();
  192. void SaveVideoSettings();
  193. void SaveHotkeySettings();
  194. void SaveAdvancedSettings();
  195. void SaveSettings();
  196. void UpdateSimpleOutStreamDelayEstimate();
  197. void UpdateAdvOutStreamDelayEstimate();
  198. void FillSimpleRecordingValues();
  199. void FillSimpleStreamingValues();
  200. void FillAudioMonitoringDevices();
  201. void RecalcOutputResPixels(const char *resText);
  202. private slots:
  203. void on_theme_activated(int idx);
  204. void on_listWidget_itemSelectionChanged();
  205. void on_buttonBox_clicked(QAbstractButton *button);
  206. void on_streamType_currentIndexChanged(int idx);
  207. void on_simpleOutputBrowse_clicked();
  208. void on_advOutRecPathBrowse_clicked();
  209. void on_advOutFFPathBrowse_clicked();
  210. void on_advOutEncoder_currentIndexChanged(int idx);
  211. void on_advOutRecEncoder_currentIndexChanged(int idx);
  212. void on_advOutFFIgnoreCompat_stateChanged(int state);
  213. void on_advOutFFFormat_currentIndexChanged(int idx);
  214. void on_advOutFFAEncoder_currentIndexChanged(int idx);
  215. void on_advOutFFVEncoder_currentIndexChanged(int idx);
  216. void on_advOutFFType_currentIndexChanged(int idx);
  217. void on_colorFormat_currentIndexChanged(const QString &text);
  218. void on_filenameFormatting_textEdited(const QString &text);
  219. void on_outputResolution_editTextChanged(const QString &text);
  220. void on_baseResolution_editTextChanged(const QString &text);
  221. void on_disableOSXVSync_clicked();
  222. void GeneralChanged();
  223. void AudioChanged();
  224. void AudioChangedRestart();
  225. void ReloadAudioSources();
  226. void SurroundWarning(int idx);
  227. void SpeakerLayoutChanged(int idx);
  228. void OutputsChanged();
  229. void Stream1Changed();
  230. void VideoChanged();
  231. void VideoChangedResolution();
  232. void VideoChangedRestart();
  233. void HotkeysChanged();
  234. void ReloadHotkeys(obs_hotkey_id ignoreKey=OBS_INVALID_HOTKEY_ID);
  235. void AdvancedChanged();
  236. void AdvancedChangedRestart();
  237. void UpdateStreamDelayEstimate();
  238. void UpdateAutomaticReplayBufferCheckboxes();
  239. void AdvOutRecCheckWarnings();
  240. void SimpleRecordingQualityChanged();
  241. void SimpleRecordingEncoderChanged();
  242. void SimpleRecordingQualityLosslessWarning(int idx);
  243. void SimpleReplayBufferChanged();
  244. void AdvReplayBufferChanged();
  245. void SimpleStreamingEncoderChanged();
  246. protected:
  247. virtual void closeEvent(QCloseEvent *event);
  248. public:
  249. OBSBasicSettings(QWidget *parent);
  250. ~OBSBasicSettings();
  251. };