1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Add state transition between different wallpaper type settings

Fix setting wallpaper values
This commit is contained in:
Elias Steurer 2019-09-16 20:30:37 +02:00
parent 272a86a61f
commit 74e05ff5b4
9 changed files with 303 additions and 132 deletions

View File

@ -129,5 +129,6 @@
<file>qml/Common/Shake.qml</file>
<file>qml/Common/Grow.qml</file>
<file>qml/Installed/InstalledWelcomeScreen.qml</file>
<file>qml/Monitors/DefaultVideoControls.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,112 @@
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
import "../Common/" as SP
ColumnLayout {
id: root
spacing: 20
state: "hidden"
clip: true
anchors.rightMargin: 10
anchors.leftMargin: 10
SP.Slider {
headline: qsTr("Volume")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "volume", value)
Layout.fillWidth: true
}
SP.Slider {
headline: qsTr("Playback rate")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "playbackRate", value)
Layout.fillWidth: true
}
SP.Slider {
headline: qsTr("Current Video Time")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "currentTime", value)
Layout.fillWidth: true
}
ColumnLayout {
height: 50
Layout.fillWidth: true
spacing: 5
Text {
id: txtComboBoxFillMode
text: qsTr("Fill Mode")
font.family: "Roboto"
verticalAlignment: Text.AlignVCenter
font.pointSize: 10
color: "#626262"
wrapMode: Text.WrapAnywhere
Layout.fillWidth: true
}
ComboBox {
id: settingsComboBox
Layout.fillWidth: true
onActivated: {
screenPlay.setWallpaperValue(
activeMonitorIndex, "fillmode",
settingsComboBox.currentText)
}
model: ListModel {
ListElement {
text: "Stretch"
}
ListElement {
text: "Fill"
}
ListElement {
text: "Contain"
}
ListElement {
text: "Cover"
}
ListElement {
text: "Scale-Down"
}
}
}
}
states: [
State {
name: "visible"
PropertyChanges {
target: root
opacity: 1
anchors.topMargin: 60
}
},
State {
name: "hidden"
PropertyChanges {
target: root
opacity: 0
anchors.topMargin: -50
}
}
]
transitions: [
Transition {
from: "visible"
to: "hidden"
reversible: true
PropertyAnimation {
target: root
duration: 300
easing.type: Easing.InOutQuart
properties: "anchors.topMargin, opacity"
}
}
]
}

View File

@ -11,7 +11,7 @@ Rectangle {
property real availableWidth: 0
property real availableHeight: 0
property int fontSize: 12
property bool canSelectMultipleMonitors: true
property bool multipleMonitorsSelectable: true
// We preselect the main monitor
property var activeMonitors:[0]
@ -32,6 +32,19 @@ Rectangle {
}
}
function deselectOthers(index){
for (var i = 0; i < rp.count; i++) {
if(i === index){
rp.itemAt(i).isSelected = true
continue;
}
rp.itemAt(i).isSelected = false
}
}
function deselectAll(){
for (var i = 0; i < rp.count; i++) {
rp.itemAt(i).isSelected = false
@ -42,7 +55,6 @@ Rectangle {
function getActiveMonitors(){
rect.activeMonitors = []
for (var i = 0; i < rp.count; i++) {
if(rp.itemAt(i).isSelected){
rect.activeMonitors.push(rp.itemAt(i).index)
}
@ -95,7 +107,6 @@ Rectangle {
Repeater {
id: rp
anchors.fill: parent
anchors.centerIn: parent
model: monitorListModel
Component.onCompleted: rp.itemAt(0).isSelected = true
@ -116,6 +127,14 @@ Rectangle {
previewImage: m_previewImage
onMonitorSelected: {
if(!multipleMonitorsSelectable){
deselectOthers(index)
} else {
rp.itemAt(index).isSelected = !rp.itemAt(index).isSelected
}
getActiveMonitors()
requestProjectSettings(index)

View File

@ -2,7 +2,8 @@ import QtQuick 2.12
import QtGraphicalEffects 1.0
Item {
id: monitorSelectionItem
id: root
property rect monitorSize: Qt.rect(0, 0, 0, 0)
property string monitorModel
property string monitorManufacturer
@ -10,34 +11,20 @@ Item {
property string monitorID
property string previewImage: ""
onPreviewImageChanged: {
if(previewImage === ""){
if (previewImage === "") {
imgPreview.opacity = 0
} else {
imgPreview.source = Qt.resolvedUrl("file:///"+previewImage)
imgPreview.source = Qt.resolvedUrl("file:///" + previewImage)
imgPreview.opacity = 1
}
}
property int fontSize: 10
property int index
property bool isSelected: false
signal monitorSelected(var index)
onMonitorSelected: {
if (isSelected) {
isSelected = false
} else {
isSelected = true
}
}
onIsSelectedChanged: root.state = isSelected ? "selected" : "default"
onIsSelectedChanged: {
if (isSelected) {
wrapper.border.color = "#F28E0D"
} else {
wrapper.border.color = "#373737"
}
}
signal monitorSelected(var index)
Text {
text: monitorSize.width + "x" + monitorSize.height
@ -49,14 +36,14 @@ Item {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: monitorSelectionItem.fontSize
font.pointSize: root.fontSize
font.family: "Roboto"
wrapMode: Text.WrapAnywhere
}
Rectangle {
id: wrapper
color: isSelected ? "#373737" : "#828282"
color: "#828282"
anchors.fill: parent
anchors.margins: 10
border.color: "#1e1e1e"
@ -76,7 +63,7 @@ Item {
Text {
font.pointSize: 14
text: monitorSelectionItem.index
text: root.index
anchors.centerIn: parent
color: "white"
}
@ -86,9 +73,38 @@ Item {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
monitorSelected(index)
monitorSelected(index)
}
}
}
states: [
State {
name: "default"
PropertyChanges {
target: wrapper
border.color: "#373737"
}
},
State {
name: "selected"
PropertyChanges {
target: wrapper
border.color: "#F28E0D"
}
}
]
transitions: [
Transition {
from: "default"
to: "selected"
reversible: true
PropertyAnimation {
target: wrapper
duration: 200
easing.type: Easing.InOutQuart
property: "border.color"
}
}
]
}

View File

@ -13,7 +13,7 @@ Item {
property string activeMonitorName: ""
property int activeMonitorIndex
onActiveMonitorIndexChanged: print(activeMonitorIndex)
onStateChanged: {
bgMouseArea.focus = monitors.state == "active" ? true : false
@ -41,6 +41,7 @@ Item {
z: 98
width: 1000
height: 500
clip: true
anchors {
top: parent.top
topMargin: 50
@ -79,6 +80,7 @@ Item {
height: 200
z: 99
width: parent.width * .9
multipleMonitorsSelectable: false
anchors {
top: txtHeadline.bottom
topMargin: 20
@ -95,22 +97,20 @@ Item {
Connections {
target: screenPlay
onProjectSettingsListModelFound: {
gridView.model = li
// TODO via states
videoControlWrapper.state = "visible"
customPropertiesGridView.model = li
if (type == "videoWallpaper") {
videoControlWrapper.z = 10
gridView.z = 0
videoControlWrapper.visible = true
gridView.visible = false
customPropertiesGridView.state = "hidden"
videoControlWrapper.state = "visible"
} else {
videoControlWrapper.visible = false
gridView.visible = true
videoControlWrapper.z = 0
gridView.z = 10
customPropertiesGridView.state = "visible"
videoControlWrapper.state = "hidden"
}
}
onProjectSettingsListModelNotFound: {
gridView.model = null
customPropertiesGridView.model = null
videoControlWrapper.state = "hidden"
customPropertiesGridView.state = "hidden"
}
}
}
@ -147,82 +147,20 @@ Item {
}
}
}
ColumnLayout {
DefaultVideoControls {
id: videoControlWrapper
spacing: 20
anchors {
top: parent.top
topMargin: 60
right: parent.right
bottom: parent.bottom
margins: 30
left: itmLeftWrapper.right
}
SP.Slider {
headline: qsTr("Volume")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "volume", value)
Layout.fillWidth: true
}
SP.Slider {
headline: qsTr("Playback rate")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "playbackRate", value)
Layout.fillWidth: true
}
SP.Slider {
headline: qsTr("Current Video Time")
onValueChanged: screenPlay.setWallpaperValue(
activeMonitorIndex, "currentTime", value)
Layout.fillWidth: true
}
ColumnLayout {
height: 50
Layout.fillWidth: true
spacing: 5
Text {
id: txtComboBoxFillMode
text: qsTr("Fill Mode")
font.family: "Roboto"
verticalAlignment: Text.AlignVCenter
font.pointSize: 10
color: "#626262"
wrapMode: Text.WrapAnywhere
Layout.fillWidth: true
}
ComboBox {
id: settingsComboBox
Layout.fillWidth: true
onActivated: {
screenPlay.setWallpaperValue(
activeMonitorIndex, "fillmode",
settingsComboBox.currentText)
}
model: ListModel {
ListElement {
text: "Stretch"
}
ListElement {
text: "Fill"
}
ListElement {
text: "Contain"
}
ListElement {
text: "Cover"
}
ListElement {
text: "Scale-Down"
}
}
}
}
}
GridView {
id: gridView
id: customPropertiesGridView
boundsBehavior: Flickable.DragOverBounds
maximumFlickVelocity: 7000
flickDeceleration: 5000
@ -242,12 +180,47 @@ Item {
delegate: MonitorsProjectSettingItem {
id: delegate
selectedMonitor: monitorSelection.activeMonitorIndex
selectedMonitor: monitors.activeMonitorIndex
}
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease
}
states: [
State {
name: "visible"
PropertyChanges {
target: customPropertiesGridView
opacity: 1
z:1
anchors.topMargin: 60
}
},
State {
name: "hidden"
PropertyChanges {
target: customPropertiesGridView
opacity: 0
z:0
anchors.topMargin: -100
}
}
]
transitions: [
Transition {
from: "visible"
to: "hidden"
reversible: true
PropertyAnimation {
target: customPropertiesGridView
duration: 300
easing.type: Easing.InOutQuart
properties: "anchors.topMargin, opacity"
}
}
]
}
MouseArea {

View File

@ -10,8 +10,7 @@ Item {
height: isHeadline ? 50 : 30
width: 300
property var selectedMonitor:[0]
property int selectedMonitor
anchors {
left: parent.left
@ -79,7 +78,7 @@ Item {
onValueChanged: {
var value = Math.round(slider.value * 100) / 100;
txtSliderValue.text = value;
screenPlay.setWallpaperValue(selectedMonitor[0],txtDescription.text,value)
screenPlay.setWallpaperValue(selectedMonitor,txtDescription.text,value)
}
}
Text {

View File

@ -24,37 +24,57 @@ void ScreenPlayManager::createWallpaper(
{
QString path = absoluteStoragePath;
if (absoluteStoragePath.contains("file:///"))
path = path.remove("file:///");
std::sort(monitorIndex.begin(), monitorIndex.end());
auto wallpaper = make_shared<ScreenPlayWallpaper>(
monitorIndex,
m_globalVariables,
Util::generateRandomString(),
path,
previewImage,
volume,
fillMode,
type,
this);
m_screenPlayWallpapers.append(wallpaper);
m_monitorListModel->setWallpaperActiveMonitor(wallpaper, monitorIndex);
QJsonArray monitors;
for (const int index : monitorIndex) {
monitors.append(index);
}
QJsonObject settings;
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("volume", static_cast<double>(volume));
settings.insert("isLooping", true);
settings.insert("fillMode", fillMode);
settings.insert("previeImage", previewImage);
settings.insert("absolutePath", absoluteStoragePath);
std::shared_ptr<ScreenPlayWallpaper> wallpaper;
if (type == "videoWallpaper") {
wallpaper = make_shared<ScreenPlayWallpaper>(
monitorIndex,
m_globalVariables,
Util::generateRandomString(),
path,
previewImage,
volume,
fillMode,
type,
this);
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("volume", static_cast<double>(volume));
settings.insert("isLooping", true);
settings.insert("fillMode", fillMode);
settings.insert("previeImage", previewImage);
settings.insert("absolutePath", absoluteStoragePath);
} else if(type == "qmlWallpaper"){
wallpaper = make_shared<ScreenPlayWallpaper>(
monitorIndex,
m_globalVariables,
Util::generateRandomString(),
path,
previewImage,
type,
this);
}
m_screenPlayWallpapers.append(wallpaper);
m_monitorListModel->setWallpaperActiveMonitor(wallpaper, monitorIndex);
saveWallpaperProfile("default", settings);
increaseActiveWallpaperCounter();
@ -108,7 +128,7 @@ void ScreenPlayManager::removeAllWallpapers()
configObj.remove("profiles");
configObj.insert("profiles", activeProfilesTmp);
qDebug() << configObj;
//qDebug() << configObj;
Util::writeJsonObjectToFile(absoluteProfilesFilePath, configObj);
setActiveWallpaperCounter(0);
@ -140,14 +160,15 @@ void ScreenPlayManager::requestProjectSettingsListModelAt(const int index)
void ScreenPlayManager::setWallpaperValue(const int index, const QString& key, const QString& value)
{
auto appID = m_monitorListModel->getAppIDByMonitorIndex(index);
if (appID.has_value()) {
if (!appID.has_value()) {
return;
}
m_sdkconnector->setWallpaperValue(appID.value(), key, value);
for (auto& wallpaper : m_screenPlayWallpapers) {
if (wallpaper->appID() == appID.value()){
if (wallpaper->appID() == appID.value()) {
}
}
}

View File

@ -67,4 +67,24 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
m_process.startDetached();
}
ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
const shared_ptr<GlobalVariables>& globalVariables,
const QString& appID,
const QString& absolutePath,
const QString& previewImage,
const QString& type,
const QJsonObject& profileJsonObject,
QObject* parent)
: QObject(parent)
, m_projectSettingsListModel { make_shared<ProjectSettingsListModel>(absolutePath + "/project.json") }
, m_globalVariables { globalVariables }
, m_screenNumber { screenNumber }
, m_previewImage { QString { absolutePath + "/" + previewImage } }
, m_type { type }
, m_appID { appID }
, m_absolutePath { absolutePath }
, m_profileJsonObject { profileJsonObject }
{
}
}

View File

@ -39,6 +39,16 @@ public:
const QString& type,
QObject* parent = nullptr);
explicit ScreenPlayWallpaper(
const QVector<int>& screenNumber,
const shared_ptr<GlobalVariables>& globalVariables,
const QString& appID,
const QString& absolutePath,
const QString& previewImage,
const QString& type,
const QJsonObject& settings,
QObject* parent = nullptr);
~ScreenPlayWallpaper() {}
const shared_ptr<ProjectSettingsListModel>& projectSettingsListModel() const