Akonadi Contacts

imagewidget.h
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2009 Tobias Koenig <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include <kcontacts/picture.h>
12 
13 #include <QPoint>
14 #include <QPushButton>
15 
16 namespace KContacts
17 {
18 class Addressee;
19 }
20 
21 class ImageLoader;
22 
23 class ImageWidget : public QPushButton
24 {
25  Q_OBJECT
26 
27 public:
28  enum Type { Photo, Logo };
29 
30  explicit ImageWidget(Type type, QWidget *parent = nullptr);
31  ~ImageWidget() override;
32 
33  void loadContact(const KContacts::Addressee &contact);
34  void storeContact(KContacts::Addressee &contact) const;
35 
36  void setReadOnly(bool readOnly);
37 
38 protected:
39  // image drop handling
40  void dragEnterEvent(QDragEnterEvent *event) override;
41  void dropEvent(QDropEvent *event) override;
42 
43  // image drag handling
44  void mousePressEvent(QMouseEvent *event) override;
45  void mouseMoveEvent(QMouseEvent *event) override;
46 
47  // context menu handling
48  void contextMenuEvent(QContextMenuEvent *event) override;
49 
50 private:
51  void updateView();
52 
53  void changeImage();
54  void changeUrl();
55  void saveImage();
56  void deleteImage();
57  ImageLoader *imageLoader();
58 
59  KContacts::Picture mPicture;
60  QPoint mDragStartPos;
61  ImageLoader *mImageLoader = nullptr;
62  Type mType;
63  bool mHasImage;
64  bool mReadOnly;
65 };
66 
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jun 17 2021 23:09:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.