// Copyright (c) 2021 Proton Technologies AG
//
// This file is part of ProtonMail Bridge.
//
// ProtonMail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ProtonMail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ProtonMail Bridge. If not, see .
import QtQuick 2.8
import ImportExportUI 1.0
import ProtonUI 1.0
import QtQuick.Controls 2.1
import QtQuick.Window 2.2
Window {
id : testroot
width : 100
height : 600
flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint
visible : true
title : "GUI test Window"
color : "transparent"
x : testgui.winMain.x - 120
y : testgui.winMain.y
property bool newVersion : true
Accessible.name: testroot.title
Accessible.description: "Window with buttons testing the GUI events"
Rectangle {
id:test_systray
anchors{
top: parent.top
horizontalCenter: parent.horizontalCenter
}
height: 40
width: 100
color: "yellow"
Image {
id: sysImg
anchors {
left : test_systray.left
top : test_systray.top
}
height: test_systray.height
mipmap: true
fillMode : Image.PreserveAspectFit
source: ""
}
Text {
id: systrText
anchors {
right : test_systray.right
verticalCenter: test_systray.verticalCenter
}
text: "unset"
}
function normal() {
test_systray.color = "#22ee22"
systrText.text = "norm"
sysImg.source= "../share/icons/rounded-systray.png"
}
function highlight() {
test_systray.color = "#eeee22"
systrText.text = "highl"
sysImg.source= "../share/icons/rounded-syswarn.png"
}
MouseArea {
property point diff: "0,0"
anchors.fill: parent
onPressed: {
diff = Qt.point(testroot.x, testroot.y)
var mousePos = mapToGlobal(mouse.x, mouse.y)
diff.x -= mousePos.x
diff.y -= mousePos.y
}
onPositionChanged: {
var currPos = mapToGlobal(mouse.x, mouse.y)
testroot.x = currPos.x + diff.x
testroot.y = currPos.y + diff.y
}
}
}
ListModel {
id: buttons
ListElement { title : "Show window" }
ListElement { title : "Logout" }
ListElement { title : "Internet on" }
ListElement { title : "Internet off" }
ListElement { title : "Macos" }
ListElement { title : "Windows" }
ListElement { title : "Linux" }
ListElement { title: "NotifyManualUpdate(CanInstall)" }
ListElement { title: "NotifyManualUpdate(CantInstall)" }
ListElement { title: "NotifyManualUpdateRestart" }
ListElement { title: "NotifyManualUpdateError" }
ListElement { title: "ForceUpdate" }
ListElement { title: "NotifySilentUpdateRestartNeeded" }
ListElement { title: "NotifySilentUpdateError" }
ListElement { title : "ImportStructure" }
ListElement { title : "DraftImpFailed" }
ListElement { title : "NoInterImp" }
ListElement { title : "ReportImp" }
ListElement { title : "NewFolder" }
ListElement { title : "EditFolder" }
ListElement { title : "EditLabel" }
ListElement { title : "ExpProgErr" }
ListElement { title : "ImpProgErr" }
}
ListView {
id: view
anchors {
top : test_systray.bottom
bottom : parent.bottom
left : parent.left
right : parent.right
}
orientation : ListView.Vertical
model : buttons
focus : true
delegate : ButtonRounded {
text : title
color_main : "orange"
color_minor : "#aa335588"
isOpaque : true
anchors.horizontalCenter: parent.horizontalCenter
onClicked : {
console.log("Clicked on ", title)
switch (title) {
case "Show window" :
go.showWindow();
break;
case "Logout" :
go.checkLoggedOut("ie");
break;
case "Internet on" :
go.setConnectionStatus(true);
break;
case "Internet off" :
go.setConnectionStatus(false);
break;
case "Macos" :
go.goos = "darwin";
break;
case "Windows" :
go.goos = "windows";
break;
case "Linux" :
go.goos = "linux";
break;
case "NotifyManualUpdate(CanInstall)" :
go.notifyManualUpdate()
go.updateCanInstall = true
break;
case "NotifyManualUpdate(CantInstall)" :
go.notifyManualUpdate()
go.updateCanInstall = false
break;
case "NotifyManualUpdateRestart":
go.notifyManualUpdateRestartNeeded()
break;
case "NotifyManualUpdateError":
go.notifyManualUpdateError()
break;
case "ForceUpdate" :
go.notifyForceUpdate()
break;
case "NotifySilentUpdateRestartNeeded" :
go.notifySilentUpdateRestartNeeded()
break;
case "NotifySilentUpdateError" :
go.notifySilentUpdateError()
break;
case "ImportStructure" :
testgui.winMain.dialogImport.address = "cuto@pm.com"
testgui.winMain.dialogImport.show()
testgui.winMain.dialogImport.currentIndex=DialogImport.Page.SourceToTarget
break
case "DraftImpFailed" :
testgui.notifyError(testgui.enums.errDraftImportFailed)
break
case "NoInterImp" :
testgui.notifyError(testgui.enums.errNoInternetWhileImport)
break
case "ReportImp" :
testgui.winMain.dialogImport.address = "cuto@pm.com"
testgui.winMain.dialogImport.show()
testgui.winMain.dialogImport.currentIndex=DialogImport.Page.Report
break
case "NewFolder" :
testgui.winMain.popupFolderEdit.show("currentName", "", "", testgui.enums.folderTypeFolder, "")
break
case "EditFolder" :
testgui.winMain.popupFolderEdit.show("currentName", "", "#7272a7", testgui.enums.folderTypeFolder, "")
break
case "EditFolder" :
testgui.winMain.popupFolderEdit.show("currentName", "", "", testgui.enums.folderTypeFolder, "")
break
case "ImpProgErr" :
go.animateProgressBar.pause()
testgui.notifyError(testgui.enums.errEmailImportFailed)
break
case "ExpProgErr" :
go.animateProgressBar.pause()
testgui.notifyError(testgui.enums.errEmailExportFailed)
break
default :
console.log("Not implemented " + title)
}
}
}
}
Component.onCompleted : {
testgui.winMain.x = 350
testgui.winMain.y = 100
}
//InstanceExistsWindow { id: ie_test }
GuiIE {
id: testgui
//checkLogTimer.interval: 3*1000
winMain.visible: true
ListModel{
id: accountsModel
ListElement{ account : "ie" ; status : "connected"; isExpanded: false; isCombinedAddressMode: false; hostname : "127.0.0.1"; password : "ZI9tKp+ryaxmbpn2E12"; security : "StarTLS"; portSMTP : 1025; portIMAP : 1143; aliases : "ie@pm.com;jaku@pm.com;DoYouKnowAboutAMovieCalledTheHorriblySlowMurderWithExtremelyInefficientWeapon@thatYouCanFindForExampleOnyoutube.com" }
ListElement{ account : "exteremelongnamewhichmustbeeladedinthemiddleoftheaddress@protonmail.com" ; status : "connected"; isExpanded: true; isCombinedAddressMode: true; hostname : "127.0.0.1"; password : "ZI9tKp+ryaxmbpn2E12"; security : "StarTLS"; portSMTP : 1025; portIMAP : 1143; aliases : "ie@pm.com;jaku@pm.com;hu@hu.hu" }
ListElement{ account : "ie2@protonmail.com" ; status : "disconnected"; isExpanded: false; isCombinedAddressMode: false; hostname : "127.0.0.1"; password : "ZI9tKp+ryaxmbpn2E12"; security : "StarTLS"; portSMTP : 1025; portIMAP : 1143; aliases : "ie@pm.com;jaku@pm.com;hu@hu.hu" }
ListElement{ account : "many@protonmail.com" ; status : "connected"; isExpanded: true; isCombinedAddressMode: true; hostname : "127.0.0.1"; password : "ZI9tKp+ryaxmbpn2E12"; security : "StarTLS"; portSMTP : 1025; portIMAP : 1143; aliases : "ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;ie@pm.com;jaku@pm.com;hu@hu.hu;"}
}
ListModel{
id: structureExternalOFF
property var globalOptions: JSON.parse('{ "folderId" : "global--uniq" , "folderName" : "" , "folderColor" : "" , "folderType" : "" , "folderEntries" : 0, "fromDate": 0, "toDate": 0, "isFolderSelected" : false , "targetFolderID": "14" , "targetLabelIDs": ";20;29" }')
ListElement{ folderId : "Inbox" ; folderName : "Inbox" ; folderColor : "black" ; folderType : "" ; folderEntries : 1 ; fromDate : 0 ; toDate : 0 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
ListElement{ folderId : "Sent" ; folderName : "Sent" ; folderColor : "black" ; folderType : "" ; folderEntries : 2 ; fromDate : 0 ; toDate : 0 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Spam" ; folderName : "Spam" ; folderColor : "black" ; folderType : "" ; folderEntries : 3 ; fromDate : 0 ; toDate : 0 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Draft" ; folderName : "Draft" ; folderColor : "black" ; folderType : "" ; folderEntries : 4 ; fromDate : 0 ; toDate : 0 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
ListElement{ folderId : "Folder0" ; folderName : "Folder0" ; folderColor : "black" ; folderType : "folder" ; folderEntries : 10 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
ListElement{ folderId : "Folder1" ; folderName : "Folder1" ; folderColor : "black" ; folderType : "folder" ; folderEntries : 20 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Folder2" ; folderName : "Folder2" ; folderColor : "black" ; folderType : "folder" ; folderEntries : 30 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
ListElement{ folderId : "Folder3" ; folderName : "Folder3ToolongAndMustBeElidedSimilarToOnOfAccountsItJustNotNeedToBeThatLong" ; folderColor : "black" ; folderType : "folder" ; folderEntries : 40 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Label0" ; folderName : "Label-" ; folderColor : "black" ; folderType : "label" ; folderEntries : 10 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Label1" ; folderName : "Label1" ; folderColor : "black" ; folderType : "label" ; folderEntries : 11 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
ListElement{ folderId : "Label2" ; folderName : "Label2" ; folderColor : "black" ; folderType : "label" ; folderEntries : 12 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" }
ListElement{ folderId : "Label3" ; folderName : "Label3" ; folderColor : "black" ; folderType : "label" ; folderEntries : 13 ; fromDate : 300000 ; toDate : 15000000 ; isFolderSelected : true ; targetFolderID : "14" ; targetLabelIDs : ";20;29" }
function addTargetLabelID ( id , label ) { structureFuncs.addTargetLabelID ( structureExternal , id , label ) }
function removeTargetLabelID ( id , label ) { structureFuncs.removeTargetLabelID ( structureExternal , id , label ) }
function setTargetFolderID ( id , label ) { structureFuncs.setTargetFolderID ( structureExternal , id , label ) }
function setFromToDate ( id , from, to ) { structureFuncs.setFromToDate ( structureExternal , id , from, to ) }
function getID ( row ) { return row == -1 ? structureExternal.globalOptions.folderId : structureExternal.get(row).folderId }
function getById ( folderId ) { return structureFuncs.getById ( structureExternal , folderId ) }
function getFrom ( folderId ) { return structureExternal.getById ( folderId ) .fromDate }
function getTo ( folderId ) { return structureExternal.getById ( folderId ) .toDate }
function getTargetLabelIDs ( folderId ) { return structureExternal.getById ( folderId ) .getTargetLabelIDs }
function hasFolderWithName ( folderName ) { return structureFuncs.hasFolderWithName ( structureExternal , folderName ) }
function hasTarget () { return structureFuncs.hasTarget(structureExternal) }
}
ListModel{
id: structurePMOFF
// group selectors
property bool selectedLabels : false
property bool selectedFolders : false
property bool atLeastOneSelected : true
property var globalOptions: JSON.parse('{ "folderId" : "global--uniq" , "folderName" : "global" , "folderColor" : "black" , "folderType" : "" , "folderEntries" : 0 , "fromDate": 300000 , "toDate": 15000000 , "isFolderSelected" : false , "targetFolderID": "14" , "targetLabelIDs": ";20;29" }')
ListElement{ folderId : "0" ; folderName : "INBOX" ; folderColor : "blue" ; folderType : "" ; folderEntries : 1 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "1" ; folderName : "Sent" ; folderColor : "blue" ; folderType : "" ; folderEntries : 2 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "2" ; folderName : "Spam" ; folderColor : "blue" ; folderType : "" ; folderEntries : 3 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "3" ; folderName : "Draft" ; folderColor : "blue" ; folderType : "" ; folderEntries : 4 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "6" ; folderName : "Archive" ; folderColor : "blue" ; folderType : "" ; folderEntries : 5 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "14" ; folderName : "Folder0" ; folderColor : "blue" ; folderType : "folder" ; folderEntries : 10 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "15" ; folderName : "Folder1" ; folderColor : "green" ; folderType : "folder" ; folderEntries : 20 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "16" ; folderName : "Folder2" ; folderColor : "pink" ; folderType : "folder" ; folderEntries : 30 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "17" ; folderName : "Folder3ToolongAndMustBeElidedSimilarToOnOfAccountsItJustNotNeedToBeThatLong" ; folderColor : "orange" ; folderType : "folder" ; folderEntries : 40 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "28" ; folderName : "Label0" ; folderColor : "red" ; folderType : "label" ; folderEntries : 10 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "29" ; folderName : "Label1" ; folderColor : "blue" ; folderType : "label" ; folderEntries : 11 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "20" ; folderName : "Label2" ; folderColor : "green" ; folderType : "label" ; folderEntries : 12 ; isFolderSelected : false ; targetFolderID : "" ; targetLabelIDs : "" ; }
ListElement{ folderId : "21" ; folderName : "Label3ToolongAndMustBeElidedSimilarToOnOfAccountsItJustNotNeedToBeThatLong" ; folderColor : "orange" ; folderType : "label" ; folderEntries : 40 ; isFolderSelected : true ; targetFolderID : "" ; targetLabelIDs : "" ; }
function setFolderSelection ( folderId , toSelect ) { structureFuncs.setFolderSelection ( structurePM , folderId , toSelect ) }
function selectType ( folderType , toSelect ) { structureFuncs.setTypeSelected ( structurePM , folderType , toSelect ) }
function setFromToDate ( id , from, to ) { structureFuncs.setFromToDate ( structureExternal , id , from, to ) }
function getID ( row ) { return row == -1 ? structurePM.globalOptions.folderId : structurePM.get(row) .folderId }
function getById ( folderId ) { return structureFuncs.getById ( structurePM , folderId ) }
function getName ( folderId ) { return structurePM.getById ( folderId ) .folderName }
function getType ( folderId ) { return structurePM.getById ( folderId ) .folderType }
function getColor ( folderId ) { return structurePM.getById ( folderId ) .folderColor }
function getFrom ( folderId ) { return structurePM.getById ( folderId ) .fromDate }
function getTo ( folderId ) { return structurePM.getById ( folderId ) .toDate }
function getTargetLabelIDs ( folderId ) { return structurePM.getById ( folderId ) .getTargetLabelIDs }
function hasFolderWithName ( folderName ) { return structureFuncs.hasFolderWithName ( structurePM , folderName ) }
onDataChanged: {
structureFuncs.updateSelection(structurePM)
}
}
QtObject {
id: structureFuncs
function setFolderSelection (model, id , toSelect ) {
console.log(" set folde sel", id, toSelect)
for (var i= -1; i createLabelOrFolder", address, fname, fcolor, isFolder, sourceID)
return (fname!="fail")
}
function checkInternet() {
// nothing to do
}
function loadImportReports(fname) {
console.log("load import reports for ", fname)
}
onToggleAutoStart: {
workAndClose("toggleAutoStart")
isAutoStart = (isAutoStart!=0) ? 0 : 1
console.log (" Test: toggleAutoStart "+isAutoStart)
}
function openReport() {
Qt.openUrlExternally("file:///home/cuto/")
}
function sendImportReport(address, fname) {
console.log("sending import report from ", address, " file ", fname)
return !fname.includes("fail")
}
onToggleAutoUpdate: {
workAndClose()
isAutoUpdate = (isAutoUpdate!=false) ? false : true
console.log (" Test: onToggleAutoUpdate "+isAutoUpdate)
}
}
}