feat: open links in user request browser with modal
This commit is contained in:
parent
bc515d2627
commit
89da5dd923
|
@ -65,6 +65,11 @@ Rectangle {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openUrlInNewTab(url) {
|
||||||
|
browserWindow.addNewTab()
|
||||||
|
currentWebView.url = determineRealURL(url)
|
||||||
|
}
|
||||||
|
|
||||||
property Component accessDialogComponent: BrowserConnectionModal {
|
property Component accessDialogComponent: BrowserConnectionModal {
|
||||||
currentTab: tabs.getTab(tabs.currentIndex) && tabs.getTab(tabs.currentIndex).item
|
currentTab: tabs.getTab(tabs.currentIndex) && tabs.getTab(tabs.currentIndex).item
|
||||||
x: browserWindow.width - width - Style.current.halfPadding
|
x: browserWindow.width - width - Style.current.halfPadding
|
||||||
|
@ -114,8 +119,7 @@ Rectangle {
|
||||||
FavoriteMenu {
|
FavoriteMenu {
|
||||||
id: favoriteMenu
|
id: favoriteMenu
|
||||||
openInNewTab: function (url) {
|
openInNewTab: function (url) {
|
||||||
browserWindow.addNewTab()
|
browserWindow.openUrlInNewTab(url)
|
||||||
currentWebView.url = url
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ Item {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt.openUrlExternally(link)
|
appMain.openLink(link)
|
||||||
}
|
}
|
||||||
|
|
||||||
onLinkHovered: {
|
onLinkHovered: {
|
||||||
|
|
|
@ -170,7 +170,7 @@ Column {
|
||||||
anchors.right: linkImage.right
|
anchors.right: linkImage.right
|
||||||
anchors.bottom: linkSite.bottom
|
anchors.bottom: linkSite.bottom
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: Qt.openUrlExternally(linkData.address)
|
onClicked: appMain.openLink(linkData.address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
import "../../../../imports"
|
||||||
|
import "../../../../shared"
|
||||||
|
import "../../../../shared/status"
|
||||||
|
|
||||||
|
ModalPopup {
|
||||||
|
property string link
|
||||||
|
|
||||||
|
id: popup
|
||||||
|
|
||||||
|
title: qsTr("Choose browser")
|
||||||
|
width: 440
|
||||||
|
height: 425
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.fill: parent
|
||||||
|
spacing: 20
|
||||||
|
|
||||||
|
Image {
|
||||||
|
source: "../../../img/chooseBrowserImage.png"
|
||||||
|
width: 240
|
||||||
|
height: 148
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusButton {
|
||||||
|
text: qsTr("Open in Status")
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
onClicked: {
|
||||||
|
appSettings.showBrowserSelector = !rememberChoiceCheckBox.checked
|
||||||
|
changeAppSection(Constants.browser)
|
||||||
|
browserLayoutContainer.item.openUrlInNewTab(popup.link)
|
||||||
|
popup.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusButton {
|
||||||
|
text: qsTr("Open in my default browser")
|
||||||
|
type: "secondary"
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
onClicked: {
|
||||||
|
appSettings.showBrowserSelector = !rememberChoiceCheckBox.checked
|
||||||
|
Qt.openUrlExternally(popup.link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StatusCheckBox {
|
||||||
|
id: rememberChoiceCheckBox
|
||||||
|
text: qsTr("Remember my choice. To override it, go to settings.")
|
||||||
|
width: parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ Item {
|
||||||
anchors.top: element12.top
|
anchors.top: element12.top
|
||||||
anchors.topMargin: 58
|
anchors.topMargin: 58
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -80,7 +80,7 @@ Item {
|
||||||
anchors.top: element13.top
|
anchors.top: element13.top
|
||||||
anchors.topMargin: 58
|
anchors.topMargin: 58
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -96,7 +96,7 @@ Item {
|
||||||
anchors.leftMargin: Style.current.bigPadding
|
anchors.leftMargin: Style.current.bigPadding
|
||||||
anchors.top: element14.top
|
anchors.top: element14.top
|
||||||
anchors.topMargin: 58
|
anchors.topMargin: 58
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -106,12 +106,12 @@ Item {
|
||||||
}
|
}
|
||||||
StyledText {
|
StyledText {
|
||||||
id: faqLink
|
id: faqLink
|
||||||
text: "<a href='https://status.im/docs/FAQs.html'>Frequently asked questions</a>"
|
text: `<a href='https://status.im/docs/FAQs.html'>${qsTr("Frequently asked questions")}</a>`
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: Style.current.bigPadding
|
anchors.leftMargin: Style.current.bigPadding
|
||||||
anchors.top: privacyPolicyLink.top
|
anchors.top: privacyPolicyLink.top
|
||||||
anchors.topMargin: 58
|
anchors.topMargin: 58
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -131,7 +131,7 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: Qt.openUrlExternally("https://status.im/user_guides/pairing_devices.html")
|
onClicked: appMain.openLink("https://status.im/user_guides/pairing_devices.html")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ Item {
|
||||||
text: qsTr(`<a href="%1%2">Look up on Etherscan</a>`).arg(walletModel.etherscanLink.replace("/tx", "/address")).arg(profileModel.ens.getUsernameRegistrar())
|
text: qsTr(`<a href="%1%2">Look up on Etherscan</a>`).arg(walletModel.etherscanLink.replace("/tx", "/address")).arg(profileModel.ens.getUsernameRegistrar())
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
||||||
|
@ -159,7 +159,7 @@ Item {
|
||||||
text: qsTr(`<a href="%1%2">Look up on Etherscan</a>`).arg(walletModel.etherscanLink.replace("/tx", "/address")).arg(profileModel.ens.getENSRegistry())
|
text: qsTr(`<a href="%1%2">Look up on Etherscan</a>`).arg(walletModel.etherscanLink.replace("/tx", "/address")).arg(profileModel.ens.getENSRegistry())
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: appMain.openLink(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
||||||
|
|
|
@ -135,49 +135,40 @@ Item {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: faqLink
|
id: faqLink
|
||||||
//% "<a href='https://status.im/docs/FAQs.html'>Frequently asked questions</a>"
|
text: `<a href='https://status.im/docs/FAQs.html'>${qsTr("Frequently asked questions")}</a>`
|
||||||
text: qsTrId("-a-href--https---status-im-docs-faqs-html--frequently-asked-questions--a-")
|
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
onLinkActivated: appMain.openLink(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
||||||
mouse.accepted = false
|
|
||||||
Qt.openUrlExternally("https://status.im/faq/")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: issueLink
|
id: issueLink
|
||||||
//% "<a href='https://github.com/status-im/nim-status-client/issues/new'>Submit a bug</a>"
|
text: `<a href='https://github.com/status-im/nim-status-client/issues/new'>${qsTr("Submit a bug")}</a>`
|
||||||
text: qsTrId("-a-href--https---github-com-status-im-nim-status-client-issues-new--submit-a-bug--a-")
|
|
||||||
anchors.topMargin: Style.current.bigPadding
|
anchors.topMargin: Style.current.bigPadding
|
||||||
anchors.top: faqLink.bottom
|
anchors.top: faqLink.bottom
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
onLinkActivated: appMain.openLink(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
||||||
mouse.accepted = false
|
|
||||||
Qt.openUrlExternally("https://github.com/status-im/nim-status-client/issues/new")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
//% "<a href='https://discuss.status.im/c/features/51'>Request a feature</a>"
|
text: `<a href='https://discuss.status.im/c/features/51'>${qsTr("Request a feature")}</a>`
|
||||||
text: qsTrId("-a-href--https---discuss-status-im-c-features-51--request-a-feature--a-")
|
|
||||||
anchors.topMargin: Style.current.bigPadding
|
anchors.topMargin: Style.current.bigPadding
|
||||||
anchors.top: issueLink.bottom
|
anchors.top: issueLink.bottom
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
|
onLinkActivated: appMain.openLink(link)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
|
||||||
mouse.accepted = false
|
|
||||||
Qt.openUrlExternally("https://discuss.status.im/c/features/51")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ ModalPopup {
|
||||||
label: popup.buttonText
|
label: popup.buttonText
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally(popup.buttonLink)
|
appMain.openLink(popup.buttonLink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import "../shared/status"
|
||||||
import "./AppLayouts"
|
import "./AppLayouts"
|
||||||
import "./AppLayouts/Timeline"
|
import "./AppLayouts/Timeline"
|
||||||
import "./AppLayouts/Wallet"
|
import "./AppLayouts/Wallet"
|
||||||
|
import "./AppLayouts/Chat/components"
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: appMain
|
id: appMain
|
||||||
|
@ -27,6 +28,33 @@ RowLayout {
|
||||||
return profileModel.contacts.list.rowData(index, useLargeImage ? "largeImage" : "thumbnailImage")
|
return profileModel.contacts.list.rowData(index, useLargeImage ? "largeImage" : "thumbnailImage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openPopup(popupComponent, params = {}) {
|
||||||
|
const popup = popupComponent.createObject(appMain, params);
|
||||||
|
popup.open()
|
||||||
|
return popup
|
||||||
|
}
|
||||||
|
|
||||||
|
function openLink(link) {
|
||||||
|
if (appSettings.showBrowserSelector) {
|
||||||
|
appMain.openPopup(chooseBrowserPopupComponent, {link: link})
|
||||||
|
} else {
|
||||||
|
if (appSettings.openLinksInStatus) {
|
||||||
|
appMain.changeAppSection(Constants.browser)
|
||||||
|
browserLayoutContainer.item.openUrlInNewTab(link)
|
||||||
|
} else {
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: chooseBrowserPopupComponent
|
||||||
|
ChooseBrowserPopup {
|
||||||
|
onClosed: {
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ToastMessage {
|
ToastMessage {
|
||||||
id: toastMessage
|
id: toastMessage
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -114,6 +114,8 @@ ApplicationWindow {
|
||||||
property int fontSize: Constants.fontSizeM
|
property int fontSize: Constants.fontSizeM
|
||||||
|
|
||||||
// Browser settings
|
// Browser settings
|
||||||
|
property bool showBrowserSelector: true
|
||||||
|
property bool openLinksInStatus: true
|
||||||
property bool showFavoritesBar: false
|
property bool showFavoritesBar: false
|
||||||
property bool autoLoadImages: true
|
property bool autoLoadImages: true
|
||||||
property bool javaScriptEnabled: true
|
property bool javaScriptEnabled: true
|
||||||
|
@ -153,6 +155,8 @@ ApplicationWindow {
|
||||||
property bool hideSignPhraseModal: defaultAppSettings.hideSignPhraseModal
|
property bool hideSignPhraseModal: defaultAppSettings.hideSignPhraseModal
|
||||||
|
|
||||||
// Browser settings
|
// Browser settings
|
||||||
|
property bool showBrowserSelector: defaultAppSettings.showBrowserSelector
|
||||||
|
property bool openLinksInStatus: defaultAppSettings.openLinksInStatus
|
||||||
property bool showFavoritesBar: defaultAppSettings.showFavoritesBar
|
property bool showFavoritesBar: defaultAppSettings.showFavoritesBar
|
||||||
property bool autoLoadImages: defaultAppSettings.autoLoadImages
|
property bool autoLoadImages: defaultAppSettings.autoLoadImages
|
||||||
property bool javaScriptEnabled: defaultAppSettings.javaScriptEnabled
|
property bool javaScriptEnabled: defaultAppSettings.javaScriptEnabled
|
||||||
|
|
|
@ -168,6 +168,7 @@ DISTFILES += \
|
||||||
app/AppLayouts/Chat/ChatColumn/MessageComponents/qmldir \
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/qmldir \
|
||||||
app/AppLayouts/Chat/ContactsColumn/AddChat.qml \
|
app/AppLayouts/Chat/ContactsColumn/AddChat.qml \
|
||||||
app/AppLayouts/Chat/ContactsColumn/ClosedEmptyView.qml \
|
app/AppLayouts/Chat/ContactsColumn/ClosedEmptyView.qml \
|
||||||
|
app/AppLayouts/Chat/components/ChooseBrowserPopup.qml \
|
||||||
app/AppLayouts/Chat/components/EmojiCategoryButton.qml \
|
app/AppLayouts/Chat/components/EmojiCategoryButton.qml \
|
||||||
app/AppLayouts/Chat/components/EmojiPopup.qml \
|
app/AppLayouts/Chat/components/EmojiPopup.qml \
|
||||||
app/AppLayouts/Chat/components/EmojiReaction.qml \
|
app/AppLayouts/Chat/components/EmojiReaction.qml \
|
||||||
|
|
|
@ -99,7 +99,7 @@ Popup {
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
anchors.leftMargin: 12
|
anchors.leftMargin: 12
|
||||||
onLinkActivated: {
|
onLinkActivated: {
|
||||||
Qt.openUrlExternally(root.link)
|
appMain.openLink(root.link)
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ CheckBox {
|
||||||
text: control.text
|
text: control.text
|
||||||
opacity: enabled ? 1.0 : 0.3
|
opacity: enabled ? 1.0 : 0.3
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
width: parent.width
|
||||||
leftPadding: !!control.text ? control.indicator.width + control.spacing : control.indicator.width
|
leftPadding: !!control.text ? control.indicator.width + control.spacing : control.indicator.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue