First of all, these are now all separate dialogs instead of shoving all of these functions (which are only marginally related) into one single dialog. We also convert these to in-app Kirigami Dialogs, which look a bit nicer. I also touched up the UX in some places, such as adding descriptions which were previously available to translators. I also hid some not oft used options like setting a topic, which almost nobody does before creating a room/space.
173 lines
5.8 KiB
QML
173 lines
5.8 KiB
QML
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
import QtQuick
|
|
import QtQuick.Controls as QQC2
|
|
import QtQuick.Layouts
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
import org.kde.kirigamiaddons.delegates as Delegates
|
|
|
|
import org.kde.neochat
|
|
|
|
Kirigami.NavigationTabBar {
|
|
id: root
|
|
|
|
/**
|
|
* @brief The connection for the current user.
|
|
*/
|
|
required property NeoChatConnection connection
|
|
|
|
/**
|
|
* @brief Emitted when the text is changed in the search field.
|
|
*/
|
|
signal textChanged(string newText)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
actions: [
|
|
Kirigami.Action {
|
|
id: infoAction
|
|
text: i18n("Search")
|
|
icon.name: "search"
|
|
onTriggered: {
|
|
if (explorePopup.visible && explorePopupLoader.sourceComponent == search) {
|
|
explorePopup.close();
|
|
root.currentIndex = -1;
|
|
} else if (explorePopup.visible && explorePopupLoader.sourceComponent != search) {
|
|
explorePopup.close();
|
|
explorePopup.open();
|
|
} else {
|
|
explorePopup.open();
|
|
}
|
|
explorePopupLoader.switchComponent(search);
|
|
}
|
|
},
|
|
Kirigami.Action {
|
|
text: i18n("Explore rooms")
|
|
icon.name: "compass"
|
|
onTriggered: {
|
|
explorePopup.close();
|
|
let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), {
|
|
connection: root.connection
|
|
}, {
|
|
title: i18nc("@title", "Explore Rooms")
|
|
});
|
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
|
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join");
|
|
});
|
|
root.currentIndex = -1;
|
|
}
|
|
},
|
|
Kirigami.Action {
|
|
text: i18n("Find your friends")
|
|
icon.name: "list-add-user"
|
|
onTriggered: {
|
|
explorePopup.close();
|
|
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UserSearchPage'), {
|
|
connection: root.connection
|
|
}, {
|
|
title: i18nc("@title", "Find your friends")
|
|
});
|
|
root.currentIndex = -1;
|
|
}
|
|
},
|
|
Kirigami.Action {
|
|
text: i18n("Create New")
|
|
icon.name: "list-add"
|
|
onTriggered: {
|
|
if (explorePopup.visible && explorePopupLoader.sourceComponent == create) {
|
|
explorePopup.close();
|
|
root.currentIndex = -1;
|
|
} else if (explorePopup.visible && explorePopupLoader.sourceComponent != create) {
|
|
explorePopup.close();
|
|
explorePopup.open();
|
|
} else {
|
|
explorePopup.open();
|
|
}
|
|
explorePopupLoader.switchComponent(create);
|
|
}
|
|
}
|
|
]
|
|
|
|
QQC2.Popup {
|
|
id: explorePopup
|
|
parent: root
|
|
|
|
y: -height + 1
|
|
width: root.width
|
|
leftPadding: Kirigami.Units.largeSpacing
|
|
rightPadding: Kirigami.Units.largeSpacing
|
|
bottomPadding: Kirigami.Units.largeSpacing
|
|
topPadding: Kirigami.Units.largeSpacing
|
|
|
|
closePolicy: QQC2.Popup.CloseOnEscape
|
|
|
|
contentItem: Loader {
|
|
id: explorePopupLoader
|
|
sourceComponent: search
|
|
|
|
function switchComponent(newComponent) {
|
|
if (sourceComponent == search) {
|
|
root.textChanged("");
|
|
}
|
|
sourceComponent = newComponent;
|
|
}
|
|
}
|
|
|
|
background: ColumnLayout {
|
|
spacing: 0
|
|
Kirigami.Separator {
|
|
Layout.fillWidth: true
|
|
}
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
color: Kirigami.Theme.backgroundColor
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: search
|
|
Kirigami.SearchField {
|
|
onTextChanged: root.textChanged(text)
|
|
}
|
|
}
|
|
Component {
|
|
id: create
|
|
ColumnLayout {
|
|
spacing: 0
|
|
Delegates.RoundedItemDelegate {
|
|
Layout.fillWidth: true
|
|
action: Kirigami.Action {
|
|
text: i18n("Create a Room")
|
|
icon.name: "system-users-symbolic"
|
|
onTriggered: {
|
|
pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'CreateRoomPage'), {
|
|
connection: root.connection
|
|
}, {
|
|
title: i18nc("@title", "Create a Room")
|
|
});
|
|
explorePopup.close();
|
|
}
|
|
shortcut: StandardKey.New
|
|
}
|
|
}
|
|
Delegates.RoundedItemDelegate {
|
|
Layout.fillWidth: true
|
|
action: Kirigami.Action {
|
|
text: i18n("Create a Space")
|
|
icon.name: "list-add"
|
|
onTriggered: {
|
|
Qt.createComponent('org.kde.neochat', 'CreateSpaceDialog').createObject(root, {
|
|
connection: root.connection
|
|
}).open();
|
|
explorePopup.close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|