Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions whatsweb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ install(FILES whatsweb-push-helper.json DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES whatsweb-push.apparmor DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES push-apparmor.json DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES content-hub.json DESTINATION ${CMAKE_INSTALL_PREFIX})
install(PROGRAMS launcher.sh DESTINATION ${CMAKE_INSTALL_PREFIX})

Binary file modified whatsweb/app/Backgrounds/screensaver-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified whatsweb/app/Backgrounds/screensaver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whatsweb/app/Icons/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whatsweb/app/Icons/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions whatsweb/app/ImportPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,26 @@ Page {
handler: picker.handler //ContentHandler.Source

onPeerSelected: {
peer.selectionType = ContentTransfer.Single
peer.selectionType = ContentTransfer.Multiple
picker.activeTransfer = peer.request()
picker.activeTransfer.stateChanged.connect(function() {
if (picker.activeTransfer.state === ContentTransfer.InProgress) {
console.log("In progress");
picker.activeTransfer.items = picker.activeTransfer.items[0].url = url;
picker.activeTransfer.state = ContentTransfer.Charged;
}
// if (picker.activeTransfer.state === ContentTransfer.InProgress) {
// console.log("In progress");
// picker.activeTransfer.items = picker.activeTransfer.items[0].url = url;
// picker.activeTransfer.state = ContentTransfer.Charged;
// }
if (picker.activeTransfer.state === ContentTransfer.Charged) {
console.log("Charged");
picker.imported(picker.activeTransfer.items[0].url)
console.log(picker.activeTransfer.items[0].url)
picker.activeTransfer = null
console.log("Charged");
var res="";
for (var i = 0; i < picker.activeTransfer.items.length; i++) {
if (res == "")
res=picker.activeTransfer.items[i].url
else
res=res+"\n"+picker.activeTransfer.items[i].url

}
picker.imported(res)
picker.activeTransfer = null
}
})
}
Expand Down
106 changes: 76 additions & 30 deletions whatsweb/app/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,42 @@ import Qt.labs.settings 1.0
import QtSystemInfo 5.5
import Ubuntu.Components.ListItems 1.3 as ListItemm
import Ubuntu.Content 1.3
import Pparent.DownloadHelper 1.0
import Pparent.DownloadHelper 1.0


MainView {
id: mainView

property var appID: "alefnode.whatsweb";
property var hook: "whatsweb";
property var localStorage: "/home/phablet/.cache/alefnode.whatsweb/alefnode.whatsweb/QtWebEngine";
property var localStorage: "/home/phablet/.cache/alefnode.whatsweb/alefnode.whatsweb/QtWebEngine";


property int lastUnreadCount: -1;
property var lastNotifyTimestamp: 0;


Settings {
id: config
category: "AppSettings"

property int webviewWidthPortait: 410
property int webviewWidthLandscape: 900
property int textFontSize: 110
property int spanFontSize: 104

property bool enableDesktopNotifications: true
property bool enableTitleChangeNotifications: true
property bool enableSoundNotifications: true
property bool enableNotificationCounter: true

property bool enableScreensaver: true
property bool disableBackgroundAudio: true

property bool enableQuickCopy: true
property bool enableGpu: true
}

DownloadHelper {
id: downloadHelper
blob_path: localStorage+"/IndexedDB/https_web.whatsapp.com_0.indexeddb.blob/"
Expand All @@ -36,48 +57,46 @@ MainView {


objectName: "mainView"
//theme.name: "Ubuntu.Components.Themes.SuruDark"
applicationName: appID
backgroundColor : "transparent"


property list<ContentItem> importItems



ScreenSaver {
id: screenSaver
screenSaverEnabled: !(Qt.application.active)
screenSaverEnabled: !(Qt.application.active)
}

ScreenSaverView {
id: screenSaverView
visible: (! Qt.application.active) && config.enableScreensaver
}

PageStack {
id: mainPageStack
visible: Qt.application.active || (! config.enableScreensaver)
anchors.fill: parent
Component.onCompleted: mainPageStack.push(pageMain)


Page {
id: pageMain
anchors.fill: parent


ScreenSaverView {
id: screenSaverView
}
visible: Qt.application.active || (! config.enableScreensaver)

//Webview-----------------------------------------------------------------------------------------------------
WebEngineView {
id: webview
audioMuted: !Qt.application.active
visible: Qt.application.active
audioMuted: config.disableBackgroundAudio && (!Qt.application.active)
visible: Qt.application.active || (! config.enableScreensaver)
property int keyboardSize: UbuntuApplication.inputMethod.visible ? 10+UbuntuApplication.inputMethod.keyboardRectangle.height/(units.gridUnit / 8) : 0
anchors{ fill: parent }
focus: true
property var currentWebview: webview
settings.pluginsEnabled: true
zoomFactor: mainView.width<mainView.height ? Math.round(100 * mainView.width / 410 ) / 100 : Math.round(100 * mainView.width / 900 ) / 100
zoomFactor: mainView.width<mainView.height ? Math.round(100 * mainView.width / config.webviewWidthPortait ) / 100 : Math.round(100 * mainView.width / config.webviewWidthLandscape ) / 100

onKeyboardSizeChanged: {
// Échapper correctement les quotes si nécessaire
//Don't hide the text edit with keyboard
var realKeyboardSize=keyboardSize/zoomFactor
const jsCode = `document.querySelector('footer').style.paddingBottom = "${realKeyboardSize}px"`;
webview.runJavaScript(jsCode);
Expand All @@ -92,11 +111,13 @@ MainView {
// Notification based on web desktop notifications (Higher priority)
//----------------------------------------------------------------------
onPresentNotification: (notification) => {
if ( config.enableDesktopNotifications )
notifier.notifyMain(notification.title, notification.message);
}

onDownloadRequested: {
//Not working for now in Qt5
//Using Download Helper instead
}

}//End WebEngineProfile
Expand All @@ -109,6 +130,16 @@ MainView {
}
url: "https://web.whatsapp.com"
userScripts: [
WebEngineScript {
name: "AppConfig"
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
sourceCode: "window.appConfig = " + JSON.stringify({
textFontSize: config.textFontSize,
spanFontSize: config.spanFontSize,
enableQuickCopy: config.enableQuickCopy
}) + ";"
},
WebEngineScript {
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
Expand All @@ -119,9 +150,13 @@ MainView {
onFileDialogRequested: function(request) {
request.accepted = true;
var importPage = mainPageStack.push(Qt.resolvedUrl("ImportPage.qml"),{"contentType": ContentType.All, "handler": ContentHandler.Source})
importPage.imported.connect(function(fileUrl) {
console.log(String(fileUrl).replace("file://", ""))
request.dialogAccept(String(fileUrl).replace("file://", ""));
importPage.imported.connect(function(fileUrls) {
var files = []
var urls = fileUrls.split("\n")
for (var i = 0; i < urls.length; i++) {
files.push(urls[i].trim().replace("file://", ""));
}
request.dialogAccept(files);
mainPageStack.pop(importPage)
})
importPage.cancel.connect(function() {
Expand Down Expand Up @@ -151,10 +186,12 @@ MainView {
}
if ( unread>lastUnreadCount && unread>0 )
{
notifier.triggerDelayedNotification2(unread+" whatsapp message unread");
if ( config.enableTitleChangeNotifications )
notifier.triggerDelayedNotification2(unread+" whatsapp message unread");
}
lastUnreadCount=unread
if (unread > 0)

if ( unread > 0 && config.enableNotificationCounter )
notifier.updateCount(unread)
else
notifier.updateCount(0)
Expand All @@ -167,16 +204,18 @@ MainView {
// Notification based on audio sound file played (Low priority)
//---------------------------------------------------------------------------
if (message.startsWith("[DbgAud] https://static.whatsapp.net/")) {
//Send notification in 50ms through timer1
notifier.triggerDelayedNotification1("New Whatsapp audio notification");
//Send notification
if ( config.enableSoundNotifications )
notifier.triggerDelayedNotification1("New Whatsapp audio notification");
}
if (message.startsWith("[ClipBoardCopy]")) {
//Send notification in 50ms through timer1
if (config.enableQuickCopy)
{
textEdit.text = message.replace(/^\[ClipBoardCopy\]\s*/, "")
//textEdit.text = message
textEdit.selectAll()
textEdit.copy()
toast.show("Message copied!")
}
}
if (message.startsWith("[ShowDebug]")) {
toast.show(message.replace(/^\[ShowDebug\]\s*/, ""))
Expand All @@ -187,17 +226,19 @@ MainView {
let output = downloadHelper.getLastDownloaded()
var exportPage = mainPageStack.push(Qt.resolvedUrl("ExportPage.qml"),{"url": Qt.resolvedUrl("file://"+output),"contentType": ContentType.All})
}

if (message.startsWith("[HideAppControls]"))
{
notificationsHowto.visible= false;
settingsButton.visible= false;
}
if (message.startsWith("[ThemeBackgroundColorDebug]")) {


if ( message.replace(/^\[ThemeBackgroundColorDebug\]\s*/, "") == "#FFFFFF" )
{
screenSaverView.backgroundSource="Backgrounds/screensaver.png";
}
else
screenSaverView.backgroundSource="Backgrounds/screensaver-black.png" ;
notificationsHowto.visible= false;
}
}

Expand All @@ -220,7 +261,12 @@ MainView {
id: notificationsHowto
pageStack: mainPageStack
}



SettingsButton{
id: settingsButton
pageStack: mainPageStack
}

}

Expand Down
6 changes: 3 additions & 3 deletions whatsweb/app/NotificationsHowto.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Item {

// Texte en gras
Text {
text: "This application supports notifications."
text: i18n.tr("This application supports notifications.")
font.pixelSize: 14
font.bold: false
color: "#666666" // gris intermédiaire visible sur clair et sombre
Expand All @@ -54,7 +54,7 @@ Item {
}

Label {
text: "Show me how!"
text: i18n.tr("Show me how!")
font.pixelSize: 14
color: "#37a5e8" // Couleur bleu typique des liens
anchors.horizontalCenter: parent.horizontalCenter
Expand Down Expand Up @@ -83,7 +83,7 @@ Item {
leadingActionBar.actions: [
Action {
iconName: "back"
text: "Retour"
text: i18n.tr("Back")
onTriggered: {
parent.pageStack.pop()
}
Expand Down
48 changes: 48 additions & 0 deletions whatsweb/app/SettingsButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import QtQuick 2.9
import Ubuntu.Components 1.3
import QtQuick.Window 2.2
import Ubuntu.Components.ListItems 1.3 as ListItemm
import Ubuntu.Content 1.3


Item {
id: notificationsHowto
width: parent.width
height: parent.height
property PageStack pageStack

opacity: 0 // initialement invisible

// Timer pour déclencher l'apparition
Timer {
interval: 2000 // 2 secondes
running: true
repeat: false
onTriggered: notificationsHowto.opacity = 1
}

// Animation du fondu
Behavior on opacity {
NumberAnimation { duration: 500 } // 0.5 secondes
}
Image {
source: "Icons/gear.png"
id:settingsButton
width: 25
height: 25
anchors {
top: parent.top
right: parent.right
topMargin: units.gu(1)
rightMargin: units.gu(1)
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
mainPageStack.push(Qt.resolvedUrl("SettingsPage.qml"),{"config":mainView.config})
}
}
}

}
Loading