1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

Merge branch 'dev-fact' of https://gitee.com/drabel/LibQQt into dev-fact

This commit is contained in:
tianduanrui 2018-05-19 18:01:14 +08:00
commit 8c5118d726
64 changed files with 2361 additions and 587 deletions

View File

@ -85,7 +85,8 @@ greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
#必开
#SUBDIRS += test/qqtdicttest2
#必开
#SUBDIRS += test/giftest
#
SUBDIRS += test/giftest
#必开 这两个例子是关于QQtAudio的最好展示
#SUBDIRS += examples/qqtaudioexample
@ -115,3 +116,4 @@ greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
#SUBDIRS += demo/TouchMonitorServer
SUBDIRS += test/QQtWidgetClickHelperTest
SUBDIRS += test/QQtWidgetClickSoundHelperTest

View File

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

View 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

View File

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

View File

@ -0,0 +1,105 @@
#ifndef QQTCLICKSOUNDLABEL_H
#define QQTCLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* basic类 click信号
* ClickHelper的能力
* MouseEvent响应
*
* 使
* new ClickHelper
* installClickHelper
*/
class QQTSHARED_EXPORT QQtClickSoundLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtClickSoundHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtClickSoundLabel() {}
/**
* App用信号
*
*/
signals:
void click();
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// 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 ) ) );
}
private:
QQtClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKSOUNDLABEL_H

View File

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

View File

@ -0,0 +1,103 @@
#ifndef QQTCLICKSOUNDWIDGET_H
#define QQTCLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* ClickHelper
*
* clickSound支持的QQtWidget
* Widget表示了如何使用QQtClickSoundHelper和它的子类
*
*/
class QQTSHARED_EXPORT QQtClickSoundWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtClickSoundHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtClickSoundWidget() {}
/**
* App用信号
*
*/
signals:
void click();
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// 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 ) ) );
}
private:
QQtClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKSOUNDWIDGET_H

View File

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

View 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

View File

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

View File

@ -0,0 +1,112 @@
#ifndef QQTDOUBLECLICKSOUNDLABEL_H
#define QQTDOUBLECLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtdoubleclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtDoubleClickSoundLabel : public QQtLabel
{
public:
explicit QQtDoubleClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtDoubleClickSoundHelper ( this );
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 );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,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 ) ) );
}
private:
QQtDoubleClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKSOUNDLABEL_H

View File

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

View File

@ -0,0 +1,115 @@
#ifndef QQTDOUBLECLICKSOUNDWIDGET_H
#define QQTDOUBLECLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtdoubleclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* DoubleClickHelper
*
* doubleClick支持的QQtClickSoundSoundWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtDoubleClickSoundWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtDoubleClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtDoubleClickSoundHelper ( this );
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 );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,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 ) ) );
}
private:
QQtDoubleClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKSOUNDWIDGET_H

View File

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

View 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

View File

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

View File

@ -0,0 +1,108 @@
#ifndef QQTLONGCLICKSOUNDLABEL_H
#define QQTLONGCLICKSOUNDLABEL_H
#include <qqtlabel.h>
#include <qqtlongclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
* Label服务
*/
class QQTSHARED_EXPORT QQtLongClickSoundLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtLongClickSoundLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtLongClickSoundHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickSoundLabel() {}
/**
* App用信号
*
*/
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// 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 ) ) );
}
private:
QQtLongClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKSOUNDLABEL_H

View File

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

View File

@ -0,0 +1,107 @@
#ifndef QQTLONGCLICKSOUNDWIDGET_H
#define QQTLONGCLICKSOUNDWIDGET_H
#include <qqtwidget.h>
#include <qqtlongclicksoundhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* ClickHelper的能力
* Widget服务
*/
class QQTSHARED_EXPORT QQtLongClickSoundWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtLongClickSoundWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtLongClickSoundHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickSoundWidget() {}
/**
* App用信号
*
*/
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickSoundHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickSoundHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// 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 ) ) );
}
private:
QQtLongClickSoundHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKSOUNDWIDGET_H

View File

@ -0,0 +1,128 @@
#include "qqtclickhelper.h"
QQtClickHelper::QQtClickHelper ( QObject* parent ) : QObject ( parent )
{
nClickNumWithCancel = 0;
nTotalClickNumWithCancel = 0;
nClickNum = 0;
nTotalClickNum = 0;
mClickType = QQtNullClick;
}
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()
{
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 )
{
switch ( type )
{
case QQtClick:
{
nClickNum++;
if ( nClickNum >= 0xFFFFFFFF )
{
p2debug() << "out......";
nClickNum = 0;
}
}
break;
default:
break;
}
nTotalClickNum = nClickNum;
if ( nTotalClickNum >= 0xFFFFFFFFFFFFFFFF )
{
p2debug() << "out......";
nTotalClickNum = 0;
}
}

View File

@ -30,6 +30,28 @@ 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:
@ -37,35 +59,18 @@ public:
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
signals:
void clickWithPointF ( QPointF point );
void longClickWithPointF ( QPointF point );
//optional
public:
//设置longClick超时 default:1200ms
void setLongClickInterval ( int millSecond = longClickInterval );
int getLongClickInterval() const;
inline const quint32 clickNum() const { return nClickNum; }
inline const quint64 totalClickNum() const { return nTotalClickNum; }
quint32 clickNum() const;
quint32 longClickNum() const;
quint64 totalClickNum() const;
inline const quint32 clickNumWithCancel() const { return nClickNumWithCancel; }
inline const quint64 totalClickNumWithCancel() const { return nTotalClickNumWithCancel; }
/**
*
*/
public:
Q_ENUMS ( QQtClickType )
Q_PROPERTY ( int mLongClickInterval READ getLongClickInterval WRITE setLongClickInterval )
typedef enum
{
QQtNullClick = 0,
@ -77,29 +82,24 @@ public:
QQtMaxClick
} QQtClickType;
Q_ENUMS ( QQtClickType )
protected:
//这个语法比较难,只有整型有特权.
static const int longClickInterval = 1200;
//用于记录点击到了什么状态.
QQtClickType mClickType;
//用于记录按钮的位置
QPoint mPoint;
int mLongClickInterval;
//click 检测使用
QTime t1;//press relase
QTime t2;//release
//click num
virtual void checkClickNum();
virtual void checkClickNumWithCancel();
virtual void checkClickNum ( QQtClickType type );
quint32 nClickNum;
quint32 nLongClickNum;
quint64 nTotalClickNum;
quint32 nClickNumWithCancel;
quint64 nTotalClickNumWithCancel;
};
#endif // QQTCLICKHELPER_H

View File

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

View File

@ -0,0 +1,105 @@
#ifndef QQTCLICKLABEL_H
#define QQTCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* basic类 click信号
* ClickHelper的能力
* MouseEvent响应
*
* 使
* new ClickHelper
* installClickHelper
*/
class QQTSHARED_EXPORT QQtClickLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtClickHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtClickLabel() {}
/**
* App用信号
*
*/
signals:
void click();
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
protected:
virtual void connectClickHelper() {
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 ) ) );
}
private:
QQtClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKLABEL_H

View File

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

View File

@ -0,0 +1,103 @@
#ifndef QQTCLICKWIDGET_H
#define QQTCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* ClickHelper
*
* click支持的QQtWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*
*/
class QQTSHARED_EXPORT QQtClickWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtClickHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtClickWidget() {}
/**
* App用信号
*
*/
signals:
void click();
signals:
void clickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
protected:
virtual void connectClickHelper() {
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 ) ) );
}
private:
QQtClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTCLICKWIDGET_H

View File

@ -1,16 +1,23 @@
#include "qqtdoubleclickhelper.h"
QQtDoubleClickHelper::QQtDoubleClickHelper ( QObject* parent ) :
QQtClickHelper ( 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;
mClickType = QQtNullClick;
m_click_timer = new QTimer ( this );
m_click_timer->setSingleShot ( false );
//击发延迟20ms
@ -45,26 +52,44 @@ void QQtDoubleClickHelper::mousePressEvent ( QMouseEvent* event , QWidget* userW
//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
t1 = QTime::currentTime();
now_doubleclick = QTime::currentTime();
//这里有小技巧: 这里没有加 && mClickType != QQtClick
//难道不会和click时钟混淆吗?不会,因为click时钟那边用的startTime和nowTime两个变量, t2比startTime还早,t1比nowTime还晚,t1-t2绝对比nowTime-startTime还长.
//如果是click,绝对不会混淆成doubleClick.
//正好mDoubleClickInterval ms代表双击 不代表单击.
if ( t2.msecsTo ( t1 ) >= 0 && t2.msecsTo ( t1 ) <= mDoubleClickInterval )
p2debug() << prev_doubleclick << now_doubleclick << mClickType;
if ( prev_doubleclick.msecsTo ( now_doubleclick ) >= 0
&& prev_doubleclick.msecsTo ( now_doubleclick ) < mDoubleClickInterval )
{
//双击发生
mClickType = QQtDoubleClick;
}
//上一次 prev click
t2 = QTime::currentTime();
prev_doubleclick = QTime::currentTime();
//梳理状态
m_long_click_timer->stop();
@ -73,7 +98,7 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
if ( mClickType == QQtLongClick )
{
//计算点击数目
checkClickNum();
checkClickNumWithCancel();
//修改状态
mClickType = QQtNullClick;
@ -90,6 +115,8 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
}
}
checkClickNum ( QQtLongClick );
//发送长信号
p2debug() << "send long click " ;
emit longClick();
@ -101,7 +128,7 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
else if ( mClickType == QQtDoubleClick )
{
//计算点击数目
checkClickNum();
checkClickNumWithCancel();
//修改状态
mClickType = QQtNullClick;
@ -118,6 +145,8 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
}
}
checkClickNum ( QQtDoubleClick );
//发送双击信号
p2debug() << "send double click." ;
emit doubleClick();
@ -129,7 +158,7 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
else if ( mClickType == QQtClick )
{
//计算点击数目
checkClickNum();
checkClickNumWithCancel();
//修改状态
mClickType = QQtNullClick;
@ -146,6 +175,8 @@ void QQtDoubleClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* user
}
}
checkClickNum ( QQtClick );
//发送单击信号
p2debug() << "send click." ;
emit click();
@ -191,8 +222,38 @@ void QQtDoubleClickHelper::slotClickTimeout()
QTime nowTime = QTime::currentTime();
int t0 = startClickTime.msecsTo ( nowTime );
p2debug() << t0 << mDoubleClickInterval << qApp->doubleClickInterval();
if ( 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;
@ -202,7 +263,8 @@ void QQtDoubleClickHelper::slotClickTimeout()
void QQtDoubleClickHelper::slotLongClickTimeout()
{
//longclick超时,确认longclick.
mClickType = QQtLongClick;
//不再使用此处检测,而是改在click时钟检测.
//mClickType = QQtLongClick;
m_long_click_timer->stop();
}
@ -211,10 +273,38 @@ void QQtDoubleClickHelper::slotDoubleClickTimeout()
}
void QQtDoubleClickHelper::checkClickNum()
void QQtDoubleClickHelper::checkClickNumWithCancel()
{
QQtClickHelper::checkClickNum();
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:
{

View File

@ -4,7 +4,7 @@
#include <QTimer>
#include <qqtevent.h>
#include <qqtclickhelper.h>
#include <qqtlongclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
@ -12,6 +12,11 @@
/**
* @brief The QQtDoubleClickHelper class
*
*
* click
* longClick
* doubleClick
*
*
* release开始检测.
* longClick只发送longClick.
@ -28,7 +33,7 @@
*
* DoubleClick检测是独立于系统的,,widget一个时延系统也没问题.
*/
class QQTSHARED_EXPORT QQtDoubleClickHelper : public QQtClickHelper
class QQTSHARED_EXPORT QQtDoubleClickHelper : public QQtLongClickHelper
{
Q_OBJECT
@ -39,9 +44,9 @@ public:
//调用于userWidget相对应的Event里
//允许重写
public:
virtual void mousePressEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 );
virtual void mousePressEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
virtual void mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
virtual void mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget = 0 ) override;
signals:
void doubleClick();
@ -54,9 +59,6 @@ signals:
//optional
public:
//这个语法比较难,只有整型有特权.
static const int doubleClickInterval = 400;
//设置双击检测时延 default: doubleClickInterval ms
//不会影响系统默认时延
void setDoubleClickInterval ( int millSecond = doubleClickInterval ) {
@ -66,7 +68,8 @@ public:
return mDoubleClickInterval;
}
quint32 doubleClickNum() const { return nDoubleClickNum; }
inline const quint32 doubleClickNum() const { return nDoubleClickNum; }
inline const quint32 doubleClickNumWithCancel() const { return nDoubleClickNumWithCancel; }
/**
*
@ -79,6 +82,9 @@ public slots:
void slotDoubleClickTimeout();
protected:
//这个语法比较难,只有整型有特权.
static const int doubleClickInterval = 260;
//clickTimer
QTimer* m_click_timer;
//longClickTimer
@ -86,8 +92,6 @@ protected:
//doubleClickTimer
QTimer* m_double_click_timer;
//用于记录按钮的位置
QPoint mPoint;
//双击200ms. 这个比较符合双击舒适度.Qt内部的Timer慢一些,可能是计算了比较完整的时间.
//在这个范围内的都 才 是双击
@ -96,13 +100,24 @@ protected:
//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();
virtual void checkClickNum ( QQtClickType type ) override;
virtual void checkClickNumWithCancel() override;
quint32 nDoubleClickNum;
quint32 nDoubleClickNumWithCancel;
};
#endif // QQTDOUBLECLICKHELPER_H

View File

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

View File

@ -0,0 +1,112 @@
#ifndef QQTDOUBLECLICKLABEL_H
#define QQTDOUBLECLICKLABEL_H
#include <qqtlabel.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtDoubleClickLabel : public QQtLabel
{
public:
explicit QQtDoubleClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtDoubleClickHelper ( this );
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 );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,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 ) ) );
}
private:
QQtDoubleClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKLABEL_H

View File

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

View File

@ -0,0 +1,115 @@
#ifndef QQTDOUBLECLICKWIDGET_H
#define QQTDOUBLECLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* DoubleClickHelper
*
* doubleClick支持的QQtClickWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtDoubleClickWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtDoubleClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtDoubleClickHelper ( this );
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 );
/**
* 使
*/
public:
inline void installClickHelper ( QQtDoubleClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtDoubleClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,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 ) ) );
}
private:
QQtDoubleClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTDOUBLECLICKWIDGET_H

View File

@ -1,56 +1,61 @@
#include "qqtclickhelper.h"
#include "qqtlongclickhelper.h"
QQtClickHelper::QQtClickHelper ( QObject* parent )
QQtLongClickHelper::QQtLongClickHelper ( QObject* parent ) : QQtClickHelper ( parent )
{
mLongClickInterval = longClickInterval;
t1 = QTime::currentTime();
t2 = QTime::currentTime();
now_press = QTime::currentTime().addMSecs ( 1 );
now_release = QTime::currentTime().addMSecs ( 2 );
nClickNum = 0;
nLongClickNum = 0;
nTotalClickNum = 0;
mClickType = QQtNullClick;
nLongClickNumWithCancel = 0;
}
QQtClickHelper::~QQtClickHelper()
QQtLongClickHelper::~QQtLongClickHelper()
{
}
void QQtClickHelper::mousePressEvent ( QMouseEvent* event, QWidget* userWidget )
void QQtLongClickHelper::mousePressEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "press" << event->pos() << userWidget;
mPoint = event->pos();
mClickType = QQtClick;
t1 = QTime::currentTime();
now_press = QTime::currentTime();
}
void QQtClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
void QQtLongClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "release" << event->pos() << userWidget;
//这一次 current click
t2 = QTime::currentTime();
QTime t2_release_preview = now_release;
now_release = QTime::currentTime();
//这里加了个判断,其实肯定>=0
if ( t1.msecsTo ( t2 ) >= 0 && t1.msecsTo ( t2 ) <= mLongClickInterval )
if ( now_press.msecsTo ( now_release ) >= 0 && now_press.msecsTo ( now_release ) <= mLongClickInterval )
{
//单击发生
mClickType = QQtClick;
}
else if ( t1.msecsTo ( t2 ) >= 0 && t1.msecsTo ( t2 ) > mLongClickInterval )
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;
}
}
//更新t1 防止用户忘记press,直接release.
//preview click
t1 = QTime::currentTime();
if ( mClickType == QQtLongClick )
{
//计算点击数目
checkClickNum();
checkClickNumWithCancel();
//修改状态
mClickType = QQtNullClick;
@ -67,18 +72,25 @@ void QQtClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget
}
}
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 )
{
//计算点击数目
checkClickNum();
checkClickNumWithCancel();
//修改状态
mClickType = QQtNullClick;
@ -95,12 +107,20 @@ void QQtClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget
}
}
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;
}
@ -113,42 +133,55 @@ void QQtClickHelper::mouseReleaseEvent ( QMouseEvent* event, QWidget* userWidget
}
void QQtClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget )
void QQtLongClickHelper::mouseDoubleClickEvent ( QMouseEvent* event, QWidget* userWidget )
{
p2debug() << "double click" << event->pos() << userWidget;
mPoint = event->pos();
}
void QQtClickHelper::setLongClickInterval ( int millSecond )
void QQtLongClickHelper::setLongClickInterval ( int millSecond )
{
mLongClickInterval = millSecond;
}
int QQtClickHelper::getLongClickInterval() const
int QQtLongClickHelper::getLongClickInterval() const
{
return mLongClickInterval;
}
quint32 QQtClickHelper::clickNum() const { return nClickNum; }
quint32 QQtClickHelper::longClickNum() const { return nLongClickNum; }
quint64 QQtClickHelper::totalClickNum() const { return nTotalClickNum; }
void QQtClickHelper::checkClickNum()
void QQtLongClickHelper::checkClickNumWithCancel()
{
QQtClickHelper::checkClickNumWithCancel();
switch ( mClickType )
{
case QQtClick:
case QQtLongClick:
{
nClickNum++;
if ( nClickNum >= 0xFFFFFFFF )
nLongClickNumWithCancel++;
if ( nLongClickNumWithCancel >= 0xFFFFFFFF )
{
p2debug() << "out......";
nClickNum = 0;
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++;

View 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

View File

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

View File

@ -0,0 +1,108 @@
#ifndef QQTLONGCLICKLABEL_H
#define QQTLONGCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtlongclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
* Label服务
*/
class QQTSHARED_EXPORT QQtLongClickLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtLongClickLabel ( QWidget* parent = 0 ) :
QQtLabel ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtLongClickHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickLabel() {}
/**
* App用信号
*
*/
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
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 ) ) );
}
private:
QQtLongClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKLABEL_H

View File

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

View File

@ -0,0 +1,107 @@
#ifndef QQTLONGCLICKWIDGET_H
#define QQTLONGCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtlongclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* ClickHelper的能力
* Widget服务
*/
class QQTSHARED_EXPORT QQtLongClickWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtLongClickWidget ( QWidget* parent = 0 ) :
QQtWidget ( parent ) {
mClickHelper = 0;
mClickHelper = new QQtLongClickHelper ( this );
installClickHelper ( mClickHelper );
}
virtual ~QQtLongClickWidget() {}
/**
* App用信号
*
*/
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
/**
* 使
*/
public:
inline void installClickHelper ( QQtLongClickHelper* helper ) {
unConnectClickHelper();
mClickHelper = helper;
if ( !mClickHelper )
return;
connectClickHelper();
}
inline QQtLongClickHelper* clickHelper() const {
return mClickHelper;
}
/**
* ,click能力
*/
// QQtWidget interface
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 ) ) );
}
private:
QQtLongClickHelper* mClickHelper;
/**
* MouseEvent函数,
* clickHelper的响应能力
*/
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
virtual void mouseReleaseEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) {
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}
};
#endif // QQTLONGCLICKWIDGET_H

View File

@ -1,35 +0,0 @@
#include "qqtcanclicklabel.h"
QQtCanClickLabel::QQtCanClickLabel ( QWidget* parent ) :
QQtLabel ( parent )
{
mClickHelper = 0;
}
QQtCanClickLabel::~QQtCanClickLabel()
{
}
void QQtCanClickLabel::mousePressEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtLabel::mousePressEvent ( event );
}
void QQtCanClickLabel::mouseReleaseEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtLabel::mouseReleaseEvent ( event );
}
void QQtCanClickLabel::mouseDoubleClickEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtLabel::mouseDoubleClickEvent ( event );
}

View File

@ -1,48 +0,0 @@
#ifndef QQTCANCLICKLABEL_H
#define QQTCANCLICKLABEL_H
#include <qqtlabel.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
* Label服务
*/
class QQTSHARED_EXPORT QQtCanClickLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtCanClickLabel ( QWidget* parent = 0 );
virtual ~QQtCanClickLabel();
signals:
signals:
public:
inline void setClickHelper ( QQtClickHelper* helper ) {
uninstallClickHelper();
mClickHelper = helper;
installClickHelper();
}
inline const QQtClickHelper* clickHelper() const {
return mClickHelper;
}
protected:
//需要重写
virtual void installClickHelper() {}
virtual void uninstallClickHelper() {}
QQtClickHelper* mClickHelper;
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) override;
virtual void mouseReleaseEvent ( QMouseEvent* event ) override;
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override;
};
#endif // QQTCANCLICKLABEL_H

View File

@ -1,35 +0,0 @@
#include "qqtcanclickwidget.h"
QQtCanClickWidget::QQtCanClickWidget ( QWidget* parent ) :
QQtWidget ( parent )
{
mClickHelper = 0;
}
QQtCanClickWidget::~QQtCanClickWidget()
{
}
void QQtCanClickWidget::mousePressEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mousePressEvent ( event, this );
return QQtWidget::mousePressEvent ( event );
}
void QQtCanClickWidget::mouseReleaseEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mouseReleaseEvent ( event, this );
return QQtWidget::mouseReleaseEvent ( event );
}
void QQtCanClickWidget::mouseDoubleClickEvent ( QMouseEvent* event )
{
if ( mClickHelper )
mClickHelper->mouseDoubleClickEvent ( event, this );
return QQtWidget::mouseDoubleClickEvent ( event );
}

View File

@ -1,48 +0,0 @@
#ifndef QQTCANCLICKWIDGET_H
#define QQTCANCLICKWIDGET_H
#include <qqtwidget.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
* Widget服务
*/
class QQTSHARED_EXPORT QQtCanClickWidget : public QQtWidget
{
Q_OBJECT
public:
explicit QQtCanClickWidget ( QWidget* parent = 0 );
virtual ~QQtCanClickWidget();
signals:
signals:
public:
inline void setClickHelper ( QQtClickHelper* helper ) {
uninstallClickHelper();
mClickHelper = helper;
installClickHelper();
}
inline const QQtClickHelper* clickHelper() const {
return mClickHelper;
}
protected:
//需要重写
virtual void installClickHelper() {}
virtual void uninstallClickHelper() {}
QQtClickHelper* mClickHelper;
// QWidget interface
protected:
virtual void mousePressEvent ( QMouseEvent* event ) override;
virtual void mouseReleaseEvent ( QMouseEvent* event ) override;
virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override;
};
#endif // QQTCANCLICKWIDGET_H

View File

@ -1,35 +0,0 @@
#include "qqtclicklabel.h"
QQtClickLabel::QQtClickLabel ( QWidget* parent ) :
QQtCanClickLabel ( parent )
{
mClickHelper = new QQtClickHelper ( this );
installClickHelper();
}
QQtClickLabel::~QQtClickLabel()
{
}
void QQtClickLabel::installClickHelper()
{
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 ) ) );
}
void QQtClickLabel::uninstallClickHelper()
{
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 ) ) );
}

View File

@ -1,35 +0,0 @@
#ifndef QQTCLICKLABEL_H
#define QQTCLICKLABEL_H
#include <qqtcanclicklabel.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtClickLabel : public QQtCanClickLabel
{
Q_OBJECT
public:
explicit QQtClickLabel ( QWidget* parent = 0 );
virtual ~QQtClickLabel();
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
// QQtWidget interface
protected:
virtual void installClickHelper() override;
virtual void uninstallClickHelper() override;
};
#endif // QQTCLICKLABEL_H

View File

@ -1,35 +0,0 @@
#include "qqtclickwidget.h"
QQtClickWidget::QQtClickWidget ( QWidget* parent ) :
QQtCanClickWidget ( parent )
{
mClickHelper = new QQtClickHelper ( this );
installClickHelper();
}
QQtClickWidget::~QQtClickWidget()
{
}
void QQtClickWidget::installClickHelper()
{
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 ) ) );
}
void QQtClickWidget::uninstallClickHelper()
{
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 ) ) );
}

View File

@ -1,38 +0,0 @@
#ifndef QQTCLICKWIDGET_H
#define QQTCLICKWIDGET_H
#include <qqtcanclickwidget.h>
#include <qqtclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* longClick支持的QQtCanClickWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtClickWidget : public QQtCanClickWidget
{
Q_OBJECT
public:
explicit QQtClickWidget ( QWidget* parent = 0 );
virtual ~QQtClickWidget();
/**
*
*/
signals:
void click();
void longClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
// QQtWidget interface
protected:
virtual void installClickHelper() override;
virtual void uninstallClickHelper() override;
};
#endif // QQTCLICKWIDGET_H

View File

@ -1,37 +0,0 @@
#include "qqtdoubleclicklabel.h"
QQtDoubleClickLabel::QQtDoubleClickLabel ( QWidget* parent ) :
QQtCanClickLabel ( parent )
{
mClickHelper = new QQtDoubleClickHelper ( this );
installClickHelper();
}
QQtDoubleClickLabel::~QQtDoubleClickLabel()
{
}
void QQtDoubleClickLabel::installClickHelper()
{
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 ) ) );
}
void QQtDoubleClickLabel::uninstallClickHelper()
{
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 ) ) );
}

View File

@ -1,37 +0,0 @@
#ifndef QQTDOUBLECLICKLABEL_H
#define QQTDOUBLECLICKLABEL_H
#include <qqtcanclicklabel.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
*
* ClickHelper的能力
*/
class QQTSHARED_EXPORT QQtDoubleClickLabel : public QQtCanClickLabel
{
Q_OBJECT
public:
explicit QQtDoubleClickLabel ( QWidget* parent = 0 );
virtual ~QQtDoubleClickLabel();
signals:
void click();
void longClick();
void doubleClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
// QQtWidget interface
protected:
virtual void installClickHelper() override;
virtual void uninstallClickHelper() override;
};
#endif // QQTDOUBLECLICKLABEL_H

View File

@ -1,38 +0,0 @@
#include "qqtdoubleclickwidget.h"
QQtDoubleClickWidget::QQtDoubleClickWidget ( QWidget* parent ) :
QQtCanClickWidget ( parent )
{
mClickHelper = new QQtDoubleClickHelper ( this );
installClickHelper();
}
QQtDoubleClickWidget::~QQtDoubleClickWidget()
{
}
void QQtDoubleClickWidget::installClickHelper()
{
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 ) ) );
}
void QQtDoubleClickWidget::uninstallClickHelper()
{
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 ) ) );
}

View File

@ -1,37 +0,0 @@
#ifndef QQTDOUBLECLICKWIDGET_H
#define QQTDOUBLECLICKWIDGET_H
#include <qqtcanclickwidget.h>
#include <qqtdoubleclickhelper.h>
#include <qqt-local.h>
#include <qqtcore.h>
/**
* doubleClick支持的QQtClickWidget
* Widget表示了如何使用QQtWidgetClickHelper和它的子类
*/
class QQTSHARED_EXPORT QQtDoubleClickWidget : public QQtCanClickWidget
{
Q_OBJECT
public:
explicit QQtDoubleClickWidget ( QWidget* parent = 0 );
virtual ~QQtDoubleClickWidget();
signals:
void click();
void longClick();
void doubleClick();
signals:
void clickWithPoint ( QPoint point );
void longClickWithPoint ( QPoint point );
void doubleClickWithPoint ( QPoint point );
// QQtWidget interface
protected:
virtual void installClickHelper() override;
virtual void uninstallClickHelper() override;
};
#endif // QQTDOUBLECLICKWIDGET_H

View File

@ -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" );

View File

@ -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

View File

@ -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}

View File

@ -318,31 +318,6 @@ contains (DEFINES, __NETWORKSUPPORT__) {
contains (DEFINES, __EXQUISITE__) {
#exquisite
SOURCES += \
$$PWD/exquisite/qqtclickhelper.cpp \
$$PWD/exquisite/qqtdoubleclickhelper.cpp
HEADERS += \
$$PWD/exquisite/qqtclickhelper.h \
$$PWD/exquisite/qqtdoubleclickhelper.h
SOURCES += \
$$PWD/exquisite/qqtcanclickwidget.cpp \
$$PWD/exquisite/qqtclickwidget.cpp \
$$PWD/exquisite/qqtdoubleclickwidget.cpp
HEADERS += \
$$PWD/exquisite/qqtcanclickwidget.h \
$$PWD/exquisite/qqtclickwidget.h \
$$PWD/exquisite/qqtdoubleclickwidget.h
SOURCES += \
$$PWD/exquisite/qqtcanclicklabel.cpp \
$$PWD/exquisite/qqtclicklabel.cpp \
$$PWD/exquisite/qqtdoubleclicklabel.cpp
HEADERS += \
$$PWD/exquisite/qqtcanclicklabel.h \
$$PWD/exquisite/qqtclicklabel.h \
$$PWD/exquisite/qqtdoubleclicklabel.h
SOURCES += \
$$PWD/exquisite/qqtframelesshelper.cpp \
$$PWD/exquisite/qqtframelesshelperprivate.cpp
@ -350,6 +325,67 @@ 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/qqtclickhelper.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclickhelper.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclickhelper.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtclickhelper.h \
$$PWD/exquisite/clickwidgets/qqtlongclickhelper.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclickhelper.h
SOURCES += \
$$PWD/exquisite/clickwidgets/qqtclickwidget.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclickwidget.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclickwidget.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtclickwidget.h \
$$PWD/exquisite/clickwidgets/qqtlongclickwidget.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclickwidget.h
SOURCES += \
$$PWD/exquisite/clickwidgets/qqtclicklabel.cpp \
$$PWD/exquisite/clickwidgets/qqtlongclicklabel.cpp \
$$PWD/exquisite/clickwidgets/qqtdoubleclicklabel.cpp
HEADERS += \
$$PWD/exquisite/clickwidgets/qqtclicklabel.h \
$$PWD/exquisite/clickwidgets/qqtlongclicklabel.h \
$$PWD/exquisite/clickwidgets/qqtdoubleclicklabel.h
}
#dialog
SOURCES += \
$$PWD/exquisite/qqtpopupdialog.cpp

View File

@ -21,6 +21,9 @@ MainWindow::MainWindow ( QWidget* parent ) :
this, SLOT ( set4Sum() ) );
connect ( ui->widget_2, SIGNAL ( longClick() ),
this, SLOT ( set5Sum() ) );
connect ( ui->widget_3, SIGNAL ( click() ),
this, SLOT ( set6Sum() ) );
}
MainWindow::~MainWindow()
@ -53,3 +56,8 @@ 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() ) );;
}

View File

@ -23,6 +23,8 @@ public slots:
void set4Sum();
void set5Sum();
void set6Sum();
private:
Ui::MainWindow* ui;
};

View File

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -42,14 +42,34 @@
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Click</string>
<string>LongClick</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QTextBrowser" name="textBrowser_2"/>
</item>
<item>
<widget class="QQtClickWidget" name="widget_2" native="true">
<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>
@ -70,7 +90,7 @@
<x>0</x>
<y>0</y>
<width>816</width>
<height>39</height>
<height>17</height>
</rect>
</property>
</widget>
@ -92,6 +112,12 @@
<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>

Binary file not shown.

View File

@ -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)

View 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();
}

View 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() ) );
ui->widget->clickHelper()->setClickSound ( qrc ( "click.wav" ) );
ui->widget->clickHelper()->setLongClickSound ( qrc ( "longclick.wav" ) );
ui->widget->clickHelper()->setDoubleClickSound ( qrc ( "doubleclick.wav" ) );
connect ( ui->widget_2, SIGNAL ( click() ),
this, SLOT ( set4Sum() ) );
connect ( ui->widget_2, SIGNAL ( longClick() ),
this, SLOT ( set5Sum() ) );
ui->widget_2->clickHelper()->setClickSound ( qrc ( "click.wav" ) );
ui->widget_2->clickHelper()->setLongClickSound ( qrc ( "longclick.wav" ) );
connect ( ui->widget_3, SIGNAL ( click() ),
this, SLOT ( set6Sum() ) );
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() ) );;
}

View 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

View 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>