Mobile Pages
Currently the page experienc on mobile is suboptimal as back gestures do not work and the startup behaviour is not ideal. This reworks it so that pages are now pushed as a layer on mobile and at startup only a saved space is restored. It is also setup so that on mobile you'll never see a blank room page (like when you select friends or home).
This commit is contained in:
@@ -18,6 +18,8 @@ Kirigami.ApplicationWindow {
|
||||
property NeoChatConnection connection: Controller.activeConnection
|
||||
readonly property HoverLinkIndicator hoverLinkIndicator: linkIndicator
|
||||
|
||||
property bool initialized: false
|
||||
|
||||
|
||||
title: NeoChatConfig.windowTitleFocus ? activeFocusItem + " " + (activeFocusItem ? activeFocusItem.Accessible.name : "") : "NeoChat"
|
||||
|
||||
@@ -82,6 +84,17 @@ Kirigami.ApplicationWindow {
|
||||
Connections {
|
||||
target: RoomManager
|
||||
|
||||
function onCurrentRoomChanged() {
|
||||
if (RoomManager.currentRoom && pageStack.depth <= 1 && initialized && Kirigami.Settings.isMobile) {
|
||||
let roomPage = pageStack.layers.push(Qt.createComponent('org.kde.neochat', 'RoomPage'), {
|
||||
connection: root.connection
|
||||
});
|
||||
roomPage.backRequested.connect(event => {
|
||||
RoomManager.clearCurrentRoom();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onAskJoinRoom(room) {
|
||||
Qt.createComponent("org.kde.neochat", "JoinRoomDialog").createObject(root, {
|
||||
room: room,
|
||||
@@ -315,9 +328,14 @@ Kirigami.ApplicationWindow {
|
||||
function load() {
|
||||
pageStack.replace(roomListComponent);
|
||||
RoomManager.loadInitialRoom();
|
||||
let roomPage = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomPage'), {
|
||||
connection: root.connection
|
||||
});
|
||||
roomPage.forceActiveFocus();
|
||||
|
||||
if (!Kirigami.Settings.isMobile) {
|
||||
let roomPage = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomPage'), {
|
||||
connection: root.connection
|
||||
});
|
||||
roomPage.forceActiveFocus();
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "urlhelper.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KRuntimePlatform>
|
||||
#include <QDesktopServices>
|
||||
#include <QQuickTextDocument>
|
||||
#include <QStandardPaths>
|
||||
@@ -41,6 +40,16 @@ RoomManager::RoomManager(QObject *parent)
|
||||
, m_mediaMessageFilterModel(new MediaMessageFilterModel(this, m_messageFilterModel))
|
||||
, m_userListModel(new UserListModel(this))
|
||||
{
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(UBUNTU_TOUCH)
|
||||
m_isMobile = true;
|
||||
#else
|
||||
// Mostly for debug purposes and for platforms which are always mobile,
|
||||
// such as Plasma Mobile
|
||||
if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE")) {
|
||||
m_isMobile = QByteArrayList{"1", "true"}.contains(qgetenv("QT_QUICK_CONTROLS_MOBILE"));
|
||||
}
|
||||
#endif
|
||||
|
||||
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
||||
m_lastSpaceConfig = m_config->group(QStringLiteral("LastOpenSpace"));
|
||||
m_directChatsConfig = m_config->group(QStringLiteral("DirectChatsActive"));
|
||||
@@ -227,8 +236,9 @@ void RoomManager::loadInitialRoom()
|
||||
resolveResource(m_arg);
|
||||
}
|
||||
|
||||
const auto runtimePlatform = KRuntimePlatform::runtimePlatform();
|
||||
if (runtimePlatform.contains(QStringLiteral("phone")) || runtimePlatform.contains(QStringLiteral("handset"))) {
|
||||
if (m_isMobile) {
|
||||
// We still need to remember the last space on mobile
|
||||
setCurrentSpace(m_lastSpaceConfig.readEntry(m_connection->userId(), QString()), false);
|
||||
// We don't want to open a room on startup on mobile
|
||||
return;
|
||||
}
|
||||
@@ -464,9 +474,10 @@ void RoomManager::setCurrentSpace(const QString &spaceId, bool setRoom)
|
||||
if (!setRoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spaceId.length() > 3) {
|
||||
resolveResource(spaceId, "no_join"_ls);
|
||||
} else {
|
||||
} else if (!m_isMobile) {
|
||||
visitRoom({}, {});
|
||||
}
|
||||
}
|
||||
@@ -531,6 +542,11 @@ void RoomManager::setCurrentRoom(const QString &roomId)
|
||||
setCurrentSpace({}, false);
|
||||
}
|
||||
|
||||
void RoomManager::clearCurrentRoom()
|
||||
{
|
||||
setCurrentRoom(QString());
|
||||
}
|
||||
|
||||
QString RoomManager::currentSpace() const
|
||||
{
|
||||
return m_currentSpaceId;
|
||||
|
||||
@@ -252,6 +252,11 @@ public:
|
||||
*/
|
||||
void setConnection(NeoChatConnection *connection);
|
||||
|
||||
/**
|
||||
* @brief Clear the current room.
|
||||
*/
|
||||
Q_INVOKABLE void clearCurrentRoom();
|
||||
|
||||
/**
|
||||
* Closes the current room and space; for situations, where it is unclear which room should be opened.
|
||||
*/
|
||||
@@ -344,6 +349,8 @@ Q_SIGNALS:
|
||||
void currentSpaceChanged();
|
||||
|
||||
private:
|
||||
bool m_isMobile = false;
|
||||
|
||||
void openRoomForActiveConnection();
|
||||
|
||||
/** The room currently being shown in the main view (RoomPage.qml). This can be null, if there is no room.
|
||||
|
||||
Reference in New Issue
Block a user