qtie

package
v1.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2021 License: GPL-3.0 Imports: 24 Imported by: 0

README

ProtonMail Import-Export Qt interface

Import-Export uses Qt framework for creating appealing graphical user interface. Package therecipe/qt is used to implement Qt into Go.

For developers

The GUI is designed inside QML files. Communication with backend is done via frontend.go. The API documentation is done via go-doc.

Setup

  • if you don't have the system wide go-1.8.1 download, install localy (e.g. ~/build/go-1.8.1) and setup:

      export GOROOT=~/build/go-1.8.1/go
      export PATH=$GOROOT/bin:$PATH
    
  • go to your working directory and export $GOPATH

      export GOPATH=`Pwd`
      mkdir -p $GOPATH/bin
      export PATH=$PATH:$GOPATH/bin
    
  • if you dont have system wide Qt-5.8.0 download, install locally (e.g. ~/build/qt/qt-5.8.0) and setup:

      export QT_DIR=~/build/qt/qt-5.8.0
      export PATH=$QT_DIR/5.8/gcc_64/bin:$PATH
    
  • Go-Qt setup (installation is system dependent see therecipe/qt/README for details)

      go get -u -v github.com/therecipe/qt/cmd/...
      $GOPATH/bin/qtsetup
    

Compile

  • it is necessary to compile the Qt-C++ with go for resources and meta-objects

      make -f Makefile.local
    
  • FIXME the rcc file is implicitly generated with package main. This needs to be changed to package qtie manually

  • check that user interface is working

      make -f Makefile.local test
    

Test

    make -f Makefile.local qmlpreview

Deploy

  • before compilation of Import-Export it is necessary to run compilation of Qt-C++ part (done in makefile)

Documentation

Index

Constants

View Source
const (
	FolderTypeSystem   = ""
	FolderTypeLabel    = "label"
	FolderTypeFolder   = "folder"
	FolderTypeExternal = "external"
)

Folder Type

View Source
const (
	StatusNoInternet          = "noInternet"
	StatusCheckingInternet    = "internetCheck"
	StatusNewVersionAvailable = "oldVersion"
	StatusUpToDate            = "upToDate"
	StatusForceUpdate         = "forceupdate"
)

Status

View Source
const (
	// Account info
	Account  = int(core.Qt__UserRole) + 1 + iota // 256 + 1 = 257
	Status                                       // 258
	Password                                     // 259
	Aliases                                      // ...
	IsExpanded
	// Folder info
	FolderId
	FolderName
	FolderColor
	FolderType
	FolderEntries
	IsFolderSelected
	FolderFromDate
	FolderToDate
	TargetFolderID
	TargetLabelIDs
	// Error list
	MailSubject
	MailDate
	MailFrom
	InputFolder
	ErrorMessage
	// Transfer rules mbox
	MboxSelectedIndex
	MboxIsActive
	MboxID
	MboxName
	MboxType
	MboxColor
	// Transfer Rules
	RuleTargetLabelColors
	RuleFromDate
	RuleToDate
)

Constants for data map

View Source
const (
	TypeEML  = "EML"
	TypeMBOX = "MBOX"
)
View Source
const (
	TabGlobal     = 0
	TabSettings   = 1
	TabHelp       = 2
	TabQuit       = 4
	TabAddAccount = -1
)
View Source
const (
	GlobalOptionIndex = -1
)

Variables

Functions

func CheckPathStatus

func CheckPathStatus(path string) int

CheckPathStatus return PathStatus flag as int

Types

type ErrorListModel

type ErrorListModel struct {
	core.QAbstractListModel

	Progress *transfer.Progress
	// contains filtered or unexported fields
}

ErrorListModel to sending error details to Qt

type FolderInfo

type FolderInfo struct {
	FolderType       string
	FolderEntries    int // todo remove
	IsFolderSelected bool
	FromDate         int64  // Unix seconds
	ToDate           int64  // Unix seconds
	TargetFolderID   string // target  ID TODO: this will be hash
	TargetLabelIDs   string // semicolon separated list of label ID same here
	// contains filtered or unexported fields
}

FolderInfo is the element of model

It contains all data for one structure entry

func (*FolderInfo) AddTargetLabel

func (s *FolderInfo) AddTargetLabel(targetID string)

func (*FolderInfo) IsType

func (s *FolderInfo) IsType(askType string) bool

func (*FolderInfo) RemoveTargetLabel

func (s *FolderInfo) RemoveTargetLabel(targetID string)

func (*FolderInfo) TargetLabelIDList

func (s *FolderInfo) TargetLabelIDList() []string

type FolderStructure

type FolderStructure struct {
	core.QAbstractListModel

	GlobalOptions FolderInfo
	// contains filtered or unexported fields
}

FolderStructure model providing container for items (folder info) to QML

QML ListView connects the model from Go and it shows item (entities) information.

Copied and edited from `github.com/therecipe/qt/internal/examples/sailfish/listview`

NOTE: When implementing a model it is important to remember that QAbstractItemModel does not store any data itself !!!! see https://doc.qt.io/qt-5/model-view-programming.html#designing-a-model

func (*FolderStructure) Clear

func (s *FolderStructure) Clear()

Clear removes all items in model

func (*FolderStructure) GetInfo

func (s *FolderStructure) GetInfo(row int) FolderInfo

type FrontendQt

type FrontendQt struct {
	App      *widgets.QApplication      // Main Application pointer
	View     *qml.QQmlApplicationEngine // QML engine pointer
	MainWin  *core.QObject              // Pointer to main window inside QML
	Qml      *GoQMLInterface            // Object accessible from both Go and QML for methods and signals
	Accounts qtcommon.Accounts          // Providing data for accounts ListView

	TransferRules *TransferRules
	ErrorList     *ErrorListModel // Providing data for error reporting
	// contains filtered or unexported fields
}

FrontendQt is API between Import-Export and Qt

With this interface it is possible to control Qt-Gui interface using pointers to Qt and QML objects. QML signals and slots are connected via methods of GoQMLInterface.

func New

func New(
	version, buildVersion string,
	panicHandler types.PanicHandler,
	config *config.Config,
	eventListener listener.Listener,
	updates types.Updater,
	ie types.ImportExporter,
) *FrontendQt

New is constructor for Import-Export Qt-Go interface

func (*FrontendQt) IsAppRestarting

func (f *FrontendQt) IsAppRestarting() bool

IsAppRestarting for Import-Export is always false i.e never restarts

func (*FrontendQt) LoadStructureForExport

func (f *FrontendQt) LoadStructureForExport(addressOrID string)

func (*FrontendQt) Loop

func (f *FrontendQt) Loop(setupError error) (err error)

Loop function for Import-Export interface. It runs QtExecute in main thread with no additional function.

func (*FrontendQt) QtExecute

func (f *FrontendQt) QtExecute(Procedure func(*FrontendQt) error) error

QtExecute in main for starting Qt application

It is needed 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 (*FrontendQt) SendNotification

func (s *FrontendQt) SendNotification(tabIndex int, msg string)

func (*FrontendQt) StartExport

func (f *FrontendQt) StartExport(rootPath, login, fileType string, attachEncryptedBody bool)

func (*FrontendQt) StartImport

func (f *FrontendQt) StartImport(email string, importEncrypted bool)

func (*FrontendQt) StartUpdate

func (f *FrontendQt) StartUpdate()

StartUpdate is identical to bridge

type GoQMLInterface

type GoQMLInterface struct {
	core.QObject
	// contains filtered or unexported fields
}

GoQMLInterface between go and qml

Here we implements all the signals / methods.

func (*GoQMLInterface) SetFrontend

func (s *GoQMLInterface) SetFrontend(f *FrontendQt)

SetFrontend connects all slots and signals from Go to QML

type MboxList

type MboxList struct {
	core.QAbstractListModel
	// contains filtered or unexported fields
}

MboxList is an interface between QML and targets for given rule.

type PathStatus

type PathStatus int

PathStatus maps folder properties to flag

const (
	PathOK PathStatus = 1 << iota
	PathEmptyPath
	PathWrongPath
	PathNotADir
	PathWrongPermissions
	PathDirEmpty
)

Definition of PathStatus flags

type TransferRules

type TransferRules struct {
	core.QAbstractListModel
	// contains filtered or unexported fields
}

TransferRules is an interface between QML and transfer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL