diff --git a/assets/.assets.index b/assets/.assets.index index 94f597b..36d830c 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,51 +1,51 @@ 1 49 -WebViewSheet.qml -PostItem.qml -RefreshItem.qml -icons/ic_favorite.png -icons/ic_cancel.png -icons/bookmark.png -icons/laughing_man.png -icons/at.png -icons/home.png -icons/ic_edit.png -icons/ic_doctype_picture.png -icons/globe.png -icons/ic_add_bookmarks.png -icons/ic_copy.png -icons/ic_to_top.png -icons/sign-out.png -icons/bell.png -icons/quote-left.png -icons/bell-slash.png -icons/ic_reply.png -icons/messages.png -icons/star-o.png -icons/ic_contact.png -icons/comments.png -icons/ic_info.png -icons/ic_to_bottom.png -icons/ic_add.png -icons/retweet.png -icons/ic_del_bookmarks.png -icons/minus-circle.png -icons/star.png -icons/ic_reload.png -icons/ic_reply_all.png -icons/refresh.png -icons/ic_compose.png -icons/default_cover.png -LoginSheet.qml -UserItem.qml -main.qml -StreamTab.qml -ThreadPage.qml -AboutPage.qml -parser.js -UserPage.qml -AppCover.qml moment.js -NewPostSheet.qml +RefreshItem.qml +PostItem.qml +WebViewSheet.qml +UserItem.qml +icons/messages.png +icons/comments.png +icons/ic_add.png +icons/bell.png +icons/minus-circle.png +icons/ic_info.png +icons/laughing_man.png +icons/default_cover.png +icons/star.png +icons/ic_reply.png +icons/ic_reply_all.png +icons/sign-out.png +icons/ic_doctype_picture.png +icons/bookmark.png +icons/star-o.png +icons/ic_cancel.png +icons/at.png +icons/ic_reload.png +icons/home.png +icons/ic_copy.png +icons/retweet.png +icons/bell-slash.png +icons/ic_favorite.png +icons/ic_contact.png +icons/refresh.png +icons/quote-left.png +icons/globe.png +icons/ic_del_bookmarks.png +icons/ic_add_bookmarks.png +icons/ic_to_top.png +icons/ic_edit.png +icons/ic_compose.png +icons/ic_to_bottom.png +StreamTab.qml ProfilePage.qml +ThreadPage.qml +parser.js +AboutPage.qml +LoginSheet.qml +AppCover.qml SettingsPage.qml +main.qml +NewPostSheet.qml +UserPage.qml diff --git a/assets/NewPostSheet.qml b/assets/NewPostSheet.qml index cf15d20..4011aa9 100644 --- a/assets/NewPostSheet.qml +++ b/assets/NewPostSheet.qml @@ -28,6 +28,7 @@ Sheet { property string counttext signal sendPost(string text) + signal postChanging(string text) Page { titleBar: TitleBar { @@ -56,19 +57,7 @@ Sheet { TextArea { id: postText preferredHeight: 350.0 - onTextChanging: { - if (postText.text.length > 0) { - sendAction.enabled = true; - } else { - sendAction.enabled = false; - } - count = 256 - postText.text.length - if (count < 0) { - counttext = "longpost" - } else { - counttext = count.toString() - } - } + onTextChanging: postChanging(text) } } Container { diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 4e18332..f926ec7 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -253,6 +253,14 @@ NavigationPane { console.log("send: " + text) pnut.sendPost(text, 0) } + onPostChanging: { + newPostSheet.count = 256 - pnut.postLength(text) + if (newPostSheet.count < 0) { + newPostSheet.counttext = "longpost" + } else { + newPostSheet.counttext = newPostSheet.count.toString() + } + } }, WebViewSheet { id: webViewSheet diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 302e0d8..67589e3 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -21,6 +21,7 @@ #include "globals.h" #include #include +#include #include const QString Pnut::PNUT_API_ROOT = QString("https://api.pnut.io/v0"); @@ -359,7 +360,7 @@ void Pnut::sendPost(QString text, int pid=0) QVariantMap map; QVariantList raw; - if (text.length() > 254) + if (postLength(text) > 254) { QVariantMap longpost; QVariantMap rawobj; @@ -569,6 +570,13 @@ void Pnut::getFollowing(QString uid) getRequest(url, parameters, req_id); } +int Pnut::postLength(QString text) +{ + QRegExp mdlink("\\[([^\\]]+)\\][^\\)]+\\)"); + text.replace(mdlink, "\\1"); + return text.length(); +} + void Pnut::onOpenBrowser(QUrl url) { qDebug() << "_onOpenBrowser_"; diff --git a/src/Pnut.h b/src/Pnut.h index 7392032..c412061 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -88,6 +88,7 @@ public: Q_INVOKABLE void getUserStream(QString uid); Q_INVOKABLE void getFollowers(QString uid); Q_INVOKABLE void getFollowing(QString uid); + Q_INVOKABLE int postLength(QString text); public slots: void onRequestReady(QByteArray data); diff --git a/translations/Goober.ts b/translations/Goober.ts index 49411e7..b26b215 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -25,17 +25,17 @@ NewPostSheet - + Send - + Cancel - + New Post