Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_home
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmp_home
Commits
7be0da64
Commit
7be0da64
authored
Apr 26, 2017
by
Carwyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 闪烁动画方式改为只对主按钮; 2. 闪烁线程卡死导致插件不能正常退出问题
parent
acf4517e
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
167 additions
and
61 deletions
+167
-61
fmp_flicker.cpp
+81
-0
fmp_flicker.h
+37
-0
fmp_home.pro
+4
-2
fmp_home_navwindow.cpp
+23
-33
fmp_home_navwindow.h
+2
-1
fmp_home_navwindow.ui
+2
-2
fmp_home_p.cpp
+14
-18
menubutton.cpp
+1
-1
menubutton.h
+2
-2
res/img.qrc
+0
-1
res/img/消息.png
+0
-0
version.h
+1
-1
No files found.
fmp_flicker.cpp
0 → 100644
View file @
7be0da64
#include "fmp_flicker.h"
#include <QVariantAnimation>
#include <QPainter>
#include <QDebug>
#include <QStyleOption>
FMPFlicker
::
FMPFlicker
(
const
QString
&
pix
,
QWidget
*
parent
)
:
QPushButton
(
parent
),
_normal
(
pix
),
_opacity
(
1.0
)
{
connect
(
&
_animation
,
SIGNAL
(
valueChanged
(
QVariant
)),
SLOT
(
onOpacityChanged
(
QVariant
)));
}
void
FMPFlicker
::
paintEvent
(
QPaintEvent
*
pe
)
{
Q_UNUSED
(
pe
);
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
int
x
=
(
_normal
.
width
()
-
opt
.
rect
.
width
())
/
2
;
int
y
=
(
_normal
.
height
()
-
opt
.
rect
.
height
())
/
2
;
p
.
translate
(
-
x
,
-
y
);
p
.
setOpacity
(
1
-
_opacity
);
p
.
drawPixmap
(
0
,
0
,
_notify
);
p
.
setOpacity
(
_opacity
);
p
.
drawPixmap
(
0
,
0
,
_normal
);
}
void
FMPFlicker
::
start
(
const
QString
&
pix_path
)
{
if
(
!
pix_path
.
isEmpty
())
{
setNotifyPixmap
(
pix_path
);
}
_animation
.
setStartValue
(
1.0
);
_animation
.
setKeyValueAt
(
0.1
,
1.0
);
_animation
.
setKeyValueAt
(
0.3
,
0.0
);
_animation
.
setKeyValueAt
(
0.7
,
0.0
);
_animation
.
setEndValue
(
1.0
);
_animation
.
setLoopCount
(
-
1
);
_animation
.
setDuration
(
1200
);
_animation
.
start
();
}
void
FMPFlicker
::
stop
()
{
_animation
.
stop
();
_opacity
=
_animation
.
endValue
().
toReal
();
update
();
}
bool
FMPFlicker
::
setNormalPixmap
(
const
QString
&
pix
)
{
QPixmap
pixmap
;
if
(
pixmap
.
load
(
pix
))
{
return
_normal
.
load
(
pix
);
}
return
false
;
}
bool
FMPFlicker
::
setNotifyPixmap
(
const
QString
&
pix
)
{
QPixmap
pixmap
;
if
(
pixmap
.
load
(
pix
))
{
return
_notify
.
load
(
pix
);
}
return
false
;
}
void
FMPFlicker
::
onOpacityChanged
(
const
QVariant
&
v
)
{
_opacity
=
v
.
toReal
();
update
(
_notify
.
rect
());
}
fmp_flicker.h
0 → 100644
View file @
7be0da64
#ifndef FMPFLICKER_H
#define FMPFLICKER_H
class
QPaintEvent
;
#include <QPushButton>
#include <QVariantAnimation>
class
FMPFlicker
:
public
QPushButton
{
Q_OBJECT
public
:
explicit
FMPFlicker
(
const
QString
&
pix
,
QWidget
*
parent
=
0
);
void
paintEvent
(
QPaintEvent
*
pe
);
bool
setNormalPixmap
(
const
QString
&
pix
);
bool
setNotifyPixmap
(
const
QString
&
pix
);
public
slots
:
void
start
(
const
QString
&
pix_path
);
void
start
()
{
start
(
QString
());
}
void
stop
();
private
slots
:
void
onOpacityChanged
(
const
QVariant
&
v
);
private
:
QPixmap
_normal
;
QPixmap
_notify
;
qreal
_opacity
;
QVariantAnimation
_animation
;
};
#endif // FMPFLICKER_H
fmp_home.pro
View file @
7be0da64
...
@@ -22,7 +22,8 @@ SOURCES +=\
...
@@ -22,7 +22,8 @@ SOURCES +=\
fmnetwork
.
cpp
\
fmnetwork
.
cpp
\
fmp_he_handlers
.
cpp
\
fmp_he_handlers
.
cpp
\
fmnumpad
.
cpp
\
fmnumpad
.
cpp
\
fmp_home_settings
.
cpp
fmp_home_settings
.
cpp
\
fmp_flicker
.
cpp
HEADERS
+=
fmp_home
.
h
\
HEADERS
+=
fmp_home
.
h
\
fmp_home_plugin_p
.
h
\
fmp_home_plugin_p
.
h
\
...
@@ -35,7 +36,8 @@ HEADERS += fmp_home.h \
...
@@ -35,7 +36,8 @@ HEADERS += fmp_home.h \
fmnetwork
.
h
\
fmnetwork
.
h
\
fmp_he_handlers
.
h
\
fmp_he_handlers
.
h
\
fmnumpad
.
h
\
fmnumpad
.
h
\
fmp_home_settings
.
h
fmp_home_settings
.
h
\
fmp_flicker
.
h
FORMS
+=
\
FORMS
+=
\
fmp_home_navwindow
.
ui
\
fmp_home_navwindow
.
ui
\
...
...
fmp_home_navwindow.cpp
View file @
7be0da64
...
@@ -25,10 +25,12 @@ NavWindow::NavWindow(QWidget *parent) :
...
@@ -25,10 +25,12 @@ NavWindow::NavWindow(QWidget *parent) :
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
ui
->
navMainBtn
->
setMovedItem
(
this
);
ui
->
navMainBtn
->
setMovedItem
(
this
);
connect
(
this
,
SIGNAL
(
startBlink
()),
ui
->
navMainBtn
,
SLOT
(
start
()));
connect
(
this
,
SIGNAL
(
stopBlink
()),
ui
->
navMainBtn
,
SLOT
(
stop
()));
btns
.
push_back
(
std
::
make_pair
(
"payment"
,
QString
::
fromLocal8Bit
(
"非码支付"
)));
btns
.
push_back
(
std
::
make_pair
(
"payment"
,
QString
::
fromLocal8Bit
(
"非码支付"
)));
btns
.
push_back
(
std
::
make_pair
(
"vip"
,
QString
::
fromLocal8Bit
(
"非码会员"
)));
btns
.
push_back
(
std
::
make_pair
(
"vip"
,
QString
::
fromLocal8Bit
(
"非码会员"
)));
btns
.
push_back
(
std
::
make_pair
(
"take
away
"
,
QString
::
fromLocal8Bit
(
"非码外卖"
)));
btns
.
push_back
(
std
::
make_pair
(
"take
out
"
,
QString
::
fromLocal8Bit
(
"非码外卖"
)));
// btns.push_back(std::make_pair("coupons", QString::fromLocal8Bit("码多多")));
// btns.push_back(std::make_pair("coupons", QString::fromLocal8Bit("码多多")));
btns
.
push_back
(
std
::
make_pair
(
"tool"
,
QString
::
fromLocal8Bit
(
"设置"
)));
btns
.
push_back
(
std
::
make_pair
(
"tool"
,
QString
::
fromLocal8Bit
(
"设置"
)));
...
@@ -54,6 +56,14 @@ NavWindow::NavWindow(QWidget *parent) :
...
@@ -54,6 +56,14 @@ NavWindow::NavWindow(QWidget *parent) :
NavWindow
::~
NavWindow
()
NavWindow
::~
NavWindow
()
{
{
FMP_DEBUG
()
<<
__FUNCTION__
<<
"****"
;
FMP_DEBUG
()
<<
__FUNCTION__
<<
"****"
;
//! 解决闪烁时退出卡死
_semaphore
.
release
(
_blinkObjQueue
.
count
());
_blinkObjQueue
.
clear
();
_blinkObjIdSet
.
clear
();
_blinkFuture
.
waitForFinished
();
delete
_btn_group
;
delete
_btn_group
;
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
actions
.
size
();
++
i
)
{
delete
actions
.
at
(
i
);
delete
actions
.
at
(
i
);
...
@@ -102,7 +112,7 @@ void NavWindow::initMenu()
...
@@ -102,7 +112,7 @@ void NavWindow::initMenu()
stateDefault
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateSpread
);
stateDefault
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateSpread
);
stateSpread
->
assignProperty
(
this
,
"navImage"
,
":fm-icon_02"
);
stateSpread
->
assignProperty
(
this
,
"navImage"
,
":fm-icon_02"
);
stateSpread
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateDefault
);
stateSpread
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateDefault
);
stateGroup
->
setInitialState
(
state
Default
);
stateGroup
->
setInitialState
(
state
Spread
);
QHistoryState
*
stateGroupHistory
=
new
QHistoryState
(
stateGroup
);
QHistoryState
*
stateGroupHistory
=
new
QHistoryState
(
stateGroup
);
stateGroupHistory
->
setDefaultState
(
stateDefault
);
stateGroupHistory
->
setDefaultState
(
stateDefault
);
_stateMachine
->
addState
(
stateGroup
);
_stateMachine
->
addState
(
stateGroup
);
...
@@ -112,7 +122,8 @@ void NavWindow::initMenu()
...
@@ -112,7 +122,8 @@ void NavWindow::initMenu()
stateBlink
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateGroupHistory
);
stateBlink
->
addTransition
(
ui
->
navMainBtn
,
&
QPushButton
::
clicked
,
stateGroupHistory
);
stateBlink
->
addTransition
(
this
,
&
NavWindow
::
stopBlink
,
stateGroupHistory
);
stateBlink
->
addTransition
(
this
,
&
NavWindow
::
stopBlink
,
stateGroupHistory
);
connect
(
stateBlink
,
&
QState
::
exited
,
this
,
[
=
](){
connect
(
stateBlink
,
&
QState
::
exited
,
this
,
[
=
](){
_isStateBlink
=
false
;
ui
->
navMainBtn
->
stop
();
_semaphore
.
release
();
});
});
_stateMachine
->
addState
(
stateBlink
);
_stateMachine
->
addState
(
stateBlink
);
...
@@ -235,7 +246,7 @@ bool NavWindow::removeBlink(int blinkId)
...
@@ -235,7 +246,7 @@ bool NavWindow::removeBlink(int blinkId)
if
(
_blinkObjQueue
.
at
(
i
).
id
==
blinkId
)
{
if
(
_blinkObjQueue
.
at
(
i
).
id
==
blinkId
)
{
_blinkObjQueue
.
removeAt
(
i
);
_blinkObjQueue
.
removeAt
(
i
);
_blinkObjIdSet
.
remove
(
blinkId
);
_blinkObjIdSet
.
remove
(
blinkId
);
if
(
i
==
0
&&
_
isStateBlink
)
{
if
(
i
==
0
&&
_
semaphore
.
available
()
==
0
)
{
emit
stopBlink
();
emit
stopBlink
();
}
}
isOk
=
true
;
isOk
=
true
;
...
@@ -255,39 +266,12 @@ void NavWindow::blink()
...
@@ -255,39 +266,12 @@ void NavWindow::blink()
while
(
!
_blinkObjQueue
.
isEmpty
())
{
while
(
!
_blinkObjQueue
.
isEmpty
())
{
BlinkObject
blinkObject
=
_blinkObjQueue
.
first
();
BlinkObject
blinkObject
=
_blinkObjQueue
.
first
();
// 发送startBlink信号使状态机进入stateBlink
// 发送startBlink信号使状态机进入stateBlink
ui
->
navMainBtn
->
setNotifyPixmap
(
blinkObject
.
image
);
emit
startBlink
();
emit
startBlink
();
_isStateBlink
=
true
;
QPropertyAnimation
m_animation
;
m_animation
.
setTargetObject
(
this
);
m_animation
.
setPropertyName
(
"windowOpacity"
);
m_animation
.
setDuration
(
200
);
m_animation
.
setEasingCurve
(
QEasingCurve
::
InOutSine
);
QEventLoop
loop
;
connect
(
&
m_animation
,
&
QPropertyAnimation
::
finished
,
&
loop
,
&
QEventLoop
::
quit
);
//! 状态机在stateBlink时持续闪烁
//! 状态机在stateBlink时持续闪烁
//! 前面刚发送了startBlink信号,状态机可能还没切换到stateBlink状态,所以不能用stateBlink->active()方法.
//! 前面刚发送了startBlink信号,状态机可能还没切换到stateBlink状态,所以不能用stateBlink->active()方法.
while
(
_isStateBlink
)
{
_semaphore
.
acquire
();
m_animation
.
setStartValue
(
1
);
m_animation
.
setEndValue
(
0
);
m_animation
.
start
();
loop
.
exec
();
QString
oldImage
=
_navImage
;
setNavImage
(
blinkObject
.
image
);
m_animation
.
setStartValue
(
0
);
m_animation
.
setEndValue
(
1
);
m_animation
.
start
();
loop
.
exec
();
m_animation
.
setStartValue
(
1
);
m_animation
.
setEndValue
(
0
);
m_animation
.
start
();
loop
.
exec
();
setNavImage
(
oldImage
);
m_animation
.
setStartValue
(
0
);
m_animation
.
setEndValue
(
1
);
m_animation
.
start
();
loop
.
exec
();
}
if
(
_blinkObjIdSet
.
contains
(
blinkObject
.
id
))
{
if
(
_blinkObjIdSet
.
contains
(
blinkObject
.
id
))
{
FMP_DEBUG
()
<<
"Active blink plugin: "
<<
blinkObject
.
id
;
FMP_DEBUG
()
<<
"Active blink plugin: "
<<
blinkObject
.
id
;
// 如果blinkObject.id还在set中,说明没有调用该闪烁的stop方法,可以发送激活插件信号
// 如果blinkObject.id还在set中,说明没有调用该闪烁的stop方法,可以发送激活插件信号
...
@@ -317,6 +301,12 @@ void NavWindow::onNavImageChanged()
...
@@ -317,6 +301,12 @@ void NavWindow::onNavImageChanged()
"background: url(%1) center no-repeat;"
"background: url(%1) center no-repeat;"
"border: none;}"
"border: none;}"
).
arg
(
_navImage
));
).
arg
(
_navImage
));
if
(
stateSpread
->
active
())
{
ui
->
navMainBtn
->
setNotifyPixmap
(
_navImage
);
}
else
{
ui
->
navMainBtn
->
setNormalPixmap
(
_navImage
);
}
}
}
void
NavWindow
::
showMessage
(
const
QString
&
title
,
const
QString
&
msg
,
QSystemTrayIcon
::
MessageIcon
icon
,
int
mecs
)
void
NavWindow
::
showMessage
(
const
QString
&
title
,
const
QString
&
msg
,
QSystemTrayIcon
::
MessageIcon
icon
,
int
mecs
)
{
{
...
...
fmp_home_navwindow.h
View file @
7be0da64
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <QSet>
#include <QSet>
#include <QString>
#include <QString>
#include <QFuture>
#include <QFuture>
#include <QSemaphore>
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
namespace
Ui
{
namespace
Ui
{
...
@@ -124,7 +125,7 @@ private:
...
@@ -124,7 +125,7 @@ private:
//! 标识状态机是否在stateBlink状态
//! 标识状态机是否在stateBlink状态
//! 之所以没用bool QState::active()方法是因为多进程同步问题
//! 之所以没用bool QState::active()方法是因为多进程同步问题
bool
_isStateBlink
;
QSemaphore
_semaphore
;
//! 闪烁队列、闪烁id的set及执行闪烁的进程future
//! 闪烁队列、闪烁id的set及执行闪烁的进程future
QQueue
<
BlinkObject
>
_blinkObjQueue
;
QQueue
<
BlinkObject
>
_blinkObjQueue
;
QSet
<
int
>
_blinkObjIdSet
;
QSet
<
int
>
_blinkObjIdSet
;
...
...
fmp_home_navwindow.ui
View file @
7be0da64
...
@@ -45,10 +45,10 @@ QPushButton:hover {
...
@@ -45,10 +45,10 @@ QPushButton:hover {
#vip:pressed {
#vip:pressed {
border-image: url(:vip_onclick);
border-image: url(:vip_onclick);
}
}
#take
away
{
#take
out
{
border-image: url(:takeaway);
border-image: url(:takeaway);
}
}
#take
away
:pressed {
#take
out
:pressed {
border-image: url(:takeaway_onclick);
border-image: url(:takeaway_onclick);
}
}
#coupons {
#coupons {
...
...
fmp_home_p.cpp
View file @
7be0da64
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <fmp_epay_i.h>
#include <fmp_epay_i.h>
#include <fmp_vip_i.h>
#include <fmp_vip_i.h>
#include <fmp_settings_i.h>
#include <fmp_settings_i.h>
#include <fmp_takeout_i.h>
#include <QApplication>
#include <QApplication>
#include "fmp_login.h"
#include "fmp_login.h"
#include "fmp_he_handlers.h"
#include "fmp_he_handlers.h"
...
@@ -127,30 +128,25 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
...
@@ -127,30 +128,25 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
}
}
}
}
FMPBaseInterface
*
svc
=
0
;
if
(
btnName
==
"payment"
)
{
if
(
btnName
==
"payment"
)
{
FMPePayInterface
*
e
=
q
->
GetService
<
FMPePayInterface
>
(
q
->
_ctx
);
svc
=
q
->
GetService
<
FMPePayInterface
>
(
q
->
_ctx
);
if
(
e
)
{
e
->
StartService
();
}
else
{
FMP_WARN
()
<<
"Pay service not available"
;
}
}
else
if
(
btnName
==
"vip"
)
{
}
else
if
(
btnName
==
"vip"
)
{
FMPVipInterface
*
e
=
q
->
GetService
<
FMPVipInterface
>
(
q
->
_ctx
);
svc
=
q
->
GetService
<
FMPVipInterface
>
(
q
->
_ctx
);
if
(
e
)
{
q
->
blink
((
FMPluginInterface
*
)
svc
,
"C:/Users/Amor/Documents/QProjects/fmPos/fmp_home/res/img/fm_neworder.png"
);
// e->StartService();
e
->
TriggerInit
();
}
else
{
FMP_WARN
()
<<
"Vip service not available"
;
}
}
else
if
(
btnName
==
"takeout"
)
{
}
else
if
(
btnName
==
"takeout"
)
{
// FMPTakeoutInterface *e = q->GetService<FMPTakeoutInterface>(q->_ctx);
svc
=
q
->
GetService
<
FMPTakeoutInterface
>
(
q
->
_ctx
);
// e->StartService();
}
else
if
(
btnName
==
"coupons"
)
{
}
else
if
(
btnName
==
"coupons"
)
{
// FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx);
// FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx);
// e->StartService();
// e->StartService();
}
else
if
(
btnName
==
"tool"
)
{
}
else
if
(
btnName
==
"tool"
)
{
FMP_DEBUG
()
<<
"tool menu"
;
svc
=
q
->
GetService
<
FMPSettingsInterface
>
(
q
->
_ctx
);
}
if
(
svc
)
{
svc
->
StartService
();
}
else
{
FMP_WARN
()
<<
"service not available"
;
}
}
}
}
menubutton.cpp
View file @
7be0da64
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include <QDebug>
#include <QDebug>
MenuButton
::
MenuButton
(
QWidget
*
parent
)
MenuButton
::
MenuButton
(
QWidget
*
parent
)
:
QPushButton
(
parent
),
:
FMPFlicker
(
""
,
parent
),
_mouseMove
(
false
),
_mouseMove
(
false
),
_mousePress
(
false
),
_mousePress
(
false
),
_canMove
(
false
),
_canMove
(
false
),
...
...
menubutton.h
View file @
7be0da64
#
ifndef
MENUBUTTON_H
#
ifndef
MENUBUTTON_H
#define MENUBUTTON_H
#define MENUBUTTON_H
#include <
QPushButton
>
#include <
fmp_flicker.h
>
#include <QMouseEvent>
#include <QMouseEvent>
class
MenuButton
:
public
QPushButton
class
MenuButton
:
public
FMPFlicker
{
{
Q_OBJECT
Q_OBJECT
public
:
public
:
...
...
res/img.qrc
View file @
7be0da64
<RCC>
<RCC>
<qresource prefix="/">
<qresource prefix="/">
<file alias="xiaoxi">img/消息.png</file>
<file>img/num_del.png</file>
<file>img/num_del.png</file>
<file alias="fm-icon_01">img/fm-icon_01.png</file>
<file alias="fm-icon_01">img/fm-icon_01.png</file>
<file alias="payment">img/fm-icon_payment.png</file>
<file alias="payment">img/fm-icon_payment.png</file>
...
...
res/img/消息.png
deleted
100644 → 0
View file @
acf4517e
5.17 KB
version.h
View file @
7be0da64
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_REVISION 0
#define VER_BUILD
8
#define VER_BUILD
9
//! Convert version numbers to string
//! Convert version numbers to string
#define _STR(S) #S
#define _STR(S) #S
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment