qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
profileinfo.h
Go to the documentation of this file.
1 /*
2  Copyright © 2017-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <QObject>
23 #include "util/interface.h"
24 #include "src/core/toxpk.h"
25 #include "iprofileinfo.h"
26 
27 class Core;
28 class QFile;
29 class QPoint;
30 class Profile;
31 
32 class ProfileInfo : public QObject, public IProfileInfo
33 {
34  Q_OBJECT
35 public:
37 
38  bool setPassword(const QString& password) override;
39  bool deletePassword() override;
40  bool isEncrypted() const override;
41 
42  void copyId() const override;
43 
44  void setUsername(const QString& name) override;
45  void setStatusMessage(const QString& status) override;
46 
47  QString getProfileName() const override;
48  RenameResult renameProfile(const QString& name) override;
49  SaveResult exportProfile(const QString& path) const override;
50  QStringList removeProfile() override;
51  void logout() override;
52 
53  void copyQr(const QImage& image) const override;
54  SaveResult saveQr(const QImage& image, const QString& path) const override;
55 
56  SetAvatarResult setAvatar(const QString& path) override;
57  void removeAvatar() override;
58 
59  SIGNAL_IMPL(ProfileInfo, idChanged, const ToxId& id)
60  SIGNAL_IMPL(ProfileInfo, usernameChanged, const QString& name)
61  SIGNAL_IMPL(ProfileInfo, statusMessageChanged, const QString& message)
62 
63 private:
64  IProfileInfo::SetAvatarResult createAvatarFromFile(QFile& file, QByteArray& avatar);
65  IProfileInfo::SetAvatarResult byteArrayToPng(QByteArray inData, QByteArray& outPng);
67  Profile* const profile;
68  Core* const core;
69 };
ProfileInfo::core
Core *const core
Definition: profileinfo.h:68
ProfileInfo::deletePassword
bool deletePassword() override
Delete a user password for profile.
Definition: profileinfo.cpp:70
IProfileInfo
Definition: iprofileinfo.h:28
ProfileInfo::ProfileInfo
ProfileInfo(Core *core, Profile *profile)
ProfileInfo constructor.
Definition: profileinfo.cpp:46
IProfileInfo::RenameResult
RenameResult
Definition: iprofileinfo.h:31
ProfileInfo::createAvatarFromFile
IProfileInfo::SetAvatarResult createAvatarFromFile(QFile &file, QByteArray &avatar)
Create an avatar from an image file.
Definition: profileinfo.cpp:316
Profile
Handles all qTox internal paths.
Definition: profile.h:42
ProfileInfo::setStatusMessage
void setStatusMessage(const QString &status) override
Set self status message.
Definition: profileinfo.cpp:112
HistMessageContentType::file
@ file
toxpk.h
ProfileInfo::saveQr
SaveResult saveQr(const QImage &image, const QString &path) const override
Save image to file.
Definition: profileinfo.cpp:251
iprofileinfo.h
ProfileInfo::isEncrypted
bool isEncrypted() const override
Check if current profile is encrypted.
Definition: profileinfo.cpp:80
ProfileInfo::copyQr
void copyQr(const QImage &image) const override
Copy image to clipboard.
Definition: profileinfo.cpp:240
HistMessageContentType::message
@ message
IProfileInfo::SaveResult
SaveResult
Definition: iprofileinfo.h:35
ProfileInfo::profile
Profile *const profile
Definition: profileinfo.h:67
ProfileInfo::copyId
void copyId() const override
Copy self ToxId to clipboard.
Definition: profileinfo.cpp:88
ProfileInfo::setUsername
void setUsername(const QString &name) override
Set self user name.
Definition: profileinfo.cpp:103
ProfileInfo::scalePngToAvatar
IProfileInfo::SetAvatarResult scalePngToAvatar(QByteArray &avatar)
Definition: profileinfo.cpp:360
ProfileInfo::renameProfile
RenameResult renameProfile(const QString &name) override
Rename profile file.
Definition: profileinfo.cpp:157
ProfileInfo::setAvatar
SetAvatarResult setAvatar(const QString &path) override
Set self avatar.
Definition: profileinfo.cpp:291
ToxId
This class represents a Tox ID.
Definition: toxid.h:29
ProfileInfo::removeProfile
QStringList removeProfile() override
Remove profile.
Definition: profileinfo.cpp:218
ProfileInfo::getProfileName
QString getProfileName() const override
Get name of tox profile file.
Definition: profileinfo.cpp:121
ProfileInfo::byteArrayToPng
IProfileInfo::SetAvatarResult byteArrayToPng(QByteArray inData, QByteArray &outPng)
Create a png from image data.
Definition: profileinfo.cpp:334
ProfileInfo::removeAvatar
void removeAvatar() override
Remove self avatar.
Definition: profileinfo.cpp:384
IProfileInfo::SetAvatarResult
SetAvatarResult
Definition: iprofileinfo.h:39
ProfileInfo::exportProfile
SaveResult exportProfile(const QString &path) const override
Save profile in custom place.
Definition: profileinfo.cpp:196
ProfileInfo::setPassword
bool setPassword(const QString &password) override
Set a user password for profile.
Definition: profileinfo.cpp:60
ProfileInfo::logout
void logout() override
Log out from current profile.
Definition: profileinfo.cpp:228
ProfileInfo
Implement interface, that provides invormation about self profile. Also, provide methods to work with...
Definition: profileinfo.h:32
Core
Definition: core.h:59