| 
    qTox
    Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
    
   | 
 
 
 
 
Go to the documentation of this file.
   27 #include <QApplication> 
   31 #include <QImageReader> 
   50     connect(core, &
Core::idSet, 
this, &ProfileInfo::idChanged);
 
   63     return errorMsg.isEmpty();
 
   73     return errorMsg.isEmpty();
 
   92     QClipboard* clip = QApplication::clipboard();
 
   93     clip->setText(txt, QClipboard::Clipboard);
 
   94     if (clip->supportsSelection()) {
 
   95         clip->setText(txt, QClipboard::Selection);
 
  131 static QString sanitize(
const QString& src)
 
  135     QList<QChar> banned{
'/', 
'\\', 
':', 
'<', 
'>', 
'"', 
'|', 
'?', 
'*'};
 
  136     for (QChar c : banned) {
 
  137         name.replace(c, 
'_');
 
  141     if (name[0] == 
'.') {
 
  145     if (name.endsWith(
'.')) {
 
  146         name[name.length() - 1] = 
'_';
 
  160     if (name.isEmpty()) {
 
  164     QString newName = sanitize(name);
 
  183 static bool tryRemoveFile(
const QString& filepath)
 
  186     bool writable = tmp.open(QIODevice::WriteOnly);
 
  199     if (path.isEmpty()) {
 
  203     if (!tryRemoveFile(path)) {
 
  222     return manualDeleteFiles;
 
  242     QApplication::clipboard()->setImage(image);
 
  254     if (path.isEmpty()) {
 
  258     if (!tryRemoveFile(path)) {
 
  264     if (!image.save(path, 
nullptr, 75)) {
 
  279     QBuffer buffer(&bytes);
 
  280     buffer.open(QIODevice::WriteOnly);
 
  281     pic.save(&buffer, 
"PNG");
 
  293     if (path.isEmpty()) {
 
  298     file.open(QIODevice::ReadOnly);
 
  299     if (!
file.isOpen()) {
 
  318     QByteArray fileContents{
file.readAll()};
 
  336     QBuffer inBuffer{&inData};
 
  337     QImageReader reader{&inBuffer};
 
  339     const auto format = reader.format();
 
  341     if (!reader.read(&image)) {
 
  345     if (format == 
"png") {
 
  363     constexpr 
int scaleSizes[] = {256, 128, 64, 32};
 
  365     for (
auto scaleSize : scaleSizes) {
 
  369         image.loadFromData(avatar);
 
  370         image = image.scaled(scaleSize, scaleSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
 
  
bool deletePassword() override
Delete a user password for profile.
 
QString toString() const
Returns the Tox ID converted to QString. Is equal to getPublicKey() if the Tox ID was constructed fro...
 
ProfileInfo(Core *core, Profile *profile)
ProfileInfo constructor.
 
IProfileInfo::SetAvatarResult createAvatarFromFile(QFile &file, QByteArray &avatar)
Create an avatar from an image file.
 
Handles all qTox internal paths.
 
bool rename(QString newName)
Tries to rename the profile.
 
void setStatusMessage(const QString &status) override
Set self status message.
 
static const QString TOX_EXT
 
QString setPassword(const QString &newPassword)
Changes the encryption password and re-saves everything with it.
 
SaveResult saveQr(const QImage &image, const QString &path) const override
Save image to file.
 
QStringList remove()
Removes the profile permanently. Updates the profiles vector.
 
void removeSelfAvatar()
Removes our own avatar.
 
bool isEncrypted() const override
Check if current profile is encrypted.
 
static bool exists(QString name)
 
void copyQr(const QImage &image) const override
Copy image to clipboard.
 
constexpr bool IsValidAvatarSize(uint64_t fileSize)
 
ToxId getSelfId() const override
Returns our Tox ID.
 
void copyId() const override
Copy self ToxId to clipboard.
 
void setUsername(const QString &name) override
Set self user name.
 
void usernameSet(const QString &username)
 
IProfileInfo::SetAvatarResult scalePngToAvatar(QByteArray &avatar)
 
RenameResult renameProfile(const QString &name) override
Rename profile file.
 
void saveGlobal()
Asynchronous, saves the global settings.
 
SetAvatarResult setAvatar(const QString &path) override
Set self avatar.
 
This class represents a Tox ID.
 
QStringList removeProfile() override
Remove profile.
 
static Settings & getInstance()
Returns the singleton instance.
 
QByteArray picToPng(const QImage &pic)
Convert QImage to png image.
 
QString getProfileName() const override
Get name of tox profile file.
 
void statusMessageSet(const QString &message)
 
void setUsername(const QString &username)
 
IProfileInfo::SetAvatarResult byteArrayToPng(QByteArray inData, QByteArray &outPng)
Create a png from image data.
 
void removeAvatar() override
Remove self avatar.
 
SaveResult exportProfile(const QString &path) const override
Save profile in custom place.
 
void idSet(const ToxId &id)
 
static Nexus & getInstance()
Returns the singleton instance.
 
bool setPassword(const QString &password) override
Set a user password for profile.
 
void setAvatar(QByteArray pic)
Sets our own avatar.
 
void setStatusMessage(const QString &message)
 
void logout() override
Log out from current profile.
 
bool isEncrypted() const
Checks, if profile has a password.