Also, use shift+return for line break.
This commit is contained in:
Black Hat 2018-09-20 13:43:47 +08:00
parent 611471b227
commit ea43cf6c80
4 changed files with 15 additions and 11 deletions

View File

@ -366,9 +366,10 @@ Item {
ToolTip.visible: currentRoom && currentRoom.hasUsersTyping ToolTip.visible: currentRoom && currentRoom.hasUsersTyping
ToolTip.text: currentRoom ? currentRoom.usersTyping : "" ToolTip.text: currentRoom ? currentRoom.usersTyping : ""
Shortcut { Keys.onReturnPressed: {
sequence: "Ctrl+Return" if (event.modifiers & Qt.ShiftModifier) {
onActivated: { inputField.insert(inputField.cursorPosition, "\n")
} else {
inputField.postMessage(inputField.text) inputField.postMessage(inputField.text)
inputField.text = "" inputField.text = ""
} }

View File

@ -40,7 +40,8 @@ ApplicationWindow {
} }
onHideWindow: window.hide() onHideWindow: window.hide()
onErrorOccured: { onErrorOccured: {
errorLabel.text = error errorDialog.error = error
errorDialog.detail = detail
errorDialog.open() errorDialog.open()
} }
} }
@ -51,14 +52,16 @@ ApplicationWindow {
} }
Dialog { Dialog {
property string error
property string detail
x: (window.width - width) / 2 x: (window.width - width) / 2
y: (window.height - height) / 2 y: (window.height - height) / 2
id: errorDialog id: errorDialog
title: "Error"
contentItem: Label { title: error + " Error"
id: errorLabel contentItem: Label { text: errorDialog.detail }
}
} }
Component { Component {

View File

@ -74,7 +74,7 @@ void Controller::loginWithCredentials(QString serverAddr, QString user,
addConnection(m_connection); addConnection(m_connection);
}); });
connect(m_connection, &Connection::loginError, [=] (QString error, QByteArray detail) { connect(m_connection, &Connection::loginError, [=] (QString error, QByteArray detail) {
emit errorOccured(error); emit errorOccured("Login", error);
}); });
} }
} }
@ -161,7 +161,7 @@ bool Controller::saveAccessToken(const AccountSettings& account,
auto fileDir = QFileInfo(accountTokenFile).dir(); auto fileDir = QFileInfo(accountTokenFile).dir();
if (!((fileDir.exists() || fileDir.mkpath(".")) && if (!((fileDir.exists() || fileDir.mkpath(".")) &&
accountTokenFile.open(QFile::WriteOnly))) { accountTokenFile.open(QFile::WriteOnly))) {
emit errorOccured("Cannot save access token."); emit errorOccured("Token", "Cannot save access token.");
} else { } else {
accountTokenFile.write(accessToken); accountTokenFile.write(accessToken);
return true; return true;

View File

@ -66,7 +66,7 @@ class Controller : public QObject {
signals: signals:
void busyChanged(); void busyChanged();
void errorOccured(QString error); void errorOccured(QString error, QString detail);
void showWindow(); void showWindow();
void hideWindow(); void hideWindow();
void connectionAdded(Connection* conn); void connectionAdded(Connection* conn);