1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
This commit is contained in:
tianduanrui 2018-06-13 17:22:50 +08:00
commit 85fd9635ce
33 changed files with 652 additions and 658 deletions

View File

@ -79,8 +79,7 @@ SUBDIRS += test/qqtdicttest
#
SUBDIRS += test/qqtdicttest2
#必开
#
SUBDIRS += test/giftest
#SUBDIRS += test/giftest
#必开 这两个例子是关于QQtAudio的最好展示
#
@ -119,15 +118,4 @@ SUBDIRS += test/osdtest
#
SUBDIRS += test/QQtWidgetClickHelperTest
#
SUBDIRS += test/QQtWidgetClickSoundHelperTest
#need webkit webkitwidgets - WebSupport
#webengine
#ignored
#lessThan(QT_MAJOR_VERSION , 5):SUBDIRS += test/qqtwebkittest
#lessThan(QT_MAJOR_VERSION , 5):SUBDIRS += test/qqtwebclient
#need QZXing, default closed.
#SUBDIRS += examples/qrcodeexample

View File

@ -22,5 +22,9 @@ SUBDIRS =
#测试libQQt的链接
#SUBDIRS += test/giftest
#SUBDIRS += test/voicetest
<<<<<<< HEAD
SUBDIRS += test/treeviewtest
=======
#SUBDIRS += examples/exquisite
>>>>>>> cf536b03ab3ae16368f46c8e35872447cc41787b

View File

@ -98,7 +98,8 @@ LibQQt为方便用户开发App过程方便的发布程序所以添加了多
用户只需要做相应的目录设定甚至包括自己的配置文件的目录设置LibQQt提供的base manager就会自动将用户的程序配置发布到指定位置
并且支持其他依赖的链接库。
经过发布的App直接点击就可以运行*大的省去了用户手动发布App的劳烦过程。
*Multi-link提供ProductExecTool可以对产品集中查看、调用运行。*
*LibQQt3.0基于Multi-link2.0发布用户使用LibQQt3.0代表用户接受其管理工具Multi-link2.0.*
========================================================================
# 使用案例

View File

@ -1,4 +1,4 @@
#include "qqtdictionary.h"
#include "qqtdictionary.h"
QQtDictionary::QQtDictionary ()
{
@ -43,7 +43,7 @@ void QQtDictionary::setType ( QQtDictionary::EDictType type )
m_type = type;
}
void QQtDictionary::setChild ( const QVariant& value )
void QQtDictionary::setValue ( const QVariant& value )
{
m_type = DictValue;
m_value = value;
@ -61,12 +61,12 @@ void QQtDictionary::setChild ( const QMap<QString, QQtDictionary>& map )
m_map = map;
}
void QQtDictionary::appendChild ( const QString& value )
void QQtDictionary::addChild ( const QString& value )
{
appendChild ( QQtDictionary ( QVariant ( value ) ) );
addChild ( QQtDictionary ( QVariant ( value ) ) );
}
void QQtDictionary::appendChild ( const QQtDictionary& dict )
void QQtDictionary::addChild ( const QQtDictionary& dict )
{
m_type = DictList;
//list类
@ -266,12 +266,18 @@ void QQtDictionary::modValue ( const QVariant& value )
void QQtDictionary::modChild ( int index, const QQtDictionary& value )
{
if ( !m_list.contains ( value ) )
return;
m_type = DictList;
m_list[index] = value;
}
void QQtDictionary::modChild ( QString key, const QQtDictionary& value )
void QQtDictionary::modChild ( const QString& key, const QQtDictionary& value )
{
if ( !m_map.contains ( key ) )
return;
m_type = DictMap;
m_map[key] = value;
}

View File

@ -1,4 +1,4 @@
#ifndef QQTDICTIONARY_H
#ifndef QQTDICTIONARY_H
#define QQTDICTIONARY_H
#include <QObject>
@ -80,6 +80,7 @@ public:
/*保存为value的*/
QVariant& getValue();
const QVariant& getValue() const;
QQtDictionary& getChild ( int index );
QQtDictionary& getChild ( const QString& key );
/*获取一个个孩子*/
@ -91,9 +92,16 @@ public:
/*如果设置Value的时候改变了Type将会以新的Type为准*/
void setType ( EDictType type );
/*插入数据自动设置type*/
//设置value
template <typename T>
void setValue ( const T& value ) {
m_type = DictValue;
m_value.setValue<T> ( value );
}
/*自己本身没有孩子,是个叶子,添加值*/
void setChild ( const QVariant& value );
void setValue ( const QVariant& value );
/*插入数据自动设置type*/
/*自己本身有孩子,添加全部孩子*/
/*whole value list*/
void setChild ( const QList<QQtDictionary>& list );
@ -102,8 +110,8 @@ public:
/*自己本身没有孩子,添加一个个的孩子*/
/*index = int*/
void appendChild ( const QString& value );
void appendChild ( const QQtDictionary& dict );
void addChild ( const QString& value );
void addChild ( const QQtDictionary& dict );
/*自己本身有孩子,添加一个个的孩子*/
/*index = int, 会在之前之后插入现更改为会替换存在的index*/
@ -115,8 +123,9 @@ public:
/*操作数据,改变数据*/
void modValue ( const QVariant& value );
/*没有这个数据会无效*/
void modChild ( int index, const QQtDictionary& value );
void modChild ( QString key, const QQtDictionary& value );
void modChild ( const QString& key, const QQtDictionary& value );
/*删除数据*/
void clear ( );

View File

@ -2,7 +2,7 @@
#define QQTEVENT_H
#include <QEvent>
#include <QMouseEvent>
#include "qqt-qt.h"
#include <qqt-local.h>
@ -12,7 +12,7 @@ class QQTSHARED_EXPORT QQtMouseEvent : public QMouseEvent
public:
QQtMouseEvent() :
QMouseEvent ( MouseButtonPress, QPointF(), QPointF(), QPointF(),
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventNotSynthesized ) {
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ) {
}
virtual ~QQtMouseEvent() {}

View File

@ -1,7 +1,7 @@
#ifndef QQTCLICKSOUNDLABEL_H
#define QQTCLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtclicksoundhelper.h>
#include <qqt-local.h>
@ -16,14 +16,14 @@
* new ClickHelper
* installClickHelper
*/
class QQTSHARED_EXPORT QQtClickSoundLabel : public QQtLabel
class QQTSHARED_EXPORT QQtClickSoundLabel : public QQtVirtualClickLabel
{
Q_OBJECT
public:
explicit QQtClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtClickSoundLabel() {}
@ -38,21 +38,6 @@ signals:
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -73,33 +58,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
}
private:
QQtClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKSOUNDLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTCLICKSOUNDWIDGET_H
#define QQTCLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtclicksoundhelper.h>
#include <qqt-local.h>
@ -14,14 +14,14 @@
* Widget表示了如何使用QQtClickSoundHelper和它的子类
*
*/
class QQTSHARED_EXPORT QQtClickSoundWidget : public QQtWidget
class QQTSHARED_EXPORT QQtClickSoundWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtClickSoundWidget() {}
@ -36,21 +36,6 @@ signals:
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -71,33 +56,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
}
private:
QQtClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKSOUNDWIDGET_H

View File

@ -1,7 +1,7 @@
#ifndef QQTDOUBLECLICKSOUNDLABEL_H
#define QQTDOUBLECLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtdoubleclicksoundhelper.h>
#include <qqt-local.h>
@ -11,13 +11,13 @@
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtDoubleClickSoundLabel : public QQtLabel
class QQTSHARED_EXPORT QQtDoubleClickSoundLabel : public QQtVirtualClickLabel
{
public:
explicit QQtDoubleClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtDoubleClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtDoubleClickSoundLabel() {}
@ -36,21 +36,6 @@ signals:
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -81,32 +66,6 @@ protected:
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
}
private:
QQtDoubleClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKSOUNDLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTDOUBLECLICKSOUNDWIDGET_H
#define QQTDOUBLECLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtdoubleclicksoundhelper.h>
#include <qqt-local.h>
@ -13,14 +13,14 @@
* doubleClick支持的QQtClickSoundSoundWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtDoubleClickSoundWidget : public QQtWidget
class QQTSHARED_EXPORT QQtDoubleClickSoundWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtDoubleClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtDoubleClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtDoubleClickSoundWidget() {}
@ -39,21 +39,6 @@ signals:
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -84,32 +69,6 @@ protected:
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
}
private:
QQtDoubleClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKSOUNDWIDGET_H

View File

@ -1,7 +1,7 @@
#ifndef QQTLONGCLICKSOUNDLABEL_H
#define QQTLONGCLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtlongclicksoundhelper.h>
#include <qqt-local.h>
@ -12,14 +12,14 @@
* ClickHelper的能力
* Label服务
*/
class QQTSHARED_EXPORT QQtLongClickSoundLabel : public QQtLabel
class QQTSHARED_EXPORT QQtLongClickSoundLabel : public QQtVirtualClickLabel
{
Q_OBJECT
public:
explicit QQtLongClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtLongClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickSoundLabel() {}
@ -36,21 +36,6 @@ signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -75,34 +60,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
}
private:
QQtLongClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKSOUNDLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTLONGCLICKSOUNDWIDGET_H
#define QQTLONGCLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtlongclicksoundhelper.h>
#include <qqt-local.h>
@ -11,15 +11,15 @@
* ClickHelper的能力
* Widget服务
*/
class QQTSHARED_EXPORT QQtLongClickSoundWidget : public QQtWidget
class QQTSHARED_EXPORT QQtLongClickSoundWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtLongClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtLongClickSoundHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickSoundWidget() {}
@ -36,21 +36,6 @@ signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -75,33 +60,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
}
private:
QQtLongClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKSOUNDWIDGET_H

View File

@ -1,14 +1,9 @@
#include "qqtclickhelper.h"
QQtClickHelper::QQtClickHelper ( QObject* parent ) : QObject ( parent )
QQtClickHelper::QQtClickHelper ( QObject* parent ) : QQtVirtualClickHelper ( parent )
{
nClickNumWithCancel = 0;
nTotalClickNumWithCancel = 0;
nClickNum = 0;
nTotalClickNum = 0;
mClickType = QQtNullClick;
}
QQtClickHelper::~QQtClickHelper()
@ -77,6 +72,7 @@ void QQtClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWi
void QQtClickHelper::checkClickNumWithCancel()
{
QQtVirtualClickHelper::checkClickNumWithCancel();
switch ( mClickType )
{
case QQtClick:
@ -103,6 +99,7 @@ void QQtClickHelper::checkClickNumWithCancel()
void QQtClickHelper::checkClickNum ( QQtClickHelper::QQtClickType type )
{
QQtVirtualClickHelper::checkClickNum ( type );
switch ( type )
{
case QQtClick:

View File

@ -1,15 +1,11 @@
#ifndef QQTCLICKHELPER_H
#define QQTCLICKHELPER_H
#include <qqtvirtualclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
#if 0
#define p2debug() p2line()
#else
#define p2debug() QNoDebug()
#endif
/**
* QQtClickHelper
* Helper是给Widget响应按钮事件用的
@ -22,7 +18,7 @@
*
*
*/
class QQTSHARED_EXPORT QQtClickHelper : public QObject
class QQTSHARED_EXPORT QQtClickHelper : public QQtVirtualClickHelper
{
Q_OBJECT
@ -55,51 +51,25 @@ signals:
//调用于userWidget相对应的Event里
//允许重写
public:
virtual void mousePressEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mousePressEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
//optional
public:
inline const quint32 clickNum() const { return nClickNum; }
inline const quint64 totalClickNum() const { return nTotalClickNum; }
inline const quint32 clickNumWithCancel() const { return nClickNumWithCancel; }
inline const quint64 totalClickNumWithCancel() const { return nTotalClickNumWithCancel; }
/**
*
*/
public:
typedef enum
{
QQtNullClick = 0,
QQtClick,
QQtLongClick,
QQtDoubleClick,
QQtMaxClick
} QQtClickType;
Q_ENUMS ( QQtClickType )
protected:
//用于记录点击到了什么状态.
QQtClickType mClickType;
//用于记录按钮的位置
QPoint mPoint;
//click num
virtual void checkClickNumWithCancel();
virtual void checkClickNum ( QQtClickType type );
virtual void checkClickNumWithCancel() override;
virtual void checkClickNum ( QQtClickType type ) override;
quint32 nClickNum;
quint64 nTotalClickNum;
quint32 nClickNumWithCancel;
quint64 nTotalClickNumWithCancel;
};
#endif // QQTCLICKHELPER_H

View File

@ -1,7 +1,7 @@
#ifndef QQTCLICKLABEL_H
#define QQTCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
@ -16,14 +16,14 @@
* new ClickHelper
* installClickHelper
*/
class QQTSHARED_EXPORT QQtClickLabel : public QQtLabel
class QQTSHARED_EXPORT QQtClickLabel : public QQtVirtualClickLabel
{
Q_OBJECT
public:
explicit QQtClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtClickLabel() {}
@ -38,21 +38,6 @@ signals:
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -74,32 +59,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
}
private:
QQtClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTCLICKWIDGET_H
#define QQTCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
@ -13,15 +13,18 @@
* click支持的QQtWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*
* QQtClickWidget不建议继承,
* clickHelper,QQtWidget继承,仿ClickWidget新写一个Widget
* xxxClickHelper和xxxClickWidget是配对出现的.
*/
class QQTSHARED_EXPORT QQtClickWidget : public QQtWidget
class QQTSHARED_EXPORT QQtClickWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtClickWidget() {}
@ -36,27 +39,12 @@ signals:
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
protected:
virtual void connectClickHelper() {
virtual void connectClickHelper() override {
if ( !mClickHelper )
return;
@ -64,40 +52,13 @@ protected:
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
}
virtual void unConnectClickHelper() {
virtual void unConnectClickHelper() override {
if ( !mClickHelper )
return;
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
}
private:
QQtClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKWIDGET_H

View File

@ -1,7 +1,7 @@
#ifndef QQTDOUBLECLICKLABEL_H
#define QQTDOUBLECLICKLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
@ -11,13 +11,13 @@
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtDoubleClickLabel : public QQtLabel
class QQTSHARED_EXPORT QQtDoubleClickLabel : public QQtVirtualClickLabel
{
public:
explicit QQtDoubleClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtDoubleClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtDoubleClickLabel() {}
@ -36,21 +36,6 @@ signals:
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -81,32 +66,6 @@ protected:
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
}
private:
QQtDoubleClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTDOUBLECLICKWIDGET_H
#define QQTDOUBLECLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
@ -13,14 +13,14 @@
* doubleClick支持的QQtClickWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtDoubleClickWidget : public QQtWidget
class QQTSHARED_EXPORT QQtDoubleClickWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtDoubleClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtDoubleClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtDoubleClickWidget() {}
@ -39,21 +39,6 @@ signals:
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -83,33 +68,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this,
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
}
private:
QQtDoubleClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKWIDGET_H

View File

@ -1,7 +1,7 @@
#ifndef QQTLONGCLICKLABEL_H
#define QQTLONGCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtvirtualclicklabel.h>
#include <qqtlongclickhelper.h>
#include <qqt-local.h>
@ -12,14 +12,14 @@
* ClickHelper的能力
* Label服务
*/
class QQTSHARED_EXPORT QQtLongClickLabel : public QQtLabel
class QQTSHARED_EXPORT QQtLongClickLabel : public QQtVirtualClickLabel
{
Q_OBJECT
public:
explicit QQtLongClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
QQtVirtualClickLabel ( parent ) {
mClickHelper = new QQtLongClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickLabel() {}
@ -36,21 +36,6 @@ signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
@ -76,33 +61,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
}
private:
QQtLongClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKLABEL_H

View File

@ -1,7 +1,7 @@
#ifndef QQTLONGCLICKWIDGET_H
#define QQTLONGCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtvirtualclickwidget.h>
#include <qqtlongclickhelper.h>
#include <qqt-local.h>
@ -11,15 +11,15 @@
* ClickHelper的能力
* Widget服务
*/
class QQTSHARED_EXPORT QQtLongClickWidget : public QQtWidget
class QQTSHARED_EXPORT QQtLongClickWidget : public QQtVirtualClickWidget
{
Q_OBJECT
public:
explicit QQtLongClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
QQtVirtualClickWidget ( parent ) {
mClickHelper = new QQtLongClickHelper ( this );
mDefaultClickHelper = mClickHelper;
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickWidget() {}
@ -36,25 +36,7 @@ signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
// QQtVirtualClickWidget interface
protected:
virtual void connectClickHelper() {
if ( !mClickHelper )
@ -75,33 +57,6 @@ protected:
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
}
private:
QQtLongClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKWIDGET_H

View File

@ -0,0 +1,60 @@
#include "qqtvirtualclickhelper.h"
QQtVirtualClickHelper::QQtVirtualClickHelper ( QObject* parent ) : QObject ( parent )
{
nTotalClickNumWithCancel = 0;
nTotalClickNum = 0;
mClickType = QQtNullClick;
}
QQtVirtualClickHelper::~QQtVirtualClickHelper()
{
}
void QQtVirtualClickHelper::mousePressEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "press" << event->pos() << userWidget;
}
void QQtVirtualClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "release" << event->pos() << userWidget;
}
void QQtVirtualClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "double click" << event->pos() << userWidget;
}
void QQtVirtualClickHelper::checkClickNumWithCancel()
{
switch ( mClickType )
{
default:
break;
}
nTotalClickNumWithCancel = 0;
if ( nTotalClickNumWithCancel >= 0xFFFFFFFFFFFFFFFF )
{
p2debug() << "out......";
nTotalClickNumWithCancel = 0;
}
}
void QQtVirtualClickHelper::checkClickNum ( QQtVirtualClickHelper::QQtClickType type )
{
switch ( type )
{
default:
break;
}
nTotalClickNum = 0;
if ( nTotalClickNum >= 0xFFFFFFFFFFFFFFFF )
{
p2debug() << "out......";
nTotalClickNum = 0;
}
}

View File

@ -0,0 +1,86 @@
#ifndef QQTVIRTUALCLICKHELPER_H
#define QQTVIRTUALCLICKHELPER_H
#include <qqt-local.h>
#include <qqtcore.h>
#if 0
#define p2debug() p2line()
#else
#define p2debug() QNoDebug()
#endif
/**
* QQtVirtualClickHelper
* click的虚类
*
* Helper是给Widget响应按钮事件用的
* QQtWidget系列添加按钮信号识别帮助
*
*
*
*
*/
class QQTSHARED_EXPORT QQtVirtualClickHelper : public QObject
{
Q_OBJECT
public:
explicit QQtVirtualClickHelper ( QObject* parent = 0 );
virtual ~QQtVirtualClickHelper();
//发给业务层
//发回界面层
//这些信号不区分Widget,谁发过来都发出去,不论Widget
signals:
signals:
signals:
//调用于userWidget相对应的Event里
//重写
public:
virtual void mousePressEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
//optional
public:
inline const quint64 totalClickNum() const { return nTotalClickNum; }
inline const quint64 totalClickNumWithCancel() const { return nTotalClickNumWithCancel; }
/**
*
*/
public:
//允许支持的点击类型 可添加
typedef enum
{
QQtNullClick = 0,
QQtClick,
QQtLongClick,
QQtDoubleClick,
QQtMaxClick
} QQtClickType;
Q_ENUMS ( QQtClickType )
protected:
//用于记录点击到了什么状态.
QQtClickType mClickType;
//用于记录按钮的位置
QPoint mPoint;
//click num 要求重写
virtual void checkClickNumWithCancel();
virtual void checkClickNum ( QQtClickType type );
quint64 nTotalClickNum;
quint64 nTotalClickNumWithCancel;
};
#endif // QQTVIRTUALCLICKHELPER_H

View File

@ -0,0 +1 @@
#include "qqtvirtualclicklabel.h"

View File

@ -0,0 +1,153 @@
#ifndef QQTVIRTUALCLICKLABEL_H
#define QQTVIRTUALCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* Virtual Click Class
* ClickHelper的能力
* MouseEvent响应
*
* 使
* new ClickHelper
* installClickHelper
*/
class QQTSHARED_EXPORT QQtVirtualClickLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtVirtualClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mDefaultClickHelper = 0;
installEventFilter ( this );
}
virtual ~QQtVirtualClickLabel() {}
/**
* App用信号
*
*/
signals:
signals:
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
mClickHelper = mDefaultClickHelper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
protected:
virtual void connectClickHelper() {
if ( !mClickHelper )
return;
}
virtual void unConnectClickHelper() {
if ( !mClickHelper )
return;
}
protected:
QQtClickHelper* mClickHelper;
QQtClickHelper* mDefaultClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
// QObject interface
public:
virtual bool eventFilter ( QObject* watched, QEvent* event ) override {
//过滤掉不是自己的
if ( watched != this )
return QQtLabel::eventFilter ( watched, event );
//修复 paint bug
/*fix the parent handled bug terminally*/
if ( event->type() == QEvent::Paint )
return QQtLabel::eventFilter ( watched, event );
//+ fix bug
//处理press
if ( event->type() == QEvent::MouseButtonPress ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::LeftButton ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( e, this );
event->accept();
return true;
}
}
//处理release
if ( event->type() == QEvent::MouseButtonRelease ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::LeftButton ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( e, this );
event->accept();
return true;
}
}
//处理doubleclick
if ( event->type() == QEvent::MouseButtonDblClick ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::NoButton ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( e, this );
event->accept();
return true;
}
}
return QQtLabel::eventFilter ( watched, event );;
}
};
#endif // QQTVIRTUALCLICKLABEL_H

View File

@ -0,0 +1 @@
#include "qqtvirtualclickwidget.h"

View File

@ -0,0 +1,158 @@
#ifndef QQTVIRTUALCLICKWIDGET_H
#define QQTVIRTUALCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* ClickHelper空指针
*
* QQtVirtualClickWidget
* Click的功能
* click信号
*
*/
class QQTSHARED_EXPORT QQtVirtualClickWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtVirtualClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mDefaultClickHelper = 0;
installEventFilter ( this );
}
virtual ~QQtVirtualClickWidget() {}
/**
* App用信号
*
*/
signals:
signals:
/**
* 使
* 使
*/
public:
inline void installClickHelper ( QQtVirtualClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
mClickHelper = mDefaultClickHelper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtVirtualClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
protected:
virtual void connectClickHelper() {
if ( !mClickHelper )
return;
}
virtual void unConnectClickHelper() {
if ( !mClickHelper )
return;
}
protected:
/**
*
* .
* clickHelper的时候初始化DefaultClickHelper
*/
QQtVirtualClickHelper* mClickHelper;
QQtVirtualClickHelper* mDefaultClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
//if ( mClickHelper )
// mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
// QObject interface
public:
virtual bool eventFilter ( QObject* watched, QEvent* event ) override {
//过滤掉不是自己的
if ( watched != this )
return QQtWidget::eventFilter ( watched, event );
//修复 paint bug
/*fix the parent handled bug terminally*/
if ( event->type() == QEvent::Paint )
return QQtWidget::eventFilter ( watched, event );
//+ fix bug
//处理press
if ( event->type() == QEvent::MouseButtonPress ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::LeftButton ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( e, this );
event->accept();
return true;
}
}
//处理release
if ( event->type() == QEvent::MouseButtonRelease ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::LeftButton ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( e, this );
event->accept();
return true;
}
}
//处理doubleclick
if ( event->type() == QEvent::MouseButtonDblClick ) {
QMouseEvent* e = ( QMouseEvent* ) event;
//pline() << hex << e->button();
if ( e->button() == Qt::NoButton ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( e, this );
event->accept();
return true;
}
}
return QQtWidget::eventFilter ( watched, event );;
}
};
#endif // QQTVIRTUALCLICKWIDGET_H

View File

@ -6,7 +6,7 @@
#注释在qqt_header.pri打开 DEFINES += __PLUGINSUPPORT__
#TODO: macOS runtime crash
contains (DEFINES, __PLUGINSUPPORT__) {
contains(QSYS_PRIVATE, Win32|Windows|Win64) {
contains(QSYS_PRIVATE, Win32|Windows|Win64 || MSVC32|MSVC|MSVC64) {
contains (DEFINES, QQT_LIBRARY) {
DEFINES += BUILD_QDEVICEWATCHER_LIB
} else: contains (DEFINES, QQT_STATIC_LIBRARY) {
@ -118,7 +118,7 @@ contains (DEFINES, __EXQUISITE__) {
#qrdecode widget
#注释在qqt_header.pri打开 DEFINES += __QRDECODE__
contains (DEFINES, __QRDECODE__) {
contains(QSYS_PRIVATE, Win32|Windows|Win64) {
contains(QSYS_PRIVATE, Win32|Windows|Win64 || MSVC32|MSVC|MSVC64) {
#ignore: QZXing has no need to export
contains (DEFINES, QQT_LIBRARY) {
DEFINES += QZXING_LIBRARY
@ -138,7 +138,7 @@ contains (DEFINES, __EXQUISITE__) {
#mathml widget
#注释在qqt_header.pri打开 DEFINES += __MATHWIDGETSUPPORT__
contains (DEFINES, __MATHWIDGETSUPPORT__) {
contains(QSYS_PRIVATE, Win32|Windows|Win64) {
contains(QSYS_PRIVATE, Win32|Windows|Win64 || MSVC32|MSVC|MSVC64) {
#mathml
contains (DEFINES, QQT_LIBRARY) {
DEFINES += QT_QTMMLWIDGET_LIBRARY

View File

@ -19,7 +19,7 @@ HEADERS += $$PWD/qqt.h \
$$PWD/qqtversion.h \
$$PWD/qqt-qt.h
#platform header
contains (QSYS_PRIVATE, Win32|Windows||Win64) {
contains (QSYS_PRIVATE, Win32|Windows|Win64 || MSVC32|MSVC|MSVC64) {
#win32 base header
HEADERS += $$PWD/qqtwin.h
} else:contains (QSYS_PRIVATE, macOS||iOS||iOSSimulator) {
@ -369,28 +369,34 @@ contains (DEFINES, __EXQUISITE__) {
contains (DEFINES, __CLICKWIDGETS__) {
SOURCES += \
$$PWD/exquisite/clickwidgets/qqtvirtualclickhelper.cpp \
$$PWD/exquisite/clickwidgets/qqtclickhelper.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclickhelper.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclickhelper.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtvirtualclickhelper.h \
$$PWD/exquisite/clickwidgets/qqtclickhelper.h \
$$PWD/exquisite/clickwidgets/qqtlongclickhelper.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclickhelper.h
SOURCES += \
$$PWD/exquisite/clickwidgets/qqtvirtualclickwidget.cpp \
$$PWD/exquisite/clickwidgets/qqtclickwidget.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclickwidget.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclickwidget.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtvirtualclickwidget.h \
$$PWD/exquisite/clickwidgets/qqtclickwidget.h \
$$PWD/exquisite/clickwidgets/qqtlongclickwidget.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclickwidget.h
SOURCES += \
$$PWD/exquisite/clickwidgets/qqtvirtualclicklabel.cpp \
$$PWD/exquisite/clickwidgets/qqtclicklabel.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclicklabel.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclicklabel.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtvirtualclicklabel.h \
$$PWD/exquisite/clickwidgets/qqtclicklabel.h \
$$PWD/exquisite/clickwidgets/qqtlongclicklabel.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclicklabel.h

View File

@ -17,6 +17,13 @@ MainWindow::MainWindow ( QWidget* parent ) :
connect ( ui->widget, SIGNAL ( longClick() ),
this, SLOT ( set3Sum() ) );
connect ( ui->widget_4, SIGNAL ( click() ),
this, SLOT ( set31Sum() ) );
connect ( ui->widget_4, SIGNAL ( doubleClick() ),
this, SLOT ( set32Sum() ) );
connect ( ui->widget_4, SIGNAL ( longClick() ),
this, SLOT ( set33Sum() ) );
connect ( ui->widget_2, SIGNAL ( click() ),
this, SLOT ( set4Sum() ) );
connect ( ui->widget_2, SIGNAL ( longClick() ),
@ -47,6 +54,21 @@ void MainWindow::set3Sum()
ui->textBrowser->append ( QString ( "%1 long click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
}
void MainWindow::set31Sum()
{
ui->textBrowser->append ( QString ( "child %1 click" ).arg ( ui->widget_4->clickHelper()->totalClickNum() ) );;
}
void MainWindow::set32Sum()
{
ui->textBrowser->append ( QString ( "child %1 double click" ).arg ( ui->widget_4->clickHelper()->totalClickNum() ) );;
}
void MainWindow::set33Sum()
{
ui->textBrowser->append ( QString ( "child %1 long click" ).arg ( ui->widget_4->clickHelper()->totalClickNum() ) );;
}
void MainWindow::set4Sum()
{
ui->textBrowser_2->append ( QString ( "%1 click" ).arg ( ui->widget_2->clickHelper()->totalClickNum() ) );;

View File

@ -19,6 +19,9 @@ public slots:
void setSum();
void set2Sum();
void set3Sum();
void set31Sum();
void set32Sum();
void set33Sum();
void set4Sum();
void set5Sum();

View File

@ -36,6 +36,36 @@
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>191</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QQtDoubleClickWidget" name="widget_4" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QWidget#widget_4 {
background-color: rgb(164, 0, 0);
}</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -90,7 +120,7 @@
<x>0</x>
<y>0</y>
<width>816</width>
<height>17</height>
<height>39</height>
</rect>
</property>
</widget>

View File

@ -18,21 +18,21 @@ MainWindow::MainWindow ( QWidget* parent ) :
connect ( ui->widget, SIGNAL ( longClick() ),
this, SLOT ( set3Sum() ) );
ui->widget->clickHelper()->setClickSound ( qrc ( "click.wav" ) );
ui->widget->clickHelper()->setLongClickSound ( qrc ( "longclick.wav" ) );
ui->widget->clickHelper()->setDoubleClickSound ( qrc ( "doubleclick.wav" ) );
( ( QQtDoubleClickSoundHelper* ) ( ui->widget->clickHelper() ) )->setClickSound ( qrc ( "click.wav" ) );
( ( QQtDoubleClickSoundHelper* ) ( ui->widget->clickHelper() ) )->setLongClickSound ( qrc ( "longclick.wav" ) );
( ( QQtDoubleClickSoundHelper* ) ( ui->widget->clickHelper() ) )->setDoubleClickSound ( qrc ( "doubleclick.wav" ) );
connect ( ui->widget_2, SIGNAL ( click() ),
this, SLOT ( set4Sum() ) );
connect ( ui->widget_2, SIGNAL ( longClick() ),
this, SLOT ( set5Sum() ) );
ui->widget_2->clickHelper()->setClickSound ( qrc ( "click.wav" ) );
ui->widget_2->clickHelper()->setLongClickSound ( qrc ( "longclick.wav" ) );
( ( QQtLongClickSoundHelper* ) ( ui->widget_2->clickHelper() ) )->setClickSound ( qrc ( "click.wav" ) );
( ( QQtLongClickSoundHelper* ) ( ui->widget_2->clickHelper() ) )->setLongClickSound ( qrc ( "longclick.wav" ) );
connect ( ui->widget_3, SIGNAL ( click() ),
this, SLOT ( set6Sum() ) );
ui->widget_3->clickHelper()->setClickSound ( qrc ( "click.wav" ) );
( ( QQtClickSoundHelper* ) ( ui->widget_3->clickHelper() ) )->setClickSound ( qrc ( "click.wav" ) );
}
MainWindow::~MainWindow()

View File

@ -29,7 +29,7 @@ int main ( int argc, char* argv[] )
QQtDictionary d1;
QQtDictionary d2 ( QVariant ( "CCCC" ) );
d1.appendChild ( d2 );
d1.addChild ( d2 );
pline() << d1[0].getValue();
d1[0] = "ff";
pline() << d1[0].getValue();
@ -43,7 +43,7 @@ int main ( int argc, char* argv[] )
for ( int i = 0; i < 5; i++ )
{
QQtDictionary d ( QVariant ( QString::number ( i ) ) );
d4.appendChild ( d );
d4.addChild ( d );
}
pline() << d4.count();
@ -56,20 +56,20 @@ int main ( int argc, char* argv[] )
QQtDictionary d5;
/*后续有map操作这一步就没有用了*/
d5.appendChild ( "5.7" );
d5.appendChild ( "5.8" );
d5.appendChild ( "5.9" );
d5.addChild ( "5.7" );
d5.addChild ( "5.8" );
d5.addChild ( "5.9" );
/*后续有map操作这一步就没有用了*/
d5["5.7"].appendChild ( "5.7.2" );
d5["5.7"].appendChild ( "5.7.3" );
d5["5.7"].appendChild ( "5.7.4" );
d5["5.7"].addChild ( "5.7.2" );
d5["5.7"].addChild ( "5.7.3" );
d5["5.7"].addChild ( "5.7.4" );
d5["5.7"]["5.7.4"].appendChild ( "xxx.dmg" );
d5["5.7"]["5.7.4"][0].appendChild ( "xxx.dmg" );
d5["5.7"]["5.7.4"][0].appendChild ( "2017-12-12" );
d5["5.7"]["5.7.4"][0].appendChild ( "1.2G" );
d5["5.7"]["5.7.4"][0].appendChild ( "Detail" );
d5["5.7"]["5.7.4"].addChild ( "xxx.dmg" );
d5["5.7"]["5.7.4"][0].addChild ( "xxx.dmg" );
d5["5.7"]["5.7.4"][0].addChild ( "2017-12-12" );
d5["5.7"]["5.7.4"][0].addChild ( "1.2G" );
d5["5.7"]["5.7.4"][0].addChild ( "Detail" );
d5["5.7"]["5.7.4"][0].insertChild ( 4, "Detail2" );
//pline() << "\n" << d5;
@ -97,7 +97,7 @@ int main ( int argc, char* argv[] )
/*在这里有list操作前边"5.7"的map就没有用了*/
/*但是再过去做过的list类型的操作都会被保留也就是说中间出现过概念错误没问题还保留着*/
d5["5.7"].appendChild ( "5.7.5" );
d5["5.7"].addChild ( "5.7.5" );
for ( int i = 0; i < d5["5.7"].count(); i++ )
{
@ -114,7 +114,7 @@ int main ( int argc, char* argv[] )
//Widget w;
//w.show();
//QQtDictionary appendChild函数存在一个问题在这里测试是否解决。
//QQtDictionary addChild函数存在一个问题在这里测试是否解决。
//内部实现使用list的append函数会引用外部的类实例这导致在free空间的时候存在很多莫名其妙的二次free尤其外部实例和QObject关联的时候。
//现在内部实现使用push_back这里检测QQtDictionary还有没有二次free这个bug。
QQtDictionary* n0 = new QQtDictionary ( QVariant ( "This is a value" ) );
@ -123,8 +123,8 @@ int main ( int argc, char* argv[] )
pline() << hex << n0->getValue().constData();
QQtDictionary t0;
//这里appendChildt0变成一个list。
t0.appendChild ( *n0 );
//这里addChildt0变成一个list。
t0.addChild ( *n0 );
//这里更改外部实例的值,显然外部实例的值已经改变了。
n0->getValue().setValue<QString> ( "This is a changed value" );
@ -155,9 +155,9 @@ int main ( int argc, char* argv[] )
pline() << v0;
QQtDictionary v1;
v1.appendChild ( "CCCC" );
v1.appendChild ( "DDDD" );
v1[0].appendChild ( "2-CCCC" );
v1.addChild ( "CCCC" );
v1.addChild ( "DDDD" );
v1[0].addChild ( "2-CCCC" );
pline() << v1;
pline() << v1[0];