Open url using QDesktopServices from Qml

This fixes some weirdness on some platforms, where Qt.openUrlExternally
does weird stuff.
This commit is contained in:
Nicolas Werner 2020-07-09 00:45:37 +02:00
parent d72eb5eb2d
commit 8d3ab300b6
3 changed files with 10 additions and 1 deletions

View file

@ -16,7 +16,7 @@ TextEdit {
timelineManager.setHistoryView(match[1]) timelineManager.setHistoryView(match[1])
chat.positionViewAtIndex(chat.model.idToIndex(match[2]), ListView.Contain) chat.positionViewAtIndex(chat.model.idToIndex(match[2]), ListView.Contain)
} }
else Qt.openUrlExternally(link) else timelineManager.openLink(link)
} }
MouseArea MouseArea
{ {

View file

@ -1,5 +1,6 @@
#include "TimelineViewManager.h" #include "TimelineViewManager.h"
#include <QDesktopServices>
#include <QMetaType> #include <QMetaType>
#include <QPalette> #include <QPalette>
#include <QQmlContext> #include <QQmlContext>
@ -219,6 +220,12 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) const
}); });
} }
void
TimelineViewManager::openLink(QString link) const
{
QDesktopServices::openUrl(link);
}
void void
TimelineViewManager::updateReadReceipts(const QString &room_id, TimelineViewManager::updateReadReceipts(const QString &room_id,
const std::vector<QString> &event_ids) const std::vector<QString> &event_ids)

View file

@ -47,6 +47,8 @@ public:
Q_INVOKABLE QString userPresence(QString id) const; Q_INVOKABLE QString userPresence(QString id) const;
Q_INVOKABLE QString userStatus(QString id) const; Q_INVOKABLE QString userStatus(QString id) const;
Q_INVOKABLE void openLink(QString link) const;
signals: signals:
void clearRoomMessageCount(QString roomid); void clearRoomMessageCount(QString roomid);
void updateRoomsLastMessage(QString roomid, const DescInfo &info); void updateRoomsLastMessage(QString roomid, const DescInfo &info);