Skip to content

Commit

Permalink
add update and heart buttons to mods
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Aug 24, 2022
1 parent 586bf88 commit 4feafc0
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [moonshadow565]
6 changes: 6 additions & 0 deletions src/CSLOLToolsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ static QJsonObject modInfoFixup(QString modName, QJsonObject object) {
if (!object.contains("Description") || !object["Description"].isString()) {
object["Description"] = "";
}
if (!object.contains("Home") || !object["Home"].isString()) {
object["Home"] = "";
}
if (!object.contains("Heart") || !object["Heart"].isString()) {
object["Heart"] = "";
}
return object;
}

Expand Down
44 changes: 42 additions & 2 deletions src/qml/CSLOLModInfoEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ColumnLayout {
fieldAuthor.text = ""
fieldVersion.text = ""
fieldDescription.text = ""
fieldHome.text = ""
fieldHeart.text = ""
fieldImage.text = ""
}

Expand All @@ -24,11 +26,15 @@ ColumnLayout {
let author = fieldAuthor.text == "" ? "UNKNOWN" : fieldAuthor.text
let version = fieldVersion.text == "" ? "1.0" : fieldVersion.text
let description = fieldDescription.text
let home = fieldHome.text
let heart = fieldHeart.text
let info = {
"Name": name,
"Author": author,
"Version": version,
"Description": description
"Description": description,
"Home": home,
"Heart": heart,
}
return info
}
Expand All @@ -38,6 +44,8 @@ ColumnLayout {
fieldAuthor.text = info["Author"]
fieldVersion.text = info["Version"]
fieldDescription.text = info["Description"]
fieldHome.text = info["Home"]
fieldHeart.text = info["Heart"]
}

RowLayout {
Expand Down Expand Up @@ -83,7 +91,39 @@ ColumnLayout {
placeholderText: "0.0.0"
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: /([0-9]{1,3})(\.[0-9]{1,3}){0,3}/
regularExpression: window.validVersion
}
}
}

RowLayout {
Layout.fillWidth: true
Label {
text: qsTr("Home: ")
}
TextField {
id: fieldHome
Layout.fillWidth: true
placeholderText: "Home or update link for a skin"
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: window.validUrl
}
}
}

RowLayout {
Layout.fillWidth: true
Label {
text: qsTr("Heart: ")
}
TextField {
id: fieldHeart
Layout.fillWidth: true
placeholderText: "Authors homepage link or twitter or whatever"
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: window.validUrl
}
}
}
Expand Down
44 changes: 42 additions & 2 deletions src/qml/CSLOLModsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ColumnLayout {
id: cslolModsView
spacing: 5

property bool showImage: true

property int columnCount: 1

property bool isBussy: false
Expand Down Expand Up @@ -36,6 +38,9 @@ ColumnLayout {
"Version": info["Version"],
"Description": info["Description"],
"Author": info["Author"],
"Home": info["Home"],
"Heart": info["Heart"],
"Image": CSLOLUtils.toFile("./installed/" + fileName + "/META/image.png"),
"Enabled": enabled === true
}
if (searchMatches(infoData)) {
Expand Down Expand Up @@ -159,6 +164,12 @@ ColumnLayout {
if (obj["Author"] !== info["Author"]) {
model.setProperty(i, "Author", info["Author"])
}
if (obj["Home"] !== info["Home"]) {
model.setProperty(i, "Home", info["Home"])
}
if (obj["Heart"] !== info["Heart"]) {
model.setProperty(i, "Heart", info["Heart"])
}
return i;
}
}
Expand Down Expand Up @@ -213,6 +224,7 @@ ColumnLayout {
Row {
width: parent.width
property string modName: model.Name

CheckBox {
width: parent.width * 0.3
id: modCheckbox
Expand All @@ -237,7 +249,7 @@ ColumnLayout {
}

Column {
width: parent.width * 0.39
width: parent.width * 0.29
anchors.verticalCenter: parent.verticalCenter
Label {
horizontalAlignment: Text.AlignHCenter
Expand All @@ -257,7 +269,7 @@ ColumnLayout {
}

Row {
width: parent.width * 0.3
width: parent.width * 0.4
layoutDirection: Qt.RightToLeft
anchors.verticalCenter: parent.verticalCenter
ToolButton {
Expand Down Expand Up @@ -297,6 +309,34 @@ ColumnLayout {
visible: parent.hovered
}
}
ToolButton {
text: "\uf059"
font.family: "FontAwesome"
onClicked: {
let url = model.Home
if (window.validUrl.test(url)) {
Qt.openUrlExternally(url)
}
}
ToolTip {
text: qsTr("Mod updates")
visible: parent.hovered
}
}
ToolButton {
text: "\uf004"
font.family: "FontAwesome"
onClicked: {
let url = model.Heart
if (window.validUrl.test(url)) {
Qt.openUrlExternally(url)
}
}
ToolTip {
text: qsTr("Support this author")
visible: parent.hovered
}
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/qml/CSLOLToolBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ ToolBar {
visible: parent.hovered
}
}
ToolButton {
id: heartButton
text: "\uf004"
font.family: "FontAwesome"
onClicked: {
Qt.openUrlExternally("https://github.com/sponsors/moonshadow565")
}
}
ToolButton {
text: qsTr("Save")
onClicked: cslolToolBar.saveProfileAndRun(false)
Expand Down
2 changes: 2 additions & 0 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ApplicationWindow {

property bool isBussy: cslolTools.state !== CSLOLTools.StateIdle
property var validName: new RegExp(/[\p{L}\p{M}\p{Z}\p{N}\w]{3,50}/u)
property var validVersion: new RegExp(/([0-9]{1,3})(\.[0-9]{1,3}){0,3}/)
property var validUrl: new RegExp(/^(http(s)?:\/\/).+$/u)
property bool firstTick: false

function showUserError(name, message) {
Expand Down

0 comments on commit 4feafc0

Please sign in to comment.