mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Merge branch 'master' into work/remove-cmake-fortify-source
This commit is contained in:
commit
4532293e2a
12 changed files with 212 additions and 207 deletions
|
@ -86,7 +86,7 @@ ComboBox {
|
||||||
id: clearStatusDelegate
|
id: clearStatusDelegate
|
||||||
width: clearComboBox.width
|
width: clearComboBox.width
|
||||||
contentItem: Label {
|
contentItem: Label {
|
||||||
text: modelData
|
text: modelData.display
|
||||||
color: Style.ncTextColor
|
color: Style.ncTextColor
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
|
@ -426,7 +426,7 @@ set(STATE_ICONS_COLORS colored black white)
|
||||||
foreach(state_icons_color ${STATE_ICONS_COLORS})
|
foreach(state_icons_color ${STATE_ICONS_COLORS})
|
||||||
set(STATE_ICONS_PATH "${theme_dir}/${state_icons_color}/")
|
set(STATE_ICONS_PATH "${theme_dir}/${state_icons_color}/")
|
||||||
|
|
||||||
message("Generating state icons from SVG in path: "${STATE_ICONS_PATH})
|
message("Generating state icons from SVG in path: ${STATE_ICONS_PATH}")
|
||||||
|
|
||||||
file(GLOB_RECURSE STATE_ICONS_SVG "${STATE_ICONS_PATH}/state-*.svg")
|
file(GLOB_RECURSE STATE_ICONS_SVG "${STATE_ICONS_PATH}/state-*.svg")
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,12 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
UserStatusSelectorButton {
|
UserStatusSelectorButton {
|
||||||
checked: NC.UserStatus.Online == userStatusSelectorModel.onlineStatus
|
checked: NC.UserStatus.Online === userStatusSelectorModel.onlineStatus
|
||||||
checkable: true
|
checkable: true
|
||||||
icon.source: userStatusSelectorModel.onlineIcon
|
icon.source: userStatusSelectorModel.onlineIcon
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
text: qsTr("Online")
|
text: qsTr("Online")
|
||||||
onClicked: userStatusSelectorModel.setOnlineStatus(NC.UserStatus.Online)
|
onClicked: userStatusSelectorModel.onlineStatus = NC.UserStatus.Online
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
||||||
|
@ -67,12 +67,12 @@ ColumnLayout {
|
||||||
Component.onCompleted: topButtonsLayout.updateMaxButtonHeight(implicitHeight)
|
Component.onCompleted: topButtonsLayout.updateMaxButtonHeight(implicitHeight)
|
||||||
}
|
}
|
||||||
UserStatusSelectorButton {
|
UserStatusSelectorButton {
|
||||||
checked: NC.UserStatus.Away == userStatusSelectorModel.onlineStatus
|
checked: NC.UserStatus.Away === userStatusSelectorModel.onlineStatus
|
||||||
checkable: true
|
checkable: true
|
||||||
icon.source: userStatusSelectorModel.awayIcon
|
icon.source: userStatusSelectorModel.awayIcon
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
text: qsTr("Away")
|
text: qsTr("Away")
|
||||||
onClicked: userStatusSelectorModel.setOnlineStatus(NC.UserStatus.Away)
|
onClicked: userStatusSelectorModel.onlineStatus = NC.UserStatus.Away
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
||||||
|
@ -82,13 +82,13 @@ ColumnLayout {
|
||||||
|
|
||||||
}
|
}
|
||||||
UserStatusSelectorButton {
|
UserStatusSelectorButton {
|
||||||
checked: NC.UserStatus.DoNotDisturb == userStatusSelectorModel.onlineStatus
|
checked: NC.UserStatus.DoNotDisturb === userStatusSelectorModel.onlineStatus
|
||||||
checkable: true
|
checkable: true
|
||||||
icon.source: userStatusSelectorModel.dndIcon
|
icon.source: userStatusSelectorModel.dndIcon
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
text: qsTr("Do not disturb")
|
text: qsTr("Do not disturb")
|
||||||
secondaryText: qsTr("Mute all notifications")
|
secondaryText: qsTr("Mute all notifications")
|
||||||
onClicked: userStatusSelectorModel.setOnlineStatus(NC.UserStatus.DoNotDisturb)
|
onClicked: userStatusSelectorModel.onlineStatus = NC.UserStatus.DoNotDisturb
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
||||||
|
@ -97,13 +97,13 @@ ColumnLayout {
|
||||||
Component.onCompleted: topButtonsLayout.updateMaxButtonHeight(implicitHeight)
|
Component.onCompleted: topButtonsLayout.updateMaxButtonHeight(implicitHeight)
|
||||||
}
|
}
|
||||||
UserStatusSelectorButton {
|
UserStatusSelectorButton {
|
||||||
checked: NC.UserStatus.Invisible == userStatusSelectorModel.onlineStatus
|
checked: NC.UserStatus.Invisible === userStatusSelectorModel.onlineStatus
|
||||||
checkable: true
|
checkable: true
|
||||||
icon.source: userStatusSelectorModel.invisibleIcon
|
icon.source: userStatusSelectorModel.invisibleIcon
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
text: qsTr("Invisible")
|
text: qsTr("Invisible")
|
||||||
secondaryText: qsTr("Appear offline")
|
secondaryText: qsTr("Appear offline")
|
||||||
onClicked: userStatusSelectorModel.setOnlineStatus(NC.UserStatus.Invisible)
|
onClicked: userStatusSelectorModel.onlineStatus = NC.UserStatus.Invisible
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
implicitWidth: 200 // Pretty much a hack to ensure all the buttons are equal in width
|
||||||
|
@ -214,7 +214,7 @@ ColumnLayout {
|
||||||
text: userStatusSelectorModel.userStatusMessage
|
text: userStatusSelectorModel.userStatusMessage
|
||||||
color: Style.ncTextColor
|
color: Style.ncTextColor
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
onEditingFinished: userStatusSelectorModel.setUserStatusMessage(text)
|
onEditingFinished: userStatusSelectorModel.userStatusMessage = text
|
||||||
|
|
||||||
property color borderColor: activeFocus ? Style.ncBlue : Style.menuBorder
|
property color borderColor: activeFocus ? Style.ncBlue : Style.menuBorder
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: userStatusSelectorModel.predefinedStatusesCount
|
model: userStatusSelectorModel.predefinedStatuses
|
||||||
|
|
||||||
PredefinedStatusButton {
|
PredefinedStatusButton {
|
||||||
id: control
|
id: control
|
||||||
|
@ -256,9 +256,9 @@ ColumnLayout {
|
||||||
Layout.rightMargin: Style.standardSpacing
|
Layout.rightMargin: Style.standardSpacing
|
||||||
internalSpacing: Style.standardSpacing + fieldButton.padding + userStatusMessageTextField.padding
|
internalSpacing: Style.standardSpacing + fieldButton.padding + userStatusMessageTextField.padding
|
||||||
|
|
||||||
emoji: userStatusSelectorModel.predefinedStatus(index).icon
|
emoji: modelData.icon
|
||||||
text: "<b>" + userStatusSelectorModel.predefinedStatus(index).message + "</b> – " + userStatusSelectorModel.predefinedStatusClearAt(index)
|
text: "<b>%1</b> – %2".arg(modelData.message).arg(userStatusSelectorModel.clearAtReadable(modelData))
|
||||||
onClicked: userStatusSelectorModel.setPredefinedStatus(index)
|
onClicked: userStatusSelectorModel.setPredefinedStatus(modelData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,9 +279,11 @@ ColumnLayout {
|
||||||
id: clearComboBox
|
id: clearComboBox
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
model: userStatusSelectorModel.clearAtValues
|
model: userStatusSelectorModel.clearStageTypes
|
||||||
displayText: userStatusSelectorModel.clearAt
|
textRole: "display"
|
||||||
onActivated: userStatusSelectorModel.setClearAt(index)
|
valueRole: "clearStageType"
|
||||||
|
displayText: userStatusSelectorModel.clearAtDisplayString
|
||||||
|
onActivated: userStatusSelectorModel.setClearAt(currentValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,6 @@ ownCloudGui::ownCloudGui(Application *parent)
|
||||||
connect(_tray.data(), &Systray::openAccountWizard,
|
connect(_tray.data(), &Systray::openAccountWizard,
|
||||||
this, &ownCloudGui::slotNewAccountWizard);
|
this, &ownCloudGui::slotNewAccountWizard);
|
||||||
|
|
||||||
connect(_tray.data(), &Systray::openMainDialog,
|
|
||||||
this, &ownCloudGui::slotOpenMainDialog);
|
|
||||||
|
|
||||||
connect(_tray.data(), &Systray::openSettings,
|
connect(_tray.data(), &Systray::openSettings,
|
||||||
this, &ownCloudGui::slotShowSettings);
|
this, &ownCloudGui::slotShowSettings);
|
||||||
|
|
||||||
|
@ -157,9 +154,7 @@ void ownCloudGui::slotOpenSettingsDialog()
|
||||||
|
|
||||||
void ownCloudGui::slotOpenMainDialog()
|
void ownCloudGui::slotOpenMainDialog()
|
||||||
{
|
{
|
||||||
if (!_tray->isOpen()) {
|
|
||||||
_tray->showWindow();
|
_tray->showWindow();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
|
|
@ -120,7 +120,7 @@ Systray::Systray()
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||||
this, [this]{ emit showWindow(); });
|
this, [this]{ showWindow(); });
|
||||||
#else
|
#else
|
||||||
// Since the positioning of the QSystemTrayIcon is borked on non-Windows and non-macOS desktop environments,
|
// Since the positioning of the QSystemTrayIcon is borked on non-Windows and non-macOS desktop environments,
|
||||||
// we hardcode the position of the tray to be in the center when we add a new account from somewhere like
|
// we hardcode the position of the tray to be in the center when we add a new account from somewhere like
|
||||||
|
@ -128,7 +128,7 @@ Systray::Systray()
|
||||||
// is placed
|
// is placed
|
||||||
|
|
||||||
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||||
this, [this]{ emit showWindow(WindowPosition::Center); });
|
this, [this]{ showWindow(WindowPosition::Center); });
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,9 @@ void Systray::create()
|
||||||
if (!AccountManager::instance()->accounts().isEmpty()) {
|
if (!AccountManager::instance()->accounts().isEmpty()) {
|
||||||
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
|
||||||
}
|
}
|
||||||
_trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
|
|
||||||
|
QQmlComponent trayWindowComponent(_trayEngine, QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
|
||||||
|
_trayWindow.reset(qobject_cast<QQuickWindow*>(trayWindowComponent.create()));
|
||||||
}
|
}
|
||||||
hideWindow();
|
hideWindow();
|
||||||
emit activated(QSystemTrayIcon::ActivationReason::Unknown);
|
emit activated(QSystemTrayIcon::ActivationReason::Unknown);
|
||||||
|
@ -152,6 +154,36 @@ void Systray::create()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Systray::showWindow(WindowPosition position)
|
||||||
|
{
|
||||||
|
if(isOpen() || !_trayWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(position == WindowPosition::Center) {
|
||||||
|
positionWindowAtScreenCenter(_trayWindow.data());
|
||||||
|
} else {
|
||||||
|
positionWindowAtTray(_trayWindow.data());
|
||||||
|
}
|
||||||
|
_trayWindow->show();
|
||||||
|
_trayWindow->raise();
|
||||||
|
_trayWindow->requestActivate();
|
||||||
|
|
||||||
|
setIsOpen(true);
|
||||||
|
|
||||||
|
UserModel::instance()->fetchCurrentActivityModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systray::hideWindow()
|
||||||
|
{
|
||||||
|
if(!isOpen() || !_trayWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_trayWindow->hide();
|
||||||
|
setIsOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
void Systray::setupContextMenu()
|
void Systray::setupContextMenu()
|
||||||
{
|
{
|
||||||
const auto oldContextMenu = _contextMenu.data();
|
const auto oldContextMenu = _contextMenu.data();
|
||||||
|
@ -169,7 +201,7 @@ void Systray::setupContextMenu()
|
||||||
if (AccountManager::instance()->accounts().isEmpty()) {
|
if (AccountManager::instance()->accounts().isEmpty()) {
|
||||||
_contextMenu->addAction(tr("Add account"), this, &Systray::openAccountWizard);
|
_contextMenu->addAction(tr("Add account"), this, &Systray::openAccountWizard);
|
||||||
} else {
|
} else {
|
||||||
_contextMenu->addAction(tr("Open main dialog"), this, &Systray::openMainDialog);
|
_contextMenu->addAction(tr("Open main dialog"), this, [this]{ showWindow(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pauseAction = _contextMenu->addAction(tr("Pause sync"), this, &Systray::slotPauseAllFolders);
|
auto pauseAction = _contextMenu->addAction(tr("Pause sync"), this, &Systray::slotPauseAllFolders);
|
||||||
|
|
|
@ -98,15 +98,10 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void currentUserChanged();
|
void currentUserChanged();
|
||||||
void openAccountWizard();
|
void openAccountWizard();
|
||||||
void openMainDialog();
|
|
||||||
void openSettings();
|
void openSettings();
|
||||||
void openHelp();
|
void openHelp();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
// These window signals are listened to in Window.qml
|
|
||||||
void hideWindow();
|
|
||||||
void showWindow(WindowPosition position = WindowPosition::Default);
|
|
||||||
|
|
||||||
void openShareDialog(const QString &sharePath, const QString &localPath);
|
void openShareDialog(const QString &sharePath, const QString &localPath);
|
||||||
void showFileActivityDialog(const QString &objectName, const int objectId);
|
void showFileActivityDialog(const QString &objectName, const int objectId);
|
||||||
void sendChatMessage(const QString &token, const QString &message, const QString &replyTo);
|
void sendChatMessage(const QString &token, const QString &message, const QString &replyTo);
|
||||||
|
@ -117,15 +112,18 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotNewUserSelected();
|
void slotNewUserSelected();
|
||||||
|
|
||||||
|
void forceWindowInit(QQuickWindow *window) const;
|
||||||
void positionWindowAtTray(QQuickWindow *window) const;
|
void positionWindowAtTray(QQuickWindow *window) const;
|
||||||
void positionWindowAtScreenCenter(QQuickWindow *window) const;
|
void positionWindowAtScreenCenter(QQuickWindow *window) const;
|
||||||
|
void positionNotificationWindow(QQuickWindow *window) const;
|
||||||
|
|
||||||
|
void showWindow(WindowPosition position = WindowPosition::Default);
|
||||||
|
void hideWindow();
|
||||||
|
|
||||||
void setSyncIsPaused(const bool syncIsPaused);
|
void setSyncIsPaused(const bool syncIsPaused);
|
||||||
void setIsOpen(const bool isOpen);
|
void setIsOpen(const bool isOpen);
|
||||||
|
|
||||||
void forceWindowInit(QQuickWindow *window) const;
|
|
||||||
void positionNotificationWindow(QQuickWindow *window) const;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotUnpauseAllFolders();
|
void slotUnpauseAllFolders();
|
||||||
void slotPauseAllFolders();
|
void slotPauseAllFolders();
|
||||||
|
@ -153,6 +151,7 @@ private:
|
||||||
bool _syncIsPaused = true;
|
bool _syncIsPaused = true;
|
||||||
QPointer<QQmlApplicationEngine> _trayEngine;
|
QPointer<QQmlApplicationEngine> _trayEngine;
|
||||||
QPointer<QMenu> _contextMenu;
|
QPointer<QMenu> _contextMenu;
|
||||||
|
QSharedPointer<QQuickWindow> _trayWindow;
|
||||||
|
|
||||||
AccessManagerFactory _accessManagerFactory;
|
AccessManagerFactory _accessManagerFactory;
|
||||||
|
|
||||||
|
|
|
@ -77,31 +77,11 @@ Window {
|
||||||
Connections {
|
Connections {
|
||||||
target: Systray
|
target: Systray
|
||||||
|
|
||||||
function onShowWindow(position) {
|
function onIsOpenChanged() {
|
||||||
if(trayWindow.visible) {
|
if(Systray.isOpen) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accountMenu.close();
|
accountMenu.close();
|
||||||
appsMenu.close();
|
appsMenu.close();
|
||||||
|
|
||||||
if(position === Systray.WindowPosition.Center) {
|
|
||||||
Systray.positionWindowAtScreenCenter(trayWindow);
|
|
||||||
} else {
|
|
||||||
Systray.positionWindowAtTray(trayWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trayWindow.show();
|
|
||||||
trayWindow.raise();
|
|
||||||
trayWindow.requestActivate();
|
|
||||||
|
|
||||||
Systray.isOpen = true;
|
|
||||||
UserModel.fetchCurrentActivityModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onHideWindow() {
|
|
||||||
trayWindow.hide();
|
|
||||||
Systray.isOpen = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onShowFileActivityDialog(objectName, objectId) {
|
function onShowFileActivityDialog(objectName, objectId) {
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
#include "userstatusselectormodel.h"
|
#include "userstatusselectormodel.h"
|
||||||
#include "tray/usermodel.h"
|
#include "tray/usermodel.h"
|
||||||
|
|
||||||
#include <ocsuserstatusconnector.h>
|
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <userstatusconnector.h>
|
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
@ -250,7 +248,7 @@ void UserStatusSelectorModel::onUserStatusFetched(const UserStatus &userStatus)
|
||||||
|
|
||||||
emit userStatusChanged();
|
emit userStatusChanged();
|
||||||
emit onlineStatusChanged();
|
emit onlineStatusChanged();
|
||||||
emit clearAtChanged();
|
emit clearAtDisplayStringChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<ClearAt> UserStatusSelectorModel::clearStageTypeToDateTime(ClearStageType type) const
|
Optional<ClearAt> UserStatusSelectorModel::clearStageTypeToDateTime(ClearStageType type) const
|
||||||
|
@ -319,36 +317,27 @@ void UserStatusSelectorModel::clearUserStatus()
|
||||||
_userStatusConnector->clearMessage();
|
_userStatusConnector->clearMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserStatusSelectorModel::onPredefinedStatusesFetched(const std::vector<UserStatus> &statuses)
|
void UserStatusSelectorModel::onPredefinedStatusesFetched(const QVector<UserStatus> &statuses)
|
||||||
{
|
{
|
||||||
_predefinedStatuses = statuses;
|
_predefinedStatuses = statuses;
|
||||||
emit predefinedStatusesChanged();
|
emit predefinedStatusesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserStatus UserStatusSelectorModel::predefinedStatus(int index) const
|
QVector<UserStatus> UserStatusSelectorModel::predefinedStatuses() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(0 <= index && index < static_cast<int>(_predefinedStatuses.size()));
|
return _predefinedStatuses;
|
||||||
return _predefinedStatuses[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserStatusSelectorModel::predefinedStatusesCount() const
|
void UserStatusSelectorModel::setPredefinedStatus(const UserStatus &predefinedStatus)
|
||||||
{
|
{
|
||||||
return static_cast<int>(_predefinedStatuses.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserStatusSelectorModel::setPredefinedStatus(int index)
|
|
||||||
{
|
|
||||||
Q_ASSERT(0 <= index && index < static_cast<int>(_predefinedStatuses.size()));
|
|
||||||
|
|
||||||
_userStatus.setMessagePredefined(true);
|
_userStatus.setMessagePredefined(true);
|
||||||
const auto predefinedStatus = _predefinedStatuses[index];
|
|
||||||
_userStatus.setId(predefinedStatus.id());
|
_userStatus.setId(predefinedStatus.id());
|
||||||
_userStatus.setMessage(predefinedStatus.message());
|
_userStatus.setMessage(predefinedStatus.message());
|
||||||
_userStatus.setIcon(predefinedStatus.icon());
|
_userStatus.setIcon(predefinedStatus.icon());
|
||||||
_userStatus.setClearAt(predefinedStatus.clearAt());
|
_userStatus.setClearAt(predefinedStatus.clearAt());
|
||||||
|
|
||||||
emit userStatusChanged();
|
emit userStatusChanged();
|
||||||
emit clearAtChanged();
|
emit clearAtDisplayStringChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserStatusSelectorModel::clearAtStageToString(ClearStageType stage) const
|
QString UserStatusSelectorModel::clearAtStageToString(ClearStageType stage) const
|
||||||
|
@ -377,21 +366,24 @@ QString UserStatusSelectorModel::clearAtStageToString(ClearStageType stage) cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList UserStatusSelectorModel::clearAtValues() const
|
QVariantList UserStatusSelectorModel::clearStageTypes() const
|
||||||
{
|
{
|
||||||
QStringList clearAtStages;
|
QVariantList clearStageTypes;
|
||||||
std::transform(_clearStages.begin(), _clearStages.end(),
|
|
||||||
std::back_inserter(clearAtStages),
|
|
||||||
[this](const ClearStageType &stage) { return clearAtStageToString(stage); });
|
|
||||||
|
|
||||||
return clearAtStages;
|
for(const auto clearStageType : _clearStages) {
|
||||||
|
QVariantMap clearStageToAdd;
|
||||||
|
clearStageToAdd.insert(QStringLiteral("display"), clearAtStageToString(clearStageType));
|
||||||
|
clearStageToAdd.insert(QStringLiteral("clearStageType"), QVariant::fromValue(clearStageType));
|
||||||
|
clearStageTypes.append(clearStageToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clearStageTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserStatusSelectorModel::setClearAt(int index)
|
void UserStatusSelectorModel::setClearAt(const ClearStageType clearStageType)
|
||||||
{
|
{
|
||||||
Q_ASSERT(0 <= index && index < static_cast<int>(_clearStages.size()));
|
_userStatus.setClearAt(clearStageTypeToDateTime(clearStageType));
|
||||||
_userStatus.setClearAt(clearStageTypeToDateTime(_clearStages[index]));
|
emit clearAtDisplayStringChanged();
|
||||||
emit clearAtChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserStatusSelectorModel::errorMessage() const
|
QString UserStatusSelectorModel::errorMessage() const
|
||||||
|
@ -427,6 +419,12 @@ QString UserStatusSelectorModel::timeDifferenceToString(int differenceSecs) cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UserStatusSelectorModel::clearAtReadable(const UserStatus &status) const
|
||||||
|
{
|
||||||
|
const auto clearAt = status.clearAt();
|
||||||
|
return clearAtReadable(clearAt);
|
||||||
|
}
|
||||||
|
|
||||||
QString UserStatusSelectorModel::clearAtReadable(const Optional<ClearAt> &clearAt) const
|
QString UserStatusSelectorModel::clearAtReadable(const Optional<ClearAt> &clearAt) const
|
||||||
{
|
{
|
||||||
if (clearAt) {
|
if (clearAt) {
|
||||||
|
@ -456,13 +454,9 @@ QString UserStatusSelectorModel::clearAtReadable(const Optional<ClearAt> &clearA
|
||||||
return tr("Don't clear");
|
return tr("Don't clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserStatusSelectorModel::predefinedStatusClearAt(int index) const
|
QString UserStatusSelectorModel::clearAtDisplayString() const
|
||||||
{
|
|
||||||
return clearAtReadable(predefinedStatus(index).clearAt());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UserStatusSelectorModel::clearAt() const
|
|
||||||
{
|
{
|
||||||
return clearAtReadable(_userStatus.clearAt());
|
return clearAtReadable(_userStatus.clearAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "common/result.h"
|
#include "common/result.h"
|
||||||
|
|
||||||
#include <userstatusconnector.h>
|
#include <userstatusconnector.h>
|
||||||
|
#include <ocsuserstatusconnector.h>
|
||||||
#include <datetimeprovider.h>
|
#include <datetimeprovider.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -33,12 +34,12 @@ class UserStatusSelectorModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString userStatusMessage READ userStatusMessage NOTIFY userStatusChanged)
|
Q_PROPERTY(QString userStatusMessage READ userStatusMessage WRITE setUserStatusMessage NOTIFY userStatusChanged)
|
||||||
Q_PROPERTY(QString userStatusEmoji READ userStatusEmoji WRITE setUserStatusEmoji NOTIFY userStatusChanged)
|
Q_PROPERTY(QString userStatusEmoji READ userStatusEmoji WRITE setUserStatusEmoji NOTIFY userStatusChanged)
|
||||||
Q_PROPERTY(OCC::UserStatus::OnlineStatus onlineStatus READ onlineStatus WRITE setOnlineStatus NOTIFY onlineStatusChanged)
|
Q_PROPERTY(OCC::UserStatus::OnlineStatus onlineStatus READ onlineStatus WRITE setOnlineStatus NOTIFY onlineStatusChanged)
|
||||||
Q_PROPERTY(int predefinedStatusesCount READ predefinedStatusesCount NOTIFY predefinedStatusesChanged)
|
Q_PROPERTY(QVector<OCC::UserStatus> predefinedStatuses READ predefinedStatuses NOTIFY predefinedStatusesChanged)
|
||||||
Q_PROPERTY(QStringList clearAtValues READ clearAtValues CONSTANT)
|
Q_PROPERTY(QVariantList clearStageTypes READ clearStageTypes CONSTANT)
|
||||||
Q_PROPERTY(QString clearAt READ clearAt NOTIFY clearAtChanged)
|
Q_PROPERTY(QString clearAtDisplayString READ clearAtDisplayString NOTIFY clearAtDisplayStringChanged)
|
||||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
||||||
Q_PROPERTY(QUrl onlineIcon READ onlineIcon CONSTANT)
|
Q_PROPERTY(QUrl onlineIcon READ onlineIcon CONSTANT)
|
||||||
Q_PROPERTY(QUrl awayIcon READ awayIcon CONSTANT)
|
Q_PROPERTY(QUrl awayIcon READ awayIcon CONSTANT)
|
||||||
|
@ -46,6 +47,16 @@ class UserStatusSelectorModel : public QObject
|
||||||
Q_PROPERTY(QUrl invisibleIcon READ invisibleIcon CONSTANT)
|
Q_PROPERTY(QUrl invisibleIcon READ invisibleIcon CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class ClearStageType {
|
||||||
|
DontClear,
|
||||||
|
HalfHour,
|
||||||
|
OneHour,
|
||||||
|
FourHour,
|
||||||
|
Today,
|
||||||
|
Week,
|
||||||
|
};
|
||||||
|
Q_ENUM(ClearStageType);
|
||||||
|
|
||||||
explicit UserStatusSelectorModel(QObject *parent = nullptr);
|
explicit UserStatusSelectorModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
explicit UserStatusSelectorModel(std::shared_ptr<UserStatusConnector> userStatusConnector,
|
explicit UserStatusSelectorModel(std::shared_ptr<UserStatusConnector> userStatusConnector,
|
||||||
|
@ -62,10 +73,8 @@ public:
|
||||||
explicit UserStatusSelectorModel(const UserStatus &userStatus,
|
explicit UserStatusSelectorModel(const UserStatus &userStatus,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE void load(int id);
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT UserStatus::OnlineStatus onlineStatus() const;
|
Q_REQUIRED_RESULT UserStatus::OnlineStatus onlineStatus() const;
|
||||||
Q_INVOKABLE void setOnlineStatus(OCC::UserStatus::OnlineStatus status);
|
void setOnlineStatus(UserStatus::OnlineStatus status);
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QUrl onlineIcon() const;
|
Q_REQUIRED_RESULT QUrl onlineIcon() const;
|
||||||
Q_REQUIRED_RESULT QUrl awayIcon() const;
|
Q_REQUIRED_RESULT QUrl awayIcon() const;
|
||||||
|
@ -73,59 +82,51 @@ public:
|
||||||
Q_REQUIRED_RESULT QUrl invisibleIcon() const;
|
Q_REQUIRED_RESULT QUrl invisibleIcon() const;
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QString userStatusMessage() const;
|
Q_REQUIRED_RESULT QString userStatusMessage() const;
|
||||||
Q_INVOKABLE void setUserStatusMessage(const QString &message);
|
void setUserStatusMessage(const QString &message);
|
||||||
void setUserStatusEmoji(const QString &emoji);
|
|
||||||
Q_REQUIRED_RESULT QString userStatusEmoji() const;
|
Q_REQUIRED_RESULT QString userStatusEmoji() const;
|
||||||
|
void setUserStatusEmoji(const QString &emoji);
|
||||||
|
|
||||||
Q_INVOKABLE void setUserStatus();
|
QVector<UserStatus> predefinedStatuses() const;
|
||||||
Q_INVOKABLE void clearUserStatus();
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT int predefinedStatusesCount() const;
|
Q_REQUIRED_RESULT QVariantList clearStageTypes() const;
|
||||||
Q_INVOKABLE UserStatus predefinedStatus(int index) const;
|
Q_REQUIRED_RESULT QString clearAtDisplayString() const;
|
||||||
Q_INVOKABLE QString predefinedStatusClearAt(int index) const;
|
Q_INVOKABLE QString clearAtReadable(const UserStatus &status) const;
|
||||||
Q_INVOKABLE void setPredefinedStatus(int index);
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QStringList clearAtValues() const;
|
|
||||||
Q_REQUIRED_RESULT QString clearAt() const;
|
|
||||||
Q_INVOKABLE void setClearAt(int index);
|
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QString errorMessage() const;
|
Q_REQUIRED_RESULT QString errorMessage() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void load(int id);
|
||||||
|
void setUserStatus();
|
||||||
|
void clearUserStatus();
|
||||||
|
void setClearAt(const ClearStageType clearStageType);
|
||||||
|
void setPredefinedStatus(const UserStatus &predefinedStatus);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorMessageChanged();
|
void errorMessageChanged();
|
||||||
void userStatusChanged();
|
void userStatusChanged();
|
||||||
void onlineStatusChanged();
|
void onlineStatusChanged();
|
||||||
void clearAtChanged();
|
void clearAtDisplayStringChanged();
|
||||||
void predefinedStatusesChanged();
|
void predefinedStatusesChanged();
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class ClearStageType {
|
|
||||||
DontClear,
|
|
||||||
HalfHour,
|
|
||||||
OneHour,
|
|
||||||
FourHour,
|
|
||||||
Today,
|
|
||||||
Week
|
|
||||||
};
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void reset();
|
void reset();
|
||||||
void onUserStatusFetched(const UserStatus &userStatus);
|
void onUserStatusFetched(const UserStatus &userStatus);
|
||||||
void onPredefinedStatusesFetched(const std::vector<UserStatus> &statuses);
|
void onPredefinedStatusesFetched(const QVector<UserStatus> &statuses);
|
||||||
void onUserStatusSet();
|
void onUserStatusSet();
|
||||||
void onMessageCleared();
|
void onMessageCleared();
|
||||||
void onError(UserStatusConnector::Error error);
|
void onError(UserStatusConnector::Error error);
|
||||||
|
|
||||||
Q_REQUIRED_RESULT QString clearAtStageToString(ClearStageType stage) const;
|
|
||||||
Q_REQUIRED_RESULT QString clearAtReadable(const Optional<ClearAt> &clearAt) const;
|
Q_REQUIRED_RESULT QString clearAtReadable(const Optional<ClearAt> &clearAt) const;
|
||||||
|
Q_REQUIRED_RESULT QString clearAtStageToString(ClearStageType stage) const;
|
||||||
Q_REQUIRED_RESULT QString timeDifferenceToString(int differenceSecs) const;
|
Q_REQUIRED_RESULT QString timeDifferenceToString(int differenceSecs) const;
|
||||||
Q_REQUIRED_RESULT Optional<ClearAt> clearStageTypeToDateTime(ClearStageType type) const;
|
Q_REQUIRED_RESULT Optional<ClearAt> clearStageTypeToDateTime(ClearStageType type) const;
|
||||||
void setError(const QString &reason);
|
void setError(const QString &reason);
|
||||||
void clearError();
|
void clearError();
|
||||||
|
|
||||||
std::shared_ptr<UserStatusConnector> _userStatusConnector {};
|
std::shared_ptr<UserStatusConnector> _userStatusConnector {};
|
||||||
std::vector<UserStatus> _predefinedStatuses;
|
QVector<UserStatus> _predefinedStatuses;
|
||||||
UserStatus _userStatus;
|
UserStatus _userStatus;
|
||||||
std::unique_ptr<DateTimeProvider> _dateTimeProvider;
|
std::unique_ptr<DateTimeProvider> _dateTimeProvider;
|
||||||
|
|
||||||
|
|
|
@ -191,15 +191,15 @@ OCC::UserStatus jsonToUserStatus(QJsonObject jsonObject)
|
||||||
return userStatus;
|
return userStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<OCC::UserStatus> jsonToPredefinedStatuses(QJsonArray jsonDataArray)
|
QVector<OCC::UserStatus> jsonToPredefinedStatuses(QJsonArray jsonDataArray)
|
||||||
{
|
{
|
||||||
std::vector<OCC::UserStatus> statuses;
|
QVector<OCC::UserStatus> statuses;
|
||||||
for (const auto &jsonEntry : jsonDataArray) {
|
for (const auto &jsonEntry : jsonDataArray) {
|
||||||
Q_ASSERT(jsonEntry.isObject());
|
Q_ASSERT(jsonEntry.isObject());
|
||||||
if (!jsonEntry.isObject()) {
|
if (!jsonEntry.isObject()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
statuses.push_back(jsonToUserStatus(jsonEntry.toObject()));
|
statuses.append(jsonToUserStatus(jsonEntry.toObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return statuses;
|
return statuses;
|
||||||
|
|
|
@ -76,6 +76,8 @@ public:
|
||||||
Q_REQUIRED_RESULT OnlineStatus state() const;
|
Q_REQUIRED_RESULT OnlineStatus state() const;
|
||||||
Q_REQUIRED_RESULT Optional<ClearAt> clearAt() const;
|
Q_REQUIRED_RESULT Optional<ClearAt> clearAt() const;
|
||||||
|
|
||||||
|
QString clearAtDisplayString() const;
|
||||||
|
|
||||||
void setId(const QString &id);
|
void setId(const QString &id);
|
||||||
void setMessage(const QString &message);
|
void setMessage(const QString &message);
|
||||||
void setState(OnlineStatus state);
|
void setState(OnlineStatus state);
|
||||||
|
@ -127,7 +129,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void userStatusFetched(const UserStatus &userStatus);
|
void userStatusFetched(const UserStatus &userStatus);
|
||||||
void predefinedStatusesFetched(const std::vector<UserStatus> &statuses);
|
void predefinedStatusesFetched(const QVector<UserStatus> &statuses);
|
||||||
void userStatusSet();
|
void userStatusSet();
|
||||||
void serverUserStatusChanged();
|
void serverUserStatusChanged();
|
||||||
void messageCleared();
|
void messageCleared();
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFakePredefinedStatuses(
|
void setFakePredefinedStatuses(
|
||||||
const std::vector<OCC::UserStatus> &statuses)
|
const QVector<OCC::UserStatus> &statuses)
|
||||||
{
|
{
|
||||||
_predefinedStatuses = statuses;
|
_predefinedStatuses = statuses;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
private:
|
private:
|
||||||
OCC::UserStatus _userStatusSetByCallerOfSetUserStatus;
|
OCC::UserStatus _userStatusSetByCallerOfSetUserStatus;
|
||||||
OCC::UserStatus _userStatus;
|
OCC::UserStatus _userStatus;
|
||||||
std::vector<OCC::UserStatus> _predefinedStatuses;
|
QVector<OCC::UserStatus> _predefinedStatuses;
|
||||||
bool _isMessageCleared = false;
|
bool _isMessageCleared = false;
|
||||||
bool _couldNotFetchPredefinedUserStatuses = false;
|
bool _couldNotFetchPredefinedUserStatuses = false;
|
||||||
bool _couldNotFetchUserStatus = false;
|
bool _couldNotFetchUserStatus = false;
|
||||||
|
@ -145,10 +145,10 @@ private:
|
||||||
QDateTime _dateTime;
|
QDateTime _dateTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<OCC::UserStatus>
|
static QVector<OCC::UserStatus>
|
||||||
createFakePredefinedStatuses(const QDateTime ¤tTime)
|
createFakePredefinedStatuses(const QDateTime ¤tTime)
|
||||||
{
|
{
|
||||||
std::vector<OCC::UserStatus> statuses;
|
QVector<OCC::UserStatus> statuses;
|
||||||
|
|
||||||
const QString userStatusId("fake-id");
|
const QString userStatusId("fake-id");
|
||||||
const QString userStatusMessage("Predefined status");
|
const QString userStatusMessage("Predefined status");
|
||||||
|
@ -161,8 +161,8 @@ createFakePredefinedStatuses(const QDateTime ¤tTime)
|
||||||
clearAt._timestamp = currentTime.addSecs(60 * 60).toSecsSinceEpoch();
|
clearAt._timestamp = currentTime.addSecs(60 * 60).toSecsSinceEpoch();
|
||||||
userStatusClearAt = clearAt;
|
userStatusClearAt = clearAt;
|
||||||
|
|
||||||
statuses.emplace_back(userStatusId, userStatusMessage, userStatusIcon,
|
statuses.append({userStatusId, userStatusMessage, userStatusIcon,
|
||||||
userStatusState, userStatusMessagePredefined, userStatusClearAt);
|
userStatusState, userStatusMessagePredefined, userStatusClearAt});
|
||||||
|
|
||||||
return statuses;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,13 @@ private slots:
|
||||||
QCOMPARE(model.userStatusMessage(), userStatusMessage);
|
QCOMPARE(model.userStatusMessage(), userStatusMessage);
|
||||||
QCOMPARE(model.userStatusEmoji(), userStatusIcon);
|
QCOMPARE(model.userStatusEmoji(), userStatusIcon);
|
||||||
QCOMPARE(model.onlineStatus(), userStatusState);
|
QCOMPARE(model.onlineStatus(), userStatusState);
|
||||||
QCOMPARE(model.clearAt(), tr("1 day"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 day"));
|
||||||
|
|
||||||
// Were predefined statuses fetched correctly?
|
// Were predefined statuses fetched correctly?
|
||||||
const auto predefinedStatusesCount = model.predefinedStatusesCount();
|
const auto predefinedStatusesCount = model.predefinedStatuses().count();
|
||||||
QCOMPARE(predefinedStatusesCount, fakePredefinedStatuses.size());
|
QCOMPARE(predefinedStatusesCount, fakePredefinedStatuses.size());
|
||||||
for (int i = 0; i < predefinedStatusesCount; ++i) {
|
for (int i = 0; i < predefinedStatusesCount; ++i) {
|
||||||
const auto predefinedStatus = model.predefinedStatus(i);
|
const auto predefinedStatus = model.predefinedStatuses()[i];
|
||||||
QCOMPARE(predefinedStatus.id(),
|
QCOMPARE(predefinedStatus.id(),
|
||||||
fakePredefinedStatuses[i].id());
|
fakePredefinedStatuses[i].id());
|
||||||
QCOMPARE(predefinedStatus.message(),
|
QCOMPARE(predefinedStatus.message(),
|
||||||
|
@ -242,7 +242,7 @@ private slots:
|
||||||
|
|
||||||
QCOMPARE(model.userStatusMessage(), "");
|
QCOMPARE(model.userStatusMessage(), "");
|
||||||
QCOMPARE(model.userStatusEmoji(), "😀");
|
QCOMPARE(model.userStatusEmoji(), "😀");
|
||||||
QCOMPARE(model.clearAt(), tr("Don't clear"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Don't clear"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testCtor_fetchStatusButNoStatusSet_showSensibleDefaults()
|
void testCtor_fetchStatusButNoStatusSet_showSensibleDefaults()
|
||||||
|
@ -255,7 +255,7 @@ private slots:
|
||||||
QCOMPARE(model.onlineStatus(), OCC::UserStatus::OnlineStatus::Online);
|
QCOMPARE(model.onlineStatus(), OCC::UserStatus::OnlineStatus::Online);
|
||||||
QCOMPARE(model.userStatusMessage(), "");
|
QCOMPARE(model.userStatusMessage(), "");
|
||||||
QCOMPARE(model.userStatusEmoji(), "😀");
|
QCOMPARE(model.userStatusEmoji(), "😀");
|
||||||
QCOMPARE(model.clearAt(), tr("Don't clear"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Don't clear"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetOnlineStatus_emitOnlineStatusChanged()
|
void testSetOnlineStatus_emitOnlineStatusChanged()
|
||||||
|
@ -284,7 +284,7 @@ private slots:
|
||||||
model.setOnlineStatus(userStatusState);
|
model.setOnlineStatus(userStatusState);
|
||||||
model.setUserStatusMessage(userStatusMessage);
|
model.setUserStatusMessage(userStatusMessage);
|
||||||
model.setUserStatusEmoji(userStatusIcon);
|
model.setUserStatusEmoji(userStatusIcon);
|
||||||
model.setClearAt(1);
|
model.setClearAt(OCC::UserStatusSelectorModel::ClearStageType::HalfHour);
|
||||||
|
|
||||||
model.setUserStatus();
|
model.setUserStatus();
|
||||||
QCOMPARE(finishedSpy.count(), 1);
|
QCOMPARE(finishedSpy.count(), 1);
|
||||||
|
@ -305,7 +305,7 @@ private slots:
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
fakeUserStatusJob->setFakePredefinedStatuses(createFakePredefinedStatuses(createDateTime()));
|
fakeUserStatusJob->setFakePredefinedStatuses(createFakePredefinedStatuses(createDateTime()));
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
model.setPredefinedStatus(0);
|
model.setPredefinedStatus(model.predefinedStatuses()[0]);
|
||||||
QSignalSpy finishedSpy(&model, &OCC::UserStatusSelectorModel::finished);
|
QSignalSpy finishedSpy(&model, &OCC::UserStatusSelectorModel::finished);
|
||||||
|
|
||||||
const QString userStatusMessage("Some status");
|
const QString userStatusMessage("Some status");
|
||||||
|
@ -313,7 +313,7 @@ private slots:
|
||||||
|
|
||||||
model.setOnlineStatus(userStatusState);
|
model.setOnlineStatus(userStatusState);
|
||||||
model.setUserStatusMessage(userStatusMessage);
|
model.setUserStatusMessage(userStatusMessage);
|
||||||
model.setClearAt(1);
|
model.setClearAt(OCC::UserStatusSelectorModel::ClearStageType::HalfHour);
|
||||||
|
|
||||||
model.setUserStatus();
|
model.setUserStatus();
|
||||||
QCOMPARE(finishedSpy.count(), 1);
|
QCOMPARE(finishedSpy.count(), 1);
|
||||||
|
@ -333,7 +333,7 @@ private slots:
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
fakeUserStatusJob->setFakePredefinedStatuses(createFakePredefinedStatuses(createDateTime()));
|
fakeUserStatusJob->setFakePredefinedStatuses(createFakePredefinedStatuses(createDateTime()));
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
model.setPredefinedStatus(0);
|
model.setPredefinedStatus(model.predefinedStatuses()[0]);
|
||||||
QSignalSpy finishedSpy(&model, &OCC::UserStatusSelectorModel::finished);
|
QSignalSpy finishedSpy(&model, &OCC::UserStatusSelectorModel::finished);
|
||||||
|
|
||||||
const QString userStatusIcon("❤");
|
const QString userStatusIcon("❤");
|
||||||
|
@ -341,7 +341,7 @@ private slots:
|
||||||
|
|
||||||
model.setOnlineStatus(userStatusState);
|
model.setOnlineStatus(userStatusState);
|
||||||
model.setUserStatusEmoji(userStatusIcon);
|
model.setUserStatusEmoji(userStatusIcon);
|
||||||
model.setClearAt(1);
|
model.setClearAt(OCC::UserStatusSelectorModel::ClearStageType::HalfHour);
|
||||||
|
|
||||||
model.setUserStatus();
|
model.setUserStatus();
|
||||||
QCOMPARE(finishedSpy.count(), 1);
|
QCOMPARE(finishedSpy.count(), 1);
|
||||||
|
@ -369,99 +369,99 @@ private slots:
|
||||||
|
|
||||||
QSignalSpy userStatusChangedSpy(&model,
|
QSignalSpy userStatusChangedSpy(&model,
|
||||||
&OCC::UserStatusSelectorModel::userStatusChanged);
|
&OCC::UserStatusSelectorModel::userStatusChanged);
|
||||||
QSignalSpy clearAtChangedSpy(&model,
|
QSignalSpy clearAtDisplayStringChangedSpy(&model,
|
||||||
&OCC::UserStatusSelectorModel::clearAtChanged);
|
&OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto fakePredefinedUserStatusIndex = 0;
|
const auto fakePredefinedUserStatusIndex = 0;
|
||||||
model.setPredefinedStatus(fakePredefinedUserStatusIndex);
|
model.setPredefinedStatus(model.predefinedStatuses()[fakePredefinedUserStatusIndex]);
|
||||||
|
|
||||||
QCOMPARE(userStatusChangedSpy.count(), 1);
|
QCOMPARE(userStatusChangedSpy.count(), 1);
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
|
|
||||||
// Was user status set correctly?
|
// Was user status set correctly?
|
||||||
const auto fakePredefinedUserStatus = fakePredefinedStatuses[fakePredefinedUserStatusIndex];
|
const auto fakePredefinedUserStatus = fakePredefinedStatuses[fakePredefinedUserStatusIndex];
|
||||||
QCOMPARE(model.userStatusMessage(), fakePredefinedUserStatus.message());
|
QCOMPARE(model.userStatusMessage(), fakePredefinedUserStatus.message());
|
||||||
QCOMPARE(model.userStatusEmoji(), fakePredefinedUserStatus.icon());
|
QCOMPARE(model.userStatusEmoji(), fakePredefinedUserStatus.icon());
|
||||||
QCOMPARE(model.onlineStatus(), fakePredefinedUserStatus.state());
|
QCOMPARE(model.onlineStatus(), fakePredefinedUserStatus.state());
|
||||||
QCOMPARE(model.clearAt(), tr("1 hour"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 hour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage0_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage0_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 0;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::DontClear;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("Don't clear"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Don't clear"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage1_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage1_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 1;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::HalfHour;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("30 minutes"));
|
QCOMPARE(model.clearAtDisplayString(), tr("30 minutes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage2_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage2_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 2;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::OneHour;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("1 hour"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 hour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage3_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage3_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 3;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::FourHour;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("4 hours"));
|
QCOMPARE(model.clearAtDisplayString(), tr("4 hours"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage4_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage4_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 4;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::Today;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("Today"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Today"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSetClear_setClearAtStage5_emitClearAtChangedAndClearAtSet()
|
void testSetClear_setClearAtStage5_emitclearAtDisplayStringChangedAndClearAtSet()
|
||||||
{
|
{
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
QSignalSpy clearAtChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtChanged);
|
QSignalSpy clearAtDisplayStringChangedSpy(&model, &OCC::UserStatusSelectorModel::clearAtDisplayStringChanged);
|
||||||
|
|
||||||
const auto clearAtIndex = 5;
|
const auto clearAtToSet = OCC::UserStatusSelectorModel::ClearStageType::Week;
|
||||||
model.setClearAt(clearAtIndex);
|
model.setClearAt(clearAtToSet);
|
||||||
|
|
||||||
QCOMPARE(clearAtChangedSpy.count(), 1);
|
QCOMPARE(clearAtDisplayStringChangedSpy.count(), 1);
|
||||||
QCOMPARE(model.clearAt(), tr("This week"));
|
QCOMPARE(model.clearAtDisplayString(), tr("This week"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testClearAtStages()
|
void testClearAtStages()
|
||||||
|
@ -469,16 +469,16 @@ private slots:
|
||||||
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
auto fakeUserStatusJob = std::make_shared<FakeUserStatusConnector>();
|
||||||
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
OCC::UserStatusSelectorModel model(fakeUserStatusJob);
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("Don't clear"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Don't clear"));
|
||||||
const auto clearAtValues = model.clearAtValues();
|
const auto clearStageTypes = model.clearStageTypes();
|
||||||
QCOMPARE(clearAtValues.count(), 6);
|
QCOMPARE(clearStageTypes.count(), 6);
|
||||||
|
|
||||||
QCOMPARE(clearAtValues[0], tr("Don't clear"));
|
QCOMPARE(clearStageTypes[0].value<QVariantMap>()[QStringLiteral("display")], tr("Don't clear"));
|
||||||
QCOMPARE(clearAtValues[1], tr("30 minutes"));
|
QCOMPARE(clearStageTypes[1].value<QVariantMap>()[QStringLiteral("display")], tr("30 minutes"));
|
||||||
QCOMPARE(clearAtValues[2], tr("1 hour"));
|
QCOMPARE(clearStageTypes[2].value<QVariantMap>()[QStringLiteral("display")], tr("1 hour"));
|
||||||
QCOMPARE(clearAtValues[3], tr("4 hours"));
|
QCOMPARE(clearStageTypes[3].value<QVariantMap>()[QStringLiteral("display")], tr("4 hours"));
|
||||||
QCOMPARE(clearAtValues[4], tr("Today"));
|
QCOMPARE(clearStageTypes[4].value<QVariantMap>()[QStringLiteral("display")], tr("Today"));
|
||||||
QCOMPARE(clearAtValues[5], tr("This week"));
|
QCOMPARE(clearStageTypes[5].value<QVariantMap>()[QStringLiteral("display")], tr("This week"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void testClearAt_clearAtTimestamp()
|
void testClearAt_clearAtTimestamp()
|
||||||
|
@ -496,7 +496,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("Less than a minute"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Less than a minute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -511,7 +511,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("1 minute"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 minute"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -526,7 +526,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("30 minutes"));
|
QCOMPARE(model.clearAtDisplayString(), tr("30 minutes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -541,7 +541,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("1 hour"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 hour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -556,7 +556,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("4 hours"));
|
QCOMPARE(model.clearAtDisplayString(), tr("4 hours"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -571,7 +571,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("1 day"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 day"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -586,7 +586,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
OCC::UserStatusSelectorModel model(userStatus, std::move(fakeDateTimeProvider));
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("7 days"));
|
QCOMPARE(model.clearAtDisplayString(), tr("7 days"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus);
|
OCC::UserStatusSelectorModel model(userStatus);
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("Today"));
|
QCOMPARE(model.clearAtDisplayString(), tr("Today"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -613,7 +613,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus);
|
OCC::UserStatusSelectorModel model(userStatus);
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("This week"));
|
QCOMPARE(model.clearAtDisplayString(), tr("This week"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +628,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus);
|
OCC::UserStatusSelectorModel model(userStatus);
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("30 minutes"));
|
QCOMPARE(model.clearAtDisplayString(), tr("30 minutes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -640,7 +640,7 @@ private slots:
|
||||||
|
|
||||||
OCC::UserStatusSelectorModel model(userStatus);
|
OCC::UserStatusSelectorModel model(userStatus);
|
||||||
|
|
||||||
QCOMPARE(model.clearAt(), tr("1 hour"));
|
QCOMPARE(model.clearAtDisplayString(), tr("1 hour"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue