diff --git a/src/models/statemodel.cpp b/src/models/statemodel.cpp index cee2ceb79..9a841fd0f 100644 --- a/src/models/statemodel.cpp +++ b/src/models/statemodel.cpp @@ -39,6 +39,9 @@ void StateModel::loadState() { beginResetModel(); m_stateEvents.clear(); + if (!m_room) { + return; + } const auto keys = m_room->currentState().events().keys(); for (const auto &[type, stateKey] : keys) { if (!m_stateEvents.contains(type)) { diff --git a/src/models/statemodel.h b/src/models/statemodel.h index effed1e46..9bdad1335 100644 --- a/src/models/statemodel.h +++ b/src/models/statemodel.h @@ -68,7 +68,7 @@ Q_SIGNALS: void roomChanged(); private: - NeoChatRoom *m_room = nullptr; + QPointer m_room; /** * @brief A map from state event type to number of events of that type diff --git a/src/qml/AccountMenu.qml b/src/qml/AccountMenu.qml index 2a4e141dc..2d70bea78 100644 --- a/src/qml/AccountMenu.qml +++ b/src/qml/AccountMenu.qml @@ -50,6 +50,18 @@ QQC2.Menu { height: Kirigami.Units.gridUnit * 42 }) } + QQC2.MenuItem { + text: i18n("Open developer tools") + icon.name: "tools" + visible: Config.developerTools + onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'DevtoolsPage.qml'), { + connection: root.connection + }, { + title: i18nc("@title:window", "Developer Tools"), + width: Kirigami.Units.gridUnit * 50, + height: Kirigami.Units.gridUnit * 42 + }) + } QQC2.MenuItem { text: i18n("Logout") icon.name: "list-remove-user" diff --git a/src/qml/RoomData.qml b/src/qml/RoomData.qml index bb862dd26..87d380ebf 100644 --- a/src/qml/RoomData.qml +++ b/src/qml/RoomData.qml @@ -39,9 +39,12 @@ ColumnLayout { } FormCard.FormHeader { title: i18n("Room Account Data") + visible: roomAccountData.count > 0 } FormCard.FormCard { + visible: roomAccountData.count > 0 Repeater { + id: roomAccountData model: root.room.accountDataEventTypes delegate: FormCard.FormButtonDelegate { text: modelData @@ -57,9 +60,12 @@ ColumnLayout { FormCard.FormHeader { id: stateEventListHeader title: i18n("Room State") + visible: roomState.count > 0 } FormCard.FormCard { + visible: roomState.count > 0 Repeater { + id: roomState model: StateModel { id: stateModel room: root.room