Automatically enter room when joining it
Related to #352 but needs an additional Quotient patch to works
This commit is contained in:
@@ -110,7 +110,7 @@ Q_SIGNALS:
|
||||
/// Either when a new room was created, a direct chat was started
|
||||
/// or a group chat was joined. The UI will react to this signal
|
||||
/// and switch to the newly joined room.
|
||||
void roomJoined(const QString &roomName);
|
||||
void roomJoined(const QString &room);
|
||||
|
||||
/// Error occurred because of server or bug in NeoChat
|
||||
void globalErrorOccured(QString error, QString detail);
|
||||
|
||||
@@ -104,13 +104,13 @@ int main(int argc, char *argv[])
|
||||
KDBusService service(KDBusService::Unique);
|
||||
service.connect(&service,
|
||||
&KDBusService::activateRequested,
|
||||
roomManager,
|
||||
&RoomManager::instance(),
|
||||
[](const QStringList &arguments, const QString &workingDirectory) {
|
||||
Q_UNUSED(workingDirectory);
|
||||
auto args = arguments;
|
||||
args.removeFirst();
|
||||
for (const auto &arg : args) {
|
||||
roomManager->openResource(arg);
|
||||
RoomManager::instance().openResource(arg);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Controller", &Controller::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Clipboard", &clipboard);
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "Config", config);
|
||||
qmlRegisterSingletonInstance<RoomManager>("org.kde.neochat", 1, 0, "RoomManager", roomManager);
|
||||
qmlRegisterSingletonInstance<RoomManager>("org.kde.neochat", 1, 0, "RoomManager", &RoomManager::instance());
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "FileType", &fileTypeSingleton);
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "LoginHelper", login);
|
||||
qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "ChatBoxHelper", &chatBoxHelper);
|
||||
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (parser.positionalArguments().length() > 0) {
|
||||
roomManager->setUrlArgument(parser.positionalArguments()[0]);
|
||||
RoomManager::instance().setUrlArgument(parser.positionalArguments()[0]);
|
||||
}
|
||||
|
||||
#ifdef HAVE_KDBUSADDONS
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "csapi/notifications.h"
|
||||
#include "notificationsmanager.h"
|
||||
#include "roommanager.h"
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
bool useUnityCounter()
|
||||
@@ -288,6 +289,7 @@ void RoomListModel::updateRoom(Room *room, Room *prev)
|
||||
} else {
|
||||
beginInsertRows(QModelIndex(), m_rooms.count(), m_rooms.count());
|
||||
doAddRoom(newRoom);
|
||||
RoomManager::instance().enterRoom(qobject_cast<NeoChatRoom *>(newRoom));
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,12 @@ RoomManager::RoomManager(QObject *parent)
|
||||
RoomManager::~RoomManager()
|
||||
{}
|
||||
|
||||
RoomManager &RoomManager::instance()
|
||||
{
|
||||
static RoomManager _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
NeoChatRoom *RoomManager::currentRoom() const
|
||||
{
|
||||
return m_currentRoom;
|
||||
@@ -118,15 +124,14 @@ void RoomManager::openRoomForActiveConnection()
|
||||
|
||||
void RoomManager::enterRoom(NeoChatRoom *room)
|
||||
{
|
||||
if (!m_currentRoom) {
|
||||
m_lastCurrentRoom = std::exchange(m_currentRoom, room);
|
||||
Q_EMIT currentRoomChanged();
|
||||
Q_EMIT pushRoom(room, QString());
|
||||
}
|
||||
|
||||
m_lastCurrentRoom = std::exchange(m_currentRoom, room);
|
||||
Q_EMIT currentRoomChanged();
|
||||
Q_EMIT replaceRoom(m_currentRoom, QString());
|
||||
|
||||
if (!m_currentRoom) {
|
||||
Q_EMIT pushRoom(room, QString());
|
||||
} else {
|
||||
Q_EMIT replaceRoom(m_currentRoom, QString());
|
||||
}
|
||||
|
||||
// Save last open room
|
||||
KConfigGroup lastOpenRoomGroup(&m_config, "LastOpenRoom");
|
||||
|
||||
@@ -31,6 +31,7 @@ class RoomManager : public QObject, public UriResolverBase
|
||||
public:
|
||||
explicit RoomManager(QObject *parent = nullptr);
|
||||
virtual ~RoomManager();
|
||||
static RoomManager &instance();
|
||||
|
||||
/// Load the last opened room or the welcome page.
|
||||
Q_INVOKABLE void loadInitialRoom();
|
||||
@@ -104,5 +105,3 @@ private:
|
||||
QString m_arg;
|
||||
KConfig m_config;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(RoomManager, roomManager)
|
||||
|
||||
Reference in New Issue
Block a user