Fix server adress retreival in tray window buttons

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
Dominique Fuchs 2020-01-03 14:00:07 +01:00
Родитель faf46fcf60
Коммит f01c47e0ec
3 изменённых файлов: 31 добавлений и 8 удалений

Просмотреть файл

@ -57,14 +57,16 @@ QString User::name() const
return name;
}
QString User::server() const
QString User::server(bool shortened) const
{
QString serverUrl = _account->account()->url().toString();
serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
if (serverUrl.size() > 21) {
serverUrl.truncate(19);
serverUrl.append("...");
if (shortened) {
serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
if (serverUrl.size() > 21) {
serverUrl.truncate(19);
serverUrl.append("...");
}
}
return serverUrl;
}
@ -181,6 +183,24 @@ Q_INVOKABLE void UserModel::openCurrentAccountLocalFolder()
_users[_currentUserId].openLocalFolder();
}
Q_INVOKABLE void UserModel::openCurrentAccountTalk()
{
QString url = _users[_currentUserId].server(false) + "/apps/spreed";
if (!(url.contains("http://") || url.contains("https://"))) {
url = "https://" + _users[_currentUserId].server(false) + "/apps/spreed";
}
QDesktopServices::openUrl(QUrl(url));
}
Q_INVOKABLE void UserModel::openCurrentAccountServer()
{
QString url = _users[_currentUserId].server(false);
if (! (url.contains("http://") || url.contains("https://")) ) {
url = "https://" + _users[_currentUserId].server(false);
}
QDesktopServices::openUrl(QUrl(url));
}
Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
{
_users[_currentUserId].setCurrentUser(false);

Просмотреть файл

@ -26,7 +26,7 @@ public:
ActivityListModel *getActivityModel();
void openLocalFolder();
QString name() const;
QString server() const;
QString server(bool shortened = true) const;
bool serverHasTalk() const;
QImage avatar() const;
QString id() const;
@ -54,6 +54,8 @@ public:
QImage avatarById(const int &id);
Q_INVOKABLE void openCurrentAccountLocalFolder();
Q_INVOKABLE void openCurrentAccountTalk();
Q_INVOKABLE void openCurrentAccountServer();
Q_INVOKABLE QImage currentUserAvatar();
Q_INVOKABLE int numUsers();
Q_INVOKABLE bool isCurrentUserConnected();

Просмотреть файл

@ -285,6 +285,7 @@ Window {
hoverEnabled: true
onClicked:
{
userModelBackend.openCurrentAccountTalk();
}
}
@ -302,7 +303,6 @@ Window {
Layout.preferredWidth: (trayWindowHeaderBackground.height)
Layout.preferredHeight: (trayWindowHeaderBackground.height)
flat: true
visible: false
icon.source: "qrc:///client/theme/white/more-apps.svg"
icon.color: "transparent"
@ -313,6 +313,7 @@ Window {
hoverEnabled: true
onClicked:
{
userModelBackend.openCurrentAccountServer();
}
}