Skip to content

Instantly share code, notes, and snippets.

@txhammer68
Created August 29, 2024 19:56
Show Gist options
  • Save txhammer68/068935a3578a30b5081c973d69440f06 to your computer and use it in GitHub Desktop.
Save txhammer68/068935a3578a30b5081c973d69440f06 to your computer and use it in GitHub Desktop.
qml webengine
import QtQuick 2.9
import QtQuick.Controls 2.5
import org.kde.plasma.core 2.1
import QtWebEngine 1.9
// g-mail suite workspace app using qt webview
// load each app in a seperate webview for fast switching views
// TO-DO
// shortcut keys to switch views
// integrate mailto handler for system wide email client
// dark mode switch gcal
// settings for universal mail app, urls for other mailboxes,calendars, etc...i.e not google
ApplicationWindow {
id:root
visible:true
visibility:"Maximized"
title:"Google Workspace"
color:Theme.viewBackgroundColor
property string selectedView:"gmail"
// [gmail,gcal,contacts,chat,voip,news,maps,drive]
Column {
id:navbar
spacing:50
width:55
leftPadding:15
topPadding:15
Image {
id:inbox
width: 36
height: 36
source: "./icons/g-mail.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewInbox.opacity || mouseArea.containsMouse ? 1:.5
Text{
anchors.top:inbox.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"Inbox"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="gmail"
}
}
Image {
id:calender
width: 36
height: 36
source: "./icons/gcal.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewCal.opacity || mouseAreaCal.containsMouse ? 1:.5
Text{
anchors.top:calender.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"Calendar"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaCal
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="gcal"
}
}
Image {
id:contacts
width: 36
height: 36
source: "./icons/contacts.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewCont.opacity || mouseAreaContacts.containsMouse ? 1:.5
Text{
anchors.top:contacts.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"Contacts"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaContacts
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="contacts"
}
}
Image {
id:chat
width: 36
height: 36
source: "./icons/chat.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewChat.opacity || mouseAreaChat.containsMouse ? 1:.5
Text{
anchors.top:chat.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"Chat"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaChat
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="chat"
}
}
Image {
id:voice
width: 36
height: 36
source: "./icons/voice.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewVoice.opacity || mouseAreaVoice.containsMouse ? 1:.5
Text{
anchors.top:parent.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"VOIP"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaVoice
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="voip"
}
}
Image {
id:maps
width: 36
height: 36
source: "./icons/maps.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewMaps.opacity || mouseAreaMaps.containsMouse ? 1:.5
Text{
anchors.top:maps.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"Maps"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaMaps
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="maps"
}
}
Image {
id:news
width: 36
height: 36
source: "./icons/news.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewNews.opacity || mouseAreaNews.containsMouse ? 1:.5
Text{
anchors.top:parent.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"News"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaNews
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="news"
}
}
Image {
id:drive
width: 36
height: 36
source: "./icons/drive.png"
antialiasing:true
smooth:true
enabled:true
opacity:viewDrive.opacity || mouseAreaDrive.containsMouse ? 1:.5
Text{
anchors.top:parent.bottom
anchors.horizontalCenter:parent.horizontalCenter
text:"G-Drive"
color:Theme.viewTextColor
font.pointSize:10
antialiasing:true
}
MouseArea {
id: mouseAreaDrive
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked:selectedView="drive"
}
}
}
Item {
id:viewGmail
anchors.left:navbar.right
anchors.top:navbar.top
anchors.leftMargin:10
height:root.height
width:root.width-navbar.width
WebEngineView {
id:viewInbox
anchors.fill:parent
focus:opacity
visible:selectedView=="gmail"
opacity: visible
smooth:true
antialiasing:true
//zoomFactor:1.25
backgroundColor :Theme.viewBackgroundColor
//url:""
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true); // allows access to system features
}
Component.onCompleted: {
url="https://mail.google.com/mail/u/0/#inbox"
//QtWebEngine.initialize();
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewCal
anchors.fill:parent
focus:opacity
visible:selectedView=="gcal"
opacity:visible
smooth:true
antialiasing:true
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true); // allows access to system features
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewCont
anchors.fill:parent
visible:selectedView=="contacts"
opacity:visible
focus:opacity
zoomFactor:1.25
smooth:true
antialiasing:true
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewChat
anchors.fill:parent
focus:opacity
visible:selectedView=="chat"
opacity:visible
smooth:true
antialiasing:true
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewMaps
anchors.fill:parent
focus:opacity
visible:selectedView=="maps"
opacity:visible
smooth:true
antialiasing:true
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewVoice
anchors.fill:parent
focus:opacity
visible:selectedView=="voip"
opacity:visible
smooth:true
antialiasing:true
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewNews
anchors.fill:parent
visible:selectedView=="news"
opacity:visible
focus:opacity
smooth:true
antialiasing:true
zoomFactor:1.55
backgroundColor :Theme.viewBackgroundColor
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
//profile: WebEngineProfile{
// httpUserAgent: "Mozilla/5.0 (Wayland; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
// }
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
WebEngineView {
id:viewDrive
anchors.fill:parent
focus:opacity
visible:selectedView=="drive"
opacity: visible
smooth:true
antialiasing:true
//zoomFactor:1.55
backgroundColor :Theme.viewBackgroundColor
//url:""
onNewViewRequested: {
if (request.userInitiated) {
request.action = WebEngineView.IgnoreRequest;
Qt.openUrlExternally(request.requestedUrl);
}
}
Behavior on opacity {
OpacityAnimator {
duration: 400//units.mediumDuration
easing.type: Easing.Linear
}}
}
}
Timer {
id:init // wait for inbox to load
running:true
repeat:false
interval:3000
onTriggered:{
selectedView=="gcal"
viewCal.url="https://calendar.google.com/calendar/u/0/r";
selectedView="contacts";
viewCont.url="https://contacts.google.com/?hl=en#contacts";
selectedView="chat";
viewChat.url="https://mail.google.com/chat/u/0/#chat/home";
selectedView="voip";
viewVoice.url="https://voice.google.com/u/0/calls";
selectedView="maps";
viewMaps.url="https://www.google.com/maps/";
selectedView="news";
viewNews.url="https://news.google.com/topstories/";
selectedView="drive";
viewDrive.url="https://drive.google.com/drive/";
selectedView="gmail";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment