mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Merge pull request #906 from LorenDB/offlineIndicator
Add offline indicator
This commit is contained in:
commit
00116e8128
4 changed files with 100 additions and 80 deletions
|
@ -17,10 +17,31 @@ Rectangle {
|
||||||
|
|
||||||
color: Nheko.colors.window
|
color: Nheko.colors.window
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
spacing: 0
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: offlineIndicator
|
||||||
|
|
||||||
|
color: Nheko.theme.error
|
||||||
|
visible: !TimelineManager.isConnected
|
||||||
|
Layout.preferredHeight: offlineLabel.height + Nheko.paddingMedium
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: offlineLabel
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: qsTr("No network connection")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AdaptiveLayout {
|
AdaptiveLayout {
|
||||||
id: adaptiveView
|
id: adaptiveView
|
||||||
|
|
||||||
anchors.fill: parent
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
|
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
|
||||||
pageIndex: 1
|
pageIndex: 1
|
||||||
|
|
||||||
|
@ -43,19 +64,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: Communities
|
|
||||||
function onCurrentTagIdChanged() {
|
|
||||||
adaptiveView.initializePageIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPageIndexChanged: {
|
|
||||||
if (adaptiveView.pageIndex == 1 && (Rooms.currentRoom || Rooms.currentRoomPreview.roomid)) {
|
|
||||||
Rooms.resetCurrentRoom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AdaptiveLayoutElement {
|
AdaptiveLayoutElement {
|
||||||
id: communityListC
|
id: communityListC
|
||||||
|
|
||||||
|
@ -95,9 +103,8 @@ Rectangle {
|
||||||
RoomList {
|
RoomList {
|
||||||
id: roomlist
|
id: roomlist
|
||||||
|
|
||||||
implicitHeight: chatPage.height
|
height: adaptiveView.height
|
||||||
collapsed: parent.collapsed
|
collapsed: parent.collapsed
|
||||||
anchors.fill: parent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding {
|
Binding {
|
||||||
|
@ -128,6 +135,8 @@ Rectangle {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
PrivacyScreen {
|
PrivacyScreen {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.privacyScreen
|
visible: Settings.privacyScreen
|
||||||
|
|
|
@ -23,7 +23,6 @@ Container {
|
||||||
|
|
||||||
onSinglePageModeChanged: if (!singlePageMode) pageIndex = 0
|
onSinglePageModeChanged: if (!singlePageMode) pageIndex = 0
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
for (var i = 0; i < count - 1; i++) {
|
for (var i = 0; i < count - 1; i++) {
|
||||||
let handle_ = handle.createObject(contentChildren[i]);
|
let handle_ = handle.createObject(contentChildren[i]);
|
||||||
|
|
|
@ -162,6 +162,14 @@ TimelineViewManager::TimelineViewManager(CallManager *, ChatPage *parent)
|
||||||
&QApplication::focusWindowChanged,
|
&QApplication::focusWindowChanged,
|
||||||
this,
|
this,
|
||||||
&TimelineViewManager::focusChanged);
|
&TimelineViewManager::focusChanged);
|
||||||
|
connect(parent, &ChatPage::connectionLost, this, [this] {
|
||||||
|
isConnected_ = false;
|
||||||
|
emit isConnectedChanged(false);
|
||||||
|
});
|
||||||
|
connect(parent, &ChatPage::connectionRestored, this, [this] {
|
||||||
|
isConnected_ = true;
|
||||||
|
emit isConnectedChanged(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -42,6 +42,7 @@ class TimelineViewManager : public QObject
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
|
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
|
||||||
Q_PROPERTY(bool isWindowFocused READ isWindowFocused NOTIFY focusChanged)
|
Q_PROPERTY(bool isWindowFocused READ isWindowFocused NOTIFY focusChanged)
|
||||||
|
Q_PROPERTY(bool isConnected READ isConnected NOTIFY isConnectedChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
|
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
|
||||||
|
@ -54,6 +55,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
||||||
bool isWindowFocused() const;
|
bool isWindowFocused() const;
|
||||||
|
bool isConnected() const { return isConnected_; }
|
||||||
Q_INVOKABLE void openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId);
|
Q_INVOKABLE void openImageOverlay(TimelineModel *room, QString mxcUrl, QString eventId);
|
||||||
Q_INVOKABLE void openImagePackSettings(QString roomid);
|
Q_INVOKABLE void openImagePackSettings(QString roomid);
|
||||||
Q_INVOKABLE void saveMedia(QString mxcUrl);
|
Q_INVOKABLE void saveMedia(QString mxcUrl);
|
||||||
|
@ -73,6 +75,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void activeTimelineChanged(TimelineModel *timeline);
|
void activeTimelineChanged(TimelineModel *timeline);
|
||||||
void initialSyncChanged(bool isInitialSync);
|
void initialSyncChanged(bool isInitialSync);
|
||||||
|
void isConnectedChanged(bool state);
|
||||||
void replyingEventChanged(QString replyingEvent);
|
void replyingEventChanged(QString replyingEvent);
|
||||||
void replyClosed();
|
void replyClosed();
|
||||||
void inviteUsers(QString roomId, QStringList users);
|
void inviteUsers(QString roomId, QStringList users);
|
||||||
|
@ -111,6 +114,7 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isInitialSync_ = true;
|
bool isInitialSync_ = true;
|
||||||
|
bool isConnected_ = true;
|
||||||
|
|
||||||
RoomlistModel *rooms_ = nullptr;
|
RoomlistModel *rooms_ = nullptr;
|
||||||
CommunitiesModel *communities_ = nullptr;
|
CommunitiesModel *communities_ = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue