Fix notification.
This commit is contained in:
parent
a7f62c13b0
commit
f0dd0a4c1d
|
@ -472,7 +472,7 @@ Rectangle {
|
||||||
color: "#273338"
|
color: "#273338"
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemDelegate {
|
RippleEffect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onClicked: errorControl.visible = false
|
onClicked: errorControl.visible = false
|
||||||
|
|
|
@ -298,9 +298,6 @@ Item {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
id: roomPanelInput
|
id: roomPanelInput
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: 48
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Spectral 0.1
|
||||||
|
|
||||||
import "qrc:/js/md.js" as Markdown
|
import "qrc:/js/md.js" as Markdown
|
||||||
|
|
||||||
Rectangle {
|
Control {
|
||||||
property bool isReply
|
property bool isReply
|
||||||
property string replyUserID
|
property string replyUserID
|
||||||
property string replyEventID
|
property string replyEventID
|
||||||
|
@ -23,13 +23,16 @@ Rectangle {
|
||||||
property int autoCompleteBeginPosition
|
property int autoCompleteBeginPosition
|
||||||
property int autoCompleteEndPosition
|
property int autoCompleteEndPosition
|
||||||
|
|
||||||
color: MSettings.darkTheme ? "#303030" : "#fafafa"
|
padding: 0
|
||||||
|
|
||||||
radius: height / 2
|
background: Rectangle {
|
||||||
|
color: MSettings.darkTheme ? "#303030" : "#fafafa"
|
||||||
|
radius: 24
|
||||||
|
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.effect: ElevationEffect {
|
layer.effect: ElevationEffect {
|
||||||
elevation: 1
|
elevation: 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
|
@ -102,12 +105,12 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
contentItem: RowLayout {
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
id: uploadButton
|
id: uploadButton
|
||||||
visible: !isReply
|
visible: !isReply
|
||||||
|
|
||||||
|
@ -135,172 +138,166 @@ Rectangle {
|
||||||
onClicked: clearReply()
|
onClicked: clearReply()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollView {
|
TextArea {
|
||||||
|
property real progress: 0
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 48
|
|
||||||
|
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
id: inputField
|
||||||
|
|
||||||
clip: true
|
wrapMode: Text.Wrap
|
||||||
|
placeholderText: isReply ? "Reply to " + replyUserID : "Send a Message"
|
||||||
|
topPadding: 0
|
||||||
|
bottomPadding: 0
|
||||||
|
selectByMouse: true
|
||||||
|
verticalAlignment: TextEdit.AlignVCenter
|
||||||
|
|
||||||
TextArea {
|
text: currentRoom ? currentRoom.cachedInput : ""
|
||||||
property real progress: 0
|
|
||||||
|
|
||||||
id: inputField
|
background: Item {
|
||||||
|
}
|
||||||
|
|
||||||
wrapMode: Text.Wrap
|
Rectangle {
|
||||||
placeholderText: isReply ? "Reply to " + replyUserID : "Send a Message"
|
width: currentRoom && currentRoom.hasFileUploading ? parent.width * currentRoom.fileUploadingProgress / 100 : 0
|
||||||
leftPadding: 16
|
height: parent.height
|
||||||
topPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
selectByMouse: true
|
|
||||||
verticalAlignment: TextEdit.AlignVCenter
|
|
||||||
|
|
||||||
text: currentRoom ? currentRoom.cachedInput : ""
|
opacity: 0.2
|
||||||
|
color: Material.accent
|
||||||
|
}
|
||||||
|
|
||||||
background: Item {
|
Timer {
|
||||||
|
id: timeoutTimer
|
||||||
|
|
||||||
|
repeat: false
|
||||||
|
interval: 2000
|
||||||
|
onTriggered: {
|
||||||
|
repeatTimer.stop()
|
||||||
|
currentRoom.sendTypingNotification(false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Timer {
|
||||||
width: currentRoom && currentRoom.hasFileUploading ? parent.width * currentRoom.fileUploadingProgress / 100 : 0
|
id: repeatTimer
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
opacity: 0.2
|
repeat: true
|
||||||
color: Material.accent
|
interval: 5000
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: currentRoom.sendTypingNotification(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.visible: currentRoom
|
||||||
|
&& currentRoom.hasUsersTyping
|
||||||
|
ToolTip.text: currentRoom ? currentRoom.usersTyping : ""
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
|
insert(cursorPosition, "\n")
|
||||||
|
} else {
|
||||||
|
postMessage(text)
|
||||||
|
text = ""
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
|
||||||
id: timeoutTimer
|
|
||||||
|
|
||||||
repeat: false
|
Keys.onTabPressed: {
|
||||||
interval: 2000
|
if (isAutoCompleting) {
|
||||||
onTriggered: {
|
autoCompleteListView.incrementCurrentIndex()
|
||||||
repeatTimer.stop()
|
} else {
|
||||||
currentRoom.sendTypingNotification(false)
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
||||||
}
|
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
||||||
}
|
if (!autoCompletePrefix) return
|
||||||
|
if (autoCompletePrefix.startsWith(":")) {
|
||||||
Timer {
|
|
||||||
id: repeatTimer
|
|
||||||
|
|
||||||
repeat: true
|
|
||||||
interval: 5000
|
|
||||||
triggeredOnStart: true
|
|
||||||
onTriggered: currentRoom.sendTypingNotification(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolTip.visible: currentRoom
|
|
||||||
&& currentRoom.hasUsersTyping
|
|
||||||
ToolTip.text: currentRoom ? currentRoom.usersTyping : ""
|
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
|
||||||
if (event.modifiers & Qt.ShiftModifier) {
|
|
||||||
insert(cursorPosition, "\n")
|
|
||||||
} else {
|
|
||||||
postMessage(text)
|
|
||||||
text = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
|
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
|
||||||
if (isAutoCompleting) {
|
|
||||||
autoCompleteListView.incrementCurrentIndex()
|
|
||||||
} else {
|
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
||||||
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
autoCompleteModel = emojiModel.filterModel(autoCompletePrefix)
|
||||||
if (!autoCompletePrefix) return
|
if (autoCompleteModel.length === 0) return
|
||||||
if (autoCompletePrefix.startsWith(":")) {
|
isAutoCompleting = true
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
autoCompleteEndPosition = cursorPosition
|
||||||
autoCompleteModel = emojiModel.filterModel(autoCompletePrefix)
|
} else {
|
||||||
if (autoCompleteModel.length === 0) return
|
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix)
|
||||||
isAutoCompleting = true
|
if (autoCompleteModel.length === 0) return
|
||||||
autoCompleteEndPosition = cursorPosition
|
isAutoCompleting = true
|
||||||
} else {
|
autoCompleteEndPosition = cursorPosition
|
||||||
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix)
|
|
||||||
if (autoCompleteModel.length === 0) return
|
|
||||||
isAutoCompleting = true
|
|
||||||
autoCompleteEndPosition = cursorPosition
|
|
||||||
}
|
|
||||||
}
|
|
||||||
replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText)
|
|
||||||
}
|
|
||||||
|
|
||||||
onTextChanged: {
|
|
||||||
timeoutTimer.restart()
|
|
||||||
repeatTimer.start()
|
|
||||||
currentRoom.cachedInput = text
|
|
||||||
|
|
||||||
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
|
||||||
isAutoCompleting = false
|
|
||||||
autoCompleteListView.currentIndex = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText)
|
||||||
|
}
|
||||||
|
|
||||||
function replaceAutoComplete(word) {
|
onTextChanged: {
|
||||||
remove(autoCompleteBeginPosition, autoCompleteEndPosition)
|
timeoutTimer.restart()
|
||||||
autoCompleteEndPosition = autoCompleteBeginPosition + word.length
|
repeatTimer.start()
|
||||||
insert(cursorPosition, word)
|
currentRoom.cachedInput = text
|
||||||
|
|
||||||
|
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
||||||
|
isAutoCompleting = false
|
||||||
|
autoCompleteListView.currentIndex = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceAutoComplete(word) {
|
||||||
|
remove(autoCompleteBeginPosition, autoCompleteEndPosition)
|
||||||
|
autoCompleteEndPosition = autoCompleteBeginPosition + word.length
|
||||||
|
insert(cursorPosition, word)
|
||||||
|
}
|
||||||
|
|
||||||
|
function postMessage(text) {
|
||||||
|
if (text.trim().length === 0) { return }
|
||||||
|
if(!currentRoom) { return }
|
||||||
|
|
||||||
|
var PREFIX_ME = '/me '
|
||||||
|
var PREFIX_NOTICE = '/notice '
|
||||||
|
var PREFIX_RAINBOW = '/rainbow '
|
||||||
|
var PREFIX_HTML = '/html '
|
||||||
|
var PREFIX_MARKDOWN = '/md '
|
||||||
|
|
||||||
|
if (isReply) {
|
||||||
|
currentRoom.sendReply(replyUserID, replyEventID, replyContent, text)
|
||||||
|
clearReply()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function postMessage(text) {
|
if (text.indexOf(PREFIX_ME) === 0) {
|
||||||
if (text.trim().length === 0) { return }
|
text = text.substr(PREFIX_ME.length)
|
||||||
if(!currentRoom) { return }
|
currentRoom.postMessage(text, RoomMessageEvent.Emote)
|
||||||
|
return
|
||||||
var PREFIX_ME = '/me '
|
|
||||||
var PREFIX_NOTICE = '/notice '
|
|
||||||
var PREFIX_RAINBOW = '/rainbow '
|
|
||||||
var PREFIX_HTML = '/html '
|
|
||||||
var PREFIX_MARKDOWN = '/md '
|
|
||||||
|
|
||||||
if (isReply) {
|
|
||||||
currentRoom.sendReply(replyUserID, replyEventID, replyContent, text)
|
|
||||||
clearReply()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text.indexOf(PREFIX_ME) === 0) {
|
|
||||||
text = text.substr(PREFIX_ME.length)
|
|
||||||
currentRoom.postMessage(text, RoomMessageEvent.Emote)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (text.indexOf(PREFIX_NOTICE) === 0) {
|
|
||||||
text = text.substr(PREFIX_NOTICE.length)
|
|
||||||
currentRoom.postMessage(text, RoomMessageEvent.Notice)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (text.indexOf(PREFIX_RAINBOW) === 0) {
|
|
||||||
text = text.substr(PREFIX_RAINBOW.length)
|
|
||||||
|
|
||||||
var parsedText = ""
|
|
||||||
var rainbowColor = ["#ff2b00", "#ff5500", "#ff8000", "#ffaa00", "#ffd500", "#ffff00", "#d4ff00", "#aaff00", "#80ff00", "#55ff00", "#2bff00", "#00ff00", "#00ff2b", "#00ff55", "#00ff80", "#00ffaa", "#00ffd5", "#00ffff", "#00d4ff", "#00aaff", "#007fff", "#0055ff", "#002bff", "#0000ff", "#2a00ff", "#5500ff", "#7f00ff", "#aa00ff", "#d400ff", "#ff00ff", "#ff00d4", "#ff00aa", "#ff0080", "#ff0055", "#ff002b", "#ff0000"]
|
|
||||||
for (var i = 0; i < text.length; i++) {
|
|
||||||
parsedText = parsedText + "<font color='" + rainbowColor[i % rainbowColor.length] + "'>" + text.charAt(i) + "</font>"
|
|
||||||
}
|
|
||||||
currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (text.indexOf(PREFIX_HTML) === 0) {
|
|
||||||
text = text.substr(PREFIX_HTML.length)
|
|
||||||
var re = new RegExp("<.*?>")
|
|
||||||
var plainText = text.replace(re, "")
|
|
||||||
currentRoom.postHtmlMessage(plainText, text, RoomMessageEvent.Text)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (text.indexOf(PREFIX_MARKDOWN) === 0) {
|
|
||||||
text = text.substr(PREFIX_MARKDOWN.length)
|
|
||||||
var parsedText = Markdown.markdown_parser(text)
|
|
||||||
currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
currentRoom.postPlainText(text)
|
|
||||||
}
|
}
|
||||||
|
if (text.indexOf(PREFIX_NOTICE) === 0) {
|
||||||
|
text = text.substr(PREFIX_NOTICE.length)
|
||||||
|
currentRoom.postMessage(text, RoomMessageEvent.Notice)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (text.indexOf(PREFIX_RAINBOW) === 0) {
|
||||||
|
text = text.substr(PREFIX_RAINBOW.length)
|
||||||
|
|
||||||
|
var parsedText = ""
|
||||||
|
var rainbowColor = ["#ff2b00", "#ff5500", "#ff8000", "#ffaa00", "#ffd500", "#ffff00", "#d4ff00", "#aaff00", "#80ff00", "#55ff00", "#2bff00", "#00ff00", "#00ff2b", "#00ff55", "#00ff80", "#00ffaa", "#00ffd5", "#00ffff", "#00d4ff", "#00aaff", "#007fff", "#0055ff", "#002bff", "#0000ff", "#2a00ff", "#5500ff", "#7f00ff", "#aa00ff", "#d400ff", "#ff00ff", "#ff00d4", "#ff00aa", "#ff0080", "#ff0055", "#ff002b", "#ff0000"]
|
||||||
|
for (var i = 0; i < text.length; i++) {
|
||||||
|
parsedText = parsedText + "<font color='" + rainbowColor[i % rainbowColor.length] + "'>" + text.charAt(i) + "</font>"
|
||||||
|
}
|
||||||
|
currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (text.indexOf(PREFIX_HTML) === 0) {
|
||||||
|
text = text.substr(PREFIX_HTML.length)
|
||||||
|
var re = new RegExp("<.*?>")
|
||||||
|
var plainText = text.replace(re, "")
|
||||||
|
currentRoom.postHtmlMessage(plainText, text, RoomMessageEvent.Text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (text.indexOf(PREFIX_MARKDOWN) === 0) {
|
||||||
|
text = text.substr(PREFIX_MARKDOWN.length)
|
||||||
|
var parsedText = Markdown.markdown_parser(text)
|
||||||
|
currentRoom.postHtmlMessage(text, parsedText, RoomMessageEvent.Text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentRoom.postPlainText(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
id: emojiButton
|
id: emojiButton
|
||||||
|
|
||||||
contentItem: MaterialIcon {
|
contentItem: MaterialIcon {
|
||||||
|
|
17
qml/main.qml
17
qml/main.qml
|
@ -55,7 +55,7 @@ ApplicationWindow {
|
||||||
quitOnLastWindowClosed: !MSettings.showTray
|
quitOnLastWindowClosed: !MSettings.showTray
|
||||||
|
|
||||||
onNotificationClicked: {
|
onNotificationClicked: {
|
||||||
roomForm.enteredRoom = spectralController.connection.room(roomId)
|
roomListForm.enteredRoom = spectralController.connection.room(roomId)
|
||||||
roomForm.goToEvent(eventId)
|
roomForm.goToEvent(eventId)
|
||||||
showWindow()
|
showWindow()
|
||||||
}
|
}
|
||||||
|
@ -131,12 +131,15 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
onVisibleChanged: {
|
||||||
spectralController.onErrorOccured.connect(function(error, detail) {
|
if (visible) spectralController.onErrorOccured.connect(showError)
|
||||||
loginDialog.busy = false
|
else spectralController.onErrorOccured.disconnect(showError)
|
||||||
loginButtonTooltip.text = error + ": " + detail
|
}
|
||||||
loginButtonTooltip.open()
|
|
||||||
})
|
function showError(error, detail) {
|
||||||
|
loginDialog.busy = false
|
||||||
|
loginButtonTooltip.text = error + ": " + detail
|
||||||
|
loginButtonTooltip.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function doLogin() {
|
function doLogin() {
|
||||||
|
|
Loading…
Reference in New Issue