mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
Merge branch 'master' of https://gitee.com/drabel/LibQQt
This commit is contained in:
commit
739d524b04
@ -54,8 +54,7 @@ SUBDIRS =
|
||||
#need GumoQuery
|
||||
#-----------------------------------------------------------------
|
||||
#greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/QtSdkManager
|
||||
#
|
||||
greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
|
||||
#greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
|
||||
#SUBDIRS += demo/GuiBuildTool
|
||||
#SUBDIRS += demo/LearnCookieTest
|
||||
#-----------------------------------------------------------------
|
||||
@ -114,3 +113,5 @@ greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
|
||||
#SUBDIRS += demo/TouchMonitor
|
||||
#SUBDIRS += demo/TouchMonitorServer
|
||||
|
||||
SUBDIRS += test/QQtWidgetClickHelperTest
|
||||
#SUBDIRS += test/QQtWidgetClickSoundHelperTest
|
||||
|
@ -103,11 +103,6 @@ contains (CONFIG, QQT_SOURCE_BUILDIN) {
|
||||
#App修改源代码,Creator会自动qmake,启动qmake步骤PRILINK+POSTLINK
|
||||
#App修改pro,必须手动qmake,Creator才会qmake,启动qmake步骤PRILINK+POSTLINK
|
||||
#App必须注意,此处不再持续编译QQt.
|
||||
#QQt持续编译配置开关
|
||||
CONFIG += continued_build
|
||||
contains(CONFIG, continued_build){
|
||||
system("touch $${QQT_SOURCE_ROOT}/frame/qqtapplication.cpp")
|
||||
}
|
||||
include ($${QQT_SOURCE_ROOT}/qqt_install.pri)
|
||||
|
||||
#in this pri use QQT_SDK_ROOT QQT_SDK_PWD QQT_LIB_PWD
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef QQTCORE_H
|
||||
#ifndef QQTCORE_H
|
||||
#define QQTCORE_H
|
||||
|
||||
#include <QWidget>
|
||||
@ -118,12 +118,13 @@ QQTSHARED_EXPORT void QQtSleep ( int millsecond );
|
||||
|
||||
|
||||
#define pline() qDebug() << __FILE__ << __LINE__/*QString("%1").arg(__LINE__, 3, 10)*/ << __func__
|
||||
#define perr(req, rsl) if(req == rsl) pline() << hex << rsl
|
||||
#define ptime() pline() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz")
|
||||
#define p2line() qDebug() << QString(__FILE__).split('/').last() << QString("%1").arg(__LINE__, 3, 10) << __func__
|
||||
//-----------------------
|
||||
#define perr(req, rsl) if(req == rsl) pline() << hex << rsl
|
||||
#define pmeta(inst) pline() << inst->metaObject()->className()
|
||||
#define pdebug() qDebug()
|
||||
#define pdebugo() qDebug().nospace()
|
||||
//-----------------------
|
||||
#define pdebug_nospace() qDebug().nospace()
|
||||
#define packline() pline() << qDebug().nospace()
|
||||
|
||||
QQTSHARED_EXPORT QByteArray& operator<< ( QByteArray& l, const quint8& r );
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 ( );
|
||||
|
2
src/core/qqtevent.cpp
Normal file
2
src/core/qqtevent.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "qqtevent.h"
|
||||
|
66
src/core/qqtevent.h
Normal file
66
src/core/qqtevent.h
Normal file
@ -0,0 +1,66 @@
|
||||
#ifndef QQTEVENT_H
|
||||
#define QQTEVENT_H
|
||||
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include "qqt-qt.h"
|
||||
#include <qqt-local.h>
|
||||
|
||||
|
||||
class QQTSHARED_EXPORT QQtMouseEvent : public QMouseEvent
|
||||
{
|
||||
public:
|
||||
QQtMouseEvent() :
|
||||
QMouseEvent ( MouseButtonPress, QPointF(), QPointF(), QPointF(),
|
||||
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ) {
|
||||
|
||||
}
|
||||
virtual ~QQtMouseEvent() {}
|
||||
|
||||
public:
|
||||
//设置
|
||||
QQtMouseEvent& operator= ( const QMouseEvent& other ) {
|
||||
QQtMouseEvent& ref = *this;
|
||||
ref.setType ( other.type() );
|
||||
ref.localPos() = other.localPos();
|
||||
ref.windowPos() = other.windowPos();
|
||||
ref.screenPos() = other.screenPos();
|
||||
|
||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||
ref.pos() = other.pos();
|
||||
ref.globalPos() = other.globalPos();
|
||||
#endif
|
||||
|
||||
ref.button() = other.button();
|
||||
ref.buttons() = other.buttons();
|
||||
ref.setModifiers ( other.modifiers() );
|
||||
|
||||
//source 无解
|
||||
return ref;
|
||||
}
|
||||
//读取
|
||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||
inline QPoint& pos() { return _l; }
|
||||
inline QPoint& globalPos() { return _s; }
|
||||
inline int& x() { return _l.rx(); }
|
||||
inline int& y() { return _l.ry(); }
|
||||
inline int& globalX() { return _s.rx(); }
|
||||
inline int& globalY() { return _s.ry(); }
|
||||
#endif
|
||||
QPointF& localPos() { return l; }
|
||||
QPointF& windowPos() { return w; }
|
||||
QPointF& screenPos() { return s; }
|
||||
|
||||
inline Qt::MouseButton& button() { return b; }
|
||||
inline Qt::MouseButtons& buttons() { return mouseState; }
|
||||
|
||||
//inline Qt::MouseEventSource& source() { return sou}
|
||||
//inline Qt::MouseEventFlags& flags();
|
||||
|
||||
inline void setType ( const Type& _t ) { t = _t; }
|
||||
|
||||
protected:
|
||||
QPoint _l, _w, _s;
|
||||
};
|
||||
|
||||
#endif // QQTEVENT_H
|
1
src/exquisite/clicksoundwidgets/qqtclicksoundhelper.cpp
Normal file
1
src/exquisite/clicksoundwidgets/qqtclicksoundhelper.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtclicksoundhelper.h"
|
47
src/exquisite/clicksoundwidgets/qqtclicksoundhelper.h
Normal file
47
src/exquisite/clicksoundwidgets/qqtclicksoundhelper.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef QQTCLICKSOUNDHELPER_H
|
||||
#define QQTCLICKSOUNDHELPER_H
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
#include <qqtclickhelper.h>
|
||||
#include <qqtsoundeffect.h>
|
||||
|
||||
/**
|
||||
* QQtClickSoundHelper
|
||||
*
|
||||
* 为Widget提供按键声音支持.
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
*
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickSoundHelper : public QQtClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtClickSoundHelper ( QObject* parent = 0 ) : QQtClickHelper ( parent ) {
|
||||
connect ( this, SIGNAL ( click() ), this, SLOT ( slotClick() ) );
|
||||
}
|
||||
virtual ~QQtClickSoundHelper() {}
|
||||
|
||||
void setClickSound ( const QString clickSoundFile ) {
|
||||
this->clickSoundFile = clickSoundFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部
|
||||
*/
|
||||
public slots:
|
||||
void slotClick() {
|
||||
if ( clickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( clickSoundFile );
|
||||
}
|
||||
|
||||
private:
|
||||
QString clickSoundFile;
|
||||
};
|
||||
|
||||
#endif // QQTCLICKSOUNDHELPER_H
|
1
src/exquisite/clicksoundwidgets/qqtclicksoundlabel.cpp
Normal file
1
src/exquisite/clicksoundwidgets/qqtclicksoundlabel.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtclicksoundlabel.h"
|
63
src/exquisite/clicksoundwidgets/qqtclicksoundlabel.h
Normal file
63
src/exquisite/clicksoundwidgets/qqtclicksoundlabel.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef QQTCLICKSOUNDLABEL_H
|
||||
#define QQTCLICKSOUNDLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个basic类 提供click信号
|
||||
* 提供安装ClickHelper的能力
|
||||
* 提供MouseEvent响应
|
||||
*
|
||||
* 用户使用方法
|
||||
* new ClickHelper
|
||||
* installClickHelper
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickSoundLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtClickSoundLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtClickSoundLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTCLICKSOUNDLABEL_H
|
1
src/exquisite/clicksoundwidgets/qqtclicksoundwidget.cpp
Normal file
1
src/exquisite/clicksoundwidgets/qqtclicksoundwidget.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtclicksoundwidget.h"
|
61
src/exquisite/clicksoundwidgets/qqtclicksoundwidget.h
Normal file
61
src/exquisite/clicksoundwidgets/qqtclicksoundwidget.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef QQTCLICKSOUNDWIDGET_H
|
||||
#define QQTCLICKSOUNDWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 内置ClickHelper
|
||||
*
|
||||
* 添加了clickSound支持的QQtWidget
|
||||
* 这个Widget表示了如何使用QQtClickSoundHelper和它的子类
|
||||
*
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickSoundWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtClickSoundWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtClickSoundWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTCLICKSOUNDWIDGET_H
|
@ -0,0 +1 @@
|
||||
#include "qqtdoubleclicksoundhelper.h"
|
69
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundhelper.h
Normal file
69
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundhelper.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef QQTDOUBLECLICKSOUNDHELPER_H
|
||||
#define QQTDOUBLECLICKSOUNDHELPER_H
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
#include <qqtdoubleclickhelper.h>
|
||||
#include <qqtsoundeffect.h>
|
||||
|
||||
/**
|
||||
* QQtDoubleClickSoundHelper
|
||||
*
|
||||
* 为Widget提供按键声音支持.
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
*
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickSoundHelper : public QQtDoubleClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtDoubleClickSoundHelper ( QObject* parent = 0 ) : QQtDoubleClickHelper ( parent ) {
|
||||
connect ( this, SIGNAL ( click() ), this, SLOT ( slotClick() ) );
|
||||
connect ( this, SIGNAL ( longClick() ), this, SLOT ( slotLongClick() ) );
|
||||
connect ( this, SIGNAL ( doubleClick() ), this, SLOT ( slotDoubleClick() ) );
|
||||
}
|
||||
virtual ~QQtDoubleClickSoundHelper() {}
|
||||
|
||||
void setClickSound ( const QString clickSoundFile ) {
|
||||
this->clickSoundFile = clickSoundFile;
|
||||
}
|
||||
void setLongClickSound ( const QString clickSoundFile ) {
|
||||
this->longClickSoundFile = clickSoundFile;
|
||||
}
|
||||
void setDoubleClickSound ( const QString clickSoundFile ) {
|
||||
this->doubleClickSoundFile = clickSoundFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部
|
||||
*/
|
||||
public slots:
|
||||
void slotClick() {
|
||||
if ( clickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( clickSoundFile );
|
||||
}
|
||||
void slotLongClick() {
|
||||
if ( longClickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( longClickSoundFile );
|
||||
}
|
||||
void slotDoubleClick() {
|
||||
if ( doubleClickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( doubleClickSoundFile );
|
||||
}
|
||||
|
||||
private:
|
||||
QString clickSoundFile;
|
||||
QString longClickSoundFile;
|
||||
QString doubleClickSoundFile;
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKSOUNDHELPER_H
|
@ -0,0 +1 @@
|
||||
#include "qqtdoubleclicksoundlabel.h"
|
71
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundlabel.h
Normal file
71
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundlabel.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef QQTDOUBLECLICKSOUNDLABEL_H
|
||||
#define QQTDOUBLECLICKSOUNDLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtdoubleclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个虚类
|
||||
* 提供安装ClickHelper的能力
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickSoundLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
public:
|
||||
explicit QQtDoubleClickSoundLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtDoubleClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtDoubleClickSoundLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
void doubleClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this, SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this,
|
||||
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKSOUNDLABEL_H
|
@ -0,0 +1 @@
|
||||
#include "qqtdoubleclicksoundwidget.h"
|
74
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundwidget.h
Normal file
74
src/exquisite/clicksoundwidgets/qqtdoubleclicksoundwidget.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef QQTDOUBLECLICKSOUNDWIDGET_H
|
||||
#define QQTDOUBLECLICKSOUNDWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtdoubleclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 内置DoubleClickHelper
|
||||
*
|
||||
* 添加了doubleClick支持的QQtClickSoundSoundWidget
|
||||
* 这个Widget表示了如何使用QQtWidgetClickHelper和它的子类
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickSoundWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtDoubleClickSoundWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtDoubleClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtDoubleClickSoundWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
void doubleClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this, SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this,
|
||||
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKSOUNDWIDGET_H
|
@ -0,0 +1 @@
|
||||
#include "qqtlongclicksoundhelper.h"
|
58
src/exquisite/clicksoundwidgets/qqtlongclicksoundhelper.h
Normal file
58
src/exquisite/clicksoundwidgets/qqtlongclicksoundhelper.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef QQTLONGCLICKSOUNDHELPER_H
|
||||
#define QQTLONGCLICKSOUNDHELPER_H
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
#include <qqtlongclickhelper.h>
|
||||
#include <qqtsoundeffect.h>
|
||||
|
||||
/**
|
||||
* QQtLongClickSoundHelper
|
||||
*
|
||||
* 为Widget提供按键声音支持.
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
*
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickSoundHelper : public QQtLongClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtLongClickSoundHelper ( QObject* parent = 0 ) : QQtLongClickHelper ( parent ) {
|
||||
connect ( this, SIGNAL ( click() ), this, SLOT ( slotClick() ) );
|
||||
connect ( this, SIGNAL ( longClick() ), this, SLOT ( slotLongClick() ) );
|
||||
}
|
||||
virtual ~QQtLongClickSoundHelper() {}
|
||||
|
||||
inline void setClickSound ( const QString clickSoundFile ) {
|
||||
this->clickSoundFile = clickSoundFile;
|
||||
}
|
||||
inline void setLongClickSound ( const QString clickSoundFile ) {
|
||||
this->longClickSoundFile = clickSoundFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部
|
||||
*/
|
||||
public slots:
|
||||
void slotClick() {
|
||||
if ( clickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( clickSoundFile );
|
||||
}
|
||||
void slotLongClick() {
|
||||
if ( longClickSoundFile.isEmpty() )
|
||||
return;
|
||||
|
||||
QQtWavSound ( longClickSoundFile );
|
||||
}
|
||||
|
||||
private:
|
||||
QString clickSoundFile;
|
||||
QString longClickSoundFile;
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKSOUNDHELPER_H
|
@ -0,0 +1 @@
|
||||
#include "qqtlongclicksoundlabel.h"
|
65
src/exquisite/clicksoundwidgets/qqtlongclicksoundlabel.h
Normal file
65
src/exquisite/clicksoundwidgets/qqtlongclicksoundlabel.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef QQTLONGCLICKSOUNDLABEL_H
|
||||
#define QQTLONGCLICKSOUNDLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtlongclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个虚类
|
||||
* 提供安装ClickHelper的能力
|
||||
* 为确定功能的子类Label服务
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickSoundLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtLongClickSoundLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtLongClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtLongClickSoundLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKSOUNDLABEL_H
|
@ -0,0 +1 @@
|
||||
#include "qqtlongclicksoundwidget.h"
|
65
src/exquisite/clicksoundwidgets/qqtlongclicksoundwidget.h
Normal file
65
src/exquisite/clicksoundwidgets/qqtlongclicksoundwidget.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef QQTLONGCLICKSOUNDWIDGET_H
|
||||
#define QQTLONGCLICKSOUNDWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtlongclicksoundhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 提供安装ClickHelper的能力
|
||||
* 为确定功能的子类Widget服务
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickSoundWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtLongClickSoundWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtLongClickSoundHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtLongClickSoundWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKSOUNDWIDGET_H
|
125
src/exquisite/clickwidgets/qqtclickhelper.cpp
Normal file
125
src/exquisite/clickwidgets/qqtclickhelper.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "qqtclickhelper.h"
|
||||
|
||||
QQtClickHelper::QQtClickHelper ( QObject* parent ) : QQtVirtualClickHelper ( parent )
|
||||
{
|
||||
nClickNumWithCancel = 0;
|
||||
nClickNum = 0;
|
||||
}
|
||||
|
||||
QQtClickHelper::~QQtClickHelper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QQtClickHelper::mousePressEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "press" << event->pos() << userWidget;
|
||||
mPoint = event->pos();
|
||||
mClickType = QQtClick;
|
||||
}
|
||||
|
||||
void QQtClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "release" << event->pos() << userWidget;
|
||||
|
||||
mClickType = QQtClick;
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtClick );
|
||||
|
||||
//发送单击信号
|
||||
p2debug() << "send click." ;
|
||||
emit click();
|
||||
emit clickWithPoint ( event->pos() );
|
||||
emit clickWithPointF ( event->localPos() );
|
||||
|
||||
#if 0
|
||||
emit click ( userWidget );
|
||||
emit clickWithPoint ( event->pos(), userWidget );
|
||||
emit clickWithPointF ( event->localPos(), userWidget );
|
||||
#endif
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//保存位置
|
||||
mPoint = event->pos();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void QQtClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "double click" << event->pos() << userWidget;
|
||||
mPoint = event->pos();
|
||||
}
|
||||
|
||||
void QQtClickHelper::checkClickNumWithCancel()
|
||||
{
|
||||
QQtVirtualClickHelper::checkClickNumWithCancel();
|
||||
switch ( mClickType )
|
||||
{
|
||||
case QQtClick:
|
||||
{
|
||||
nClickNumWithCancel++;
|
||||
if ( nClickNumWithCancel >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNumWithCancel = nClickNumWithCancel;
|
||||
if ( nTotalClickNumWithCancel >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QQtClickHelper::checkClickNum ( QQtClickHelper::QQtClickType type )
|
||||
{
|
||||
QQtVirtualClickHelper::checkClickNum ( type );
|
||||
switch ( type )
|
||||
{
|
||||
case QQtClick:
|
||||
{
|
||||
nClickNum++;
|
||||
if ( nClickNum >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nClickNum = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNum = nClickNum;
|
||||
if ( nTotalClickNum >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNum = 0;
|
||||
}
|
||||
}
|
75
src/exquisite/clickwidgets/qqtclickhelper.h
Normal file
75
src/exquisite/clickwidgets/qqtclickhelper.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef QQTCLICKHELPER_H
|
||||
#define QQTCLICKHELPER_H
|
||||
|
||||
#include <qqtvirtualclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* QQtClickHelper
|
||||
* 这个Helper是给Widget响应按钮事件用的
|
||||
* 主要用于为QQtWidget系列添加按钮信号识别帮助
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
* longClick
|
||||
* 不支持DoubleClick, doubleClick会导致click延时
|
||||
*
|
||||
* 可以统计按键次数
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickHelper : public QQtVirtualClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtClickHelper ( QObject* parent = 0 );
|
||||
virtual ~QQtClickHelper();
|
||||
|
||||
//发给业务层
|
||||
//发回界面层
|
||||
//这些信号不区分Widget,谁发过来都发出去,不论Widget
|
||||
signals:
|
||||
void click();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
|
||||
signals:
|
||||
void clickWithPointF ( QPointF point );
|
||||
|
||||
#if 0
|
||||
//发给业务层
|
||||
//发回界面层
|
||||
//这里的信号都带着Widget指针,可以区分Widget
|
||||
signals:
|
||||
void click ( QWidget* userWidget );
|
||||
void clickWithPoint ( QPoint point, QWidget* userWidget );
|
||||
void clickWithPointF ( QPointF point, QWidget* userWidget );
|
||||
#endif
|
||||
|
||||
//调用于userWidget相对应的Event里
|
||||
//允许重写
|
||||
public:
|
||||
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 quint32 clickNumWithCancel() const { return nClickNumWithCancel; }
|
||||
|
||||
/**
|
||||
* 以下用于内部
|
||||
*/
|
||||
protected:
|
||||
//click num
|
||||
virtual void checkClickNumWithCancel() override;
|
||||
virtual void checkClickNum ( QQtClickType type ) override;
|
||||
|
||||
quint32 nClickNum;
|
||||
quint32 nClickNumWithCancel;
|
||||
};
|
||||
|
||||
#endif // QQTCLICKHELPER_H
|
1
src/exquisite/clickwidgets/qqtclicklabel.cpp
Normal file
1
src/exquisite/clickwidgets/qqtclicklabel.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtclicklabel.h"
|
64
src/exquisite/clickwidgets/qqtclicklabel.h
Normal file
64
src/exquisite/clickwidgets/qqtclicklabel.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef QQTCLICKLABEL_H
|
||||
#define QQTCLICKLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个basic类 提供click信号
|
||||
* 提供安装ClickHelper的能力
|
||||
* 提供MouseEvent响应
|
||||
*
|
||||
* 用户使用方法
|
||||
* new ClickHelper
|
||||
* installClickHelper
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtClickLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtClickLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // QQTCLICKLABEL_H
|
1
src/exquisite/clickwidgets/qqtclickwidget.cpp
Normal file
1
src/exquisite/clickwidgets/qqtclickwidget.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtclickwidget.h"
|
64
src/exquisite/clickwidgets/qqtclickwidget.h
Normal file
64
src/exquisite/clickwidgets/qqtclickwidget.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef QQTCLICKWIDGET_H
|
||||
#define QQTCLICKWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 内置ClickHelper
|
||||
*
|
||||
* 添加了click支持的QQtWidget
|
||||
* 这个Widget表示了如何使用QQtWidgetClickHelper和它的子类
|
||||
*
|
||||
* 注意QQtClickWidget不建议继承,
|
||||
* 如果用户添加了新的clickHelper,那么从QQtWidget继承,仿照这几个ClickWidget新写一个Widget
|
||||
* xxxClickHelper和xxxClickWidget是配对出现的.
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtClickWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtClickWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtClickWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() override {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() override {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTCLICKWIDGET_H
|
329
src/exquisite/clickwidgets/qqtdoubleclickhelper.cpp
Normal file
329
src/exquisite/clickwidgets/qqtdoubleclickhelper.cpp
Normal file
@ -0,0 +1,329 @@
|
||||
#include "qqtdoubleclickhelper.h"
|
||||
|
||||
QQtDoubleClickHelper::QQtDoubleClickHelper ( QObject* parent ) :
|
||||
QQtLongClickHelper ( parent )
|
||||
{
|
||||
mDoubleClickInterval = doubleClickInterval;
|
||||
|
||||
nDoubleClickNum = 0;
|
||||
nDoubleClickNumWithCancel = 0;
|
||||
|
||||
prev_doubleclick = QTime::currentTime().addMSecs ( 3 );
|
||||
now_doubleclick = QTime::currentTime().addMSecs ( 4 );
|
||||
|
||||
p2debug() << prev_doubleclick.msecsTo ( now_doubleclick );
|
||||
|
||||
prev_release = QTime::currentTime().addMSecs ( 5 );
|
||||
now_release_initial = QTime::currentTime().addMSecs ( 6 );
|
||||
|
||||
mMouseEvent = new QQtMouseEvent;
|
||||
|
||||
m_click_timer = new QTimer ( this );
|
||||
m_click_timer->setSingleShot ( false );
|
||||
//击发延迟20ms
|
||||
m_click_timer->setInterval ( 20 );
|
||||
connect ( m_click_timer, SIGNAL ( timeout() ), this, SLOT ( slotClickTimeout() ) );
|
||||
|
||||
m_long_click_timer = new QTimer ( this );
|
||||
m_long_click_timer->setSingleShot ( false );
|
||||
m_long_click_timer->setInterval ( mLongClickInterval );
|
||||
connect ( m_long_click_timer, SIGNAL ( timeout() ), this, SLOT ( slotLongClickTimeout() ) );
|
||||
|
||||
m_double_click_timer = new QTimer ( this );
|
||||
m_double_click_timer->setSingleShot ( false );
|
||||
//人比较累了,用的时延就会比较长.
|
||||
m_double_click_timer->setInterval ( 100 );
|
||||
connect ( m_double_click_timer, SIGNAL ( timeout() ), this, SLOT ( slotDoubleClickTimeout() ) );
|
||||
|
||||
}
|
||||
|
||||
QQtDoubleClickHelper::~QQtDoubleClickHelper()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QQtDoubleClickHelper::mousePressEvent ( QMouseEvent* event , QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "press" << event->pos() << userWidget;
|
||||
//保存位置 这个记录什么用?
|
||||
mPoint = event->pos();
|
||||
|
||||
//初始化一些状态
|
||||
//mClickType = QQtNullClick;
|
||||
m_long_click_timer->start();
|
||||
m_click_timer->stop();
|
||||
|
||||
//复用一下t1_press t2_release 这里的实现和父类关系不太大
|
||||
now_press = QTime::currentTime();
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "release" << event->pos() << userWidget;
|
||||
|
||||
//添加longClick检测, 更新longclick检测时间
|
||||
prev_release = now_release;//记录上次的release
|
||||
now_release = QTime::currentTime();
|
||||
//在release-press>longclick暨click时钟判定为longclick后 加一次判断修复误判 防止用户不发press,引起click一直longclick.
|
||||
// if ( t1_press.msecsTo ( t2_release ) >= mLongClickInterval
|
||||
// && t2_doubleclick.msecsTo ( t2_release ) >= 0
|
||||
// && t2_doubleclick.msecsTo ( t2_release ) < mLongClickInterval )
|
||||
// {
|
||||
// //单击发生
|
||||
// mClickType = QQtClick;
|
||||
// }
|
||||
|
||||
//doubleClick检测不依赖press,所以只要发release就会有doubleClick发生.
|
||||
//检测方式: 两次release的间隔小于doubleClickInterval那么触发doubleClick.
|
||||
//这一次 current click
|
||||
now_doubleclick = QTime::currentTime();
|
||||
//这里有小技巧: 这里没有加 && mClickType != QQtClick
|
||||
//难道不会和click时钟混淆吗?不会,因为click时钟那边用的startTime和nowTime两个变量, t2比startTime还早,t1比nowTime还晚,t1-t2绝对比nowTime-startTime还长.
|
||||
//如果是click,绝对不会混淆成doubleClick.
|
||||
//正好mDoubleClickInterval ms代表双击 不代表单击.
|
||||
p2debug() << prev_doubleclick << now_doubleclick << mClickType;
|
||||
if ( prev_doubleclick.msecsTo ( now_doubleclick ) >= 0
|
||||
&& prev_doubleclick.msecsTo ( now_doubleclick ) < mDoubleClickInterval )
|
||||
{
|
||||
//双击发生
|
||||
mClickType = QQtDoubleClick;
|
||||
}
|
||||
//上一次 prev click
|
||||
prev_doubleclick = QTime::currentTime();
|
||||
|
||||
//梳理状态
|
||||
m_long_click_timer->stop();
|
||||
m_click_timer->stop();
|
||||
|
||||
if ( mClickType == QQtLongClick )
|
||||
{
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send long click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtLongClick );
|
||||
|
||||
//发送长信号
|
||||
p2debug() << "send long click " ;
|
||||
emit longClick();
|
||||
emit longClickWithPoint ( event->pos() );
|
||||
|
||||
emit longClickWithPointF ( event->localPos() );
|
||||
return;
|
||||
}
|
||||
else if ( mClickType == QQtDoubleClick )
|
||||
{
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send double click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtDoubleClick );
|
||||
|
||||
//发送双击信号
|
||||
p2debug() << "send double click." ;
|
||||
emit doubleClick();
|
||||
emit doubleClickWithPoint ( event->pos() );
|
||||
|
||||
emit doubleClickWithPointF ( event->localPos() );
|
||||
return;
|
||||
}
|
||||
else if ( mClickType == QQtClick )
|
||||
{
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtClick );
|
||||
|
||||
//发送单击信号
|
||||
p2debug() << "send click." ;
|
||||
emit click();
|
||||
emit clickWithPoint ( event->pos() );
|
||||
|
||||
emit clickWithPointF ( event->localPos() );
|
||||
return;
|
||||
}
|
||||
|
||||
//枷锁? 不,每一次双击肯定会冲掉单击检测.双击来了,单击检测取消.双击来了,不必要单击了,那不是单击.
|
||||
//双击来了,单击检测会被自动取消,发射双击信号以后,这一次单击\双击检测完成.
|
||||
|
||||
//同样的,单击来了,单击发生,单击\双击监测完成.开始新的检测.
|
||||
|
||||
//保存数据.
|
||||
mUserWidget = userWidget;
|
||||
*mMouseEvent = *event;
|
||||
startClickTime = QTime::currentTime();
|
||||
//启动click检测timer.
|
||||
m_click_timer->start();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//保存位置
|
||||
mPoint = event->pos();
|
||||
return;
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::mouseDoubleClickEvent ( QMouseEvent* event , QWidget* userWidget )
|
||||
{
|
||||
p2debug() << event->pos() << userWidget;
|
||||
//这里关闭状态修改,会和内部的检测冲突,分不清是单击还是双击.
|
||||
//修改状态
|
||||
//mClickType = QQtDoubleClick;
|
||||
|
||||
//保存位置 这个保存没有意义?
|
||||
mPoint = event->pos();
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::slotClickTimeout()
|
||||
{
|
||||
QTime nowTime = QTime::currentTime();
|
||||
int t0 = startClickTime.msecsTo ( nowTime );
|
||||
p2debug() << t0 << mDoubleClickInterval << qApp->doubleClickInterval();
|
||||
if ( t0 >= mDoubleClickInterval/*qApp->doubleClickInterval()*/ )
|
||||
{
|
||||
//先判断是否为长击
|
||||
//注意:必须和点击一样在超时的时候检测,否则和双击检测冲突,分不清是长击还是双击.导致长击必发.
|
||||
//注意:必须press击发.
|
||||
//不发press 发生误判 认为总是long click
|
||||
if ( now_press.msecsTo ( now_release ) >= 0
|
||||
&& now_press.msecsTo ( now_release ) >= mLongClickInterval )
|
||||
{
|
||||
//长击发生
|
||||
mClickType = QQtLongClick;
|
||||
|
||||
//有误判, 未发press的时候, 这个一直都是longclick,其实还有click
|
||||
//press比前一次release小的时候 其实是click
|
||||
if ( prev_release.msecsTo ( now_release ) >= 0
|
||||
&& prev_release.msecsTo ( now_press ) <= 0 )
|
||||
{
|
||||
mClickType = QQtClick;
|
||||
}
|
||||
|
||||
//initial press
|
||||
if ( prev_release.msecsTo ( now_release ) >= 0
|
||||
&& prev_release == now_release_initial )
|
||||
{
|
||||
mClickType = QQtClick;
|
||||
}
|
||||
|
||||
//经过以上两部fix,不发press过来,longclick绝不会发生.
|
||||
mouseReleaseEvent ( mMouseEvent, mUserWidget );
|
||||
return;
|
||||
}
|
||||
|
||||
mClickType = QQtClick;
|
||||
mouseReleaseEvent ( mMouseEvent, mUserWidget );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::slotLongClickTimeout()
|
||||
{
|
||||
//longclick超时,确认longclick.
|
||||
//不再使用此处检测,而是改在click时钟检测.
|
||||
//mClickType = QQtLongClick;
|
||||
m_long_click_timer->stop();
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::slotDoubleClickTimeout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QQtDoubleClickHelper::checkClickNumWithCancel()
|
||||
{
|
||||
QQtLongClickHelper::checkClickNumWithCancel();
|
||||
switch ( mClickType )
|
||||
{
|
||||
case QQtDoubleClick:
|
||||
{
|
||||
nDoubleClickNumWithCancel++;
|
||||
if ( nDoubleClickNumWithCancel >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nDoubleClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNumWithCancel = nClickNumWithCancel + nLongClickNumWithCancel + nDoubleClickNumWithCancel;
|
||||
if ( nTotalClickNumWithCancel >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QQtDoubleClickHelper::checkClickNum ( QQtClickType type )
|
||||
{
|
||||
QQtLongClickHelper::checkClickNum ( type );
|
||||
switch ( type )
|
||||
{
|
||||
case QQtDoubleClick:
|
||||
{
|
||||
nDoubleClickNum++;
|
||||
if ( nDoubleClickNum >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nDoubleClickNum = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNum = nClickNum + nLongClickNum + nDoubleClickNum;
|
||||
if ( nTotalClickNum >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNum = 0;
|
||||
}
|
||||
}
|
123
src/exquisite/clickwidgets/qqtdoubleclickhelper.h
Normal file
123
src/exquisite/clickwidgets/qqtdoubleclickhelper.h
Normal file
@ -0,0 +1,123 @@
|
||||
#ifndef QQTDOUBLECLICKHELPER_H
|
||||
#define QQTDOUBLECLICKHELPER_H
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <qqtevent.h>
|
||||
#include <qqtlongclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* @brief The QQtDoubleClickHelper class
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
* longClick
|
||||
* doubleClick
|
||||
*
|
||||
* 原理
|
||||
* release开始检测.
|
||||
* 发现longClick只发送longClick.
|
||||
* 发现click只发送click.
|
||||
* 发现doubleClick只发送doubleClick.包括Qt的和内部的检测都管用.
|
||||
* 以最新click为准
|
||||
*
|
||||
* 行为
|
||||
* releaseEvent是核心.
|
||||
* 仅仅接收到release,就可以发生单击和双击检测,击发其中一个.
|
||||
* 必须被press击发,才会检测发生长击,长击到点,如果没有release也不会发射信号.
|
||||
* 仅仅使用pressEvent,不会发生任何情况.
|
||||
* 仅仅使用DoubleClickEvent,不会发生任何情况.
|
||||
*
|
||||
* DoubleClick检测是独立于系统的,用户可以在页面里实现多套独立的按键时延检测,一个widget一个时延系统也没问题.
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickHelper : public QQtLongClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtDoubleClickHelper ( QObject* parent = 0 );
|
||||
virtual ~QQtDoubleClickHelper();
|
||||
|
||||
//调用于userWidget相对应的Event里
|
||||
//允许重写
|
||||
public:
|
||||
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;
|
||||
|
||||
signals:
|
||||
void doubleClick();
|
||||
|
||||
signals:
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
|
||||
signals:
|
||||
void doubleClickWithPointF ( QPointF point );
|
||||
|
||||
//optional
|
||||
public:
|
||||
//设置双击检测时延 default: doubleClickInterval ms
|
||||
//不会影响系统默认时延
|
||||
void setDoubleClickInterval ( int millSecond = doubleClickInterval ) {
|
||||
mDoubleClickInterval = millSecond;
|
||||
}
|
||||
int getDoubleClickInterval() const {
|
||||
return mDoubleClickInterval;
|
||||
}
|
||||
|
||||
inline const quint32 doubleClickNum() const { return nDoubleClickNum; }
|
||||
inline const quint32 doubleClickNumWithCancel() const { return nDoubleClickNumWithCancel; }
|
||||
|
||||
/**
|
||||
* 以下用于内部
|
||||
*/
|
||||
public:
|
||||
|
||||
public slots:
|
||||
void slotClickTimeout();
|
||||
void slotLongClickTimeout();
|
||||
void slotDoubleClickTimeout();
|
||||
|
||||
protected:
|
||||
//这个语法比较难,只有整型有特权.
|
||||
static const int doubleClickInterval = 260;
|
||||
|
||||
//clickTimer
|
||||
QTimer* m_click_timer;
|
||||
//longClickTimer
|
||||
QTimer* m_long_click_timer;
|
||||
//doubleClickTimer
|
||||
QTimer* m_double_click_timer;
|
||||
|
||||
|
||||
//双击200ms. 这个比较符合双击舒适度.Qt内部的Timer慢一些,可能是计算了比较完整的时间.
|
||||
//在这个范围内的都 才 是双击
|
||||
int mDoubleClickInterval;
|
||||
|
||||
//click 检测使用
|
||||
QTime startClickTime;
|
||||
|
||||
//double click检测用
|
||||
QTime prev_doubleclick;
|
||||
QTime now_doubleclick;
|
||||
|
||||
//long click用
|
||||
QTime prev_release;
|
||||
QTime now_release_initial;
|
||||
|
||||
//click 用
|
||||
QWidget* mUserWidget;
|
||||
QQtMouseEvent* mMouseEvent;
|
||||
|
||||
//click num
|
||||
virtual void checkClickNum ( QQtClickType type ) override;
|
||||
virtual void checkClickNumWithCancel() override;
|
||||
|
||||
quint32 nDoubleClickNum;
|
||||
quint32 nDoubleClickNumWithCancel;
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKHELPER_H
|
1
src/exquisite/clickwidgets/qqtdoubleclicklabel.cpp
Normal file
1
src/exquisite/clickwidgets/qqtdoubleclicklabel.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtdoubleclicklabel.h"
|
71
src/exquisite/clickwidgets/qqtdoubleclicklabel.h
Normal file
71
src/exquisite/clickwidgets/qqtdoubleclicklabel.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef QQTDOUBLECLICKLABEL_H
|
||||
#define QQTDOUBLECLICKLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtdoubleclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个虚类
|
||||
* 提供安装ClickHelper的能力
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
public:
|
||||
explicit QQtDoubleClickLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtDoubleClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtDoubleClickLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
void doubleClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this, SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this,
|
||||
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKLABEL_H
|
1
src/exquisite/clickwidgets/qqtdoubleclickwidget.cpp
Normal file
1
src/exquisite/clickwidgets/qqtdoubleclickwidget.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtdoubleclickwidget.h"
|
73
src/exquisite/clickwidgets/qqtdoubleclickwidget.h
Normal file
73
src/exquisite/clickwidgets/qqtdoubleclickwidget.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef QQTDOUBLECLICKWIDGET_H
|
||||
#define QQTDOUBLECLICKWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtdoubleclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 内置DoubleClickHelper
|
||||
*
|
||||
* 添加了doubleClick支持的QQtClickWidget
|
||||
* 这个Widget表示了如何使用QQtWidgetClickHelper和它的子类
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDoubleClickWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtDoubleClickWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtDoubleClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtDoubleClickWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
void doubleClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this, SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClick() ), this, SIGNAL ( doubleClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( doubleClickWithPoint ( QPoint ) ), this,
|
||||
SIGNAL ( doubleClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTDOUBLECLICKWIDGET_H
|
205
src/exquisite/clickwidgets/qqtlongclickhelper.cpp
Normal file
205
src/exquisite/clickwidgets/qqtlongclickhelper.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
#include "qqtlongclickhelper.h"
|
||||
|
||||
QQtLongClickHelper::QQtLongClickHelper ( QObject* parent ) : QQtClickHelper ( parent )
|
||||
{
|
||||
mLongClickInterval = longClickInterval;
|
||||
|
||||
now_press = QTime::currentTime().addMSecs ( 1 );
|
||||
now_release = QTime::currentTime().addMSecs ( 2 );
|
||||
|
||||
nLongClickNum = 0;
|
||||
nLongClickNumWithCancel = 0;
|
||||
}
|
||||
|
||||
QQtLongClickHelper::~QQtLongClickHelper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QQtLongClickHelper::mousePressEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "press" << event->pos() << userWidget;
|
||||
mPoint = event->pos();
|
||||
mClickType = QQtClick;
|
||||
now_press = QTime::currentTime();
|
||||
}
|
||||
|
||||
void QQtLongClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "release" << event->pos() << userWidget;
|
||||
//这一次 current click
|
||||
QTime t2_release_preview = now_release;
|
||||
now_release = QTime::currentTime();
|
||||
//这里加了个判断,其实肯定>=0
|
||||
if ( now_press.msecsTo ( now_release ) >= 0 && now_press.msecsTo ( now_release ) <= mLongClickInterval )
|
||||
{
|
||||
//单击发生
|
||||
mClickType = QQtClick;
|
||||
}
|
||||
else if ( now_press.msecsTo ( now_release ) >= 0 && now_press.msecsTo ( now_release ) > mLongClickInterval )
|
||||
{
|
||||
//长击发生
|
||||
mClickType = QQtLongClick;
|
||||
|
||||
//这次点击,
|
||||
//上次的release竟然比press晚,说明press没发生,置位click
|
||||
//第一次click, 上一次release=press也在这里被置位click
|
||||
if ( t2_release_preview.msecsTo ( now_release ) >= 0
|
||||
&& t2_release_preview.msecsTo ( now_press ) <= 0 )
|
||||
{
|
||||
mClickType = QQtClick;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( mClickType == QQtLongClick )
|
||||
{
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send long click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtLongClick );
|
||||
|
||||
//发送长信号
|
||||
p2debug() << "send long click " ;
|
||||
emit longClick();
|
||||
emit longClickWithPoint ( event->pos() );
|
||||
emit longClickWithPointF ( event->localPos() );
|
||||
|
||||
#if 0
|
||||
emit longClick ( userWidget );
|
||||
emit longClickWithPoint ( event->pos(), userWidget );
|
||||
emit longClickWithPointF ( event->localPos(), userWidget );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else if ( mClickType == QQtClick )
|
||||
{
|
||||
//计算点击数目
|
||||
checkClickNumWithCancel();
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//如果手移开了,那么不发送.
|
||||
//条件是用户传入了这个Widget为真.
|
||||
if ( userWidget )
|
||||
{
|
||||
p2debug() << userWidget << userWidget->rect() << event->pos() << userWidget->rect().contains ( event->pos() );
|
||||
if ( !userWidget->rect().contains ( event->pos() ) )
|
||||
{
|
||||
p2debug() << "send click canceled." ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkClickNum ( QQtClick );
|
||||
|
||||
//发送单击信号
|
||||
p2debug() << "send click." ;
|
||||
emit click();
|
||||
emit clickWithPoint ( event->pos() );
|
||||
emit clickWithPointF ( event->localPos() );
|
||||
|
||||
#if 0
|
||||
emit click ( userWidget );
|
||||
emit clickWithPoint ( event->pos(), userWidget );
|
||||
emit clickWithPointF ( event->localPos(), userWidget );
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//修改状态
|
||||
mClickType = QQtNullClick;
|
||||
|
||||
//保存位置
|
||||
mPoint = event->pos();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void QQtLongClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget )
|
||||
{
|
||||
p2debug() << "double click" << event->pos() << userWidget;
|
||||
mPoint = event->pos();
|
||||
}
|
||||
|
||||
void QQtLongClickHelper::setLongClickInterval ( int millSecond )
|
||||
{
|
||||
mLongClickInterval = millSecond;
|
||||
}
|
||||
|
||||
int QQtLongClickHelper::getLongClickInterval() const
|
||||
{
|
||||
return mLongClickInterval;
|
||||
}
|
||||
|
||||
|
||||
void QQtLongClickHelper::checkClickNumWithCancel()
|
||||
{
|
||||
QQtClickHelper::checkClickNumWithCancel();
|
||||
switch ( mClickType )
|
||||
{
|
||||
case QQtLongClick:
|
||||
{
|
||||
nLongClickNumWithCancel++;
|
||||
if ( nLongClickNumWithCancel >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nLongClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNumWithCancel = nClickNumWithCancel + nLongClickNumWithCancel;
|
||||
if ( nTotalClickNumWithCancel >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNumWithCancel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QQtLongClickHelper::checkClickNum ( QQtLongClickHelper::QQtClickType type )
|
||||
{
|
||||
QQtClickHelper::checkClickNum ( type );
|
||||
switch ( type )
|
||||
{
|
||||
case QQtLongClick:
|
||||
{
|
||||
nLongClickNum++;
|
||||
if ( nLongClickNum >= 0xFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nLongClickNum = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
nTotalClickNum = nClickNum + nLongClickNum;
|
||||
if ( nTotalClickNum >= 0xFFFFFFFFFFFFFFFF )
|
||||
{
|
||||
p2debug() << "out......";
|
||||
nTotalClickNum = 0;
|
||||
}
|
||||
}
|
92
src/exquisite/clickwidgets/qqtlongclickhelper.h
Normal file
92
src/exquisite/clickwidgets/qqtlongclickhelper.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef QQTLONGCLICKHELPER_H
|
||||
#define QQTLONGCLICKHELPER_H
|
||||
|
||||
#include <qqtclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* QQtLongClickHelper
|
||||
* 这个Helper是给Widget响应按钮事件用的
|
||||
* 主要用于为QQtWidget系列添加按钮信号识别帮助
|
||||
*
|
||||
* 支持
|
||||
* click
|
||||
* longClick
|
||||
* 不支持DoubleClick
|
||||
*
|
||||
* 可以统计按键次数
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickHelper : public QQtClickHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtLongClickHelper ( QObject* parent = 0 );
|
||||
virtual ~QQtLongClickHelper();
|
||||
|
||||
//发给业务层
|
||||
//发回界面层
|
||||
//这些信号不区分Widget,谁发过来都发出去,不论Widget
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
signals:
|
||||
void clickWithPointF ( QPointF point );
|
||||
void longClickWithPointF ( QPointF point );
|
||||
|
||||
#if 0
|
||||
//发给业务层
|
||||
//发回界面层
|
||||
//这里的信号都带着Widget指针,可以区分Widget
|
||||
signals:
|
||||
void longClick ( QWidget* userWidget );
|
||||
void longClickWithPoint ( QPoint point, QWidget* userWidget );
|
||||
void longClickWithPointF ( QPointF point, QWidget* userWidget );
|
||||
#endif
|
||||
|
||||
//调用于userWidget相对应的Event里
|
||||
//允许重写
|
||||
public:
|
||||
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:
|
||||
//设置longClick超时 default:1200ms
|
||||
void setLongClickInterval ( int millSecond = longClickInterval );
|
||||
int getLongClickInterval() const;
|
||||
|
||||
inline const quint32 longClickNum() const { return nLongClickNum; }
|
||||
inline const quint32 longClickNumWithCancel() const { return nLongClickNumWithCancel; }
|
||||
|
||||
|
||||
/**
|
||||
* 以下用于内部
|
||||
*/
|
||||
protected:
|
||||
//这个语法比较难,只有整型有特权.
|
||||
static const int longClickInterval = 1200;
|
||||
|
||||
int mLongClickInterval;
|
||||
|
||||
//click 检测使用
|
||||
QTime now_press;//press relase
|
||||
QTime now_release;//release
|
||||
|
||||
//click num
|
||||
virtual void checkClickNum ( QQtClickType type ) override;
|
||||
virtual void checkClickNumWithCancel() override;
|
||||
|
||||
quint32 nLongClickNum;
|
||||
quint32 nLongClickNumWithCancel;
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKHELPER_H
|
1
src/exquisite/clickwidgets/qqtlongclicklabel.cpp
Normal file
1
src/exquisite/clickwidgets/qqtlongclicklabel.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtlongclicklabel.h"
|
66
src/exquisite/clickwidgets/qqtlongclicklabel.h
Normal file
66
src/exquisite/clickwidgets/qqtlongclicklabel.h
Normal file
@ -0,0 +1,66 @@
|
||||
#ifndef QQTLONGCLICKLABEL_H
|
||||
#define QQTLONGCLICKLABEL_H
|
||||
|
||||
#include <qqtvirtualclicklabel.h>
|
||||
#include <qqtlongclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 这个是个虚类
|
||||
* 提供安装ClickHelper的能力
|
||||
* 为确定功能的子类Label服务
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickLabel : public QQtVirtualClickLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtLongClickLabel ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickLabel ( parent ) {
|
||||
mClickHelper = new QQtLongClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtLongClickLabel() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
/**
|
||||
* 子类重写这两个函数,实现丰富的click能力
|
||||
*/
|
||||
// QQtWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKLABEL_H
|
1
src/exquisite/clickwidgets/qqtlongclickwidget.cpp
Normal file
1
src/exquisite/clickwidgets/qqtlongclickwidget.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtlongclickwidget.h"
|
62
src/exquisite/clickwidgets/qqtlongclickwidget.h
Normal file
62
src/exquisite/clickwidgets/qqtlongclickwidget.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef QQTLONGCLICKWIDGET_H
|
||||
#define QQTLONGCLICKWIDGET_H
|
||||
|
||||
#include <qqtvirtualclickwidget.h>
|
||||
#include <qqtlongclickhelper.h>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 提供安装ClickHelper的能力
|
||||
* 为确定功能的子类Widget服务
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLongClickWidget : public QQtVirtualClickWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtLongClickWidget ( QWidget* parent = 0 ) :
|
||||
QQtVirtualClickWidget ( parent ) {
|
||||
mClickHelper = new QQtLongClickHelper ( this );
|
||||
mDefaultClickHelper = mClickHelper;
|
||||
installClickHelper ( mClickHelper );
|
||||
}
|
||||
virtual ~QQtLongClickWidget() {}
|
||||
|
||||
/**
|
||||
* 提供给App用信号
|
||||
* 界面层内部直接处理
|
||||
*/
|
||||
signals:
|
||||
void click();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
// QQtVirtualClickWidget interface
|
||||
protected:
|
||||
virtual void connectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
connect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
connect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
connect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
|
||||
virtual void unConnectClickHelper() {
|
||||
if ( !mClickHelper )
|
||||
return;
|
||||
|
||||
disconnect ( mClickHelper, SIGNAL ( click() ), this, SIGNAL ( click() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClick() ), this, SIGNAL ( longClick() ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( clickWithPoint ( QPoint ) ), this, SIGNAL ( clickWithPoint ( QPoint ) ) );
|
||||
disconnect ( mClickHelper, SIGNAL ( longClickWithPoint ( QPoint ) ), this, SIGNAL ( longClickWithPoint ( QPoint ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QQTLONGCLICKWIDGET_H
|
60
src/exquisite/clickwidgets/qqtvirtualclickhelper.cpp
Normal file
60
src/exquisite/clickwidgets/qqtvirtualclickhelper.cpp
Normal 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;
|
||||
}
|
||||
}
|
86
src/exquisite/clickwidgets/qqtvirtualclickhelper.h
Normal file
86
src/exquisite/clickwidgets/qqtvirtualclickhelper.h
Normal 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
|
1
src/exquisite/clickwidgets/qqtvirtualclicklabel.cpp
Normal file
1
src/exquisite/clickwidgets/qqtvirtualclicklabel.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtvirtualclicklabel.h"
|
153
src/exquisite/clickwidgets/qqtvirtualclicklabel.h
Normal file
153
src/exquisite/clickwidgets/qqtvirtualclicklabel.h
Normal 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
|
1
src/exquisite/clickwidgets/qqtvirtualclickwidget.cpp
Normal file
1
src/exquisite/clickwidgets/qqtvirtualclickwidget.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "qqtvirtualclickwidget.h"
|
158
src/exquisite/clickwidgets/qqtvirtualclickwidget.h
Normal file
158
src/exquisite/clickwidgets/qqtvirtualclickwidget.h
Normal 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
|
@ -1,4 +1,4 @@
|
||||
#include "qqtapplication.h"
|
||||
#include "qqtapplication.h"
|
||||
#ifdef __PLUGINSUPPORT__
|
||||
#include "qqtpluginwatcher.h"
|
||||
#endif
|
||||
@ -49,14 +49,14 @@ QQtApplication::QQtApplication ( int& argc, char** argv ) :
|
||||
QDir::setCurrent ( qApp->applicationDirPath() );
|
||||
#endif
|
||||
|
||||
/*在linux系统,不自动在当前目录寻找lib,需要命令行设置LD_LIBRARY_PATH,这里添加一下自动查找,不冲突。*/
|
||||
addLibraryPath ( qApp->applicationDirPath() );//[qApp->]
|
||||
|
||||
pline() << "app root:" << qApp->applicationDirPath();
|
||||
pline() << "app work root:" << QDir::currentPath();
|
||||
pline() << "Qt version:" << QT_VERSION_STR;
|
||||
pline() << "LibQQt version:" << STR ( QQT_VERSION );
|
||||
|
||||
/*在linux系统,不自动在当前目录寻找lib,需要命令行设置LD_LIBRARY_PATH,这里添加一下自动查找,不冲突。*/
|
||||
addLibraryPath ( QDir::currentPath() );//[qApp->]
|
||||
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
pline() << "QTDIR:" << QProcessEnvironment::systemEnvironment().value ( "QTDIR" );
|
||||
pline() << "TSLIB_TSDEVICE:" << QProcessEnvironment::systemEnvironment().value ( "TSLIB_TSDEVICE" );
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "qqtprogressdialog.h"
|
||||
#include "qqtprogressdialog.h"
|
||||
#include "ui_qqtprogressdialog.h"
|
||||
#include "qqtcore.h"
|
||||
#include "qqtobjectmanager.h"
|
||||
@ -17,7 +17,7 @@ QQtProgressDialog::QQtProgressDialog ( QWidget* parent ) :
|
||||
|
||||
//setFixedWidth(260);
|
||||
|
||||
#ifdef __QQTWIDGETS_K1160__
|
||||
#ifdef __QQTWIDGETS_BIGICON__
|
||||
setFixedSize ( 526, 283 );
|
||||
bar->setFixedSize ( 481, 31 );
|
||||
bar->move ( 20, 50 );
|
||||
|
12
src/qqt.pro
12
src/qqt.pro
@ -161,6 +161,18 @@ DISTFILES += \
|
||||
linux_write_ini.sh \
|
||||
win_read_ini.bat
|
||||
|
||||
#################################################################
|
||||
##QQt Lib工程持续编译
|
||||
#################################################################
|
||||
#如果不touch一下,资源文件改变不会引发编译,可是我们需要编译一下,不开持续编译,岂不是漏失?
|
||||
#修改pro,如果不需要编译源文件,还是编译了一下,岂不是多余?
|
||||
#权衡利弊,在qqt工程里开启开关.保证用户在编译源代码的时候,任何改动一定持续生效.
|
||||
#依赖touch命令 :|
|
||||
#QQt持续编译配置开关
|
||||
CONFIG += continued_build
|
||||
contains(CONFIG, continued_build){
|
||||
system("touch $${PWD}/frame/qqtapplication.cpp")
|
||||
}
|
||||
|
||||
#################################################################
|
||||
##project environ
|
||||
|
@ -343,6 +343,11 @@ contains (DEFINES, __EXQUISITE__) {
|
||||
#single color only widget
|
||||
DEFINES += __COLORWIDGETS__
|
||||
|
||||
#click widgets
|
||||
DEFINES += __CLICKWIDGETS__
|
||||
|
||||
#click sound widgets
|
||||
DEFINES += __CLICKSOUNDWIDGETS__
|
||||
}
|
||||
|
||||
########################################################################
|
||||
@ -432,6 +437,8 @@ defineReplace(qqt_header){
|
||||
|
||||
#exquisite widgets
|
||||
command += $${path}/exquisite
|
||||
command += $${path}/exquisite/clicksoundwidgets
|
||||
command += $${path}/exquisite/clickwidgets
|
||||
command += $${path}/exquisite/svgwidgets
|
||||
command += $${path}/exquisite/gifwidgets
|
||||
command += $${path}/exquisite/openglwidgets
|
||||
|
@ -9,10 +9,29 @@
|
||||
|
||||
#FileSystemName的终极状态是编译器_目标系统名,比如gcc_macOS, clang_macOS这样。
|
||||
|
||||
#target arch type
|
||||
#当工程编译目标相同,可是编译配置的Qt版本不同的时候,这个机制有一点点缺点,
|
||||
#使用相同的中间编译目录吗? 很明显,这不合理?No,这很合理.Qt版本变化,引起链接库变化,但是,还是Qt,依然是Qt.程序中应当注意使用的Qt库(Qt4和Qt5库名字不太一样)和版本(版本号不一样,源代码会有点小区别,需要注意兼容性).
|
||||
#比如桌面 gcc_64的Qt4 和 gcc_64的Qt5,不合适使用相同的中间编译目录,可是他们的FileSystemName都是Linux64,导致中间编译目录相同.
|
||||
#为此,做出改进? No,用户请注意电脑上用Qt5开发就不要用Qt4,如果使用Qt4,请换电脑进行开发.(或者全部rebuild?其实Qt的版本之间引起的差异,如果不大,混用没什么问题,Qt库只能使用一个版本的)
|
||||
#整体而言,Qt版本变化,引发的编译会比较多源文件.建议使用不同电脑开发.
|
||||
|
||||
#原理
|
||||
#Qt Creator kit页的FileSystemName Creator自己用,忘记了传给qmake.(存储于Qt Creator配置区域)
|
||||
#工程构建和配置页(存储于.pro.userxxx)里的环境变量QKIT给qmake用.
|
||||
#如果用户在pro里面设置QMAKE.KIT QMAKE.SYSNAME,Qt Creator从qmake里读也挺好的.
|
||||
|
||||
#You need define a env variable QKIT=XX
|
||||
#target arch type
|
||||
#注释
|
||||
#config += xxx qmake用配置开关
|
||||
#$$(XXX) 环境变量XXX
|
||||
#$${XXX} qmake用变量XXX
|
||||
#XXX = AAA 给qmake用变量XXX赋值
|
||||
#DEFINES += XXX 源代码用宏 和上边的XXX可以重名,但是是两回事,不干扰.
|
||||
|
||||
QKIT_PRIVATE = $$(QKIT)
|
||||
#处理文件内平台小差异
|
||||
#源文件内平台小差异
|
||||
#QKIT -> 源文件宏
|
||||
#EMBEDDED __EMBEDDED_LINUX__
|
||||
#MIPS __MIPS_LINUX__
|
||||
#ARM __ARM_LINUX__
|
||||
@ -53,7 +72,7 @@ equals(QKIT_PRIVATE, EMBEDDED) {
|
||||
DEFINES += __ANDROID__
|
||||
} else:equals(QKIT_PRIVATE, ANDROIDX86) {
|
||||
DEFINES += __ANDROID__
|
||||
DEFINES += __ANDROIDX86__
|
||||
DEFINES += __ANDROIDX86__ #可能废弃
|
||||
}
|
||||
|
||||
#QMAKESPEC_NAME = $${QMAKESPEC}
|
||||
|
@ -36,10 +36,12 @@ contains (QKIT_PRIVATE, WIN32||WIN64) {
|
||||
#core
|
||||
SOURCES += \
|
||||
$$PWD/core/qqtcore.cpp \
|
||||
$$PWD/core/qqtevent.cpp \
|
||||
$$PWD/core/qqtdictionary.cpp \
|
||||
$$PWD/core/qqtobjectmanager.cpp
|
||||
HEADERS += \
|
||||
$$PWD/core/qqtcore.h \
|
||||
$$PWD/core/qqtevent.h \
|
||||
$$PWD/core/qqtdictionary.h \
|
||||
$$PWD/core/qqtobjectmanager.h
|
||||
|
||||
@ -323,6 +325,73 @@ contains (DEFINES, __EXQUISITE__) {
|
||||
$$PWD/exquisite/qqtframelesshelper.h \
|
||||
$$PWD/exquisite/qqtframelesshelperprivate.h
|
||||
|
||||
#can click sound support widgets
|
||||
contains (DEFINES, __CLICKSOUNDWIDGETS__) {
|
||||
SOURCES += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundhelper.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundhelper.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundhelper.cpp
|
||||
HEADERS += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundhelper.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundhelper.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundhelper.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundwidget.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundwidget.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundwidget.cpp
|
||||
HEADERS += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundwidget.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundwidget.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundwidget.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundlabel.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundlabel.cpp \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundlabel.cpp
|
||||
HEADERS += \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtclicksoundlabel.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtlongclicksoundlabel.h \
|
||||
$$PWD/exquisite/clicksoundwidgets/qqtdoubleclicksoundlabel.h
|
||||
}
|
||||
|
||||
#can click support widgets
|
||||
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
|
||||
}
|
||||
|
||||
#dialog
|
||||
SOURCES += \
|
||||
$$PWD/exquisite/qqtpopupdialog.cpp
|
||||
|
@ -1,41 +1,6 @@
|
||||
#include "qqtlabel.h"
|
||||
#include "qqtlabel.h"
|
||||
|
||||
QQtLabel::QQtLabel ( QWidget* parent ) : QLabel ( parent )
|
||||
{
|
||||
m_lcTimer = new QTimer ( this );
|
||||
m_lcTimer->setSingleShot ( true );
|
||||
m_lcTimer->setInterval ( 2200 );
|
||||
connect ( m_lcTimer, SIGNAL ( timeout() ),
|
||||
this, SLOT ( slot_timeout() ) );
|
||||
}
|
||||
|
||||
|
||||
void QQtLabel::mouseReleaseEvent ( QMouseEvent* event )
|
||||
{
|
||||
if ( m_lcTimer->isActive() )
|
||||
{
|
||||
m_lcTimer->stop();
|
||||
emit click();
|
||||
}
|
||||
|
||||
return QLabel::mouseReleaseEvent ( event );
|
||||
}
|
||||
|
||||
|
||||
void QQtLabel::mouseDoubleClickEvent ( QMouseEvent* event )
|
||||
{
|
||||
emit doubleClick();
|
||||
return QLabel::mouseDoubleClickEvent ( event );
|
||||
}
|
||||
|
||||
void QQtLabel::slot_timeout()
|
||||
{
|
||||
emit longClick();
|
||||
}
|
||||
|
||||
|
||||
void QQtLabel::mousePressEvent ( QMouseEvent* event )
|
||||
{
|
||||
m_lcTimer->start();
|
||||
return QLabel::mousePressEvent ( event );
|
||||
}
|
||||
|
@ -1,40 +1,19 @@
|
||||
#ifndef QQTLABEL_H
|
||||
#ifndef QQTLABEL_H
|
||||
#define QQTLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/**
|
||||
* 用于解决QLabel可能存在的问题.
|
||||
*/
|
||||
class QQtLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtLabel ( QWidget* parent = nullptr );
|
||||
virtual ~QQtLabel() {}
|
||||
signals:
|
||||
void click();
|
||||
void doubleClick();
|
||||
void longClick();
|
||||
|
||||
public slots:
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void mouseReleaseEvent ( QMouseEvent* event ) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override;
|
||||
|
||||
protected slots:
|
||||
void slot_timeout();
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void mousePressEvent ( QMouseEvent* event ) override;
|
||||
|
||||
private:
|
||||
QTimer* m_lcTimer;
|
||||
};
|
||||
|
||||
#endif // QQTLABEL_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "qqtwidget.h"
|
||||
#include "qqtwidget.h"
|
||||
#include <QStylePainter>
|
||||
#include "qqtcore.h"
|
||||
|
||||
@ -6,18 +6,14 @@ QQtWidget::QQtWidget ( QWidget* parent ) :
|
||||
QWidget ( parent )
|
||||
{
|
||||
m_style = QQTCENTER;
|
||||
|
||||
m_lcTimer = new QTimer ( this );
|
||||
m_lcTimer->setSingleShot ( true );
|
||||
m_lcTimer->setInterval ( 2200 );
|
||||
connect ( m_lcTimer, SIGNAL ( timeout() ),
|
||||
this, SLOT ( slot_timeout() ) );
|
||||
}
|
||||
|
||||
QQtWidget::~QQtWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void QQtWidget::setImageStyle ( QQtWidget::ImageStyle style ) { m_style = style; }
|
||||
|
||||
void QQtWidget::setPixmap ( const QString& pic )
|
||||
{
|
||||
bool ret = mImage.load ( pic );
|
||||
@ -198,36 +194,3 @@ void QQtWidget::paintEvent ( QPaintEvent* event )
|
||||
return QWidget::paintEvent ( event );
|
||||
}
|
||||
|
||||
|
||||
void QQtWidget::mousePressEvent ( QMouseEvent* event )
|
||||
{
|
||||
mlongClickPoint = event->pos();
|
||||
m_lcTimer->start();
|
||||
return QWidget::mousePressEvent ( event );
|
||||
}
|
||||
|
||||
void QQtWidget::mouseReleaseEvent ( QMouseEvent* event )
|
||||
{
|
||||
if ( m_lcTimer->isActive() )
|
||||
{
|
||||
m_lcTimer->stop();
|
||||
emit click();
|
||||
emit clickWithPoint ( event->pos() );
|
||||
}
|
||||
|
||||
return QWidget::mouseReleaseEvent ( event );
|
||||
}
|
||||
|
||||
void QQtWidget::mouseDoubleClickEvent ( QMouseEvent* event )
|
||||
{
|
||||
emit doubleClick();
|
||||
emit doubleClickWithPoint ( event->pos() );
|
||||
return QWidget::mouseDoubleClickEvent ( event );
|
||||
}
|
||||
|
||||
void QQtWidget::slot_timeout()
|
||||
{
|
||||
emit longClick();
|
||||
emit longClickWithPoint ( mlongClickPoint );
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef QQTWIDGET_H
|
||||
#ifndef QQTWIDGET_H
|
||||
#define QQTWIDGET_H
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QImage>
|
||||
|
||||
#include <qqt-local.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
/*
|
||||
* QSS美化,和QQtWidget图片背景不能共存
|
||||
* QSS部分影响QQtWidget,比如Size等
|
||||
@ -17,9 +17,6 @@ class QQTSHARED_EXPORT QQtWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtWidget ( QWidget* parent = 0 );
|
||||
virtual ~QQtWidget();
|
||||
|
||||
enum ImageStyle
|
||||
{
|
||||
/**
|
||||
@ -53,44 +50,26 @@ public:
|
||||
|
||||
QQTIMAGESTYLEMAX
|
||||
};
|
||||
void setImageStyle ( ImageStyle style = QQTCENTER ) { m_style = style; }
|
||||
|
||||
public:
|
||||
explicit QQtWidget ( QWidget* parent = 0 );
|
||||
virtual ~QQtWidget();
|
||||
|
||||
void setImageStyle ( ImageStyle style = QQTCENTER );
|
||||
void setPixmap ( const QString& pic = QString() );
|
||||
void setPixmap ( const QPixmap& pixmap );
|
||||
void setPixmap ( const QImage& image );
|
||||
|
||||
signals:
|
||||
void click();
|
||||
void doubleClick();
|
||||
void longClick();
|
||||
|
||||
signals:
|
||||
void clickWithPoint ( QPoint point );
|
||||
void doubleClickWithPoint ( QPoint point );
|
||||
void longClickWithPoint ( QPoint point );
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void paintEvent ( QPaintEvent* ) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void mousePressEvent ( QMouseEvent* event ) override;
|
||||
virtual void mouseReleaseEvent ( QMouseEvent* event ) override;
|
||||
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override;
|
||||
|
||||
protected slots:
|
||||
void slot_timeout();
|
||||
|
||||
private:
|
||||
quint32 m_style;
|
||||
QTimer* m_lcTimer;
|
||||
/*pixmap是必要的。绘图用pixmap。*/
|
||||
/*内部没有使用QPixmap存储,因为如果缩放widget,pixmap就没办法了,img有*/
|
||||
/*内部对QIcon的使用删除了,icon不是必要的。*/
|
||||
QImage mImage;
|
||||
//for longClickWithPoint()
|
||||
QPoint mlongClickPoint;
|
||||
};
|
||||
|
||||
#endif // QPICWIDGET_H
|
||||
#endif // QWIDGET_H
|
||||
|
34
test/QQtWidgetClickHelperTest/QQtWidgetClickHelperTest.pro
Normal file
34
test/QQtWidgetClickHelperTest/QQtWidgetClickHelperTest.pro
Normal file
@ -0,0 +1,34 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-03-28T19:21:56
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = QQtWidgetClickHelperTest
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
system(touch main.cpp)
|
||||
include (../../src/app_base_manager.pri)
|
11
test/QQtWidgetClickHelperTest/main.cpp
Normal file
11
test/QQtWidgetClickHelperTest/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
85
test/QQtWidgetClickHelperTest/mainwindow.cpp
Normal file
85
test/QQtWidgetClickHelperTest/mainwindow.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "qqtcore.h"
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
ui->widget;
|
||||
ui->widget->setPixmap ( "" );
|
||||
|
||||
connect ( ui->widget, SIGNAL ( click() ),
|
||||
this, SLOT ( setSum() ) );
|
||||
connect ( ui->widget, SIGNAL ( doubleClick() ),
|
||||
this, SLOT ( set2Sum() ) );
|
||||
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() ),
|
||||
this, SLOT ( set5Sum() ) );
|
||||
|
||||
connect ( ui->widget_3, SIGNAL ( click() ),
|
||||
this, SLOT ( set6Sum() ) );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::setSum()
|
||||
{
|
||||
sender();
|
||||
ui->textBrowser->append ( QString ( "%1 click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set2Sum()
|
||||
{
|
||||
ui->textBrowser->append ( QString ( "%1 double click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
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() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set5Sum()
|
||||
{
|
||||
ui->textBrowser_2->append ( QString ( "%1 long click" ).arg ( ui->widget_2->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set6Sum()
|
||||
{
|
||||
ui->textBrowser_3->append ( QString ( "%1 click" ).arg ( ui->widget_3->clickHelper()->totalClickNum() ) );;
|
||||
}
|
35
test/QQtWidgetClickHelperTest/mainwindow.h
Normal file
35
test/QQtWidgetClickHelperTest/mainwindow.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void setSum();
|
||||
void set2Sum();
|
||||
void set3Sum();
|
||||
void set31Sum();
|
||||
void set32Sum();
|
||||
void set33Sum();
|
||||
|
||||
void set4Sum();
|
||||
void set5Sum();
|
||||
|
||||
void set6Sum();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
160
test/QQtWidgetClickHelperTest/mainwindow.ui
Normal file
160
test/QQtWidgetClickHelperTest/mainwindow.ui
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Double Click</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtDoubleClickWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>LongClick</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtLongClickWidget" name="widget_2" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Click</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser_3"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtClickWidget" name="widget_3" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>39</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QQtDoubleClickWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtdoubleclickwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QQtLongClickWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtlongclickwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QQtClickWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtclickwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/click.wav
Normal file
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/click.wav
Normal file
Binary file not shown.
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/doubleclick.wav
Normal file
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/doubleclick.wav
Normal file
Binary file not shown.
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/longclick.wav
Normal file
BIN
test/QQtWidgetClickSoundHelperTest/AppRoot/longclick.wav
Normal file
Binary file not shown.
@ -0,0 +1,40 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-03-28T19:21:56
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = QQtWidgetClickSoundHelperTest
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
#促使qqt_deploy_config配置执行,没有这个变量不执行。
|
||||
APP_CONFIG_PWD = $${PWD}/AppRoot
|
||||
equals(QMAKE_HOST.os, Windows) {
|
||||
APP_CONFIG_PWD ~=s,/,\\,g
|
||||
}
|
||||
|
||||
system(touch main.cpp)
|
||||
include (../../src/app_base_manager.pri)
|
11
test/QQtWidgetClickSoundHelperTest/main.cpp
Normal file
11
test/QQtWidgetClickSoundHelperTest/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
72
test/QQtWidgetClickSoundHelperTest/mainwindow.cpp
Normal file
72
test/QQtWidgetClickSoundHelperTest/mainwindow.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "qqtcore.h"
|
||||
#include <qqtframe.h>
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
ui->widget;
|
||||
ui->widget->setPixmap ( "" );
|
||||
|
||||
connect ( ui->widget, SIGNAL ( click() ),
|
||||
this, SLOT ( setSum() ) );
|
||||
connect ( ui->widget, SIGNAL ( doubleClick() ),
|
||||
this, SLOT ( set2Sum() ) );
|
||||
connect ( ui->widget, SIGNAL ( longClick() ),
|
||||
this, SLOT ( set3Sum() ) );
|
||||
|
||||
( ( 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() ) );
|
||||
|
||||
( ( 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() ) );
|
||||
( ( QQtClickSoundHelper* ) ( ui->widget_3->clickHelper() ) )->setClickSound ( qrc ( "click.wav" ) );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::setSum()
|
||||
{
|
||||
sender();
|
||||
ui->textBrowser->append ( QString ( "%1 click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set2Sum()
|
||||
{
|
||||
ui->textBrowser->append ( QString ( "%1 double click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set3Sum()
|
||||
{
|
||||
ui->textBrowser->append ( QString ( "%1 long click" ).arg ( ui->widget->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set4Sum()
|
||||
{
|
||||
ui->textBrowser_2->append ( QString ( "%1 click" ).arg ( ui->widget_2->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set5Sum()
|
||||
{
|
||||
ui->textBrowser_2->append ( QString ( "%1 long click" ).arg ( ui->widget_2->clickHelper()->totalClickNum() ) );;
|
||||
}
|
||||
|
||||
void MainWindow::set6Sum()
|
||||
{
|
||||
ui->textBrowser_3->append ( QString ( "%1 click" ).arg ( ui->widget_3->clickHelper()->totalClickNum() ) );;
|
||||
}
|
32
test/QQtWidgetClickSoundHelperTest/mainwindow.h
Normal file
32
test/QQtWidgetClickSoundHelperTest/mainwindow.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void setSum();
|
||||
void set2Sum();
|
||||
void set3Sum();
|
||||
|
||||
void set4Sum();
|
||||
void set5Sum();
|
||||
|
||||
void set6Sum();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
130
test/QQtWidgetClickSoundHelperTest/mainwindow.ui
Normal file
130
test/QQtWidgetClickSoundHelperTest/mainwindow.ui
Normal file
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Double Click</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtDoubleClickSoundWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>LongClick</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtLongClickSoundWidget" name="widget_2" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Click</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser_3"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QQtClickSoundWidget" name="widget_3" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>816</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QQtDoubleClickSoundWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtdoubleclicksoundwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QQtLongClickSoundWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtlongclicksoundwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QQtClickSoundWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtclicksoundwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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;
|
||||
//这里appendChild,t0变成一个list。
|
||||
t0.appendChild ( *n0 );
|
||||
//这里addChild,t0变成一个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];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user