From 5b3f077fa98b5ac2da7fa1704b13c0c9247bdf73 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 30 Jun 2020 17:35:24 -0400 Subject: [PATCH] feat: bundle resources - Update linux build to package resources - Refactor macOS packaging re: resources.rcc --- .gitignore | 2 ++ Makefile | 18 +++++++++++++----- src/nim_status_client.nim | 6 ++++-- ui/app/AppLayouts/Chat/ChatColumn/Message.qml | 3 +-- .../Chat/components/PrivateChatPopup.qml | 6 ++---- ui/generate-rcc.sh | 15 +++++++++++++++ 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100755 ui/generate-rcc.sh diff --git a/.gitignore b/.gitignore index 47820107fc..ee4390dff7 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ yarn-debug.log* yarn-error.log* yarn.lock TODO +resources.rcc +resources.qrc diff --git a/Makefile b/Makefile index 73b05b1309..6b378949cc 100644 --- a/Makefile +++ b/Makefile @@ -167,7 +167,13 @@ $(QRCODEGEN): | deps + cd vendor/QR-Code-generator/c && \ $(MAKE) -nim_status_client: | $(DOTHERSIDE) $(STATUSGO) $(QRCODEGEN) deps +rcc: + rm -f ./bin/resources.rcc + rm -f ./resources.qrc + ./ui/generate-rcc.sh + rcc --binary ui/resources.qrc -o ./resources.rcc + +nim_status_client: | $(DOTHERSIDE) $(STATUSGO) $(QRCODEGEN) rcc deps echo -e $(BUILD_MSG) "$@" && \ $(ENV_SCRIPT) nim c $(NIM_PARAMS) --passL:"$(STATUSGO)" --passL:"$(QRCODEGEN)" --passL:"-lm" src/nim_status_client.nim @@ -193,10 +199,11 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop cp bin/nim_status_client tmp/linux/dist/usr/bin cp nim-status.desktop tmp/linux/dist/. cp status.svg tmp/linux/dist/status.svg - cp -R ui tmp/linux/dist/usr/. + cp status.svg tmp/linux/dist/usr/. + cp -R resources.rcc tmp/linux/dist/usr/. echo -e $(BUILD_MSG) "AppImage" - linuxdeployqt tmp/linux/dist/nim-status.desktop -no-translations -no-copy-copyright-files -qmldir=tmp/linux/dist/usr/ui -qmlimport=$(QTDIR)/qml -bundle-non-qt-libs + linuxdeployqt tmp/linux/dist/nim-status.desktop -no-translations -no-copy-copyright-files -qmldir=ui -qmlimport=$(QTDIR)/qml -bundle-non-qt-libs rm tmp/linux/dist/AppRun cp AppRun tmp/linux/dist/. @@ -223,7 +230,8 @@ $(STATUS_CLIENT_DMG): nim_status_client $(DMG_TOOL) cp nim_status_client.sh $(MACOS_OUTER_BUNDLE)/Contents/MacOS/ chmod +x $(MACOS_OUTER_BUNDLE)/Contents/MacOS/nim_status_client.sh cp status-icon.icns $(MACOS_OUTER_BUNDLE)/Contents/Resources/ - cp -R ui $(MACOS_OUTER_BUNDLE)/Contents/ + cp status.svg $(MACOS_OUTER_BUNDLE)/Contents/ + cp -R resources.rcc $(MACOS_OUTER_BUNDLE)/Contents/ macdeployqt \ $(MACOS_OUTER_BUNDLE) \ @@ -269,7 +277,7 @@ clean: | clean-common rm -rf bin/* node_modules pkg/* tmp/* $(STATUSGO) + $(MAKE) -C vendor/DOtherSide/build --no-print-directory clean -run: +run: | rcc LD_LIBRARY_PATH="$(QT5_LIBDIR)" ./bin/nim_status_client endif # "variables.mk" was not included diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index 3fb396ac32..094b95b4a3 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -23,7 +23,9 @@ proc mainProc() = enableHDPI() let app = newQApplication("Nim Status Client") - app.icon("./status.svg") + QResource.registerResource(app.applicationDirPath & "/../resources.rcc") + + app.icon(app.applicationDirPath & "/../status.svg") let engine = newQQmlApplicationEngine() let signalController = signals.newController(app) @@ -116,7 +118,7 @@ proc mainProc() = engine.setRootContextProperty("signals", signalController.variant) - engine.load("../ui/main.qml") + engine.load(newQUrl("qrc:///main.qml")) # Please note that this must use the `cdecl` calling convention because # it will be passed as a regular C function to libstatus. This means that diff --git a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml index 6673bcdf4d..4fd544d1f7 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml @@ -261,11 +261,10 @@ Item { textFormat: TextEdit.RichText text: { if(contentType === Constants.stickerType) return ""; - if (isMessage) return linkify(message); if(isEmoji){ return Emoji.parse(message, "72x72"); } else { - return Emoji.parse(message, "26x26"); + return Emoji.parse(linkify(message), "26x26"); } } anchors.left: parent.left diff --git a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml index e179f2fecc..46dc72f251 100644 --- a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml +++ b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml @@ -83,13 +83,11 @@ ModalPopup { ScrollView { anchors.fill: parent - anchors.topMargin: 50 - anchors.top: searchBox.bottom Layout.fillWidth: true Layout.fillHeight: true ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: groupMembers.contentHeight > groupMembers.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff + ScrollBar.vertical.policy: contactListView.contentHeight > contactListView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff ListView { anchors.fill: parent @@ -101,7 +99,7 @@ ModalPopup { showCheckbox: false pubKey: model.pubKey isContact: model.isContact - isUser: model.isUser + isUser: false name: model.name address: model.address identicon: model.identicon diff --git a/ui/generate-rcc.sh b/ui/generate-rcc.sh new file mode 100755 index 0000000000..91641578dc --- /dev/null +++ b/ui/generate-rcc.sh @@ -0,0 +1,15 @@ +#!/bin/sh +cd ./ui/ +QRC=./resources.qrc +echo '' > $QRC +echo '' >> $QRC +echo ' ' >> $QRC +for a in $(find . -not -name "*.pro" -not -name "*.rcc" -not -name "*.sh" -not -name "*.qrc" ) +do + if [ ! -d "$a" ]; then + echo ' '$a'' >> $QRC + fi +done +echo ' ' >> $QRC +echo '' >> $QRC +cd .. \ No newline at end of file