Skip to content

Commit

Permalink
feat: Improve user experience for email input field
Browse files Browse the repository at this point in the history
优化邮件输入框的用户体验

Log:
Issues: linuxdeepin/developer-center#6430
  • Loading branch information
myml committed Jan 2, 2024
1 parent a632dbc commit 57363e4
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/dbusservice/com.deepin.Home.Daemon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<method name="setAutoStart">
<arg name="enable" type="b" direction="in"/>
</method>
<method name="getEmail">
<arg type="s" direction="out"/>
</method>
<method name="setEmail">
<arg name="enable" type="s" direction="in"/>
</method>
<method name="activeMainWindows">
</method>
<method name="getVersion">
Expand Down
2 changes: 1 addition & 1 deletion src/main/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char *argv[])
dbus.registerObject(DEEPIN_HOME_DAEMON_PATH, &daemon);

if (!dbus.registerService(DEEPIN_HOME_DAEMON_SERVICE)) {
qDebug() << "Register DBus Error" << dbus.lastError().message();
qDebug() << "Register DBus Error" << dbus.lastError().message() << "Process may already be running.";
return -1;
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/homeDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void HomeDaemon::openForum()
// 退出daemon
void HomeDaemon::quit()
{
qCInfo(logger) << "quic by dbus call";
qCInfo(logger) << "quit by dbus call";
QCoreApplication::quit();
}
// 获取开机自启配置
Expand All @@ -467,6 +467,18 @@ void HomeDaemon::setAutoStart(bool enable)
{
return m_settings.setValue("autostart", enable);
}

// 获取用户邮箱记录
QString HomeDaemon::getEmail()
{
return m_settings.value("email", "").toString();
}
// 保持用户邮箱记录
void HomeDaemon::setEmail(QString email)
{
return m_settings.setValue("email", email);
}

// 发出showMainWindow信号,通知客户端激活窗口
void HomeDaemon::activeMainWindows()
{
Expand Down
4 changes: 4 additions & 0 deletions src/main/homeDaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public slots:
bool getAutoStart();
// 设置开启自启配置
void setAutoStart(bool enable);
// 获取用户邮箱
QString getEmail();
// 设置用户邮箱
void setEmail(QString email);
// 因为客户端是单例应用,重复启动会自动退出,并调用daemon的这个接口来通知已存在的客户端激活自己的窗口。
void activeMainWindows();
// 获取当前应用版本信息
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char *argv[])
QDBusConnection dbus = QDBusConnection::sessionBus();
if (!dbus.registerService("com.deepin.Home")) {
activeMainWindows();
qDebug() << "Register DBus Error" << dbus.lastError().message();
qDebug() << "Register DBus Error" << dbus.lastError().message() << "Process may already be running.";
return -1;
}
// 兼容旧版本 DtkDeclarative
Expand Down
40 changes: 27 additions & 13 deletions src/maincomponentplugin/feedback/Submit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Item {
}
Component.onCompleted: {
show();
emailText.text = worker.getEmail();
if (root.type == "req")
reqType.checked = true;
else
Expand All @@ -101,8 +102,8 @@ Item {
font.pixelSize: DTK.fontManager.t6.pixelSize
font.bold: true
}
// 反馈类型

// 反馈类型
Row {
spacing: 10

Expand Down Expand Up @@ -140,8 +141,8 @@ Item {
}

}
// 标题

// 标题
Row {
spacing: 10

Expand Down Expand Up @@ -176,8 +177,8 @@ Item {
}

}
// 内容

// 内容
Row {
spacing: 10

Expand Down Expand Up @@ -221,15 +222,28 @@ Item {
}

}
// 联系邮箱

// 联系邮箱
Row {
spacing: 10

ControlLabel {
text: qsTr("Email:")
verticalAlignment: Text.AlignVCenter
}
// 使用隐藏的输入框做邮箱校验,避免validator阻止用户输入,用户体验不好

LineEdit {
id: emailTextValidate

text: emailText.text
visible: false

validator: RegExpValidator {
regExp: /^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
}

}

LineEdit {
id: emailText
Expand All @@ -248,15 +262,11 @@ Item {
visible: !emailText.text && !emailText.activeFocus
}

validator: RegExpValidator {
regExp: /^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
}

}

}
// 系统版本

// 系统版本
Row {
spacing: 10

Expand All @@ -275,8 +285,8 @@ Item {
}

}
// 上传设备信息

// 上传设备信息
Row {
visible: bugType.checked
spacing: 10
Expand Down Expand Up @@ -309,8 +319,8 @@ Item {
}

}
// 图片说明

// 图片说明
Row {
spacing: 10

Expand Down Expand Up @@ -435,8 +445,8 @@ Item {
}

}
// 底部按钮

// 底部按钮
RowLayout {
spacing: 10
Layout.alignment: Qt.AlignHCenter
Expand Down Expand Up @@ -531,10 +541,14 @@ Item {
API.notify(qsTr("Unable to submit feedback."), qsTr("Please provide the content of your feedback."));
return ;
}
if (emailText.text.length > 0 && !emailText.acceptableInput) {
if (emailText.text.length > 0 && !emailTextValidate.acceptableInput) {
API.notify(qsTr("Unable to submit feedback."), qsTr("Incorrect email address entered."));
return ;
}
// 保存用户邮箱,下次自动填写
if (emailText.text != worker.getEmail())
worker.setEmail(emailText.text);

if (!API.isLogin) {
API.login();
return ;
Expand Down
12 changes: 12 additions & 0 deletions src/maincomponentplugin/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ void Worker::setAutoStart(bool enable)
{
m_daemon->setAutoStart(enable);
}

// 获取开机自启配置
QString Worker::getEmail()
{
return m_daemon->getEmail();
}
// 设置开启自启配置
void Worker::setEmail(QString email)
{
m_daemon->setEmail(email);
}

// 获取本地文件信息
QMap<QString, QVariant> Worker::getFileInfo(QString filepath)
{
Expand Down
4 changes: 4 additions & 0 deletions src/maincomponentplugin/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public slots:
bool getAutoStart();
// 设置开启自启配置
void setAutoStart(bool enable);
// 获取用户邮箱记录
QString getEmail();
// 保持用户邮箱记录
void setEmail(QString email);
// 获取本地文件信息
QMap<QString, QVariant> getFileInfo(QString filepath);
// 弹出通知
Expand Down

0 comments on commit 57363e4

Please sign in to comment.