2019-10-20 19:39:11 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2019-10-23 14:49:56 +00:00
|
|
|
#include <QPixmap>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMimeDatabase>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QStandardPaths>
|
2019-10-31 14:01:48 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QGraphicsOpacityEffect>
|
|
|
|
#include <QVBoxLayout>
|
2019-11-02 20:50:25 +00:00
|
|
|
#include <QMenu>
|
2019-11-06 15:14:49 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
2019-10-23 14:49:56 +00:00
|
|
|
|
|
|
|
#include <set>
|
2019-10-20 19:39:11 +00:00
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
#include "shared/vcard.h"
|
2019-11-02 20:50:25 +00:00
|
|
|
#include "emailsmodel.h"
|
2019-11-06 15:14:49 +00:00
|
|
|
#include "phonesmodel.h"
|
2019-11-02 20:50:25 +00:00
|
|
|
#include "ui/utils/progress.h"
|
|
|
|
#include "ui/utils/comboboxdelegate.h"
|
2019-10-21 15:02:41 +00:00
|
|
|
|
2019-10-20 19:39:11 +00:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class VCard;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo write docs
|
|
|
|
*/
|
|
|
|
class VCard : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-10-22 15:13:56 +00:00
|
|
|
VCard(const QString& jid, bool edit = false, QWidget* parent = nullptr);
|
2019-10-20 19:39:11 +00:00
|
|
|
~VCard();
|
|
|
|
|
2019-10-22 15:13:56 +00:00
|
|
|
void setVCard(const Shared::VCard& card);
|
2019-10-21 15:02:41 +00:00
|
|
|
void setVCard(const QString& jid, const Shared::VCard& card);
|
2019-10-22 15:13:56 +00:00
|
|
|
QString getJid() const;
|
2019-10-31 14:01:48 +00:00
|
|
|
void showProgress(const QString& = "");
|
|
|
|
void hideProgress();
|
2019-10-21 15:02:41 +00:00
|
|
|
|
|
|
|
signals:
|
2019-10-22 15:13:56 +00:00
|
|
|
void saveVCard(const Shared::VCard& card);
|
2019-10-21 15:02:41 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onButtonBoxAccepted();
|
2019-10-23 14:49:56 +00:00
|
|
|
void onClearAvatar();
|
|
|
|
void onSetAvatar();
|
|
|
|
void onAvatarSelected();
|
2019-11-02 20:50:25 +00:00
|
|
|
void onAddAddress();
|
|
|
|
void onRemoveAddress();
|
|
|
|
void onAddEmail();
|
2019-11-06 15:14:49 +00:00
|
|
|
void onCopyEmail();
|
2019-11-02 20:50:25 +00:00
|
|
|
void onRemoveEmail();
|
|
|
|
void onAddPhone();
|
2019-11-06 15:14:49 +00:00
|
|
|
void onCopyPhone();
|
2019-11-02 20:50:25 +00:00
|
|
|
void onRemovePhone();
|
|
|
|
void onContextMenu(const QPoint& point);
|
2019-10-21 15:02:41 +00:00
|
|
|
|
2019-10-20 19:39:11 +00:00
|
|
|
private:
|
|
|
|
QScopedPointer<Ui::VCard> m_ui;
|
2019-10-23 14:49:56 +00:00
|
|
|
QSize avatarButtonMargins;
|
|
|
|
QMenu* avatarMenu;
|
|
|
|
bool editable;
|
|
|
|
Shared::Avatar currentAvatarType;
|
|
|
|
QString currentAvatarPath;
|
2019-10-31 14:01:48 +00:00
|
|
|
Progress* progress;
|
|
|
|
QLabel* progressLabel;
|
|
|
|
QWidget* overlay;
|
2019-11-02 20:50:25 +00:00
|
|
|
QMenu* contextMenu;
|
|
|
|
UI::VCard::EMailsModel emails;
|
2019-11-06 15:14:49 +00:00
|
|
|
UI::VCard::PhonesModel phones;
|
2019-11-02 20:50:25 +00:00
|
|
|
ComboboxDelegate* roleDelegate;
|
2019-11-06 15:14:49 +00:00
|
|
|
ComboboxDelegate* phoneTypeDelegate;
|
2019-10-23 14:49:56 +00:00
|
|
|
|
|
|
|
static const std::set<QString> supportedTypes;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateAvatar();
|
2019-10-20 19:39:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VCARD_H
|