File indexing completed on 2024-12-22 04:31:07
0001 #include <QtCore> 0002 #include <QtQuick> 0003 0004 /* 0005 class QfShareItem * 0006 brief Manager to use share logic. 0007 * 0008 author Andrew Shapovalov*/ 0009 0010 class QfShareItem : public QQuickPaintedItem 0011 { 0012 Q_OBJECT 0013 Q_PROPERTY(QString shareString READ getShareString WRITE setShareString NOTIFY shareStringChanged) 0014 Q_PROPERTY(QUrl shareUrl READ getShareUrl WRITE setShareUrl NOTIFY shareUrlChanged) 0015 private: 0016 /** The share string info.*/ 0017 QString m_shareString; 0018 /* The share link.*/ 0019 QUrl m_shareUrl; 0020 /* 0021 brief Strip all HTML tags from string. 0022 * 0023 param body The source string. * 0024 return Plain text. 0025 * 0026 author Andrew Shapovalov*/ 0027 QString stripHTMLTags(QString body); 0028 /** 0029 brief Works with all applications events. 0030 * 0031 param obj The object which call event. * 0032 param event The event of call. 0033 * 0034 author Andrew Shapovalov*/ 0035 bool eventFilter(QObject *obj, QEvent *event); 0036 /** 0037 brief Share current content. 0038 * 0039 author Andrew Shapovalov*/ 0040 void shareCurrentContent(); 0041 0042 public: 0043 /** 0044 brief Create a new object. 0045 * 0046 param parent Parent object. * 0047 author Andrew Shapovalov*/ 0048 explicit QfShareItem(QQuickPaintedItem *parent = nullptr); 0049 0050 // Others 0051 /* 0052 brief Called when current object will redrawing. * 0053 param painter The object for draw data. 0054 * 0055 author Andrew Shapovalov*/ 0056 void paint(QPainter painter); 0057 // Getters 0058 /* 0059 brief Get share content string. 0060 * 0061 return Share string content. * 0062 author Andrew Shapovalov*/ 0063 inline QString getShareString() 0064 { 0065 return m_shareString; 0066 } 0067 0068 /** 0069 brief Get share url. * 0070 return Share url. 0071 * 0072 author Andrew Shapovalov*/ 0073 inline QUrl getShareUrl() 0074 { 0075 return m_shareUrl; 0076 } 0077 // Setters 0078 /** 0079 brief Set share content string. 0080 * 0081 param value Share string content. * 0082 author Andrew Shapovalov*/ 0083 inline void setShareString(QString value) 0084 { 0085 m_shareString = value; 0086 emit shareStringChanged(m_shareString); 0087 } 0088 0089 /** 0090 brief Set share url. * 0091 param value Share url. 0092 * 0093 author Andrew Shapovalov*/ 0094 inline void setShareUrl(QUrl value) 0095 { 0096 m_shareUrl = value; 0097 emit shareUrlChanged(m_shareUrl); 0098 } 0099 /** 0100 brief Share content and url. 0101 * 0102 param text The text of share. * 0103 param url The url to share. 0104 * 0105 author Andrew Shapovalov*/ 0106 Q_INVOKABLE void shareContent(QString text = QString(), QUrl url = QUrl()); 0107 signals: 0108 /** 0109 brief Called when share content string was changed. 0110 * 0111 param value Share string content. * 0112 author Andrew Shapovalov*/ 0113 void shareStringChanged(QString value); 0114 0115 /** 0116 brief Called when share url was changed. * 0117 param value Share url. 0118 * 0119 author Andrew Shapovalov*/ 0120 void shareUrlChanged(QUrl value); 0121 /** 0122 brief Called when user select share service. 0123 * 0124 param serviceName The name of selected service. * 0125 author Andrew Shapovalov*/ 0126 void selectedService(QString serviceName); 0127 0128 public slots: 0129 };