diff options
author | Nicolas Werner <nicolas.werner@ymail.com> | 2022-04-16 02:13:01 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@ymail.com> | 2022-04-23 03:10:27 +0200 |
commit | da96558bb96678d60b5cc3072e33ad7c3e1ec91c (patch) | |
tree | e55b54399824f4cc08f77fe43c803328f68a7007 | |
parent | a8bd8dddbfcb0c4837e44618ed4443d644196b3d (diff) |
Lint qml
93 files changed, 4298 insertions, 5855 deletions
diff --git a/.ci/licenses.sh b/.ci/licenses.sh index cdcd305f..b54f8c39 100755 --- a/.ci/licenses.sh +++ b/.ci/licenses.sh @@ -7,7 +7,7 @@ set -eu -FILES=$(find src resources/qml -type f \( -iname "*.cpp" -o -iname "*.h" -o -iname "*.qml" \)) +FILES=$(find src qml -type f \( -iname "*.cpp" -o -iname "*.h" -o -iname "*.qml" \)) reuse addheader --copyright="Nheko Contributors" --license="GPL-3.0-or-later" $FILES diff --git a/.qmlformat.ini b/.qmlformat.ini new file mode 100644 index 00000000..c103c200 --- /dev/null +++ b/.qmlformat.ini @@ -0,0 +1,5 @@ +[General] +IndentWidth=4 +NewlineType=native +NormalizeOrder=true +UseTabs=false diff --git a/.qmllint.ini b/.qmllint.ini new file mode 100644 index 00000000..ccf13177 --- /dev/null +++ b/.qmllint.ini @@ -0,0 +1,23 @@ +[General] +AdditionalQmlImportPaths= +DisableDefaultImports=false +OverwriteImportTypes= +ResourcePath= + +[Warnings] +AttachedPropertyReuse=disable +BadSignalHandler=warning +CompilerWarnings=disable +ControlsSanity=disable +DeferredPropertyId=warning +Deprecated=warning +ImportFailure=warning +InheritanceCycle=warning +MultilineStrings=info +PropertyAlias=warning +RequiredProperty=warning +TypeError=warning +UnknownProperty=warning +UnqualifiedAccess=disable +UnusedImports=info +WithStatement=warning diff --git a/qml/Avatar.qml b/qml/Avatar.qml index 72ebdc14..e944d921 100644 --- a/qml/Avatar.qml +++ b/qml/Avatar.qml @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors // SPDX-FileCopyrightText: 2022 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later - -import "./ui" +import "ui" import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Window 2.15 @@ -12,70 +10,54 @@ import im.nheko AbstractButton { id: avatar - property string url - property string userid - property string roomid + property alias color: bg.color + property bool crop: true property string displayName + property string roomid property alias textColor: label.color - property bool crop: true - property alias color: bg.color + property string url + property string userid - width: 48 height: 48 + width: 48 + background: Rectangle { id: bg - radius: Settings.avatarCircles ? height / 2 : height / 8 color: timelineRoot.palette.alternateBase + radius: Settings.avatarCircles ? height / 2 : height / 8 } Label { id: label - - enabled: false - anchors.fill: parent + color: timelineRoot.palette.text + enabled: false + font.pixelSize: avatar.height / 2 + horizontalAlignment: Text.AlignHCenter text: TimelineManager.escapeEmoji(displayName ? String.fromCodePoint(displayName.codePointAt(0)) : "") textFormat: Text.RichText - font.pixelSize: avatar.height / 2 verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter visible: img.status != Image.Ready && !Settings.useIdenticon - color: timelineRoot.palette.text } - Image { id: identicon - anchors.fill: parent - visible: Settings.useIdenticon && img.status != Image.Ready source: Settings.useIdenticon ? ("image://jdenticon/" + (userid !== "" ? userid : roomid) + "?radius=" + (Settings.avatarCircles ? 100 : 25)) : "" + visible: Settings.useIdenticon && img.status != Image.Ready } - Image { id: img - anchors.fill: parent asynchronous: true fillMode: avatar.crop ? Image.PreserveAspectCrop : Image.PreserveAspectFit mipmap: true smooth: true - sourceSize.width: avatar.width * Screen.devicePixelRatio - sourceSize.height: avatar.height * Screen.devicePixelRatio source: avatar.url ? (avatar.url + "?radius=" + (Settings.avatarCircles ? 100 : 25) + ((avatar.crop) ? "" : "&scale")) : "" - + sourceSize.height: avatar.height * Screen.devicePixelRatio + sourceSize.width: avatar.width * Screen.devicePixelRatio } - Rectangle { id: onlineIndicator - - anchors.bottom: avatar.bottom - anchors.right: avatar.right - visible: !!userid - height: avatar.height / 6 - width: height - radius: Settings.avatarCircles ? height / 2 : height / 8 - color: updatePresence() - function updatePresence() { switch (Presence.userPresence(userid)) { case "online": @@ -89,22 +71,28 @@ AbstractButton { } } - Connections { - target: Presence + anchors.bottom: avatar.bottom + anchors.right: avatar.right + color: updatePresence() + height: avatar.height / 6 + radius: Settings.avatarCircles ? height / 2 : height / 8 + visible: !!userid + width: height + Connections { function onPresenceChanged(id) { - if (id == userid) onlineIndicator.color = onlineIndicator.updatePresence(); + if (id == userid) + onlineIndicator.color = onlineIndicator.updatePresence(); } + + target: Presence } } - NhekoCursorShape { anchors.fill: parent cursorShape: Qt.PointingHandCursor } - Ripple { color: Qt.rgba(timelineRoot.palette.alternateBase.r, timelineRoot.palette.alternateBase.g, timelineRoot.palette.alternateBase.b, 0.5) } - } diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml index d8ae7feb..7b0da916 100644 --- a/qml/ChatPage.qml +++ b/qml/ChatPage.qml @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors // SPDX-FileCopyrightText: 2022 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later - import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.3 @@ -14,41 +12,28 @@ import QtQml 2.15 Rectangle { id: chatPage - color: timelineRoot.palette.window ColumnLayout { - spacing: 0 anchors.fill: parent + spacing: 0 Rectangle { id: offlineIndicator - + Layout.fillWidth: true + Layout.preferredHeight: offlineLabel.height + Nheko.paddingMedium color: Nheko.theme.error visible: !TimelineManager.isConnected - Layout.preferredHeight: offlineLabel.height + Nheko.paddingMedium - Layout.fillWidth: true z: 1 Label { id: offlineLabel - anchors.centerIn: parent text: qsTr("No network connection") } } - AdaptiveLayout { id: adaptiveView - - Layout.fillWidth: true - Layout.fillHeight: true - singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width - pageIndex: 1 - - Component.onCompleted: initializePageIndex() - onSinglePageModeChanged: initializePageIndex() - function initializePageIndex() { if (!singlePageMode) adaptiveView.pageIndex = 0; @@ -58,91 +43,80 @@ Rectangle { adaptiveView.pageIndex = 1; } + Layout.fillHeight: true + Layout.fillWidth: true + pageIndex: 1 + singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width + + Component.onCompleted: initializePageIndex() + onSinglePageModeChanged: initializePageIndex() + Connections { - target: Rooms function onCurrentRoomChanged() { adaptiveView.initializePageIndex(); } - } + target: Rooms + } AdaptiveLayoutElement { id: communityListC - - visible: Settings.groupView - minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2 collapsedWidth: communitiesList.avatarSize + 2 * Nheko.paddingMedium - preferredWidth: Settings.communityListWidth >= minimumWidth ? Settings.communityListWidth : collapsedWidth maximumWidth: communitiesList.avatarSize * 10 + 2 * Nheko.paddingMedium + minimumWidth: communitiesList.avatarSize * 4 + Nheko.paddingMedium * 2 + preferredWidth: Settings.communityListWidth >= minimumWidth ? Settings.communityListWidth : collapsedWidth + visible: Settings.groupView CommunitiesList { id: communitiesList - collapsed: parent.collapsed } - Binding { - target: Settings + delayed: true property: 'communityListWidth' + restoreMode: Binding.RestoreBindingOrValue + target: Settings value: communityListC.preferredWidth when: !adaptiveView.singlePageMode - delayed: true - restoreMode: Binding.RestoreBindingOrValue } - } - AdaptiveLayoutElement { id: roomListC - - minimumWidth: roomlist.avatarSize * 4 + Nheko.paddingSmall * 2 - preferredWidth: (Settings.roomListWidth == - 1) - ? (roomlist.avatarSize * 5 + Nheko.paddingSmall * 2) - : (Settings.roomListWidth >= minimumWidth ? Settings.roomListWidth : collapsedWidth) - maximumWidth: roomlist.avatarSize * 10 + Nheko.paddingSmall * 2 collapsedWidth: roomlist.avatarSize + 2 * Nheko.paddingMedium + maximumWidth: roomlist.avatarSize * 10 + Nheko.paddingSmall * 2 + minimumWidth: roomlist.avatarSize * 4 + Nheko.paddingSmall * 2 + preferredWidth: (Settings.roomListWidth == -1) ? (roomlist.avatarSize * 5 + Nheko.paddingSmall * 2) : (Settings.roomListWidth >= minimumWidth ? Setti |