1""" 2 @file 3 @brief This file contains helper functions for Qt types (string to base64) 4 @author Noah Figg <eggmunkee@hotmail.com> 5 @author Jonathan Thomas <jonathan@openshot.org> 6 @author Olivier Girard <eolinwen@gmail.com> 7 8 @section LICENSE 9 10 Copyright (c) 2008-2018 OpenShot Studios, LLC 11 (http://www.openshotstudios.com). This file is part of 12 OpenShot Video Editor (http://www.openshot.org), an open-source project 13 dedicated to delivering high quality video editing and animation solutions 14 to the world. 15 16 OpenShot Video Editor is free software: you can redistribute it and/or modify 17 it under the terms of the GNU General Public License as published by 18 the Free Software Foundation, either version 3 of the License, or 19 (at your option) any later version. 20 21 OpenShot Video Editor is distributed in the hope that it will be useful, 22 but WITHOUT ANY WARRANTY; without even the implied warranty of 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 GNU General Public License for more details. 25 26 You should have received a copy of the GNU General Public License 27 along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>. 28 """ 29 30from PyQt5.QtCore import QByteArray 31 32 33# Utility functions for handling qt types 34 35# QByteArray helpers 36def str_to_bytes(string): 37 """ This is required to save Qt byte arrays into a base64 string (to save screen preferences) """ 38 return QByteArray.fromBase64(string.encode("utf-8")) 39 40 41def bytes_to_str(bytes): 42 """ This is required to load base64 Qt byte array strings into a Qt byte array (to load screen preferences) """ 43 return bytes.toBase64().data().decode("utf-8") 44