mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Add working videoFillMode as enum. The Sidebar now also uses this value as default!
This commit is contained in:
parent
71b5d2294b
commit
9bf63b3aee
@ -74,6 +74,12 @@ App::App()
|
||||
qRegisterMetaType<MonitorListModel*>();
|
||||
qRegisterMetaType<ProfileListModel*>();
|
||||
|
||||
qmlRegisterAnonymousType<GlobalVariables>("ScreenPlay",1);
|
||||
qmlRegisterAnonymousType<ScreenPlayManager>("ScreenPlay",1);
|
||||
qmlRegisterAnonymousType<Util>("ScreenPlay",1);
|
||||
qmlRegisterAnonymousType<Create>("ScreenPlay",1);
|
||||
qmlRegisterAnonymousType<Settings>("ScreenPlay",1);
|
||||
|
||||
// Util should be created as first so we redirect qDebugs etc. into the log
|
||||
auto* nam = new QNetworkAccessManager(this);
|
||||
m_util = make_unique<Util>(nam);
|
||||
|
@ -6,12 +6,13 @@ import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls.Material 2.12
|
||||
|
||||
import ScreenPlay 1.0
|
||||
import Settings 1.0
|
||||
|
||||
import "../Monitors"
|
||||
import "../Common" as SP
|
||||
|
||||
Item {
|
||||
id: sidebar
|
||||
id: root
|
||||
width: 400
|
||||
state: "inactive"
|
||||
focus: true
|
||||
@ -20,19 +21,29 @@ Item {
|
||||
property string type
|
||||
property string activeScreen
|
||||
|
||||
function indexOfValue(model, value) {
|
||||
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
let ourValue = model[i].value
|
||||
if (value === ourValue)
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ScreenPlay.util
|
||||
|
||||
onSetSidebarItem: {
|
||||
|
||||
// Toggle sidebar if clicked on the same content twice
|
||||
if (activeScreen === screenId && sidebar.state !== "inactive") {
|
||||
sidebar.state = "inactive"
|
||||
if (activeScreen === screenId && root.state !== "inactive") {
|
||||
root.state = "inactive"
|
||||
return
|
||||
}
|
||||
|
||||
activeScreen = screenId
|
||||
sidebar.type = type
|
||||
root.type = type
|
||||
|
||||
switch (type) {
|
||||
case "videoWallpaper":
|
||||
@ -89,13 +100,7 @@ Item {
|
||||
|
||||
Item {
|
||||
id: sidebarWrapper
|
||||
|
||||
anchors {
|
||||
top: sidebar.top
|
||||
right: sidebar.right
|
||||
bottom: sidebar.bottom
|
||||
left: sidebar.left
|
||||
}
|
||||
anchors.fill: parent
|
||||
|
||||
Item {
|
||||
id: navBackground
|
||||
@ -208,7 +213,7 @@ Item {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: sidebar.state = "inactive"
|
||||
onClicked: root.state = "inactive"
|
||||
|
||||
Image {
|
||||
id: imgBack
|
||||
@ -280,28 +285,32 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
ComboBox {
|
||||
id:cbVideoFillMode
|
||||
visible: false
|
||||
id: settingsComboBox
|
||||
Layout.fillWidth: true
|
||||
currentIndex: 3
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
currentIndex: root.indexOfValue(
|
||||
cbVideoFillMode.model,
|
||||
ScreenPlay.settings.videoFillMode)
|
||||
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
text: "Stretch"
|
||||
}
|
||||
ListElement {
|
||||
text: "Fill"
|
||||
}
|
||||
ListElement {
|
||||
text: "Contain"
|
||||
}
|
||||
ListElement {
|
||||
text: "Cover"
|
||||
}
|
||||
ListElement {
|
||||
text: "Scale-Down"
|
||||
}
|
||||
}
|
||||
|
||||
model: [{
|
||||
"value": FillMode.Stretch,
|
||||
"text": qsTr("Stretch")
|
||||
}, {
|
||||
"value": FillMode.Fill,
|
||||
"text": qsTr("Fill")
|
||||
}, {
|
||||
"value": FillMode.Contain,
|
||||
"text": qsTr("Contain")
|
||||
}, {
|
||||
"value": FillMode.Cover,
|
||||
"text": qsTr("Cover")
|
||||
}, {
|
||||
"value": FillMode.Scale_Down,
|
||||
"text": qsTr("Scale-Down")
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,14 +327,14 @@ Item {
|
||||
icon.width: 16
|
||||
icon.height: 16
|
||||
enabled: {
|
||||
if(type.endsWith("Wallpaper")) {
|
||||
if (monitorSelection.activeMonitors.length > 0) {
|
||||
return true
|
||||
}
|
||||
} else if(type.endsWith("Widget")){
|
||||
return true
|
||||
if (type.endsWith("Wallpaper")) {
|
||||
if (monitorSelection.activeMonitors.length > 0) {
|
||||
return true
|
||||
}
|
||||
} else if (type.endsWith("Widget")) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return false
|
||||
}
|
||||
|
||||
anchors {
|
||||
@ -348,7 +357,7 @@ Item {
|
||||
+ "/" + activeScreen,
|
||||
ScreenPlay.installedListModel.get(activeScreen).screenPreview,
|
||||
(Math.round(sliderVolume.value * 100) / 100),
|
||||
settingsComboBox.model.get(settingsComboBox.currentIndex).text.toString(
|
||||
cbVideoFillMode.model.get(cbVideoFillMode.currentIndex).text.toString(
|
||||
), type)
|
||||
} else {
|
||||
ScreenPlay.screenPlayManager.createWidget(
|
||||
@ -357,7 +366,7 @@ Item {
|
||||
ScreenPlay.installedListModel.get(
|
||||
activeScreen).screenPreview, type)
|
||||
}
|
||||
sidebar.state = "inactive"
|
||||
root.state = "inactive"
|
||||
monitorSelection.deselectAll()
|
||||
}
|
||||
}
|
||||
@ -402,7 +411,7 @@ Item {
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: sidebar
|
||||
target: root
|
||||
anchors.rightMargin: 0
|
||||
}
|
||||
PropertyChanges {
|
||||
@ -428,8 +437,8 @@ Item {
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: sidebar
|
||||
anchors.rightMargin: -sidebar.width
|
||||
target: root
|
||||
anchors.rightMargin: -root.width
|
||||
}
|
||||
PropertyChanges {
|
||||
target: image
|
||||
@ -525,7 +534,7 @@ Item {
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: settingsComboBox
|
||||
target: cbVideoFillMode
|
||||
opacity: 1
|
||||
visible: true
|
||||
}
|
||||
@ -538,7 +547,7 @@ Item {
|
||||
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
target: sidebar
|
||||
target: root
|
||||
properties: "anchors.rightMargin"
|
||||
duration: 250
|
||||
easing.type: Easing.OutQuart
|
||||
@ -573,7 +582,7 @@ Item {
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: sidebar
|
||||
target: root
|
||||
properties: "anchors.rightMargin"
|
||||
duration: 250
|
||||
easing.type: Easing.OutQuart
|
||||
@ -584,7 +593,7 @@ Item {
|
||||
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
target: sidebar
|
||||
target: root
|
||||
properties: "anchors.rightMargin"
|
||||
duration: 250
|
||||
easing.type: Easing.OutQuart
|
||||
@ -609,7 +618,7 @@ Item {
|
||||
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
target: sidebar
|
||||
target: root
|
||||
properties: "anchors.rightMargin"
|
||||
duration: 250
|
||||
easing.type: Easing.OutQuart
|
||||
@ -634,7 +643,7 @@ Item {
|
||||
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
target: sidebar
|
||||
target: root
|
||||
properties: "anchors.rightMargin"
|
||||
duration: 250
|
||||
easing.type: Easing.OutQuart
|
||||
|
@ -6,13 +6,24 @@ import QtGraphicalEffects 1.0
|
||||
import Qt.labs.platform 1.0
|
||||
|
||||
import ScreenPlay 1.0
|
||||
import Settings 1.0
|
||||
|
||||
import "../Common"
|
||||
|
||||
Item {
|
||||
id: settingsWrapper
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
|
||||
function indexOfValue(model, value) {
|
||||
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
let ourValue = model[i].value
|
||||
if (value === ourValue)
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: flickableWrapper
|
||||
width: 800
|
||||
@ -114,7 +125,8 @@ Item {
|
||||
description: qsTr("Help us make ScreenPlay faster and more stable. All collected data is purely anonymous and only used for development purposes!")
|
||||
isChecked: ScreenPlay.settings.anonymousTelemetry
|
||||
onCheckboxChanged: {
|
||||
ScreenPlay.settings.setAnonymousTelemetry(checked)
|
||||
ScreenPlay.settings.setAnonymousTelemetry(
|
||||
checked)
|
||||
ScreenPlay.settings.writeSingleSettingConfig(
|
||||
"anonymousTelemetry", checked)
|
||||
}
|
||||
@ -171,26 +183,16 @@ Item {
|
||||
id: settingsLanguage
|
||||
headline: qsTr("Language")
|
||||
description: qsTr("Set the ScreenPlay UI Language")
|
||||
comboBox.currentIndex: indexOfValue(ScreenPlay.settings.language)
|
||||
|
||||
|
||||
function indexOfValue(value) {
|
||||
for (var i = 0; i < liLanguage.count; i++) {
|
||||
let ourValue = liLanguage.get(i).value
|
||||
if (value === ourValue)
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
Component.onCompleted: comboBox.currentIndex
|
||||
= settingsLanguage.comboBox.indexOfValue(
|
||||
ScreenPlay.settings.language)
|
||||
comboBox.onActivated: {
|
||||
ScreenPlay.settings.setqSetting(
|
||||
"language",
|
||||
liLanguage.get(comboBox.currentIndex).value)
|
||||
"language", liLanguage.get(
|
||||
comboBox.currentIndex).value)
|
||||
ScreenPlay.settings.setupLanguage()
|
||||
ScreenPlay.mainWindowEngine.retranslate()
|
||||
}
|
||||
comboBox.textRole: "text"
|
||||
comboBox.valueRole: "value"
|
||||
comboBox.model: ListModel {
|
||||
id: liLanguage
|
||||
ListElement {
|
||||
@ -221,7 +223,7 @@ Item {
|
||||
|
||||
Item {
|
||||
id: settingsPerformanceWrapper
|
||||
height: 260
|
||||
height: perfomanceWrapper.childrenRect.height + headerPerformance.height + 48
|
||||
width: parent.width
|
||||
|
||||
RectangularGlow {
|
||||
@ -257,6 +259,7 @@ Item {
|
||||
}
|
||||
|
||||
Column {
|
||||
id: perfomanceWrapper
|
||||
anchors {
|
||||
top: headerPerformance.bottom
|
||||
margins: 20
|
||||
@ -274,25 +277,40 @@ Item {
|
||||
ScreenPlay.settings.setCheckWallpaperVisible(
|
||||
checked)
|
||||
ScreenPlay.settings.writeSingleSettingConfig(
|
||||
"checkWallpaperVisible",
|
||||
checked)
|
||||
"checkWallpaperVisible", checked)
|
||||
}
|
||||
}
|
||||
SettingsHorizontalSeperator {}
|
||||
SettingsComboBox {
|
||||
id: settingsFillModeComboBox
|
||||
id: cbVideoFillMode
|
||||
headline: qsTr("Default Fill Mode")
|
||||
description: qsTr("Set this property to define how the video is scaled to fit the target area.")
|
||||
comboBox.model: ListModel {
|
||||
ListElement {
|
||||
text: "Stretch"
|
||||
}
|
||||
ListElement {
|
||||
text: "PreserveAspectFit"
|
||||
}
|
||||
ListElement {
|
||||
text: "PreserveAspectCrop"
|
||||
}
|
||||
Component.onCompleted:{
|
||||
cbVideoFillMode.comboBox.currentIndex
|
||||
= root.indexOfValue(
|
||||
cbVideoFillMode.comboBox.model,
|
||||
ScreenPlay.settings.videoFillMode)
|
||||
}
|
||||
comboBox {
|
||||
onActivated: ScreenPlay.settings.setVideoFillMode(
|
||||
cbVideoFillMode.comboBox.currentValue)
|
||||
|
||||
model: [{
|
||||
"value": FillMode.Stretch,
|
||||
"text": qsTr("Stretch")
|
||||
}, {
|
||||
"value": FillMode.Fill,
|
||||
"text": qsTr("Fill")
|
||||
}, {
|
||||
"value": FillMode.Contain,
|
||||
"text": qsTr("Contain")
|
||||
}, {
|
||||
"value": FillMode.Cover,
|
||||
"text": qsTr("Cover")
|
||||
}, {
|
||||
"value": FillMode.Scale_Down,
|
||||
"text": qsTr("Scale-Down")
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +1,59 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
|
||||
Item {
|
||||
id: settingsComboBox
|
||||
property string headline: "Headline"
|
||||
property string description: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
|
||||
property bool isChecked: false
|
||||
property bool enabled: true
|
||||
property alias comboBox: comboBox
|
||||
|
||||
onEnabledChanged: {
|
||||
|
||||
}
|
||||
|
||||
signal checkboxChanged(bool checked)
|
||||
|
||||
|
||||
height: 50
|
||||
height: 20 + txtDescription.paintedHeight + txtHeadline.paintedHeight
|
||||
width: parent.width
|
||||
|
||||
Text {
|
||||
id: txtHeadline
|
||||
color: "#5D5D5D"
|
||||
text: settingsComboBox.headline
|
||||
|
||||
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
anchors{
|
||||
top:parent.top
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: 6
|
||||
left:parent.left
|
||||
left: parent.left
|
||||
leftMargin: 20
|
||||
|
||||
}
|
||||
|
||||
font.pointSize: 12
|
||||
font.family: "Roboto"
|
||||
font.pointSize: 12
|
||||
font.family: "Roboto"
|
||||
}
|
||||
|
||||
Text {
|
||||
id: txtDescription
|
||||
text: settingsComboBox.description
|
||||
color: "#B5B5B5"
|
||||
|
||||
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
wrapMode: Text.WordWrap
|
||||
font.pointSize: 10
|
||||
font.family: "Roboto"
|
||||
anchors{
|
||||
top:txtHeadline.bottom
|
||||
anchors {
|
||||
top: txtHeadline.bottom
|
||||
topMargin: 6
|
||||
left:parent.left
|
||||
left: parent.left
|
||||
leftMargin: 20
|
||||
right:comboBox.left
|
||||
right: comboBox.left
|
||||
rightMargin: 20
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ComboBox {
|
||||
id:comboBox
|
||||
id: comboBox
|
||||
implicitWidth: 200
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: 20
|
||||
|
@ -43,6 +43,9 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
|
||||
, m_globalVariables { globalVariables }
|
||||
{
|
||||
|
||||
qRegisterMetaType<Settings::FillMode>("Settings::FillMode");
|
||||
qmlRegisterUncreatableType<Settings>("Settings", 1, 0, "FillMode", "Error only for enums");
|
||||
|
||||
setGitBuildHash(GIT_VERSION);
|
||||
setupLanguage();
|
||||
|
||||
@ -50,6 +53,22 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
|
||||
m_qSettings.setValue("ScreenPlayExecutable", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()));
|
||||
m_qSettings.sync();
|
||||
}
|
||||
{
|
||||
auto metaEnum = QMetaEnum::fromType<Settings::FillMode>();
|
||||
if (!m_qSettings.value("VideoFillMode").isNull()) {
|
||||
QString value = m_qSettings.value("VideoFillMode").toString();
|
||||
|
||||
|
||||
bool ok = false;
|
||||
auto wantedEnum = static_cast<Settings::FillMode>(metaEnum.keyToValue(value.toUtf8(), &ok));
|
||||
|
||||
if (ok) {
|
||||
setVideoFillMode(wantedEnum);
|
||||
}
|
||||
} else {
|
||||
setVideoFillMode(FillMode::Fill);
|
||||
}
|
||||
}
|
||||
|
||||
QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
m_globalVariables->setLocalSettingsPath(QUrl::fromUserInput(appConfigLocation));
|
||||
@ -171,7 +190,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
|
||||
// We need these settings also in the steam version.
|
||||
// This way it is easier to access them. Maybe we should move everything into
|
||||
// the windows registry
|
||||
//Computer\HKEY_CURRENT_USER\Software\ScreenPlay\ScreenPlay
|
||||
// Computer\HKEY_CURRENT_USER\Software\ScreenPlay\ScreenPlay
|
||||
if (m_qSettings.value("ScreenPlayContentPath").toUrl() != QUrl::fromLocalFile(m_globalVariables->localStoragePath().toString())) {
|
||||
m_qSettings.setValue("ScreenPlayContentPath", QDir::toNativeSeparators(m_globalVariables->localStoragePath().toString().remove("file:///")));
|
||||
m_qSettings.sync();
|
||||
|
@ -54,6 +54,8 @@ class Settings : public QObject {
|
||||
Q_PROPERTY(bool checkWallpaperVisible READ checkWallpaperVisible WRITE setCheckWallpaperVisible NOTIFY checkWallpaperVisibleChanged)
|
||||
Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged)
|
||||
|
||||
Q_PROPERTY(FillMode videoFillMode READ videoFillMode WRITE setVideoFillMode NOTIFY videoFillModeChanged)
|
||||
|
||||
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
|
||||
Q_PROPERTY(QString gitBuildHash READ gitBuildHash WRITE setGitBuildHash NOTIFY gitBuildHashChanged)
|
||||
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
|
||||
@ -63,6 +65,15 @@ public:
|
||||
const shared_ptr<GlobalVariables>& globalVariables,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
enum class FillMode {
|
||||
Stretch,
|
||||
Fill,
|
||||
Contain,
|
||||
Cover,
|
||||
Scale_Down
|
||||
};
|
||||
Q_ENUM(FillMode)
|
||||
|
||||
QVersionNumber version() const
|
||||
{
|
||||
return m_version;
|
||||
@ -118,6 +129,11 @@ public:
|
||||
return m_checkWallpaperVisible;
|
||||
}
|
||||
|
||||
FillMode videoFillMode() const
|
||||
{
|
||||
return m_videoFillMode;
|
||||
}
|
||||
|
||||
signals:
|
||||
void autostartChanged(bool autostart);
|
||||
void highPriorityStartChanged(bool highPriorityStart);
|
||||
@ -132,6 +148,8 @@ signals:
|
||||
void languageChanged(QString language);
|
||||
void checkWallpaperVisibleChanged(bool checkWallpaperVisible);
|
||||
|
||||
void videoFillModeChanged(FillMode videoFillMode);
|
||||
|
||||
public slots:
|
||||
bool writeSingleSettingConfig(QString name, QVariant value);
|
||||
void writeJsonFileFromResource(const QString& filename);
|
||||
@ -253,6 +271,18 @@ public slots:
|
||||
emit checkWallpaperVisibleChanged(m_checkWallpaperVisible);
|
||||
}
|
||||
|
||||
void setVideoFillMode(FillMode videoFillMode)
|
||||
{
|
||||
if (m_videoFillMode == videoFillMode)
|
||||
return;
|
||||
|
||||
m_qSettings.setValue("VideoFillMode", QVariant::fromValue(videoFillMode).toString());
|
||||
m_qSettings.sync();
|
||||
|
||||
m_videoFillMode = videoFillMode;
|
||||
emit videoFillModeChanged(m_videoFillMode);
|
||||
}
|
||||
|
||||
private:
|
||||
void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType);
|
||||
|
||||
@ -272,6 +302,7 @@ private:
|
||||
|
||||
QString m_gitBuildHash;
|
||||
QString m_decoder { "" };
|
||||
QString m_language;
|
||||
QString m_language { "en" };
|
||||
FillMode m_videoFillMode;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user