mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 19:42:45 +01:00
Cleanup ProjectSettingsListModel
Remove unnecessary shared_ptr Fix dark mode white background by moving from Rectangle to Item
This commit is contained in:
parent
b035ec716b
commit
fb503d2fd0
@ -16,7 +16,6 @@ Item {
|
||||
property string activeMonitorName: ""
|
||||
property int activeMonitorIndex
|
||||
|
||||
|
||||
onStateChanged: {
|
||||
bgMouseArea.focus = monitors.state == "active" ? true : false
|
||||
if (monitors.state === "active") {
|
||||
@ -203,7 +202,10 @@ Item {
|
||||
delegate: MonitorsProjectSettingItem {
|
||||
id: delegate
|
||||
width: parent.width - 40
|
||||
selectedMonitor: monitors.activeMonitorIndex
|
||||
selectedMonitor: activeMonitorIndex
|
||||
name: m_name
|
||||
isHeadline: m_isHeadline
|
||||
value: m_value
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
@ -217,7 +219,7 @@ Item {
|
||||
PropertyChanges {
|
||||
target: customPropertiesGridView
|
||||
opacity: 1
|
||||
z:1
|
||||
z: 1
|
||||
anchors.topMargin: 60
|
||||
}
|
||||
},
|
||||
@ -226,7 +228,7 @@ Item {
|
||||
PropertyChanges {
|
||||
target: customPropertiesGridView
|
||||
opacity: 0
|
||||
z:-1
|
||||
z: -1
|
||||
anchors.topMargin: -100
|
||||
}
|
||||
}
|
||||
@ -349,3 +351,4 @@ Designer {
|
||||
D{i:0;autoSize:true;height:768;width:1366}
|
||||
}
|
||||
##^##*/
|
||||
|
||||
|
@ -8,31 +8,34 @@ import QtQuick.Layouts 1.3
|
||||
|
||||
import ScreenPlay 1.0
|
||||
|
||||
Rectangle {
|
||||
id: delegate
|
||||
Item {
|
||||
id: root
|
||||
focus: true
|
||||
height: isHeadline ? 50 : 30
|
||||
property int selectedMonitor
|
||||
property string name
|
||||
property var value
|
||||
property bool isHeadline
|
||||
|
||||
Text {
|
||||
id: txtDescription
|
||||
text: name
|
||||
text: root.name
|
||||
width: 100
|
||||
font.pointSize: isHeadline ? 18 : 12
|
||||
font.pointSize: root.isHeadline ? 18 : 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: ScreenPlay.settings.font
|
||||
font.weight: Font.Normal
|
||||
color: isHeadline ? Qt.darker(Material.foreground) : Material.foreground
|
||||
color: root.isHeadline ? Qt.darker(Material.foreground) : Material.foreground
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: isHeadline ? 0 : 25
|
||||
leftMargin: root.isHeadline ? 0 : 25
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: parent.height
|
||||
visible: !isHeadline
|
||||
visible: !root.isHeadline
|
||||
anchors {
|
||||
left: txtDescription.right
|
||||
leftMargin: 20
|
||||
@ -40,11 +43,11 @@ Rectangle {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (value.toString() === "") {
|
||||
if (root.value.toString() === "") {
|
||||
return
|
||||
}
|
||||
|
||||
var obj = JSON.parse(value.toString())
|
||||
var obj = JSON.parse(root.value.toString())
|
||||
|
||||
if (obj["text"]) {
|
||||
txtDescription.text = obj["text"]
|
||||
|
@ -58,7 +58,6 @@ struct ProjectSettingsListItem {
|
||||
m_isHeadline = isHeadline;
|
||||
m_value = value;
|
||||
}
|
||||
ProjectSettingsListItem() {}
|
||||
|
||||
QString m_name;
|
||||
bool m_isHeadline { false };
|
||||
|
@ -79,9 +79,9 @@ QVariant ProjectSettingsListModel::data(const QModelIndex& index, int role) cons
|
||||
QHash<int, QByteArray> ProjectSettingsListModel::roleNames() const
|
||||
{
|
||||
static const QHash<int, QByteArray> roles {
|
||||
{ NameRole, "name" },
|
||||
{ IsHeadlineRole, "isHeadline" },
|
||||
{ ValueRole, "value" },
|
||||
{ NameRole, "m_name" },
|
||||
{ IsHeadlineRole, "m_isHeadline" },
|
||||
{ ValueRole, "m_value" },
|
||||
};
|
||||
return roles;
|
||||
}
|
||||
@ -90,7 +90,7 @@ QHash<int, QByteArray> ProjectSettingsListModel::roleNames() const
|
||||
Recursively loads the content of a project.json.
|
||||
See also \l {https://kelteseth.gitlab.io/ScreenPlayDocs/project/project/} .
|
||||
*/
|
||||
void ProjectSettingsListModel::init(QString file)
|
||||
void ProjectSettingsListModel::init(const QString& file)
|
||||
{
|
||||
if (auto config = Util::openJsonFileToObject(file)) {
|
||||
|
||||
@ -105,23 +105,26 @@ void ProjectSettingsListModel::init(QString file)
|
||||
|
||||
QJsonObject::iterator itParent, itChild;
|
||||
for (itParent = tmpParent.begin(); itParent != tmpParent.end(); itParent++) {
|
||||
|
||||
// The first object is always a category
|
||||
QJsonObject tmpChildObj = tmpParent.value(itParent.key()).toObject();
|
||||
append(itParent.key(), true, "");
|
||||
|
||||
// Children of this category
|
||||
for (itChild = tmpChildObj.begin(); itChild != tmpChildObj.end(); itChild++) {
|
||||
append(itChild.key(), false, QJsonDocument(tmpChildObj.value(itChild.key()).toObject()).toJson());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Could not load: " << file << " for wallpaper settings!";
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectSettingsListModel::append(QString name, bool isHeadline, QVariant value)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_projectSettings.size(), m_projectSettings.size());
|
||||
|
||||
ProjectSettingsListItem tmpFile(name, isHeadline, value);
|
||||
ProjectSettingsListItem tmpFile(name, isHeadline, value.toString());
|
||||
m_projectSettings.append(tmpFile);
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
};
|
||||
Q_ENUM(ProjectSettingsRole)
|
||||
|
||||
void init(QString file);
|
||||
void init(const QString& file);
|
||||
|
||||
public slots:
|
||||
void append(QString name, bool isHeadline, QVariant value);
|
||||
|
@ -26,7 +26,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(
|
||||
const bool checkWallpaperVisible,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_projectSettingsListModel { std::make_shared<ProjectSettingsListModel>(absolutePath + "/project.json") }
|
||||
, m_projectSettingsListModel { absolutePath + "/project.json"}
|
||||
, m_globalVariables { globalVariables }
|
||||
, m_screenNumber { screenNumber }
|
||||
, m_previewImage { previewImage }
|
||||
@ -110,4 +110,9 @@ void ScreenPlayWallpaper::processError(QProcess::ProcessError error)
|
||||
qDebug() << "EX: " << error;
|
||||
}
|
||||
|
||||
ProjectSettingsListModel* ScreenPlayWallpaper::getProjectSettingsListModel()
|
||||
{
|
||||
return &m_projectSettingsListModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,11 +94,6 @@ public:
|
||||
|
||||
QJsonObject getActiveSettingsJson();
|
||||
|
||||
const std::shared_ptr<ProjectSettingsListModel>& projectSettingsListModel() const
|
||||
{
|
||||
return m_projectSettingsListModel;
|
||||
}
|
||||
|
||||
QVector<int> screenNumber() const
|
||||
{
|
||||
return m_screenNumber;
|
||||
@ -144,6 +139,8 @@ public:
|
||||
return m_isLooping;
|
||||
}
|
||||
|
||||
ProjectSettingsListModel* getProjectSettingsListModel();
|
||||
|
||||
signals:
|
||||
void screenNumberChanged(QVector<int> screenNumber);
|
||||
void previewImageChanged(QString previewImage);
|
||||
@ -247,7 +244,7 @@ public slots:
|
||||
private:
|
||||
QProcess m_process;
|
||||
|
||||
std::shared_ptr<ProjectSettingsListModel> m_projectSettingsListModel;
|
||||
ProjectSettingsListModel m_projectSettingsListModel;
|
||||
const std::shared_ptr<GlobalVariables>& m_globalVariables;
|
||||
|
||||
QVector<int> m_screenNumber;
|
||||
|
Loading…
Reference in New Issue
Block a user