doing dumb things for obs
This commit is contained in:
parent
4b489d4e45
commit
b07e59659d
4 changed files with 101 additions and 43 deletions
|
@ -155,6 +155,8 @@ int main(int argc, char *argv[])
|
||||||
QScopedPointer<ServiceItemModel> serviceItemC(new ServiceItemModel);
|
QScopedPointer<ServiceItemModel> serviceItemC(new ServiceItemModel);
|
||||||
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
||||||
QScopedPointer<ObsModel> obsModel(new ObsModel);
|
QScopedPointer<ObsModel> obsModel(new ObsModel);
|
||||||
|
obsModel.get()->getObs();
|
||||||
|
obsModel.get()->updateScenes();
|
||||||
|
|
||||||
Settings *settings = new Settings;
|
Settings *settings = new Settings;
|
||||||
settings->setup();
|
settings->setup();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
/* import QtQuick.Dialogs 1.0 */
|
/* import QtQuick.Dialogs 1.0 */
|
||||||
import QtQuick.Controls 2.0 as Controls
|
import QtQuick.Controls 2.12 as Controls
|
||||||
/* import QtQuick.Window 2.15 */
|
/* import QtQuick.Window 2.15 */
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import QtQuick.Shapes 1.15
|
import QtQuick.Shapes 1.15
|
||||||
|
@ -279,35 +279,33 @@ Item {
|
||||||
}
|
}
|
||||||
Controls.Menu {
|
Controls.Menu {
|
||||||
id: rightClickMenu
|
id: rightClickMenu
|
||||||
x: mouse.mouseX
|
|
||||||
y: mouse.mouseY + 10
|
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "copy"
|
text: "Copy"
|
||||||
}
|
}
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "paste"
|
text: "Paste"
|
||||||
}
|
}
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: "delete"
|
text: "Delete"
|
||||||
onTriggered: removeItem(index)
|
onTriggered: removeItem(index)
|
||||||
}
|
}
|
||||||
Kirigami.Action {
|
|
||||||
text: "Obs Scenes"
|
Controls.MenuSeparator {}
|
||||||
onTriggered: {
|
|
||||||
ObsModel.updateScenes();
|
|
||||||
console.log("udated")
|
|
||||||
obsList.model = ObsModel.scenes
|
|
||||||
obsMenu.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Controls.Menu {
|
Controls.Menu {
|
||||||
id: obsMenu
|
id: obsMenu
|
||||||
x: rightClickMenu.x + rightClickMenu.width
|
title: "Obs Scenes"
|
||||||
y: mouse.mouseY
|
|
||||||
ListView {
|
ListView {
|
||||||
id: obsList
|
width: parent.width
|
||||||
delegate: Kirigami.Action { text: modelData }
|
height: 200
|
||||||
|
model: ObsModel.scenes
|
||||||
|
delegate: Controls.ToolButton {
|
||||||
|
width: parent.width
|
||||||
|
text: modelData
|
||||||
|
onClicked: ObsModel.setScene(modelData)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,10 @@ Kirigami.OverlaySheet {
|
||||||
text: "Settings"
|
text: "Settings"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Component.onCompleted: { */
|
Component.onCompleted: {
|
||||||
/* showPassiveNotification(screenModel.get(1).name) */
|
/* ObsModel.getObs(); */
|
||||||
/* } */
|
/* ObsModel.updateScenes(); */
|
||||||
|
}
|
||||||
|
|
||||||
Kirigami.FormLayout {
|
Kirigami.FormLayout {
|
||||||
implicitHeight: Kirigami.Units.gridUnit * 30
|
implicitHeight: Kirigami.Units.gridUnit * 30
|
||||||
|
@ -61,6 +62,21 @@ Kirigami.OverlaySheet {
|
||||||
text: "Sound Effect"
|
text: "Sound Effect"
|
||||||
onClicked: soundFileDialog.open()
|
onClicked: soundFileDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.ToolButton {
|
||||||
|
Kirigami.FormData.label: i18nc("@label:button", "OBS debug")
|
||||||
|
text: "Obs Debug"
|
||||||
|
onClicked: {
|
||||||
|
ObsModel.updateScenes();
|
||||||
|
console.log(ObsModel.scenes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.ActionTextField {
|
||||||
|
Kirigami.FormData.label: i18nc("@label:textbox", "Obs Connection")
|
||||||
|
text: ObsModel.connected
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use obws::responses::scenes::Scenes;
|
use obws::responses::scenes::Scenes;
|
||||||
use obws::Client;
|
use obws::Client;
|
||||||
|
@ -67,22 +68,18 @@ impl Obs {
|
||||||
self,
|
self,
|
||||||
scene: String,
|
scene: String,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
debug!("Starting function");
|
||||||
if self.client.is_some() {
|
if self.client.is_some() {
|
||||||
if let Some(scene) = self
|
debug!("Starting to set");
|
||||||
.scenes
|
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||||
.scenes
|
tokio::spawn(async move {
|
||||||
.iter()
|
debug!(scene, "working in thread");
|
||||||
.filter(|x| x.name == scene)
|
|
||||||
.next()
|
|
||||||
{
|
|
||||||
self.client
|
self.client
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.scenes()
|
.scenes()
|
||||||
.set_current_program_scene(scene.name.as_str());
|
.set_current_program_scene(scene.as_str()).await
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
|
||||||
Err("Couldn't set the scene".to_owned())?
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Err("There is no client".to_owned())?
|
Err("There is no client".to_owned())?
|
||||||
}
|
}
|
||||||
|
@ -98,7 +95,7 @@ fn make_client() -> Client {
|
||||||
|
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod obs_model {
|
mod obs_model {
|
||||||
use tracing::debug;
|
use tracing::{debug, error};
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
|
@ -114,6 +111,10 @@ mod obs_model {
|
||||||
pub struct ObsModel {
|
pub struct ObsModel {
|
||||||
#[qproperty]
|
#[qproperty]
|
||||||
scenes: QStringList,
|
scenes: QStringList,
|
||||||
|
#[qproperty]
|
||||||
|
port: QString,
|
||||||
|
#[qproperty]
|
||||||
|
connected: bool,
|
||||||
obs: Option<super::Obs>,
|
obs: Option<super::Obs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +125,53 @@ mod obs_model {
|
||||||
debug!("updating scenes");
|
debug!("updating scenes");
|
||||||
let mut scenes_list = QList_QString::default();
|
let mut scenes_list = QList_QString::default();
|
||||||
if let Some(obs) = self.obs() {
|
if let Some(obs) = self.obs() {
|
||||||
obs.scenes.scenes.iter().map(|x| {
|
debug!("found obs");
|
||||||
debug!(?x);
|
for scene in obs.scenes.scenes.iter() {
|
||||||
scenes_list.append(QString::from(&x.name))
|
debug!(?scene);
|
||||||
|
scenes_list.append(QString::from(&scene.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for s in scenes_list.iter() {
|
||||||
|
debug!(?s);
|
||||||
|
}
|
||||||
|
let list = QStringList::from(&scenes_list);
|
||||||
|
debug!(?list);
|
||||||
|
self.as_mut().set_scenes(list.clone());
|
||||||
|
list
|
||||||
|
}
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn get_obs(mut self: Pin<&mut Self>) -> bool {
|
||||||
|
debug!("getting obs");
|
||||||
|
|
||||||
|
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||||
|
match super::Obs::new().await {
|
||||||
|
Ok(o) => {
|
||||||
|
self.as_mut().set_connected(true);
|
||||||
|
self.as_mut().set_obs(Some(o));
|
||||||
|
self.as_mut().update_scenes();
|
||||||
|
},
|
||||||
|
Err(e) => error!(e)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(_obs) = self.obs() {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[qinvokable]
|
||||||
|
pub fn set_scene(mut self: Pin<&mut Self>, scene: QString) {
|
||||||
|
let scene = scene.to_string();
|
||||||
|
if let Some(obs) = self.obs_mut() {
|
||||||
|
let obs = obs.clone();
|
||||||
|
match obs.set_scene(scene) {
|
||||||
|
Ok(()) => debug!("Successfully set scene"),
|
||||||
|
Err(e) => error!(e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QStringList::from(&scenes_list)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue