diff --git a/debian/control b/debian/control index 28250e9..4ee10e8 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: CutefishOS Build-Depends: cmake, debhelper (>= 9), extra-cmake-modules, + libcrypt-dev, libfreetype6-dev, libfontconfig1-dev, libkf5networkmanagerqt-dev, diff --git a/src/images/dark/down.svg b/src/images/dark/down.svg new file mode 100644 index 0000000..f279d3c --- /dev/null +++ b/src/images/dark/down.svg @@ -0,0 +1,61 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/images/dark/up.svg b/src/images/dark/up.svg new file mode 100644 index 0000000..7965f04 --- /dev/null +++ b/src/images/dark/up.svg @@ -0,0 +1,61 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/images/light/down.svg b/src/images/light/down.svg new file mode 100644 index 0000000..54ceffd --- /dev/null +++ b/src/images/light/down.svg @@ -0,0 +1,61 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/images/light/up.svg b/src/images/light/up.svg new file mode 100644 index 0000000..87aee29 --- /dev/null +++ b/src/images/light/up.svg @@ -0,0 +1,61 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/qml/AccountsPage.qml b/src/qml/AccountsPage.qml index 6efae88..bec0735 100644 --- a/src/qml/AccountsPage.qml +++ b/src/qml/AccountsPage.qml @@ -2,17 +2,18 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtGraphicalEffects 1.0 -import Qt.labs.platform 1.0 as LabsPlatform import MeuiKit 1.0 as Meui import Cutefish.Settings 1.0 import Cutefish.Accounts 1.0 +import "./UserPage" + ItemPage { headerTitle: qsTr("User") UserAccount { - id: currentUser + id: loggedUser } UsersModel { @@ -23,10 +24,6 @@ ItemPage { id: accountsManager } - AddUserDialog { - id: addUserDialog - } - Scrollable { anchors.fill: parent anchors.bottomMargin: Meui.Units.largeSpacing @@ -36,216 +33,43 @@ ItemPage { id: layout anchors.fill: parent - Label { - text: qsTr("Currently logged in as") - color: Meui.Theme.disabledTextColor - bottomPadding: Meui.Units.largeSpacing - } - - RowLayout { - LabsPlatform.FileDialog { - id: currentUserFileDialog - folder: LabsPlatform.StandardPaths.writableLocation(LabsPlatform.StandardPaths.PicturesLocation) - nameFilters: ["Pictures (*.png *.jpg *.gif)"] - onFileChanged: { - currentUser.iconFileName = currentFile.toString().replace("file://", "") - currentUserImage.source = currentFile - currentUserImage.update() - } - } - - Image { - id: currentUserImage - Layout.preferredWidth: 64 - Layout.preferredHeight: 64 - width: 64 - height: width - sourceSize: Qt.size(width, height) - source: currentUser.iconFileName ? "file://" + currentUser.iconFileName : "image://icontheme/default-user" - asynchronous: true - fillMode: Image.PreserveAspectCrop - cache: false - - property bool counter: false - - MouseArea { - id: userImageMouseArea - anchors.fill: parent - acceptedButtons: Qt.LeftButton - onClicked: currentUserFileDialog.open() - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - } - - ColorOverlay { - id: colorOverlay - anchors.fill: currentUserImage - source: currentUserImage - color: "#000000" - opacity: userImageMouseArea.pressed ? 0.3 : 0.2 - visible: userImageMouseArea.containsMouse || userImageMouseArea.pressed - } - - layer.enabled: true - layer.effect: OpacityMask { - maskSource: Item { - width: currentUserImage.width - height: width - - Rectangle { - anchors.fill: parent - radius: width / 2 - } - } - } - } - Label { - Layout.alignment: Qt.AlignVCenter - id: currentUserLabel - text: currentUser.displayName - font.pointSize: 16 - bottomPadding: Meui.Units.smallSpacing - leftPadding: Meui.Units.largeSpacing - } - - Label { - Layout.alignment: Qt.AlignVCenter - id: currentUserLabel2 - text: currentUser.userName - color: Meui.Theme.disabledTextColor - visible: currentUser.displayName !== currentUser.userName - font.pointSize: 16 - bottomPadding: Meui.Units.smallSpacing - } - - Item { - Layout.fillWidth: true - } - - Button { - text: additionalSettings.shown ? qsTr("Hide additional settings") : qsTr("Show additional settings") - onClicked: additionalSettings.toggle() - } - } - - Hideable { - id: additionalSettings - - Label { - text: qsTr("Additional settings") - color: Meui.Theme.disabledTextColor - Layout.bottomMargin: Meui.Units.largeSpacing - } - - RowLayout { - Layout.fillWidth: true - Layout.bottomMargin: Meui.Units.smallSpacing - - Label { - text: qsTr("Automatic login") - } - - Item { - Layout.fillWidth: true - } - - Switch { - id: automaticLoginSwitch - Layout.fillHeight: true - leftPadding: 0 - rightPadding: 0 - onCheckedChanged: currentUser.automaticLogin = checked - } - - Component.onCompleted: { - automaticLoginSwitch.checked = currentUser.automaticLogin - } - } - - HorizontalDivider {} - } - - Label { - id: otherAccountsLabel - text: qsTr("Other Accounts") - color: Meui.Theme.disabledTextColor - topPadding: Meui.Units.largeSpacing - bottomPadding: Meui.Units.largeSpacing - visible: _userView.count > 1 - } - ListView { id: _userView model: userModel Layout.fillWidth: true + spacing: Meui.Units.largeSpacing + interactive: false - Layout.preferredHeight: itemHeight * (_userView.count - 1) + Layout.preferredHeight: { + var totalHeight = 0 + for (var i = 0; i < _userView.visibleChildren.length; ++i) { + totalHeight += _userView.visibleChildren[i].height + } + totalHeight += (_userView.count - 1) * _userView.spacing + return totalHeight + } - property var itemHeight: 50 + Meui.Units.largeSpacing + property int itemHeight: 64 - delegate: Item { + delegate: UserDelegateItem { width: _userView.width - height: _userView.itemHeight - visible: userId !== currentUser.userId - - RowLayout { - id: _itemLayout - anchors.fill: parent - spacing: Meui.Units.largeSpacing - - Image { - width: 64 - height: width - sourceSize: Qt.size(width, height) - source: iconFileName ? "file:///" + iconFileName : "image://icontheme/default-user" - visible: status === Image.Ready - - layer.enabled: true - layer.effect: OpacityMask { - maskSource: Item { - width: currentUserImage.width - height: width - - Rectangle { - anchors.fill: parent - radius: width / 2 - } - } - } - } - - Label { - Layout.alignment: Qt.AlignVCenter - text: userName - font.pointSize: 16 - bottomPadding: Meui.Units.smallSpacing - leftPadding: Meui.Units.largeSpacing - } - - Label { - Layout.alignment: Qt.AlignVCenter - text: realName - color: Meui.Theme.disabledTextColor - visible: realName !== userName - font.pointSize: 16 - bottomPadding: Meui.Units.smallSpacing - } - - Item { - Layout.fillWidth: true - } - } } } Item { - height: Meui.Units.largeSpacing * 2 + height: Meui.Units.smallSpacing } Button { id: _addUserButton text: qsTr("Add user") - onClicked: addUserDialog.open() + onClicked: { + var component = Qt.createComponent("AddUserDialog.qml") + if (component.status === Component.Ready) { + var dialog = component.createObject(rootWindow) + dialog.open() + } + } } } } diff --git a/src/qml/AddUserDialog.qml b/src/qml/AddUserDialog.qml index e017952..e7fe352 100644 --- a/src/qml/AddUserDialog.qml +++ b/src/qml/AddUserDialog.qml @@ -8,7 +8,6 @@ import Cutefish.Accounts 1.0 Dialog { id: control - // parent: rootWindow x: (parent.width - width) / 2 y: (parent.height - height) / 2 modal: true diff --git a/src/qml/UserPage/UserDelegateItem.qml b/src/qml/UserPage/UserDelegateItem.qml new file mode 100644 index 0000000..3f8eeb6 --- /dev/null +++ b/src/qml/UserPage/UserDelegateItem.qml @@ -0,0 +1,161 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtGraphicalEffects 1.0 +import Qt.labs.platform 1.0 as LabsPlatform + +import Cutefish.Settings 1.0 +import Cutefish.Accounts 1.0 +import MeuiKit 1.0 as Meui + +import "../" + +Item { + id: control + + height: mainLayout.implicitHeight + + UserAccount { + id: currentUser + userId: model.userId + } + + LabsPlatform.FileDialog { + id: currentUserFileDialog + folder: LabsPlatform.StandardPaths.writableLocation(LabsPlatform.StandardPaths.PicturesLocation) + nameFilters: ["Pictures (*.png *.jpg *.gif)"] + onFileChanged: { + currentUser.iconFileName = currentFile.toString().replace("file://", "") + _userImage.source = currentFile + _userImage.update() + } + } + + ColumnLayout { + id: mainLayout + anchors.fill: parent + spacing: 0 + + RowLayout { + id: _itemLayout + spacing: 0 + + Image { + id: _userImage + width: 50 + height: 50 + sourceSize: Qt.size(width, height) + source: iconFileName ? "file:///" + iconFileName : "image://icontheme/default-user" + visible: status === Image.Ready + + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Item { + width: _userImage.width + height: width + + Rectangle { + anchors.fill: parent + radius: width / 2 + } + } + } + } + + Label { + Layout.alignment: Qt.AlignVCenter + text: userName + font.pointSize: 16 + bottomPadding: Meui.Units.smallSpacing + leftPadding: Meui.Units.largeSpacing + } + + Label { + Layout.alignment: Qt.AlignVCenter + text: realName + color: Meui.Theme.disabledTextColor + visible: realName !== userName + font.pointSize: 16 + bottomPadding: Meui.Units.smallSpacing + } + + Item { + Layout.fillWidth: true + } + + Label { + text: qsTr("Currently logged") + rightPadding: Meui.Units.largeSpacing + visible: currentUser.userId === loggedUser.userId + } + + Button { + onClicked: additionalSettings.toggle() + + implicitWidth: height + + Image { + anchors.centerIn: parent + width: 22 + height: 22 + sourceSize: Qt.size(width, height) + source: Meui.Theme.darkMode ? additionalSettings.shown ? "qrc:/images/dark/up.svg" : "qrc:/images/dark/down.svg" + : additionalSettings.shown ? "qrc:/images/light/up.svg" : "qrc:/images/light/down.svg" + } + } + } + + Item { + height: Meui.Units.largeSpacing + } + + Hideable { + id: additionalSettings + + GridLayout { + Layout.fillWidth: true + Layout.bottomMargin: Meui.Units.smallSpacing + rowSpacing: Meui.Units.largeSpacing + columns: 2 + + Label { + text: qsTr("Avatar") + Layout.fillWidth: true + } + + Button { + text: qsTr("Choose") + Layout.alignment: Qt.AlignVCenter | Qt.AlignRight + onClicked: currentUserFileDialog.open() + } + + Label { + text: qsTr("Automatic login") + Layout.fillWidth: true + } + + Switch { + id: automaticLoginSwitch + Layout.fillHeight: true + leftPadding: 0 + rightPadding: 0 + onCheckedChanged: currentUser.automaticLogin = checked + + Layout.alignment: Qt.AlignVCenter | Qt.AlignRight + + Component.onCompleted: { + automaticLoginSwitch.checked = currentUser.automaticLogin + } + } + } + + Button { + text: qsTr("Delete this user") + enabled: model.userId !== loggedUser.userId + onClicked: accountsManager.deleteUser(userId, true) + } + + HorizontalDivider {} + } + } +} diff --git a/src/qml/WirelessDetailsDialog.qml b/src/qml/WirelessDetailsDialog.qml index 082a40a..b8259fe 100644 --- a/src/qml/WirelessDetailsDialog.qml +++ b/src/qml/WirelessDetailsDialog.qml @@ -11,8 +11,8 @@ Dialog { width: Math.max(detailsLayout.implicitWidth, footer.implicitWidth) - x: (rootWindow.width - width) / 4 - y: (rootWindow.height - height) / 4 + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 modal: true padding: Meui.Units.largeSpacing * 2 @@ -155,7 +155,9 @@ Dialog { text: qsTr("Forget this network") Layout.alignment: Qt.AlignHCenter DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole - onClicked: control.forgetBtnClicked() + onClicked: { + networking.removeConnection(model.connectionPath) + } } } } diff --git a/src/qml/WirelessItem.qml b/src/qml/WirelessItem.qml index 4eebdcd..2c758f4 100644 --- a/src/qml/WirelessItem.qml +++ b/src/qml/WirelessItem.qml @@ -118,16 +118,13 @@ Item { IconButton { source: "qrc:/images/info.svg" - onClicked: detailsDialog.open() - } - } - - WirelessDetailsDialog { - id: detailsDialog - - onForgetBtnClicked: { - networking.removeConnection(model.connectionPath) - detailsDialog.close() + onClicked: { + var component = Qt.createComponent("WirelessDetailsDialog.qml") + if (component.status === Component.Ready) { + var dialog = component.createObject(rootWindow) + dialog.open() + } + } } } diff --git a/src/resources.qrc b/src/resources.qrc index 338d9c3..cf4a450 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -69,5 +69,10 @@ images/rot270.svg images/rotnormal.svg qml/RotationButton.qml + qml/UserPage/UserDelegateItem.qml + images/light/down.svg + images/light/up.svg + images/dark/down.svg + images/dark/up.svg diff --git a/translations/en_US.ts b/translations/en_US.ts index ae18fd1..cbfe8d0 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -27,42 +27,36 @@ AccountsPage - + User - Currently logged in as - Currently logged in as + Currently logged in as - Hide additional settings - Hide additional settings + Hide additional settings - Show additional settings - Show additional settings + Show additional settings - Additional settings - Additional settings + Additional settings - Automatic login - Automatic login + Automatic login - Other Accounts - Other Accounts + Other Accounts - + Add user Add user @@ -70,12 +64,12 @@ AddUserDialog - + Add Add - + Cancel Cancel @@ -116,72 +110,72 @@ AppearancePage - + Appearance Appearance - + Theme Theme - + Light Light - + Dark Dark - + Dim the wallpaper in dark theme Dim the wallpaper in dark theme - + Accent color Accent color - + Font Font - + General Font General Font - + Fixed Font Fixed Font - + Font Size Font Size - + Small Small - + Medium Medium - + Large Large - + Huge Huge @@ -197,39 +191,70 @@ BatteryPage - + Battery Battery - + + Last hour + + + + + Last 2 hours + + + + + Last 12 hours + + + + + Last 24 hours + + + + + Last 48 hours + + + + + Last 7 days + + + + History History - - + + W + + + Yesterday - Yesterday + Yesterday - - Today - Today + Today - + Last Charged to Last Charged to - + Maximum Capacity Maximum Capacity - + No battery found No battery found @@ -260,7 +285,32 @@ Brightness - + + Screen + + + + + Resolution + + + + + Refresh rate + + + + + Rotation + + + + + Enabled + + + + Scale Scale @@ -329,12 +379,12 @@ Network - + Wired Wired - + Wi-Fi Wi-Fi @@ -392,55 +442,78 @@ About + + UserDelegateItem + + + Avatar + + + + + Choose + + + + + Automatic login + Automatic login + + + + Delete this user + + + WirelessDetailsDialog - + Auto-Join Auto-Join - + Security Security - + Signal Signal - + IPv4 Address IPv4 Address - + IPv6 Address IPv6 Address - + MAC Address MAC Address - + Gateway Gateway - + DNS DNS - + Forget this network Forget this network - + Close Close @@ -448,22 +521,22 @@ WirelessItem - + Password Password - + Show password Show password - + Connect Connect - + Cancel Cancel diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 8b4cc03..8018186 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -27,42 +27,36 @@ AccountsPage - + User 用户 - Currently logged in as - 当前登陆 + 当前登陆 - Hide additional settings - 隐藏其他设置 + 隐藏其他设置 - Show additional settings - 显示其他设置 + 显示其他设置 - Additional settings - 其他设置 + 其他设置 - Automatic login - 自动登陆 + 自动登陆 - Other Accounts - 其他用户 + 其他用户 - + Add user 添加用户 @@ -70,45 +64,45 @@ AddUserDialog - + Add 添加 - + Cancel 取消 - - + + User name 用户名 - - + + Password 密码 - - + + Verify password 验证密码 - + Account type 类型 - + Standard 标准 - + Administrator 管理员 @@ -121,67 +115,67 @@ 外观 - + Theme 主题 - + Light 浅色模式 - + Dark 深色模式 - + Dim the wallpaper in dark theme 在深色模式下调暗壁纸 - + Accent color 强调色 - + Font 字体 - + General Font 常规字体 - + Fixed Font 固定字体 - + Font Size 字体大小 - + Small - + Medium - + Large - + Huge 巨大 @@ -288,27 +282,27 @@ 屏幕 - + Enabled 已开启 - + Resolution 分辨率 - + Refresh rate 刷新率 - + Rotation 方向 - + Scale 缩放 @@ -440,6 +434,34 @@ 关于 + + UserDelegateItem + + + Currently logged + 当前登录 + + + + Avatar + 头像 + + + + Choose + 选择 + + + + Automatic login + 自动登陆 + + + + Delete this user + 删除该用户 + + WirelessDetailsDialog @@ -496,22 +518,22 @@ WirelessItem - + Password 密码 - + Show password 显示密码 - + Connect 连接 - + Cancel 取消