attempts at making obs work
This commit is contained in:
parent
81883099de
commit
c96f188c70
2 changed files with 62 additions and 5 deletions
|
@ -73,16 +73,61 @@ Item {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
id: obsSceneLabel
|
||||||
|
width: previewHighlight.width
|
||||||
|
anchors.top: previewHighlight.bottom
|
||||||
|
anchors.left: previewHighlight.left
|
||||||
|
anchors.topMargin: Kirigami.Units.smallSpacing
|
||||||
|
anchors.rightMargin: Kirigami.Units.smallSpacing * 2
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: model.obsScene
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: previewerMouse
|
id: previewerMouse
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
changeSlide(index);
|
if (mouse.button === Qt.RightButton) {
|
||||||
showPassiveNotification(model.serviceItemId);
|
rightClickMenu.popup(mouse);
|
||||||
|
} else {
|
||||||
|
changeSlide(index);
|
||||||
|
showPassiveNotification(model.serviceItemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
|
|
||||||
|
Controls.ToolTip {
|
||||||
|
text: model.obsScene
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.Menu {
|
||||||
|
id: rightClickMenu
|
||||||
|
|
||||||
|
Controls.Menu {
|
||||||
|
id: obsMenu
|
||||||
|
title: "Obs Scenes"
|
||||||
|
enabled: ObsModel.connected
|
||||||
|
Instantiator {
|
||||||
|
model: ObsModel.scenes
|
||||||
|
Kirigami.Action {
|
||||||
|
text: modelData
|
||||||
|
onTriggered: {
|
||||||
|
Utils.dbg("setting: " + modelData)
|
||||||
|
Utils.dbg(model.obsScene);
|
||||||
|
SlideModel.updateObsScene(modelData);
|
||||||
|
/* ObsModel.setScene(modelData); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onObjectAdded: obsMenu.insertAction(index, object)
|
||||||
|
onObjectRemoved: obsMenu.removeAction(object)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::obs::obs_model::QList_QString;
|
||||||
pub struct Obs {
|
pub struct Obs {
|
||||||
scenes: Scenes,
|
scenes: Scenes,
|
||||||
client: Option<Client>,
|
client: Option<Client>,
|
||||||
|
current_program_scene: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Obs {
|
impl fmt::Debug for Obs {
|
||||||
|
@ -29,6 +30,7 @@ impl Clone for Obs {
|
||||||
Self {
|
Self {
|
||||||
scenes: self.scenes.clone(),
|
scenes: self.scenes.clone(),
|
||||||
client: Some(make_client()),
|
client: Some(make_client()),
|
||||||
|
current_program_scene: self.current_program_scene.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +40,7 @@ impl Default for Obs {
|
||||||
Self {
|
Self {
|
||||||
scenes: Scenes::default(),
|
scenes: Scenes::default(),
|
||||||
client: None,
|
client: None,
|
||||||
|
current_program_scene: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,11 +49,14 @@ impl Obs {
|
||||||
pub async fn new() -> Result<Self, Box<dyn Error>> {
|
pub async fn new() -> Result<Self, Box<dyn Error>> {
|
||||||
let client =
|
let client =
|
||||||
Client::connect("localhost", 4455, Some("")).await?;
|
Client::connect("localhost", 4455, Some("")).await?;
|
||||||
let scene_list = client.scenes().list().await?;
|
let scenes_object = client.scenes();
|
||||||
|
let scene_list = scenes_object.list().await?;
|
||||||
|
let current_program_scene = scenes_object.current_program_scene().await?;
|
||||||
debug!(?scene_list);
|
debug!(?scene_list);
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
scenes: scene_list,
|
scenes: scene_list,
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
|
current_program_scene: Some(current_program_scene)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +79,7 @@ impl Obs {
|
||||||
scene: String,
|
scene: String,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
debug!("Starting function");
|
debug!("Starting function");
|
||||||
if self.client.is_some() {
|
if let Some(client) = self.client {
|
||||||
debug!("Starting to set");
|
debug!("Starting to set");
|
||||||
let runtime =
|
let runtime =
|
||||||
tokio::runtime::Builder::new_current_thread()
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
@ -125,6 +131,7 @@ mod obs_model {
|
||||||
#[qproperty(QStringList, scenes)]
|
#[qproperty(QStringList, scenes)]
|
||||||
#[qproperty(QString, port)]
|
#[qproperty(QString, port)]
|
||||||
#[qproperty(bool, connected)]
|
#[qproperty(bool, connected)]
|
||||||
|
#[qproperty(QString, current_program_scene)]
|
||||||
type ObsModel = super::ObsModelRust;
|
type ObsModel = super::ObsModelRust;
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
|
@ -142,6 +149,7 @@ pub struct ObsModelRust {
|
||||||
port: QString,
|
port: QString,
|
||||||
connected: bool,
|
connected: bool,
|
||||||
obs: Option<Obs>,
|
obs: Option<Obs>,
|
||||||
|
current_program_scene: QString
|
||||||
}
|
}
|
||||||
|
|
||||||
impl obs_model::ObsModel {
|
impl obs_model::ObsModel {
|
||||||
|
@ -175,6 +183,10 @@ impl obs_model::ObsModel {
|
||||||
self.as_mut().set_connected(true);
|
self.as_mut().set_connected(true);
|
||||||
self.as_mut().rust_mut().obs = Some(o);
|
self.as_mut().rust_mut().obs = Some(o);
|
||||||
self.as_mut().update_scenes();
|
self.as_mut().update_scenes();
|
||||||
|
if let Some(scene) = o.current_program_scene {
|
||||||
|
let scene = QString::from(&scene);
|
||||||
|
self.as_mut().set_current_program_scene(scene);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(e);
|
error!(e);
|
||||||
|
@ -193,7 +205,7 @@ impl obs_model::ObsModel {
|
||||||
pub fn set_scene(mut self: Pin<&mut Self>, scene: QString) {
|
pub fn set_scene(mut self: Pin<&mut Self>, scene: QString) {
|
||||||
let scene = scene.to_string();
|
let scene = scene.to_string();
|
||||||
if let Some(obs) = &self.as_mut().rust_mut().obs {
|
if let Some(obs) = &self.as_mut().rust_mut().obs {
|
||||||
let obs = obs.clone();
|
// let obs = obs.clone();
|
||||||
match obs.set_scene(scene) {
|
match obs.set_scene(scene) {
|
||||||
Ok(()) => debug!("Successfully set scene"),
|
Ok(()) => debug!("Successfully set scene"),
|
||||||
Err(e) => error!(e),
|
Err(e) => error!(e),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue