mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 03:58:49 +03:00
Allow setting presence state again
This commit is contained in:
parent
51976cf367
commit
bbfbba30b0
5 changed files with 58 additions and 26 deletions
|
@ -267,6 +267,40 @@ Page {
|
||||||
|
|
||||||
onTriggered: statusDialog.show()
|
onTriggered: statusDialog.show()
|
||||||
}
|
}
|
||||||
|
Platform.MenuSeparator {
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform.MenuItemGroup {
|
||||||
|
id: onlineStateGroup
|
||||||
|
}
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Automatic online status")
|
||||||
|
group: onlineStateGroup
|
||||||
|
checkable: true
|
||||||
|
checked: Settings.presence == Settings.AutomaticPresence
|
||||||
|
onTriggered: if (checked) Settings.presence = Settings.AutomaticPresence
|
||||||
|
}
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Online")
|
||||||
|
group: onlineStateGroup
|
||||||
|
checkable: true
|
||||||
|
checked: Settings.presence == Settings.Online
|
||||||
|
onTriggered: if (checked) Settings.presence = Settings.Online
|
||||||
|
}
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Unavailable")
|
||||||
|
group: onlineStateGroup
|
||||||
|
checkable: true
|
||||||
|
checked: Settings.presence == Settings.Unavailable
|
||||||
|
onTriggered: if (checked) Settings.presence = Settings.Unavailable
|
||||||
|
}
|
||||||
|
Platform.MenuItem {
|
||||||
|
text: qsTr("Offline")
|
||||||
|
group: onlineStateGroup
|
||||||
|
checkable: true
|
||||||
|
checked: Settings.presence == Settings.Offline
|
||||||
|
onTriggered: if (checked) Settings.presence = Settings.Offline
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "encryption/DeviceVerificationFlow.h"
|
#include "encryption/DeviceVerificationFlow.h"
|
||||||
#include "encryption/Olm.h"
|
#include "encryption/Olm.h"
|
||||||
#include "ui/RoomSummary.h"
|
#include "ui/RoomSummary.h"
|
||||||
#include "ui/Theme.h"
|
|
||||||
#include "ui/UserProfile.h"
|
#include "ui/UserProfile.h"
|
||||||
#include "voip/CallManager.h"
|
#include "voip/CallManager.h"
|
||||||
|
|
||||||
|
@ -29,8 +28,6 @@
|
||||||
|
|
||||||
#include "timeline/TimelineViewManager.h"
|
#include "timeline/TimelineViewManager.h"
|
||||||
|
|
||||||
#include "blurhash.hpp"
|
|
||||||
|
|
||||||
ChatPage *ChatPage::instance_ = nullptr;
|
ChatPage *ChatPage::instance_ = nullptr;
|
||||||
static constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
|
static constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
|
||||||
static constexpr int RETRY_TIMEOUT = 5'000;
|
static constexpr int RETRY_TIMEOUT = 5'000;
|
||||||
|
@ -404,6 +401,19 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
||||||
[](std::function<void()> f) { f(); },
|
[](std::function<void()> f) { f(); },
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
connect(qobject_cast<QGuiApplication *>(QGuiApplication::instance()),
|
||||||
|
&QGuiApplication::focusWindowChanged,
|
||||||
|
this,
|
||||||
|
[this](QWindow *activeWindow) {
|
||||||
|
if (activeWindow) {
|
||||||
|
nhlog::ui()->debug("Stopping inactive timer.");
|
||||||
|
lastWindowActive = QDateTime();
|
||||||
|
} else {
|
||||||
|
nhlog::ui()->debug("Starting inactive timer.");
|
||||||
|
lastWindowActive = QDateTime::currentDateTime();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connectCallMessage<mtx::events::voip::CallInvite>();
|
connectCallMessage<mtx::events::voip::CallInvite>();
|
||||||
connectCallMessage<mtx::events::voip::CallCandidates>();
|
connectCallMessage<mtx::events::voip::CallCandidates>();
|
||||||
connectCallMessage<mtx::events::voip::CallAnswer>();
|
connectCallMessage<mtx::events::voip::CallAnswer>();
|
||||||
|
@ -1107,6 +1117,13 @@ ChatPage::currentPresence() const
|
||||||
return mtx::presence::unavailable;
|
return mtx::presence::unavailable;
|
||||||
case UserSettings::Presence::Offline:
|
case UserSettings::Presence::Offline:
|
||||||
return mtx::presence::offline;
|
return mtx::presence::offline;
|
||||||
|
case UserSettings::Presence::AutomaticPresence:
|
||||||
|
if (lastWindowActive.isValid() &&
|
||||||
|
lastWindowActive.addSecs(60 * 5) < QDateTime::currentDateTime())
|
||||||
|
return mtx::presence::unavailable;
|
||||||
|
else
|
||||||
|
return mtx::presence::online;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return mtx::presence::online;
|
return mtx::presence::online;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "CacheCryptoStructs.h"
|
|
||||||
#include "CacheStructs.h"
|
|
||||||
#include "ui/RoomSummary.h"
|
#include "ui/RoomSummary.h"
|
||||||
|
|
||||||
class TimelineViewManager;
|
class TimelineViewManager;
|
||||||
|
@ -225,6 +223,9 @@ private:
|
||||||
std::unique_ptr<mtx::pushrules::PushRuleEvaluator> pushrules;
|
std::unique_ptr<mtx::pushrules::PushRuleEvaluator> pushrules;
|
||||||
|
|
||||||
QDateTime lastSpacesUpdate = QDateTime::currentDateTime();
|
QDateTime lastSpacesUpdate = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
// Stores when our windows lost focus. Invalid when our windows have focus.
|
||||||
|
QDateTime lastWindowActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Collection>
|
template<class Collection>
|
||||||
|
|
|
@ -9,42 +9,23 @@
|
||||||
#include <mtx/requests.hpp>
|
#include <mtx/requests.hpp>
|
||||||
#include <mtx/responses/login.hpp>
|
#include <mtx/responses/login.hpp>
|
||||||
|
|
||||||
#include "AliasEditModel.h"
|
|
||||||
#include "BlurhashProvider.h"
|
#include "BlurhashProvider.h"
|
||||||
#include "Cache.h"
|
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Clipboard.h"
|
|
||||||
#include "ColorImageProvider.h"
|
#include "ColorImageProvider.h"
|
||||||
#include "CombinedImagePackModel.h"
|
|
||||||
#include "CompletionProxyModel.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "EventAccessors.h"
|
|
||||||
#include "GridImagePackModel.h"
|
|
||||||
#include "ImagePackListModel.h"
|
|
||||||
#include "InviteesModel.h"
|
|
||||||
#include "JdenticonProvider.h"
|
#include "JdenticonProvider.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
#include "MemberList.h"
|
|
||||||
#include "MxcImageProvider.h"
|
#include "MxcImageProvider.h"
|
||||||
#include "PowerlevelsEditModels.h"
|
|
||||||
#include "SingleImagePackModel.h"
|
|
||||||
#include "TrayIcon.h"
|
#include "TrayIcon.h"
|
||||||
#include "UserDirectoryModel.h"
|
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "dock/Dock.h"
|
#include "dock/Dock.h"
|
||||||
#include "emoji/Provider.h"
|
|
||||||
#include "encryption/DeviceVerificationFlow.h"
|
#include "encryption/DeviceVerificationFlow.h"
|
||||||
#include "encryption/SelfVerificationStatus.h"
|
|
||||||
#include "timeline/DelegateChooser.h"
|
|
||||||
#include "timeline/TimelineFilter.h"
|
|
||||||
#include "timeline/TimelineViewManager.h"
|
#include "timeline/TimelineViewManager.h"
|
||||||
#include "ui/NhekoGlobalObject.h"
|
#include "ui/Theme.h"
|
||||||
#include "ui/RoomSummary.h"
|
|
||||||
#include "ui/UIA.h"
|
|
||||||
#include "voip/CallManager.h"
|
#include "voip/CallManager.h"
|
||||||
#include "voip/WebRTCSession.h"
|
#include "voip/WebRTCSession.h"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <mtx/secret_storage.hpp>
|
#include <mtx/secret_storage.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "JdenticonProvider.h"
|
#include "JdenticonProvider.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
Loading…
Reference in a new issue