mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Move the logic for handling the featured app qml to cpp.
Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
parent
b7bf6083d9
commit
fcf07b60c4
3 changed files with 46 additions and 34 deletions
|
@ -622,15 +622,12 @@ ApplicationWindow {
|
|||
|
||||
HeaderButton {
|
||||
id: trayWindowFeaturedAppButton
|
||||
visible: UserModel.currentUser.isNcAssistantEnabled || UserModel.currentUser.serverHasTalk
|
||||
icon.source: UserModel.currentUser.isNcAssistantEnabled
|
||||
? "image:///client/theme/white/nc-assistant-app.svg" + "/" + Style.currentUserHeaderTextColor
|
||||
: "image:///client/theme/white/talk-app.svg" + "/" + Style.currentUserHeaderTextColor
|
||||
icon.color: Style.currentUserHeaderTextColor
|
||||
onClicked: UserModel.currentUser.isNcAssistantEnabled ? UserModel.openCurrentAccountNcAssistant() : UserModel.openCurrentAccountTalk()
|
||||
visible: UserModel.currentUser.isFeaturedAppEnabled
|
||||
icon.source: UserModel.currentUser.featuredAppIcon + "/" + Style.currentUserHeaderTextColor
|
||||
onClicked: UserModel.openCurrentAccountFeaturedApp()
|
||||
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: UserModel.currentUser.isNcAssistantEnabled ? qsTr("Open Nextcloud Assistant in browser") : qsTr("Open Nextcloud Talk in browser")
|
||||
Accessible.name: UserModel.currentUser.featuredAppAccessibleName
|
||||
Accessible.onPressAction: trayWindowFeaturedAppButton.clicked()
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
|
|
@ -470,8 +470,7 @@ void User::slotRefreshNotifications()
|
|||
|
||||
void User::slotRebuildNavigationAppList()
|
||||
{
|
||||
emit serverHasTalkChanged();
|
||||
emit ncAssistantAvailabityChanged();
|
||||
emit featuredAppChanged();
|
||||
// Rebuild App list
|
||||
UserAppsModel::instance()->buildAppList();
|
||||
}
|
||||
|
@ -1037,6 +1036,22 @@ bool User::serverHasTalk() const
|
|||
return talkApp() != nullptr;
|
||||
}
|
||||
|
||||
bool User::isFeaturedAppEnabled() const
|
||||
{
|
||||
return isNcAssistantEnabled() || serverHasTalk();
|
||||
}
|
||||
|
||||
QString User::featuredAppIcon() const
|
||||
{
|
||||
return isNcAssistantEnabled() ? "image://svgimage-custom-color/nc-assistant-app.svg"
|
||||
: "image://svgimage-custom-color/talk-app.svg";
|
||||
}
|
||||
|
||||
QString User::featuredAppAccessibleName() const
|
||||
{
|
||||
return isNcAssistantEnabled() ? tr("Open Nextcloud Assistant in browser") : tr("Open Nextcloud Talk in browser");
|
||||
}
|
||||
|
||||
AccountApp *User::talkApp() const
|
||||
{
|
||||
return _account->findApp(QStringLiteral("spreed"));
|
||||
|
@ -1335,19 +1350,6 @@ void UserModel::openCurrentAccountLocalFolder()
|
|||
_users[_currentUserId]->openLocalFolder();
|
||||
}
|
||||
|
||||
void UserModel::openCurrentAccountTalk()
|
||||
{
|
||||
if (!currentUser())
|
||||
return;
|
||||
|
||||
const auto talkApp = currentUser()->talkApp();
|
||||
if (talkApp) {
|
||||
Utility::openBrowser(talkApp->url());
|
||||
} else {
|
||||
qCWarning(lcActivity) << "The Talk app is not enabled on" << currentUser()->server();
|
||||
}
|
||||
}
|
||||
|
||||
void UserModel::openCurrentAccountServer()
|
||||
{
|
||||
if (_currentUserId < 0 || _currentUserId >= _users.size())
|
||||
|
@ -1370,16 +1372,26 @@ void UserModel::openCurrentAccountFolderFromTrayInfo(const QString &fullRemotePa
|
|||
_users[_currentUserId]->openFolderLocallyOrInBrowser(fullRemotePath);
|
||||
}
|
||||
|
||||
void UserModel::openCurrentAccountNcAssistant()
|
||||
void UserModel::openCurrentAccountFeaturedApp()
|
||||
{
|
||||
if (!currentUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentUser()->isFeaturedAppEnabled()) {
|
||||
qCWarning(lcActivity) << "There is no feature app enabled on" << currentUser()->server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentUser()->isNcAssistantEnabled()) {
|
||||
QDesktopServices::openUrl(QUrl(_users[_currentUserId]->server(false).append("/apps/assistant/")));
|
||||
} else {
|
||||
qCWarning(lcActivity) << "The Nextcloud Assistant app is not enabled on" << currentUser()->server();
|
||||
auto serverUrl = currentUser()->server(false);
|
||||
const auto assistanceUrl = serverUrl.append("/apps/assistant/");
|
||||
QDesktopServices::openUrl(QUrl::fromUserInput(assistanceUrl));
|
||||
return;
|
||||
}
|
||||
|
||||
if (const auto talkApp = currentUser()->talkApp()) {
|
||||
Utility::openBrowser(talkApp->url());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1662,7 @@ void UserAppsModel::buildAppList()
|
|||
|
||||
if (UserModel::instance()->appList().count() > 0) {
|
||||
const auto talkApp = UserModel::instance()->currentUser()->talkApp();
|
||||
for (auto &app : UserModel::instance()->appList()) {
|
||||
for (const auto &app : UserModel::instance()->appList()) {
|
||||
// Filter out Talk because we have a dedicated button for it
|
||||
if (talkApp && app->id() == talkApp->id() && !UserModel::instance()->currentUser()->isNcAssistantEnabled()) {
|
||||
continue;
|
||||
|
|
|
@ -56,8 +56,9 @@ class User : public QObject
|
|||
Q_PROPERTY(QString statusMessage READ statusMessage NOTIFY statusChanged)
|
||||
Q_PROPERTY(bool desktopNotificationsAllowed READ isDesktopNotificationsAllowed NOTIFY desktopNotificationsAllowedChanged)
|
||||
Q_PROPERTY(bool hasLocalFolder READ hasLocalFolder NOTIFY hasLocalFolderChanged)
|
||||
Q_PROPERTY(bool serverHasTalk READ serverHasTalk NOTIFY serverHasTalkChanged)
|
||||
Q_PROPERTY(bool isNcAssistantEnabled READ isNcAssistantEnabled NOTIFY ncAssistantAvailabityChanged)
|
||||
Q_PROPERTY(bool isFeaturedAppEnabled READ isFeaturedAppEnabled NOTIFY featuredAppChanged)
|
||||
Q_PROPERTY(QString featuredAppIcon READ featuredAppIcon NOTIFY featuredAppChanged)
|
||||
Q_PROPERTY(QString featuredAppAccessibleName READ featuredAppAccessibleName NOTIFY featuredAppChanged)
|
||||
Q_PROPERTY(QString avatar READ avatarUrl NOTIFY avatarChanged)
|
||||
Q_PROPERTY(bool isConnected READ isConnected NOTIFY accountStateChanged)
|
||||
Q_PROPERTY(UnifiedSearchResultsListModel* unifiedSearchResultsListModel READ getUnifiedSearchResultsListModel CONSTANT)
|
||||
|
@ -80,7 +81,9 @@ public:
|
|||
[[nodiscard]] QString name() const;
|
||||
[[nodiscard]] QString server(bool shortened = true) const;
|
||||
[[nodiscard]] bool hasLocalFolder() const;
|
||||
[[nodiscard]] bool serverHasTalk() const;
|
||||
[[nodiscard]] bool isFeaturedAppEnabled() const;
|
||||
[[nodiscard]] QString featuredAppIcon() const;
|
||||
[[nodiscard]] QString featuredAppAccessibleName() const;
|
||||
[[nodiscard]] bool serverHasUserStatus() const;
|
||||
[[nodiscard]] AccountApp *talkApp() const;
|
||||
[[nodiscard]] bool hasActivities() const;
|
||||
|
@ -105,7 +108,7 @@ public:
|
|||
signals:
|
||||
void nameChanged();
|
||||
void hasLocalFolderChanged();
|
||||
void serverHasTalkChanged();
|
||||
void featuredAppChanged();
|
||||
void avatarChanged();
|
||||
void accountStateChanged();
|
||||
void statusChanged();
|
||||
|
@ -115,7 +118,6 @@ signals:
|
|||
void accentColorChanged();
|
||||
void sendReplyMessage(const int activityIndex, const QString &conversationToken, const QString &message, const QString &replyTo);
|
||||
void groupFoldersChanged();
|
||||
void ncAssistantAvailabityChanged();
|
||||
|
||||
public slots:
|
||||
void slotItemCompleted(const QString &folder, const OCC::SyncFileItemPtr &item);
|
||||
|
@ -171,6 +173,8 @@ private:
|
|||
|
||||
void checkAndRemoveSeenActivities(const ActivityList &list, const int numTalkNotificationsReceived);
|
||||
|
||||
[[nodiscard]] bool serverHasTalk() const;
|
||||
|
||||
AccountStatePtr _account;
|
||||
bool _isCurrentUser;
|
||||
ActivityListModel *_activityModel;
|
||||
|
@ -251,10 +255,9 @@ signals:
|
|||
public slots:
|
||||
void fetchCurrentActivityModel();
|
||||
void openCurrentAccountLocalFolder();
|
||||
void openCurrentAccountTalk();
|
||||
void openCurrentAccountServer();
|
||||
void openCurrentAccountFolderFromTrayInfo(const QString &fullRemotePath);
|
||||
void openCurrentAccountNcAssistant();
|
||||
void openCurrentAccountFeaturedApp();
|
||||
void setCurrentUserId(const int id);
|
||||
void login(const int id);
|
||||
void logout(const int id);
|
||||
|
|
Loading…
Reference in a new issue