fix reply post counting and enable send action when there is something to post

This commit is contained in:
Morgan McMillian 2019-10-13 17:23:47 -07:00
parent 82d5a1bc0d
commit 3e9499670d
5 changed files with 24 additions and 6 deletions

View file

@ -57,7 +57,14 @@ Sheet {
TextArea { TextArea {
id: postText id: postText
preferredHeight: 350.0 preferredHeight: 350.0
onTextChanging: postChanging(text) onTextChanging: {
postChanging(text)
if (count > 0) {
sendAction.enabled = true
} else {
sendAction.enabled = false
}
}
} }
} }
Container { Container {

View file

@ -377,6 +377,14 @@ Container {
onSendPost: { onSendPost: {
postitem.ListItem.view.sendReply(text, ListItemData.id); postitem.ListItem.view.sendReply(text, ListItemData.id);
} }
onPostChanging: {
replySheet.count = 256 - postitem.ListItem.view.postLength(text)
if (replySheet.count < 0) {
replySheet.counttext = "longpost"
} else {
replySheet.counttext = replySheet.count.toString()
}
}
} }
] ]
function parseMentions(mentions) { function parseMentions(mentions) {

View file

@ -113,6 +113,9 @@ NavigationPane {
function getPost(pid) { function getPost(pid) {
pnut.getPost(pid) pnut.getPost(pid)
} }
function postLength(text) {
return pnut.postLength(text)
}
function ccOnReply() { function ccOnReply() {
if (_app.setting("cc") === "true") { if (_app.setting("cc") === "true") {
return true return true

View file

@ -360,7 +360,7 @@ void Pnut::sendPost(QString text, int pid=0)
QVariantMap map; QVariantMap map;
QVariantList raw; QVariantList raw;
if (postLength(text) > 254) if (postLength(text) > 256)
{ {
QVariantMap longpost; QVariantMap longpost;
QVariantMap rawobj; QVariantMap rawobj;

View file

@ -233,22 +233,22 @@
<context> <context>
<name>StreamTab</name> <name>StreamTab</name>
<message> <message>
<location filename="../assets/StreamTab.qml" line="182"/> <location filename="../assets/StreamTab.qml" line="185"/>
<source>New Post</source> <source>New Post</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="196"/> <location filename="../assets/StreamTab.qml" line="199"/>
<source>To Top</source> <source>To Top</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="224"/> <location filename="../assets/StreamTab.qml" line="227"/>
<source>To Bottom</source> <source>To Bottom</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="211"/> <location filename="../assets/StreamTab.qml" line="214"/>
<source>Reload</source> <source>Reload</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>