Shared GUI for Bridge and Import/Export

This commit is contained in:
Jakub
2020-05-27 15:58:50 +02:00
committed by Michal Horejsek
parent b598779c0f
commit 49316a935c
96 changed files with 11469 additions and 209 deletions

View File

@ -17,14 +17,14 @@ translate.ts: ${QMLfiles}
lupdate -recursive qml/ -ts $@
rcc.cpp: ${QMLfiles} ${Icons} resources.qrc
rm -f rcc.cpp rcc.qrc && qtrcc -o .
rm -f rcc.cpp rcc.qrc && qtrcc -o .
qmltest:
qmltestrunner -eventdelay 500 -import ./qml/
qmlcheck : ../qml/ProtonUI/fontawesome.ttf ../qml/ProtonUI/images
qmltestrunner -eventdelay 500 -import ../qml/
qmlcheck: ../qml/ProtonUI/fontawesome.ttf ../qml/ProtonUI/images
qmlscene -I ../qml/ -f ../qml/tst_Gui.qml --quit
qmlpreview : ../qml/ProtonUI/fontawesome.ttf ../qml/ProtonUI/images
qmlpreview: ../qml/ProtonUI/fontawesome.ttf ../qml/ProtonUI/images
rm -f ../qml/*.qmlc ../qml/BridgeUI/*.qmlc
qmlscene -verbose -I ../qml/ -f ../qml/tst_Gui.qml
#qmlscene -qmljsdebugger=port:3768,block -verbose -I ../qml/ -f ../qml/tst_Gui.qml

View File

@ -40,6 +40,7 @@ import (
"github.com/ProtonMail/proton-bridge/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/events"
"github.com/ProtonMail/proton-bridge/internal/frontend/autoconfig"
"github.com/ProtonMail/proton-bridge/internal/frontend/qt-common"
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/preferences"
"github.com/ProtonMail/proton-bridge/pkg/config"
@ -151,7 +152,7 @@ func New(
// InstanceExistAlert is a global warning window indicating an instance already exists.
func (s *FrontendQt) InstanceExistAlert() {
log.Warn("Instance already exists")
s.QtSetupCoreAndControls()
qtcommon.QtSetupCoreAndControls(s.programName, s.programVer)
s.App = widgets.NewQApplication(len(os.Args), os.Args)
s.View = qml.NewQQmlApplicationEngine(s.App)
s.View.AddImportPath("qrc:///")
@ -283,28 +284,13 @@ func (s *FrontendQt) InvMethod(method string) error {
return nil
}
// QtSetupCoreAndControls hanldes global setup of Qt.
// Should be called once per program. Probably once per thread is fine.
func (s *FrontendQt) QtSetupCoreAndControls() {
installMessageHandler()
// Core setup.
core.QCoreApplication_SetApplicationName(s.programName)
core.QCoreApplication_SetApplicationVersion(s.programVer)
// High DPI scaling for windows.
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, false)
// Software OpenGL: to avoid dedicated GPU.
core.QCoreApplication_SetAttribute(core.Qt__AA_UseSoftwareOpenGL, true)
// Basic style for QuickControls2 objects.
//quickcontrols2.QQuickStyle_SetStyle("material")
}
// qtExecute is the main function for starting the Qt application.
//
// It is better to have just one Qt application per program (at least per same
// thread). This functions reads the main user interface defined in QML files.
// The files are appended to library by Qt-QRC.
func (s *FrontendQt) qtExecute(Procedure func(*FrontendQt) error) error {
s.QtSetupCoreAndControls()
qtcommon.QtSetupCoreAndControls(s.programName, s.programVer)
s.App = widgets.NewQApplication(len(os.Args), os.Args)
if runtime.GOOS == "linux" { // Fix default font.
s.App.SetFont(gui.NewQFont2(FcMatchSans(), 12, int(gui.QFont__Normal), false), "")
@ -624,7 +610,7 @@ func (s *FrontendQt) StartUpdate() {
defer s.panicHandler.HandlePanic()
for current := range progress {
s.Qml.SetProgress(current.Processed)
s.Qml.SetProgressDescription(current.Description)
s.Qml.SetProgressDescription(strconv.Itoa(current.Description))
// Error happend
if current.Err != nil {
log.Error("update progress: ", current.Err)

View File

@ -1,23 +0,0 @@
// +build !nogui
#include "logs.h"
#include "_cgo_export.h"
#include <QByteArray>
#include <QString>
#include <QtGlobal>
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_UNUSED(type);
Q_UNUSED(context);
QByteArray localMsg = msg.toUtf8().prepend("WHITESPACE");
logMsgPacked(
const_cast<char*>( (localMsg.constData()) +10 ),
localMsg.size()-10
);
//printf("Handler: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
}
void InstallMessageHandler() { qInstallMessageHandler(messageHandler); }

View File

@ -1,38 +0,0 @@
// Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
// +build !nogui
package qt
//#include "logs.h"
import "C"
import (
"github.com/sirupsen/logrus"
)
func installMessageHandler() {
C.InstallMessageHandler()
}
//export logMsgPacked
func logMsgPacked(data *C.char, len C.int) {
log.WithFields(logrus.Fields{
"pkg": "frontend-qml",
}).Warnln(C.GoStringN(data, len))
}

View File

@ -1,20 +0,0 @@
#pragma once
#ifndef GO_LOG_H
#define GO_LOG_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif // C++
void InstallMessageHandler();
;
#ifdef __cplusplus
}
#endif // C++
#endif // LOG

View File

@ -1,77 +0,0 @@
<!--This file is process during qtdeploy and resources are added to executable.-->
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="ProtonUI">
<file alias="qmldir" >../qml/ProtonUI/qmldir</file>
<file alias="AccessibleButton.qml" >../qml/ProtonUI/AccessibleButton.qml</file>
<file alias="AccessibleText.qml" >../qml/ProtonUI/AccessibleText.qml</file>
<file alias="AccessibleSelectableText.qml" >../qml/ProtonUI/AccessibleSelectableText.qml</file>
<file alias="AccountView.qml" >../qml/ProtonUI/AccountView.qml</file>
<file alias="AddAccountBar.qml" >../qml/ProtonUI/AddAccountBar.qml</file>
<file alias="BubbleNote.qml" >../qml/ProtonUI/BubbleNote.qml</file>
<file alias="BugReportWindow.qml" >../qml/ProtonUI/BugReportWindow.qml</file>
<file alias="ButtonIconText.qml" >../qml/ProtonUI/ButtonIconText.qml</file>
<file alias="ButtonRounded.qml" >../qml/ProtonUI/ButtonRounded.qml</file>
<file alias="CheckBoxLabel.qml" >../qml/ProtonUI/CheckBoxLabel.qml</file>
<file alias="ClickIconText.qml" >../qml/ProtonUI/ClickIconText.qml</file>
<file alias="Dialog.qml" >../qml/ProtonUI/Dialog.qml</file>
<file alias="DialogAddUser.qml" >../qml/ProtonUI/DialogAddUser.qml</file>
<file alias="DialogUpdate.qml" >../qml/ProtonUI/DialogUpdate.qml</file>
<file alias="DialogConnectionTroubleshoot.qml" >../qml/ProtonUI/DialogConnectionTroubleshoot.qml</file>
<file alias="FileAndFolderSelect.qml" >../qml/ProtonUI/FileAndFolderSelect.qml</file>
<file alias="InformationBar.qml" >../qml/ProtonUI/InformationBar.qml</file>
<file alias="InputField.qml" >../qml/ProtonUI/InputField.qml</file>
<file alias="InstanceExistsWindow.qml" >../qml/ProtonUI/InstanceExistsWindow.qml</file>
<file alias="LogoHeader.qml" >../qml/ProtonUI/LogoHeader.qml</file>
<file alias="PopupMessage.qml" >../qml/ProtonUI/PopupMessage.qml</file>
<file alias="Style.qml" >../qml/ProtonUI/Style.qml</file>
<file alias="TabButton.qml" >../qml/ProtonUI/TabButton.qml</file>
<file alias="TabLabels.qml" >../qml/ProtonUI/TabLabels.qml</file>
<file alias="TextLabel.qml" >../qml/ProtonUI/TextLabel.qml</file>
<file alias="TextValue.qml" >../qml/ProtonUI/TextValue.qml</file>
<file alias="TLSCertPinIssueBar.qml" >../qml/ProtonUI/TLSCertPinIssueBar.qml</file>
<file alias="WindowTitleBar.qml" >../qml/ProtonUI/WindowTitleBar.qml</file>
<file alias="fontawesome.ttf" >../share/fontawesome-webfont.ttf</file>
</qresource>
<qresource prefix="ProtonUI/images">
<file alias="systray.png" >../share/icons/rounded-systray.png</file>
<file alias="systray-warn.png" >../share/icons/rounded-syswarn.png</file>
<file alias="systray-error.png" >../share/icons/rounded-syswarn.png</file>
<file alias="systray-mono.png" >../share/icons/white-systray.png</file>
<file alias="systray-warn-mono.png" >../share/icons/white-syswarn.png</file>
<file alias="systray-error-mono.png">../share/icons/white-syserror.png</file>
<file alias="icon.png" >../share/icons/rounded-app.png</file>
<file alias="pm_logo.png" >../share/icons/pm_logo.png</file>
<file alias="win10_Dash.png" >../share/icons/win10_Dash.png</file>
<file alias="win10_Times.png" >../share/icons/win10_Times.png</file>
<file alias="macos_gray.png" >../share/icons/macos_gray.png</file>
<file alias="macos_red.png" >../share/icons/macos_red.png</file>
<file alias="macos_red_hl.png" >../share/icons/macos_red_hl.png</file>
<file alias="macos_red_dark.png" >../share/icons/macos_red_dark.png</file>
<file alias="macos_yellow.png" >../share/icons/macos_yellow.png</file>
<file alias="macos_yellow_hl.png" >../share/icons/macos_yellow_hl.png</file>
<file alias="macos_yellow_dark.png" >../share/icons/macos_yellow_dark.png</file>
</qresource>
<qresource prefix="BridgeUI">
<file alias="qmldir" >../qml/BridgeUI/qmldir</file>
<file alias="AccountDelegate.qml" >../qml/BridgeUI/AccountDelegate.qml</file>
<file alias="BubbleMenu.qml" >../qml/BridgeUI/BubbleMenu.qml</file>
<file alias="Credits.qml" >../qml/BridgeUI/Credits.qml</file>
<file alias="DialogFirstStart.qml" >../qml/BridgeUI/DialogFirstStart.qml</file>
<file alias="DialogPortChange.qml" >../qml/BridgeUI/DialogPortChange.qml</file>
<file alias="DialogYesNo.qml" >../qml/BridgeUI/DialogYesNo.qml</file>
<file alias="DialogTLSCertInfo.qml" >../qml/BridgeUI/DialogTLSCertInfo.qml</file>
<file alias="HelpView.qml" >../qml/BridgeUI/HelpView.qml</file>
<file alias="InfoWindow.qml" >../qml/BridgeUI/InfoWindow.qml</file>
<file alias="MainWindow.qml" >../qml/BridgeUI/MainWindow.qml</file>
<file alias="ManualWindow.qml" >../qml/BridgeUI/ManualWindow.qml</file>
<file alias="OutgoingNoEncPopup.qml" >../qml/BridgeUI/OutgoingNoEncPopup.qml</file>
<file alias="SettingsView.qml" >../qml/BridgeUI/SettingsView.qml</file>
<file alias="StatusFooter.qml" >../qml/BridgeUI/StatusFooter.qml</file>
<file alias="VersionInfo.qml" >../qml/BridgeUI/VersionInfo.qml</file>
</qresource>
<qresource>
<file alias="ui.qml" >../qml/Gui.qml</file>
</qresource>
</RCC>

View File

@ -64,7 +64,7 @@ type GoQMLInterface struct {
_ string `property:"genericErrSeeLogs"`
_ float32 `property:"progress"`
_ int `property:"progressDescription"`
_ string `property:"progressDescription"`
_ func(isAvailable bool) `signal:"setConnectionStatus"`
_ func(updateState string) `signal:"setUpdateState"`