mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
utils: remove transition hacks
This commit is contained in:
parent
b18d597bdc
commit
84629f6e63
@ -300,20 +300,6 @@ QSpinBox* Utils::GetTransitionDurationControl() {
|
|||||||
return window->findChild<QSpinBox*>("transitionDuration");
|
return window->findChild<QSpinBox*>("transitionDuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Utils::GetTransitionDuration() {
|
|
||||||
QSpinBox* control = GetTransitionDurationControl();
|
|
||||||
if (control)
|
|
||||||
return control->value();
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Utils::SetTransitionDuration(int ms) {
|
|
||||||
QSpinBox* control = GetTransitionDurationControl();
|
|
||||||
if (control && ms >= 0)
|
|
||||||
control->setValue(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Utils::SetTransitionByName(QString transitionName) {
|
bool Utils::SetTransitionByName(QString transitionName) {
|
||||||
OBSSourceAutoRelease transition = GetTransitionFromName(transitionName);
|
OBSSourceAutoRelease transition = GetTransitionFromName(transitionName);
|
||||||
|
|
||||||
@ -325,40 +311,6 @@ bool Utils::SetTransitionByName(QString transitionName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton* Utils::GetPreviewModeButtonControl() {
|
|
||||||
QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window();
|
|
||||||
return main->findChild<QPushButton*>("modeSwitch");
|
|
||||||
}
|
|
||||||
|
|
||||||
QLayout* Utils::GetPreviewLayout() {
|
|
||||||
QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window();
|
|
||||||
return main->findChild<QLayout*>("previewLayout");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Utils::TransitionToProgram() {
|
|
||||||
if (!obs_frontend_preview_program_mode_active())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// WARNING : if the layout created in OBS' CreateProgramOptions() changes
|
|
||||||
// then this won't work as expected
|
|
||||||
|
|
||||||
QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window();
|
|
||||||
|
|
||||||
// The program options widget is the second item in the left-to-right layout
|
|
||||||
QWidget* programOptions = GetPreviewLayout()->itemAt(1)->widget();
|
|
||||||
|
|
||||||
// The "Transition" button lies in the mainButtonLayout
|
|
||||||
// which is the first itemin the program options' layout
|
|
||||||
QLayout* mainButtonLayout = programOptions->layout()->itemAt(1)->layout();
|
|
||||||
QWidget* transitionBtnWidget = mainButtonLayout->itemAt(0)->widget();
|
|
||||||
|
|
||||||
// Try to cast that widget into a button
|
|
||||||
QPushButton* transitionBtn = qobject_cast<QPushButton*>(transitionBtnWidget);
|
|
||||||
|
|
||||||
// Perform a click on that button
|
|
||||||
transitionBtn->click();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Utils::OBSVersionString() {
|
QString Utils::OBSVersionString() {
|
||||||
uint32_t version = obs_get_version();
|
uint32_t version = obs_get_version();
|
||||||
|
|
||||||
|
@ -53,17 +53,9 @@ class Utils {
|
|||||||
|
|
||||||
// TODO contribute a proper frontend API method for this to OBS and remove this hack
|
// TODO contribute a proper frontend API method for this to OBS and remove this hack
|
||||||
static QSpinBox* GetTransitionDurationControl();
|
static QSpinBox* GetTransitionDurationControl();
|
||||||
static int GetTransitionDuration();
|
|
||||||
static void SetTransitionDuration(int ms);
|
|
||||||
|
|
||||||
static bool SetTransitionByName(QString transitionName);
|
static bool SetTransitionByName(QString transitionName);
|
||||||
|
|
||||||
static QPushButton* GetPreviewModeButtonControl();
|
|
||||||
static QLayout* GetPreviewLayout();
|
|
||||||
|
|
||||||
// TODO contribute a proper frontend API method for this to OBS and remove this hack
|
|
||||||
static void TransitionToProgram();
|
|
||||||
|
|
||||||
static QString OBSVersionString();
|
static QString OBSVersionString();
|
||||||
|
|
||||||
static QSystemTrayIcon* GetTrayIcon();
|
static QSystemTrayIcon* GetTrayIcon();
|
||||||
|
@ -830,7 +830,7 @@ void WSEvents::OnTransitionBegin(void* param, calldata_t* data) {
|
|||||||
{
|
{
|
||||||
duration = obs_data_get_int(destinationSettings, "transition_duration");
|
duration = obs_data_get_int(destinationSettings, "transition_duration");
|
||||||
} else {
|
} else {
|
||||||
duration = Utils::GetTransitionDuration();
|
duration = obs_frontend_get_transition_duration();
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSDataAutoRelease fields = obs_data_create();
|
OBSDataAutoRelease fields = obs_data_create();
|
||||||
|
@ -116,11 +116,11 @@ HandlerResponse WSRequestHandler::HandleTransitionToProgram(WSRequestHandler* re
|
|||||||
if (obs_data_has_user_value(transitionInfo, "duration")) {
|
if (obs_data_has_user_value(transitionInfo, "duration")) {
|
||||||
int transitionDuration =
|
int transitionDuration =
|
||||||
obs_data_get_int(transitionInfo, "duration");
|
obs_data_get_int(transitionInfo, "duration");
|
||||||
Utils::SetTransitionDuration(transitionDuration);
|
obs_frontend_set_transition_duration(transitionDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::TransitionToProgram();
|
obs_frontend_preview_program_trigger_transition();
|
||||||
return req->SendOKResponse();
|
return req->SendOKResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ HandlerResponse WSRequestHandler::HandleGetCurrentTransition(WSRequestHandler* r
|
|||||||
obs_source_get_name(currentTransition));
|
obs_source_get_name(currentTransition));
|
||||||
|
|
||||||
if (!obs_transition_fixed(currentTransition))
|
if (!obs_transition_fixed(currentTransition))
|
||||||
obs_data_set_int(response, "duration", Utils::GetTransitionDuration());
|
obs_data_set_int(response, "duration", obs_frontend_get_transition_duration());
|
||||||
|
|
||||||
return req->SendOKResponse(response);
|
return req->SendOKResponse(response);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ HandlerResponse WSRequestHandler::HandleSetTransitionDuration(WSRequestHandler*
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ms = obs_data_get_int(req->data, "duration");
|
int ms = obs_data_get_int(req->data, "duration");
|
||||||
Utils::SetTransitionDuration(ms);
|
obs_frontend_set_transition_duration(ms);
|
||||||
return req->SendOKResponse();
|
return req->SendOKResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +117,6 @@ HandlerResponse WSRequestHandler::HandleSetTransitionDuration(WSRequestHandler*
|
|||||||
*/
|
*/
|
||||||
HandlerResponse WSRequestHandler::HandleGetTransitionDuration(WSRequestHandler* req) {
|
HandlerResponse WSRequestHandler::HandleGetTransitionDuration(WSRequestHandler* req) {
|
||||||
OBSDataAutoRelease response = obs_data_create();
|
OBSDataAutoRelease response = obs_data_create();
|
||||||
obs_data_set_int(response, "transition-duration", Utils::GetTransitionDuration());
|
obs_data_set_int(response, "transition-duration", obs_frontend_get_transition_duration());
|
||||||
return req->SendOKResponse(response);
|
return req->SendOKResponse(response);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user