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

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

876 lines
23 KiB
C++
Raw Normal View History

2016-02-23 23:16:51 +00:00
/******************************************************************************
Copyright (C) 2013-2014 by Hugh Bailey <obs.jim@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 <QBuffer>
#include <QAction>
2019-07-27 12:47:10 +00:00
#include <QWidgetAction>
2016-10-10 19:01:40 +00:00
#include <QSystemTrayIcon>
2019-07-27 12:47:10 +00:00
#include <QStyledItemDelegate>
2016-02-23 23:16:51 +00:00
#include <obs.hpp>
#include <vector>
#include <memory>
#include "window-main.hpp"
#include "window-basic-interaction.hpp"
#include "window-basic-properties.hpp"
#include "window-basic-transform.hpp"
#include "window-basic-adv-audio.hpp"
#include "window-basic-filters.hpp"
2018-12-16 16:14:58 +00:00
#include "window-projector.hpp"
2019-07-27 12:47:10 +00:00
#include "window-basic-about.hpp"
#include "auth-base.hpp"
2016-02-23 23:16:51 +00:00
2016-10-10 19:01:40 +00:00
#include <obs-frontend-internal.hpp>
2016-02-23 23:16:51 +00:00
#include <util/platform.h>
#include <util/threading.h>
#include <util/util.hpp>
#include <QPointer>
2017-04-19 19:54:15 +00:00
class QMessageBox;
2016-02-23 23:16:51 +00:00
class QListWidgetItem;
class VolControl;
2017-06-29 19:01:10 +00:00
class OBSBasicStats;
2016-02-23 23:16:51 +00:00
#include "ui_OBSBasic.h"
2018-12-16 16:14:58 +00:00
#include "ui_ColorSelect.h"
2016-02-23 23:16:51 +00:00
#define DESKTOP_AUDIO_1 Str("DesktopAudioDevice1")
#define DESKTOP_AUDIO_2 Str("DesktopAudioDevice2")
2019-09-22 21:19:10 +00:00
#define AUX_AUDIO_1 Str("AuxAudioDevice1")
#define AUX_AUDIO_2 Str("AuxAudioDevice2")
#define AUX_AUDIO_3 Str("AuxAudioDevice3")
#define AUX_AUDIO_4 Str("AuxAudioDevice4")
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
#define SIMPLE_ENCODER_X264 "x264"
#define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu"
#define SIMPLE_ENCODER_QSV "qsv"
#define SIMPLE_ENCODER_NVENC "nvenc"
#define SIMPLE_ENCODER_AMD "amd"
2016-02-23 23:16:51 +00:00
#define PREVIEW_EDGE_SIZE 10
struct BasicOutputHandler;
enum class QtDataRole {
OBSRef = Qt::UserRole,
OBSSignals,
};
2018-12-16 16:14:58 +00:00
struct SavedProjectorInfo {
ProjectorType type;
int monitor;
std::string geometry;
std::string name;
2018-02-19 19:54:37 +00:00
};
2016-02-23 23:16:51 +00:00
struct QuickTransition {
QPushButton *button = nullptr;
OBSSource source;
2018-12-16 16:14:58 +00:00
obs_hotkey_id hotkey = OBS_INVALID_HOTKEY_ID;
2016-02-23 23:16:51 +00:00
int duration = 0;
int id = 0;
inline QuickTransition() {}
inline QuickTransition(OBSSource source_, int duration_, int id_)
2019-09-22 21:19:10 +00:00
: source(source_),
duration(duration_),
id(id_),
renamedSignal(std::make_shared<OBSSignal>(
obs_source_get_signal_handler(source), "rename",
SourceRenamed, this))
{
}
2018-12-16 16:14:58 +00:00
private:
static void SourceRenamed(void *param, calldata_t *data);
std::shared_ptr<OBSSignal> renamedSignal;
2016-02-23 23:16:51 +00:00
};
2019-07-27 12:47:10 +00:00
class ColorSelect : public QWidget {
public:
explicit ColorSelect(QWidget *parent = 0);
private:
std::unique_ptr<Ui::ColorSelect> ui;
};
2016-02-23 23:16:51 +00:00
class OBSBasic : public OBSMainWindow {
Q_OBJECT
2019-07-27 12:47:10 +00:00
friend class OBSAbout;
2016-02-23 23:16:51 +00:00
friend class OBSBasicPreview;
friend class OBSBasicStatusBar;
2016-08-28 12:07:43 +00:00
friend class OBSBasicSourceSelect;
2017-04-19 19:54:15 +00:00
friend class OBSBasicSettings;
2019-07-27 12:47:10 +00:00
friend class Auth;
friend class AutoConfig;
friend class AutoConfigStreamPage;
2019-09-22 21:19:10 +00:00
friend class RecordButton;
friend class ExtraBrowsersModel;
friend class ExtraBrowsersDelegate;
2016-10-10 19:01:40 +00:00
friend struct OBSStudioAPI;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
enum class MoveDir { Up, Down, Left, Right };
2016-02-23 23:16:51 +00:00
2017-04-19 19:54:15 +00:00
enum DropType {
DropType_RawText,
DropType_Text,
DropType_Image,
2018-02-19 19:54:37 +00:00
DropType_Media,
2019-09-22 21:19:10 +00:00
DropType_Html,
2017-04-19 19:54:15 +00:00
};
2016-02-23 23:16:51 +00:00
private:
2016-10-10 19:01:40 +00:00
obs_frontend_callbacks *api = nullptr;
2019-07-27 12:47:10 +00:00
std::shared_ptr<Auth> auth;
2019-09-22 21:19:10 +00:00
std::vector<VolControl *> volumes;
2016-02-23 23:16:51 +00:00
std::vector<OBSSignal> signalHandlers;
2019-07-27 12:47:10 +00:00
QList<QPointer<QDockWidget>> extraDocks;
2016-02-23 23:16:51 +00:00
bool loaded = false;
long disableSaving = 1;
bool projectChanged = false;
bool previewEnabled = true;
2018-02-19 19:54:37 +00:00
bool fullscreenInterface = false;
2016-02-23 23:16:51 +00:00
2017-06-29 19:01:10 +00:00
const char *copyString;
2019-07-27 12:47:10 +00:00
const char *copyFiltersString = nullptr;
2017-06-29 19:01:10 +00:00
bool copyVisible = true;
2018-12-16 16:14:58 +00:00
QScopedPointer<QThread> updateCheckThread;
QScopedPointer<QThread> introCheckThread;
QScopedPointer<QThread> logUploadThread;
2016-02-23 23:16:51 +00:00
QPointer<OBSBasicInteraction> interaction;
QPointer<OBSBasicProperties> properties;
QPointer<OBSBasicTransform> transformWindow;
QPointer<OBSBasicAdvAudio> advAudioWindow;
QPointer<OBSBasicFilters> filters;
2019-07-27 12:47:10 +00:00
QPointer<QDockWidget> statsDock;
QPointer<OBSAbout> about;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
QPointer<QTimer> cpuUsageTimer;
QPointer<QTimer> diskFullTimer;
2016-02-23 23:16:51 +00:00
os_cpu_usage_info_t *cpuUsageInfo = nullptr;
OBSService service;
std::unique_ptr<BasicOutputHandler> outputHandler;
2016-10-10 19:01:40 +00:00
bool streamingStopping = false;
bool recordingStopping = false;
2017-04-19 19:54:15 +00:00
bool replayBufferStopping = false;
2016-02-23 23:16:51 +00:00
gs_vertbuffer_t *box = nullptr;
2016-05-24 19:53:01 +00:00
gs_vertbuffer_t *boxLeft = nullptr;
gs_vertbuffer_t *boxTop = nullptr;
gs_vertbuffer_t *boxRight = nullptr;
gs_vertbuffer_t *boxBottom = nullptr;
2016-02-23 23:16:51 +00:00
gs_vertbuffer_t *circle = nullptr;
2019-09-22 21:19:10 +00:00
bool sceneChanging = false;
bool ignoreSelectionUpdate = false;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
int previewX = 0, previewY = 0;
int previewCX = 0, previewCY = 0;
float previewScale = 0.0f;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
ConfigFile basicConfig;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
std::vector<SavedProjectorInfo *> savedProjectorsArray;
2016-02-23 23:16:51 +00:00
QPointer<QWidget> projectors[10];
2017-06-29 19:01:10 +00:00
QList<QPointer<QWidget>> windowProjectors;
QPointer<QWidget> stats;
2018-12-16 16:14:58 +00:00
QPointer<QWidget> remux;
2019-09-22 21:19:10 +00:00
QPointer<QWidget> extraBrowsers;
2016-02-23 23:16:51 +00:00
QPointer<QMenu> startStreamMenu;
2019-07-27 12:47:10 +00:00
QPointer<QPushButton> transitionButton;
2017-04-19 19:54:15 +00:00
QPointer<QPushButton> replayBufferButton;
2019-09-22 21:19:10 +00:00
QScopedPointer<QPushButton> pause;
2017-04-19 19:54:15 +00:00
2018-12-16 16:14:58 +00:00
QScopedPointer<QSystemTrayIcon> trayIcon;
2019-09-22 21:19:10 +00:00
QPointer<QAction> sysTrayStream;
QPointer<QAction> sysTrayRecord;
QPointer<QAction> sysTrayReplayBuffer;
QPointer<QAction> showHide;
QPointer<QAction> exit;
QPointer<QMenu> trayMenu;
QPointer<QMenu> previewProjector;
QPointer<QMenu> studioProgramProjector;
QPointer<QMenu> multiviewProjectorMenu;
QPointer<QMenu> previewProjectorSource;
QPointer<QMenu> previewProjectorMain;
QPointer<QMenu> sceneProjectorMenu;
QPointer<QMenu> sourceProjector;
QPointer<QMenu> scaleFilteringMenu;
QPointer<QMenu> colorMenu;
QPointer<QWidgetAction> colorWidgetAction;
QPointer<ColorSelect> colorSelect;
QPointer<QMenu> deinterlaceMenu;
QPointer<QMenu> perSceneTransitionMenu;
QPointer<QObject> shortcutFilter;
2019-07-27 12:47:10 +00:00
QPointer<QWidget> programWidget;
QPointer<QVBoxLayout> programLayout;
QPointer<QLabel> programLabel;
QScopedPointer<QThread> patronJsonThread;
std::string patronJson;
2016-10-10 19:01:40 +00:00
2019-09-22 21:19:10 +00:00
void UpdateMultiviewProjectorMenu();
2018-05-29 19:13:02 +00:00
2019-09-22 21:19:10 +00:00
void DrawBackdrop(float cx, float cy);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void SetupEncoders();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void CreateFirstRunSources();
void CreateDefaultScene(bool firstStart);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void UpdateVolumeControlsDecayRate();
void UpdateVolumeControlsPeakMeterType();
void ClearVolumeControls();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void UploadLog(const char *subdir, const char *file);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void Save(const char *file);
void Load(const char *file);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void InitHotkeys();
void CreateHotkeys();
void ClearHotkeys();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
bool InitService();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
bool InitBasicConfigDefaults();
void InitBasicConfigDefaults2();
bool InitBasicConfig();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void InitOBSCallbacks();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void InitPrimitives();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void OnFirstLoad();
2018-12-16 16:14:58 +00:00
2019-09-22 21:19:10 +00:00
OBSSceneItem GetSceneItem(QListWidgetItem *item);
OBSSceneItem GetCurrentSceneItem();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
bool QueryRemoveSource(obs_source_t *source);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void TimedCheckForUpdates();
void CheckForUpdates(bool manualUpdate);
2016-02-23 23:16:51 +00:00
void GetFPSCommon(uint32_t &num, uint32_t &den) const;
void GetFPSInteger(uint32_t &num, uint32_t &den) const;
void GetFPSFraction(uint32_t &num, uint32_t &den) const;
void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
void GetConfigFPS(uint32_t &num, uint32_t &den) const;
2017-04-19 19:54:15 +00:00
void UpdatePreviewScalingMenu();
2016-02-23 23:16:51 +00:00
void LoadSceneListOrder(obs_data_array_t *array);
obs_data_array_t *SaveSceneListOrder();
void ChangeSceneIndex(bool relative, int idx, int invalidIdx);
void TempFileOutput(const char *path, int vBitrate, int aBitrate);
2019-09-22 21:19:10 +00:00
void TempStreamOutput(const char *url, const char *key, int vBitrate,
int aBitrate);
2016-02-23 23:16:51 +00:00
void CloseDialogs();
void ClearSceneData();
void Nudge(int dist, MoveDir dir);
2018-12-16 16:14:58 +00:00
OBSProjector *OpenProjector(obs_source_t *source, int monitor,
2019-09-22 21:19:10 +00:00
QString title, ProjectorType type);
2016-02-23 23:16:51 +00:00
void GetAudioSourceFilters();
void GetAudioSourceProperties();
void VolControlContextMenu();
2018-12-16 16:14:58 +00:00
void ToggleVolControlLayout();
void ToggleMixerLayout(bool vertical);
2016-02-23 23:16:51 +00:00
void RefreshSceneCollections();
void ChangeSceneCollection();
2016-08-28 12:07:43 +00:00
void LogScenes();
2016-02-23 23:16:51 +00:00
void LoadProfile();
void ResetProfileData();
bool AddProfile(bool create_new, const char *title, const char *text,
2019-07-27 12:47:10 +00:00
const char *init_text = nullptr, bool rename = false);
2016-02-23 23:16:51 +00:00
void DeleteProfile(const char *profile_name, const char *profile_dir);
void RefreshProfiles();
void ChangeProfile();
2018-02-19 19:54:37 +00:00
void CheckForSimpleModeX264Fallback();
2016-02-23 23:16:51 +00:00
void SaveProjectNow();
2018-12-16 16:14:58 +00:00
int GetTopSelectedSourceItem();
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
obs_hotkey_pair_id streamingHotkeys, recordingHotkeys, pauseHotkeys,
replayBufHotkeys, togglePreviewHotkeys;
2016-02-23 23:16:51 +00:00
obs_hotkey_id forceStreamingStopHotkey;
void InitDefaultTransitions();
void InitTransition(obs_source_t *transition);
obs_source_t *FindTransition(const char *name);
OBSSource GetCurrentTransition();
2016-05-24 19:53:01 +00:00
obs_data_array_t *SaveTransitions();
void LoadTransitions(obs_data_array_t *transitions);
2016-02-23 23:16:51 +00:00
obs_source_t *fadeTransition;
void CreateProgramDisplay();
void CreateProgramOptions();
void AddQuickTransitionId(int id);
void AddQuickTransition();
void AddQuickTransitionHotkey(QuickTransition *qt);
void RemoveQuickTransitionHotkey(QuickTransition *qt);
void LoadQuickTransitions(obs_data_array_t *array);
obs_data_array_t *SaveQuickTransitions();
2017-06-29 19:01:10 +00:00
void ClearQuickTransitionWidgets();
2016-02-23 23:16:51 +00:00
void RefreshQuickTransitions();
2019-07-27 12:47:10 +00:00
void DisableQuickTransitionWidgets();
void EnableQuickTransitionWidgets();
2016-02-23 23:16:51 +00:00
void CreateDefaultQuickTransitions();
2018-02-19 19:54:37 +00:00
QMenu *CreatePerSceneTransitionMenu();
2016-02-23 23:16:51 +00:00
QuickTransition *GetQuickTransition(int id);
int GetQuickTransitionIdx(int id);
QMenu *CreateTransitionMenu(QWidget *parent, QuickTransition *qt);
void ClearQuickTransitions();
void QuickTransitionClicked();
void QuickTransitionChange();
void QuickTransitionChangeDuration(int value);
void QuickTransitionRemoveClicked();
void SetPreviewProgramMode(bool enabled);
void ResizeProgram(uint32_t cx, uint32_t cy);
2018-02-19 19:54:37 +00:00
void SetCurrentScene(obs_scene_t *scene, bool force = false,
2019-09-22 21:19:10 +00:00
bool direct = false);
2016-02-23 23:16:51 +00:00
static void RenderProgram(void *data, uint32_t cx, uint32_t cy);
std::vector<QuickTransition> quickTransitions;
QPointer<QWidget> programOptions;
QPointer<OBSQTDisplay> program;
OBSWeakSource lastScene;
OBSWeakSource swapScene;
OBSWeakSource programScene;
bool editPropertiesMode = false;
bool sceneDuplicationMode = true;
bool swapScenesMode = true;
volatile bool previewProgramMode = false;
obs_hotkey_id togglePreviewProgramHotkey = 0;
obs_hotkey_id transitionHotkey = 0;
int quickTransitionIdCounter = 1;
2018-02-19 19:54:37 +00:00
bool overridingTransition = false;
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
int programX = 0, programY = 0;
int programCX = 0, programCY = 0;
2016-02-23 23:16:51 +00:00
float programScale = 0.0f;
2017-06-29 19:01:10 +00:00
int disableOutputsRef = 0;
2016-10-10 19:01:40 +00:00
inline void OnActivate();
inline void OnDeactivate();
2017-04-19 19:54:15 +00:00
void AddDropSource(const char *file, DropType image);
2016-10-10 19:01:40 +00:00
void dragEnterEvent(QDragEnterEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dropEvent(QDropEvent *event) override;
2017-04-19 19:54:15 +00:00
void ReplayBufferClicked();
bool sysTrayMinimizeToTray();
void EnumDialogs();
2019-09-22 21:19:10 +00:00
QList<QDialog *> visDialogs;
QList<QDialog *> modalDialogs;
QList<QMessageBox *> visMsgBoxes;
2017-04-19 19:54:15 +00:00
QList<QPoint> visDlgPositions;
2018-02-19 19:54:37 +00:00
QByteArray startingDockLayout;
2017-04-19 19:54:15 +00:00
obs_data_array_t *SaveProjectors();
void LoadSavedProjectors(obs_data_array_t *savedProjectors);
2018-12-16 16:14:58 +00:00
void ReceivedIntroJson(const QString &text);
2017-04-19 19:54:15 +00:00
2018-12-16 16:14:58 +00:00
bool NoSourcesConfirmation();
2018-02-19 19:54:37 +00:00
2019-09-22 21:19:10 +00:00
#ifdef BROWSER_AVAILABLE
QList<QSharedPointer<QDockWidget>> extraBrowserDocks;
QList<QSharedPointer<QAction>> extraBrowserDockActions;
QStringList extraBrowserDockTargets;
void ClearExtraBrowserDocks();
void LoadExtraBrowserDocks();
void SaveExtraBrowserDocks();
void ManageExtraBrowserDocks();
void AddExtraBrowserDock(const QString &title, const QString &url,
bool firstCreate);
#endif
2016-02-23 23:16:51 +00:00
public slots:
2018-12-16 16:14:58 +00:00
void DeferSaveBegin();
void DeferSaveEnd();
2016-02-23 23:16:51 +00:00
void StartStreaming();
void StopStreaming();
void ForceStopStreaming();
void StreamDelayStarting(int sec);
void StreamDelayStopping(int sec);
void StreamingStart();
2016-08-28 12:07:43 +00:00
void StreamStopping();
2017-06-29 19:01:10 +00:00
void StreamingStop(int errorcode, QString last_error);
2016-02-23 23:16:51 +00:00
void StartRecording();
void StopRecording();
void RecordingStart();
2016-08-28 12:07:43 +00:00
void RecordStopping();
2019-07-27 12:47:10 +00:00
void RecordingStop(int code, QString last_error);
2016-02-23 23:16:51 +00:00
2019-09-22 21:19:10 +00:00
void ShowReplayBufferPauseWarning();
2017-04-19 19:54:15 +00:00
void StartReplayBuffer();
void StopReplayBuffer();
void ReplayBufferStart();
2018-02-19 19:54:37 +00:00
void ReplayBufferSave();
2017-04-19 19:54:15 +00:00
void ReplayBufferStopping();
void ReplayBufferStop(int code);
2016-02-23 23:16:51 +00:00
void SaveProjectDeferred();
void SaveProject();
2016-10-10 19:01:40 +00:00
void SetTransition(OBSSource transition);
2018-02-19 19:54:37 +00:00
void TransitionToScene(OBSScene scene, bool force = false,
2019-09-22 21:19:10 +00:00
bool direct = false);
2018-02-19 19:54:37 +00:00
void TransitionToScene(OBSSource scene, bool force = false,
2019-09-22 21:19:10 +00:00
bool direct = false,
bool quickTransition = false);
2018-02-19 19:54:37 +00:00
void SetCurrentScene(OBSSource scene, bool force = false,
2019-09-22 21:19:10 +00:00
bool direct = false);
2016-10-10 19:01:40 +00:00
2019-09-22 21:19:10 +00:00
bool AddSceneCollection(bool create_new,
const QString &name = QString());
2018-12-16 16:14:58 +00:00
2019-07-27 12:47:10 +00:00
void UpdatePatronJson(const QString &text, const QString &error);
2019-09-22 21:19:10 +00:00
void PauseRecording();
void UnpauseRecording();
2016-02-23 23:16:51 +00:00
private slots:
void AddSceneItem(OBSSceneItem item);
void AddScene(OBSSource source);
void RemoveScene(OBSSource source);
2018-02-19 19:54:37 +00:00
void RenameSources(OBSSource source, QString newName, QString prevName);
2016-02-23 23:16:51 +00:00
void SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select);
void ActivateAudioSource(OBSSource source);
void DeactivateAudioSource(OBSSource source);
void DuplicateSelectedScene();
void RemoveSelectedScene();
void RemoveSelectedSceneItem();
void ToggleAlwaysOnTop();
void ReorderSources(OBSScene scene);
void ProcessHotkey(obs_hotkey_id id, bool pressed);
2016-05-24 19:53:01 +00:00
void AddTransition();
void RenameTransition();
2016-02-23 23:16:51 +00:00
void TransitionClicked();
void TransitionStopped();
2018-02-19 19:54:37 +00:00
void TransitionFullyStopped();
2016-02-23 23:16:51 +00:00
void TriggerQuickTransition(int id);
2016-05-24 19:53:01 +00:00
void SetDeinterlacingMode();
void SetDeinterlacingOrder();
2016-08-28 12:07:43 +00:00
void SetScaleFilter();
2016-10-10 19:01:40 +00:00
void IconActivated(QSystemTrayIcon::ActivationReason reason);
void SetShowing(bool showing);
2017-04-19 19:54:15 +00:00
void ToggleShowHide();
2016-10-10 19:01:40 +00:00
2018-02-19 19:54:37 +00:00
void HideAudioControl();
void UnhideAllAudioControls();
void ToggleHideMixer();
void MixerRenameSource();
2018-12-16 16:14:58 +00:00
void on_vMixerScrollArea_customContextMenuRequested();
void on_hMixerScrollArea_customContextMenuRequested();
2018-02-19 19:54:37 +00:00
2017-06-29 19:01:10 +00:00
void on_actionCopySource_triggered();
void on_actionPasteRef_triggered();
void on_actionPasteDup_triggered();
void on_actionCopyFilters_triggered();
void on_actionPasteFilters_triggered();
2018-12-16 16:14:58 +00:00
void ColorChange();
SourceTreeItem *GetItemWidgetFromSceneItem(obs_sceneitem_t *sceneItem);
2019-07-27 12:47:10 +00:00
void on_actionShowAbout_triggered();
void AudioMixerCopyFilters();
void AudioMixerPasteFilters();
void EnablePreview();
void DisablePreview();
void SceneCopyFilters();
void ScenePasteFilters();
2019-09-22 21:19:10 +00:00
void CheckDiskSpaceRemaining();
2016-02-23 23:16:51 +00:00
private:
/* OBS Callbacks */
static void SceneReordered(void *data, calldata_t *params);
static void SceneItemAdded(void *data, calldata_t *params);
static void SceneItemSelected(void *data, calldata_t *params);
static void SceneItemDeselected(void *data, calldata_t *params);
2018-12-16 16:14:58 +00:00
static void SourceCreated(void *data, calldata_t *params);
2016-02-23 23:16:51 +00:00
static void SourceRemoved(void *data, calldata_t *params);
static void SourceActivated(void *data, calldata_t *params);
static void SourceDeactivated(void *data, calldata_t *params);
2019-09-22 21:19:10 +00:00
static void SourceAudioActivated(void *data, calldata_t *params);
static void SourceAudioDeactivated(void *data, calldata_t *params);
2016-02-23 23:16:51 +00:00
static void SourceRenamed(void *data, calldata_t *params);
static void RenderMain(void *data, uint32_t cx, uint32_t cy);
void ResizePreview(uint32_t cx, uint32_t cy);
void AddSource(const char *id);
QMenu *CreateAddSourcePopupMenu();
void AddSourcePopupMenu(const QPoint &pos);
void copyActionsDynamicProperties();
static void HotkeyTriggered(void *data, obs_hotkey_id id, bool pressed);
2019-07-27 12:47:10 +00:00
void AutoRemux();
2019-09-22 21:19:10 +00:00
void UpdatePause(bool activate = true);
bool LowDiskSpace();
void DiskSpaceMessage();
2016-02-23 23:16:51 +00:00
public:
2018-02-19 19:54:37 +00:00
OBSSource GetProgramSource();
OBSScene GetCurrentScene();
2016-02-23 23:16:51 +00:00
2016-10-10 19:01:40 +00:00
void SysTrayNotify(const QString &text, QSystemTrayIcon::MessageIcon n);
2016-02-23 23:16:51 +00:00
inline OBSSource GetCurrentSceneSource()
{
OBSScene curScene = GetCurrentScene();
return OBSSource(obs_scene_get_source(curScene));
}
obs_service_t *GetService();
2019-09-22 21:19:10 +00:00
void SetService(obs_service_t *service);
2016-02-23 23:16:51 +00:00
2019-07-27 12:47:10 +00:00
int GetTransitionDuration();
2018-02-19 19:54:37 +00:00
inline bool IsPreviewProgramMode() const
{
return os_atomic_load_bool(&previewProgramMode);
}
2016-08-28 12:07:43 +00:00
bool StreamingActive() const;
bool Active() const;
2016-02-23 23:16:51 +00:00
2018-02-19 19:54:37 +00:00
void ResetUI();
2019-09-22 21:19:10 +00:00
int ResetVideo();
2016-02-23 23:16:51 +00:00
bool ResetAudio();
void ResetOutputs();
void ResetAudioDevice(const char *sourceId, const char *deviceId,
2019-09-22 21:19:10 +00:00
const char *deviceDesc, int channel);
2016-02-23 23:16:51 +00:00
void NewProject();
void LoadProject();
inline void GetDisplayRect(int &x, int &y, int &cx, int &cy)
{
2019-09-22 21:19:10 +00:00
x = previewX;
y = previewY;
2016-02-23 23:16:51 +00:00
cx = previewCX;
cy = previewCY;
}
2019-09-22 21:19:10 +00:00
inline bool SavingDisabled() const { return disableSaving; }
2018-12-16 16:14:58 +00:00
2016-02-23 23:16:51 +00:00
inline double GetCPUUsage() const
{
return os_cpu_usage_info_query(cpuUsageInfo);
}
void SaveService();
bool LoadService();
2019-09-22 21:19:10 +00:00
inline Auth *GetAuth() { return auth.get(); }
2019-07-27 12:47:10 +00:00
2017-06-29 19:01:10 +00:00
inline void EnableOutputs(bool enable)
{
if (enable) {
if (--disableOutputsRef < 0)
disableOutputsRef = 0;
} else {
disableOutputsRef++;
}
}
2019-07-27 12:47:10 +00:00
QMenu *AddDeinterlacingMenu(QMenu *menu, obs_source_t *source);
QMenu *AddScaleFilteringMenu(QMenu *menu, obs_sceneitem_t *item);
QMenu *AddBackgroundColorMenu(QMenu *menu, QWidgetAction *widgetAction,
2019-09-22 21:19:10 +00:00
ColorSelect *select,
obs_sceneitem_t *item);
2018-12-16 16:14:58 +00:00
void CreateSourcePopupMenu(int idx, bool preview);
2016-02-23 23:16:51 +00:00
void UpdateTitleBar();
void UpdateSceneSelection(OBSSource source);
2016-10-10 19:01:40 +00:00
void SystemTrayInit();
void SystemTray(bool firstStarted);
2017-04-19 19:54:15 +00:00
void OpenSavedProjectors();
2018-12-16 16:14:58 +00:00
void CreateInteractionWindow(obs_source_t *source);
void CreatePropertiesWindow(obs_source_t *source);
void CreateFiltersWindow(obs_source_t *source);
2017-04-19 19:54:15 +00:00
2019-07-27 12:47:10 +00:00
QAction *AddDockWidget(QDockWidget *dock);
static OBSBasic *Get();
2016-02-23 23:16:51 +00:00
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent *event) override;
private slots:
2018-02-19 19:54:37 +00:00
void on_actionFullscreenInterface_triggered();
2016-02-23 23:16:51 +00:00
void on_actionShow_Recordings_triggered();
void on_actionRemux_triggered();
void on_action_Settings_triggered();
void on_actionAdvAudioProperties_triggered();
void on_advAudioProps_clicked();
void on_advAudioProps_destroyed();
void on_actionShowLogs_triggered();
void on_actionUploadCurrentLog_triggered();
void on_actionUploadLastLog_triggered();
void on_actionViewCurrentLog_triggered();
void on_actionCheckForUpdates_triggered();
2018-05-29 19:13:02 +00:00
void on_actionShowCrashLogs_triggered();
void on_actionUploadLastCrashLog_triggered();
2016-02-23 23:16:51 +00:00
void on_actionEditTransform_triggered();
2017-04-19 19:54:15 +00:00
void on_actionCopyTransform_triggered();
void on_actionPasteTransform_triggered();
2016-02-23 23:16:51 +00:00
void on_actionRotate90CW_triggered();
void on_actionRotate90CCW_triggered();
void on_actionRotate180_triggered();
void on_actionFlipHorizontal_triggered();
void on_actionFlipVertical_triggered();
void on_actionFitToScreen_triggered();
void on_actionStretchToScreen_triggered();
void on_actionCenterToScreen_triggered();
2019-07-27 12:47:10 +00:00
void on_actionVerticalCenter_triggered();
void on_actionHorizontalCenter_triggered();
2016-02-23 23:16:51 +00:00
void on_scenes_currentItemChanged(QListWidgetItem *current,
2019-09-22 21:19:10 +00:00
QListWidgetItem *prev);
2016-02-23 23:16:51 +00:00
void on_scenes_customContextMenuRequested(const QPoint &pos);
void on_actionAddScene_triggered();
void on_actionRemoveScene_triggered();
void on_actionSceneUp_triggered();
void on_actionSceneDown_triggered();
void on_sources_customContextMenuRequested(const QPoint &pos);
2018-02-19 19:54:37 +00:00
void on_scenes_itemDoubleClicked(QListWidgetItem *item);
2016-02-23 23:16:51 +00:00
void on_actionAddSource_triggered();
void on_actionRemoveSource_triggered();
void on_actionInteract_triggered();
void on_actionSourceProperties_triggered();
void on_actionSourceUp_triggered();
void on_actionSourceDown_triggered();
void on_actionMoveUp_triggered();
void on_actionMoveDown_triggered();
void on_actionMoveToTop_triggered();
void on_actionMoveToBottom_triggered();
2016-08-28 12:07:43 +00:00
void on_actionLockPreview_triggered();
2017-04-19 19:54:15 +00:00
void on_scalingMenu_aboutToShow();
void on_actionScaleWindow_triggered();
void on_actionScaleCanvas_triggered();
void on_actionScaleOutput_triggered();
2016-02-23 23:16:51 +00:00
void on_streamButton_clicked();
void on_recordButton_clicked();
void on_settingsButton_clicked();
2018-02-19 19:54:37 +00:00
void on_actionHelpPortal_triggered();
2016-02-23 23:16:51 +00:00
void on_actionWebsite_triggered();
2018-12-16 16:14:58 +00:00
void on_actionDiscord_triggered();
2016-02-23 23:16:51 +00:00
void on_preview_customContextMenuRequested(const QPoint &pos);
2018-02-19 19:54:37 +00:00
void on_program_customContextMenuRequested(const QPoint &pos);
2019-09-22 21:19:10 +00:00
void PreviewDisabledMenu(const QPoint &pos);
2016-02-23 23:16:51 +00:00
void on_actionNewSceneCollection_triggered();
void on_actionDupSceneCollection_triggered();
void on_actionRenameSceneCollection_triggered();
void on_actionRemoveSceneCollection_triggered();
2017-04-19 19:54:15 +00:00
void on_actionImportSceneCollection_triggered();
void on_actionExportSceneCollection_triggered();
2016-02-23 23:16:51 +00:00
void on_actionNewProfile_triggered();
void on_actionDupProfile_triggered();
void on_actionRenameProfile_triggered();
void on_actionRemoveProfile_triggered();
2017-04-19 19:54:15 +00:00
void on_actionImportProfile_triggered();
void on_actionExportProfile_triggered();
2016-02-23 23:16:51 +00:00
void on_actionShowSettingsFolder_triggered();
void on_actionShowProfileFolder_triggered();
void on_actionAlwaysOnTop_triggered();
2016-08-28 12:07:43 +00:00
void on_toggleListboxToolbars_toggled(bool visible);
void on_toggleStatusBar_toggled(bool visible);
2016-02-23 23:16:51 +00:00
void on_transitions_currentIndexChanged(int index);
2016-05-24 19:53:01 +00:00
void on_transitionAdd_clicked();
void on_transitionRemove_clicked();
2016-02-23 23:16:51 +00:00
void on_transitionProps_clicked();
void on_modeSwitch_clicked();
2017-06-29 19:01:10 +00:00
void on_autoConfigure_triggered();
void on_stats_triggered();
2018-02-19 19:54:37 +00:00
void on_resetUI_triggered();
void on_lockUI_toggled(bool lock);
2019-09-22 21:19:10 +00:00
void PauseToggled();
2016-02-23 23:16:51 +00:00
void logUploadFinished(const QString &text, const QString &error);
2017-04-19 19:54:15 +00:00
void updateCheckFinished();
2016-02-23 23:16:51 +00:00
void AddSourceFromAction();
void MoveSceneToTop();
void MoveSceneToBottom();
void EditSceneName();
void EditSceneItemName();
void SceneNameEdited(QWidget *editor,
2019-09-22 21:19:10 +00:00
QAbstractItemDelegate::EndEditHint endHint);
2016-02-23 23:16:51 +00:00
void OpenSceneFilters();
void OpenFilters();
void EnablePreviewDisplay(bool enable);
void TogglePreview();
void NudgeUp();
void NudgeDown();
void NudgeLeft();
void NudgeRight();
2018-02-19 19:54:37 +00:00
void OpenStudioProgramProjector();
2016-02-23 23:16:51 +00:00
void OpenPreviewProjector();
void OpenSourceProjector();
2018-02-19 19:54:37 +00:00
void OpenMultiviewProjector();
2016-02-23 23:16:51 +00:00
void OpenSceneProjector();
2018-02-19 19:54:37 +00:00
void OpenStudioProgramWindow();
2017-06-29 19:01:10 +00:00
void OpenPreviewWindow();
void OpenSourceWindow();
2018-02-19 19:54:37 +00:00
void OpenMultiviewWindow();
2017-06-29 19:01:10 +00:00
void OpenSceneWindow();
2019-07-27 12:47:10 +00:00
void DeferredSysTrayLoad(int requeueCount);
2018-12-16 16:14:58 +00:00
void StackedMixerAreaContextMenuRequested();
2019-07-27 12:47:10 +00:00
void ResizeOutputSizeOfSource();
2016-10-10 19:01:40 +00:00
public slots:
void on_actionResetTransform_triggered();
2019-07-27 12:47:10 +00:00
bool StreamingActive();
bool RecordingActive();
bool ReplayBufferActive();
2016-02-23 23:16:51 +00:00
public:
explicit OBSBasic(QWidget *parent = 0);
virtual ~OBSBasic();
virtual void OBSInit() override;
virtual config_t *Config() const override;
2019-09-22 21:19:10 +00:00
virtual int GetProfilePath(char *path, size_t size,
const char *file) const override;
2016-02-23 23:16:51 +00:00
2019-07-27 12:47:10 +00:00
static void InitBrowserPanelSafeBlock();
2016-02-23 23:16:51 +00:00
private:
std::unique_ptr<Ui::OBSBasic> ui;
};
2018-12-16 16:14:58 +00:00
2019-07-27 12:47:10 +00:00
class SceneRenameDelegate : public QStyledItemDelegate {
Q_OBJECT
2018-12-16 16:14:58 +00:00
public:
2019-07-27 12:47:10 +00:00
SceneRenameDelegate(QObject *parent);
2019-09-22 21:19:10 +00:00
virtual void setEditorData(QWidget *editor,
const QModelIndex &index) const override;
2018-12-16 16:14:58 +00:00
2019-07-27 12:47:10 +00:00
protected:
virtual bool eventFilter(QObject *editor, QEvent *event) override;
2018-12-16 16:14:58 +00:00
};