118 lines
2.9 KiB
C++
118 lines
2.9 KiB
C++
/*
|
|
* Squawk messenger.
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
*
|
|
* This program 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.
|
|
*
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef VCARD_H
|
|
#define VCARD_H
|
|
|
|
#include <QWidget>
|
|
#include <QScopedPointer>
|
|
#include <QPixmap>
|
|
#include <QMenu>
|
|
#include <QFileDialog>
|
|
#include <QMimeDatabase>
|
|
#include <QImage>
|
|
#include <QStandardPaths>
|
|
#include <QLabel>
|
|
#include <QGraphicsOpacityEffect>
|
|
#include <QVBoxLayout>
|
|
#include <QMenu>
|
|
#include <QApplication>
|
|
#include <QClipboard>
|
|
|
|
#include <set>
|
|
|
|
#include "shared/vcard.h"
|
|
#include "ui/models/info/emails.h"
|
|
#include "ui/models/info/phones.h"
|
|
#include "ui/utils/progress.h"
|
|
#include "ui/utils/comboboxdelegate.h"
|
|
|
|
#ifdef WITH_OMEMO
|
|
#include "ui/widgets/info/omemo/omemo.h"
|
|
#endif
|
|
|
|
namespace Ui
|
|
{
|
|
class VCard;
|
|
}
|
|
|
|
class VCard : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
VCard(const QString& jid, bool edit = false, QWidget* parent = nullptr);
|
|
~VCard();
|
|
|
|
void setVCard(const Shared::VCard& card);
|
|
void setVCard(const QString& jid, const Shared::VCard& card);
|
|
QString getJid() const;
|
|
void showProgress(const QString& = "");
|
|
void hideProgress();
|
|
|
|
signals:
|
|
void saveVCard(const Shared::VCard& card);
|
|
|
|
private slots:
|
|
void onButtonBoxAccepted();
|
|
void onClearAvatar();
|
|
void onSetAvatar();
|
|
void onAvatarSelected();
|
|
void onAddAddress();
|
|
void onRemoveAddress();
|
|
void onAddEmail();
|
|
void onCopyEmail();
|
|
void onRemoveEmail();
|
|
void onAddPhone();
|
|
void onCopyPhone();
|
|
void onRemovePhone();
|
|
void onContextMenu(const QPoint& point);
|
|
|
|
private:
|
|
QScopedPointer<Ui::VCard> m_ui;
|
|
QSize avatarButtonMargins;
|
|
QMenu* avatarMenu;
|
|
bool editable;
|
|
Shared::Avatar currentAvatarType;
|
|
QString currentAvatarPath;
|
|
Progress* progress;
|
|
QLabel* progressLabel;
|
|
QWidget* overlay;
|
|
QMenu* contextMenu;
|
|
Models::EMails emails;
|
|
Models::Phones phones;
|
|
ComboboxDelegate* roleDelegate;
|
|
ComboboxDelegate* phoneTypeDelegate;
|
|
#ifdef WITH_OMEMO
|
|
Omemo* omemo;
|
|
#endif
|
|
|
|
static const std::set<QString> supportedTypes;
|
|
|
|
private:
|
|
void updateAvatar();
|
|
void initializeDelegates();
|
|
void initializeViews();
|
|
void initializeActions();
|
|
void initializeInteractiveElements(const QString& jid);
|
|
void initializeOverlay();
|
|
#ifdef WITH_OMEMO
|
|
void initializeOmemo();
|
|
#endif
|
|
};
|
|
|
|
#endif // VCARD_H
|