Add Start a chat page
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
module NeoChat.Component
|
||||
AutoMouseArea 1.0 AutoMouseArea.qml
|
||||
AutoListView 1.0 AutoListView.qml
|
||||
FullScreenImage 1.0 FullScreenImage.qml
|
||||
ChatTextInput 1.0 ChatTextInput.qml
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import org.kde.kirigami 2.0 as Kirigami
|
||||
|
||||
import NeoChat.Component 1.0
|
||||
import NeoChat.Effect 1.0
|
||||
import NeoChat.Setting 1.0
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
Dialog {
|
||||
property var connection
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: 360
|
||||
height: Math.min(window.height - 100, 640)
|
||||
|
||||
id: root
|
||||
|
||||
title: i18n("Start a Chat")
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
AutoTextField {
|
||||
property bool isUserID: text.match(/@(.+):(.+)/g)
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
id: identifierField
|
||||
|
||||
placeholderText: i18n("Find a user...")
|
||||
|
||||
onAccepted: {
|
||||
userDictListModel.search()
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
visible: identifierField.isUserID
|
||||
|
||||
text: i18n("Chat")
|
||||
highlighted: true
|
||||
|
||||
onClicked: {
|
||||
Controller.createDirectChat(connection, identifierField.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
AutoListView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
id: userDictListView
|
||||
|
||||
clip: true
|
||||
|
||||
spacing: 4
|
||||
|
||||
model: UserDirectoryListModel {
|
||||
id: userDictListModel
|
||||
|
||||
connection: root.connection
|
||||
keyword: identifierField.text
|
||||
}
|
||||
|
||||
delegate: Control {
|
||||
width: userDictListView.width
|
||||
height: 48
|
||||
|
||||
padding: 8
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: 8
|
||||
|
||||
Kirigami.Avatar {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar
|
||||
name: name
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
spacing: 0
|
||||
|
||||
Kirigami.Heading {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: name
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: userID
|
||||
color: Kirigami.Theme.disabledColor
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.preferredWidth: 32
|
||||
Layout.preferredHeight: 32
|
||||
|
||||
visible: directChats != null
|
||||
|
||||
icon.name: "document-send"
|
||||
onClicked: {
|
||||
roomListForm.joinRoom(connection.room(directChats[0]))
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
icon.name: "irc-join-channel"
|
||||
|
||||
onClicked: {
|
||||
Controller.createDirectChat(connection, userID)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {}
|
||||
|
||||
Label {
|
||||
anchors.centerIn: parent
|
||||
|
||||
visible: userDictListView.count < 1
|
||||
|
||||
text: i18n("No users available")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClosed: destroy()
|
||||
}
|
||||
133
imports/NeoChat/Page/StartChatPage.qml
Normal file
133
imports/NeoChat/Page/StartChatPage.qml
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import org.kde.kirigami 2.14 as Kirigami
|
||||
|
||||
import NeoChat.Component 1.0
|
||||
import NeoChat.Effect 1.0
|
||||
import NeoChat.Setting 1.0
|
||||
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
id: root
|
||||
|
||||
property var connection
|
||||
|
||||
title: i18n("Start a Chat")
|
||||
|
||||
header: RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Kirigami.SearchField {
|
||||
id: identifierField
|
||||
|
||||
property bool isUserID: text.match(/@(.+):(.+)/g)
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
placeholderText: i18n("Find a user...")
|
||||
|
||||
onAccepted: userDictListModel.search()
|
||||
}
|
||||
|
||||
Button {
|
||||
visible: identifierField.isUserID
|
||||
|
||||
text: i18n("Chat")
|
||||
highlighted: true
|
||||
|
||||
onClicked: Controller.createDirectChat(connection, identifierField.text)
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: userDictListView
|
||||
|
||||
clip: true
|
||||
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
model: UserDirectoryListModel {
|
||||
id: userDictListModel
|
||||
|
||||
connection: root.connection
|
||||
keyword: identifierField.text
|
||||
}
|
||||
|
||||
delegate: Kirigami.AbstractListItem {
|
||||
width: userDictListView.width
|
||||
contentItem: RowLayout {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
|
||||
Kirigami.Avatar {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
source: avatar
|
||||
name: name
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
spacing: 0
|
||||
|
||||
Kirigami.Heading {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: name
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: userID
|
||||
color: Kirigami.Theme.disabledColor
|
||||
textFormat: Text.PlainText
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
visible: directChats != null
|
||||
|
||||
icon.name: "document-send"
|
||||
onClicked: {
|
||||
roomListForm.joinRoom(connection.room(directChats[0]))
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
icon.name: "irc-join-channel"
|
||||
|
||||
onClicked: {
|
||||
Controller.createDirectChat(connection, userID)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
anchors.centerIn: parent
|
||||
visible: userDictListView.count < 1
|
||||
text: i18n("No users available")
|
||||
}
|
||||
}
|
||||
}
|
||||
15
qml/main.qml
15
qml/main.qml
@@ -100,25 +100,32 @@ Kirigami.ApplicationWindow {
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Explore rooms")
|
||||
iconName: "compass"
|
||||
icon.name: "compass"
|
||||
onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/JoinRoomPage.qml", {"connection": Controller.activeConnection})
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Explore Rooms")
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Start a Chat")
|
||||
icon.name: "irc-join-channel"
|
||||
onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/StartChatPage.qml", {"connection": Controller.activeConnection})
|
||||
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Start a Chat")
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Accounts")
|
||||
iconName: "im-user"
|
||||
icon.name: "im-user"
|
||||
onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/AccountsPage.qml")
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Accounts")
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Settings")
|
||||
iconName: "settings-configure"
|
||||
icon.name: "settings-configure"
|
||||
onTriggered: pushReplaceLayer("qrc:/imports/NeoChat/Page/SettingsPage.qml")
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("Settings")
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("About Neochat")
|
||||
iconName: "help-about"
|
||||
icon.name: "help-about"
|
||||
onTriggered: pushReplaceLayer(aboutPage)
|
||||
enabled: pageStack.layers.currentItem.title !== i18n("About")
|
||||
}
|
||||
|
||||
2
res.qrc
2
res.qrc
@@ -13,6 +13,7 @@
|
||||
<file>imports/NeoChat/Page/InviteUserPage.qml</file>
|
||||
<file>imports/NeoChat/Page/SettingsPage.qml</file>
|
||||
<file>imports/NeoChat/Page/InvitationPage.qml</file>
|
||||
<file>imports/NeoChat/Page/StartChatPage.qml</file>
|
||||
<file>imports/NeoChat/Component/qmldir</file>
|
||||
<file>imports/NeoChat/Component/ChatTextInput.qml</file>
|
||||
<file>imports/NeoChat/Component/AutoMouseArea.qml</file>
|
||||
@@ -44,7 +45,6 @@
|
||||
<file>imports/NeoChat/Dialog/RoomSettingsDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/UserDetailDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/CreateRoomDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/StartChatDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/EmojiDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/OpenFileDialog.qml</file>
|
||||
<file>imports/NeoChat/Dialog/OpenFolderDialog.qml</file>
|
||||
|
||||
Reference in New Issue
Block a user