Commit e32c00d4 by guanghui.cui

插件更新

parent 88ad1f82
......@@ -2,18 +2,17 @@
#include "fmp_he_handlers.h"
#include "fmp_home.h"
FMPHomeEventHandler::FMPHomeEventHandler(const QString &topic, FMPHome *home, ctkPluginContext *ctx)
FMPHomeEventHandler::FMPHomeEventHandler(const QString &topic, FMPHome *home)
: _home(home),
_topic(topic),
_ctx(ctx)
_topic(topic)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
_ctx->registerService<ctkEventHandler>(this, props);
FMP::RegisterService<ctkEventHandler>(this, props);
}
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home)
: FMPHomeEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_START "/*", home, ctx)
FMPStartEventHandler::FMPStartEventHandler(FMPHome *home)
: FMPHomeEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_START "/*", home)
{
// connect();
}
......@@ -33,8 +32,8 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
}
}
FMPUpgradeAckEventHandler::FMPUpgradeAckEventHandler(ctkPluginContext *ctx, FMPHome *home)
: FMPHomeEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_UPDATE "/*" , home, ctx)
FMPUpgradeAckEventHandler::FMPUpgradeAckEventHandler(FMPHome *home)
: FMPHomeEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_UPDATE "/*" , home)
{
}
......
......@@ -12,25 +12,24 @@ class FMPHomeEventHandler : public QObject, public ctkEventHandler
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPHomeEventHandler(const QString &topic, FMPHome *home, ctkPluginContext *ctx);
explicit FMPHomeEventHandler(const QString &topic, FMPHome *home);
protected:
FMPHome* _home;
const QString _topic;
ctkPluginContext* _ctx;
};
class FMPStartEventHandler : public FMPHomeEventHandler
{
public:
explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home);
explicit FMPStartEventHandler(FMPHome *home);
void handleEvent(const ctkEvent &event);
};
class FMPUpgradeAckEventHandler : FMPHomeEventHandler
{
public:
explicit FMPUpgradeAckEventHandler(ctkPluginContext *ctx, FMPHome *home);
explicit FMPUpgradeAckEventHandler(FMPHome *home);
void handleEvent(const ctkEvent &event);
};
......
#include "fmp_home_p.h"
#include <QVariant>
#include <ctkPluginContext.h>
FMPHome::FMPHome(ctkPluginContext *context)
: FMPHomeInterface(context),
FMPHome::FMPHome(const FMPContext ctx)
: FMPHomeInterface(),
pluginContext(ctx),
d_ptr(new FMPHomePrivate(this)),
_inited(false)
{
......
......@@ -6,7 +6,6 @@
#include "fmp_home_i.h"
class ctkPluginContext;
class FMPHomePrivate;
class FMPStartEventHandler;
......@@ -18,7 +17,7 @@ class FMPHome : public FMPHomeInterface
Q_INTERFACES(FMPHomeInterface)
Q_DECLARE_PRIVATE(FMPHome)
public:
explicit FMPHome(ctkPluginContext *context);
explicit FMPHome(const FMPContext ctx);
virtual ~FMPHome();
int login();
......@@ -31,12 +30,16 @@ public:
void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME),
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000);
protected:
const FMPContext GetContext() const { return pluginContext; }
protected slots:
virtual void InitService();
virtual void UninitService();
private:
friend class FMPStartEventHandler;
const FMPContext pluginContext;
FMPHomePrivate *d_ptr;
bool _inited;
};
......
......@@ -12,14 +12,11 @@ class FMPHomeInterface : public QObject, public FMPluginInterface
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface)
public:
explicit FMPHomeInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
explicit FMPHomeInterface() : FMPluginInterface()
{
connect(this, &FMPHomeInterface::TriggerInit, this, &FMPHomeInterface::OnTriggerInit);
connect(this, &FMPHomeInterface::TriggerUninit, this, &FMPHomeInterface::OnTriggerUninit);
}
virtual int login() = 0;
virtual bool isLogined() = 0;
virtual QString userName() = 0;
/**
* Entry 插件不需要请求启动,直接执行 StartService 启动
......@@ -34,6 +31,10 @@ public:
return FMP_SUCCESS;
}
virtual int login() = 0;
virtual bool isLogined() = 0;
virtual QString userName() = 0;
/**
* @brief blink
* 在导航窗口中闪烁某张图片,并在下次点击导航窗口时唤起传入的插件
......@@ -71,6 +72,6 @@ protected slots:
void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
};
Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home")
Q_DECLARE_INTERFACE(FMPHomeInterface, "fmp.home")
#endif // FMP_HOME_I_H
......@@ -30,11 +30,11 @@ NavWindow::NavWindow(QWidget *parent) :
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("vip", QString::fromLocal8Bit("非码会员")));
btns.push_back(std::make_pair("takeout", 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("payment", QString::fromLocal8Bit("非码支付")));
// btns.push_back(std::make_pair("vip", QString::fromLocal8Bit("非码会员")));
// btns.push_back(std::make_pair("takeout", QString::fromLocal8Bit("非码外卖")));
// btns.push_back(std::make_pair("coupons", QString::fromLocal8Bit("码多多")));
// btns.push_back(std::make_pair("tool", QString::fromLocal8Bit("设置")));
MenuUiProp.distance = 100;
MenuUiProp.beginAngle = -(PI/2);
......@@ -46,7 +46,7 @@ NavWindow::NavWindow(QWidget *parent) :
this->setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
connect(_btn_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onMenuBtnClicked(QAbstractButton*)));
// initMenu();
initMenu();
initSystemTrayIcon();
......@@ -65,6 +65,7 @@ NavWindow::NavWindow(QWidget *parent) :
this->move(pos);
connect(ui->navMainBtn, SIGNAL(moved(QPoint)), this, SLOT(onMoved(QPoint)));
// connect(ui->navMainBtn, SIGNAL(clicked(bool)), this, SLOT(onOnlyPayment()));
connect(this, SIGNAL(navImageChanged()), this, SLOT(onNavImageChanged()));
}
......@@ -152,10 +153,10 @@ void NavWindow::initMenu()
_centerPoint = QPoint(centerX, centerY);
_centerGeometry = QRect(centerX-MenuUiProp.btnWidth/2,centerY-MenuUiProp.btnWidth/2,MenuUiProp.btnWidth,MenuUiProp.btnWidth);
// for(int i=0; i<btns.size(); i++) {
// std::pair<QString, QString> btnP = btns.at(i);
// createMenuBtn(btnP.first, btnP.second);
// }
for(int i=0; i<btns.size(); i++) {
std::pair<QString, QString> btnP = btns.at(i);
createMenuBtn(btnP.first, btnP.second);
}
}
void NavWindow::createMenuBtn(const QString &btnName, const QString &showName)
......@@ -342,3 +343,8 @@ void NavWindow::showMessage(const QString &title, const QString &msg, QSystemTra
{
_systemTrayIcon->showMessage(title, msg, icon, mecs);
}
void NavWindow::onOnlyPayment()
{
emit menuBtnClicked("payment");
}
......@@ -108,6 +108,7 @@ private slots:
void onMenuBtnClicked(QAbstractButton*);
void onMoved(QPoint point);
void onNavImageChanged();
void onOnlyPayment(); //针对只有支付功能 点击悬浮按钮直接弹出收银窗口
private:
Ui::NavWindow *ui;
......
#include "fmp_home_p.h"
#include "fmp_home_navwindow.h"
#include <fmp_logger_i.h>
#include <ctkPluginContext.h>
#include <ctkServiceReference.h>
#include <QDebug>
#include <fmp_epay_i.h>
......@@ -12,6 +11,8 @@
#include "fmp_login.h"
#include "fmp_he_handlers.h"
#include "fmp_home_settings.h"
#include <QTimer>
#include <QEventLoop>
FMPHomePrivate::FMPHomePrivate(FMPHome *q)
: q_ptr(q),
......@@ -20,7 +21,6 @@ FMPHomePrivate::FMPHomePrivate(FMPHome *q)
_userName(""),
_errorMsg("")
{
FMPLoggerInterface::InitContext(q->_ctx);
}
FMPHomePrivate::~FMPHomePrivate()
......@@ -31,21 +31,21 @@ FMPHomePrivate::~FMPHomePrivate()
int FMPHomePrivate::Init()
{
Q_Q(FMPHome);
_settings = q->GetService<FMPSettingsInterface>(q->_ctx);
FMPHomeSettings::instance()->init(_settings);
settings = FMP::GetService<FMPSettingsInterface>();
FMPHomeSettings::instance()->init(settings);
FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q);
FMPStartEventHandler* handler = new FMPStartEventHandler(q);
_navWindow = new NavWindow;
std::vector<FMPBaseInterface*> svcVector;
svcVector.push_back(q->GetService<FMPVipInterface>(q->_ctx));
svcVector.push_back(q->GetService<FMPePayInterface>(q->_ctx));
svcVector.push_back(FMP::GetService<FMPVipInterface>());
svcVector.push_back(FMP::GetService<FMPePayInterface>());
// _navWindow->createMenuBtn("payment", QString::fromLocal8Bit("非码支付"));
_navWindow->createMenuBtn("payment", QString::fromLocal8Bit("非码支付"));
// _navWindow->createMenuBtn("vip", QString::fromLocal8Bit("非码会员"));
// _navWindow->createMenuBtn("takeout", QString::fromLocal8Bit("非码外卖"));
_navWindow->createMenuBtn("takeout", QString::fromLocal8Bit("非码外卖"));
// _navWindow->createMenuBtn("coupons", QString::fromLocal8Bit("码多多"));
// _navWindow->createMenuBtn("tool", QString::fromLocal8Bit("设置"));
// _navWindow->createMenuBtn("tool", QString::fromLocal8Bit("设置"));
_navWindow->show();
connect(_navWindow, SIGNAL(menuBtnClicked(QString)), this, SLOT(onMenuBtnClicked(QString)));
......@@ -54,11 +54,17 @@ int FMPHomePrivate::Init()
login();
// 启动会员
FMPBaseInterface *svc = q->GetService<FMPVipInterface>(q->_ctx);
FMPBaseInterface* svc = FMP::GetService<FMPVipInterface>();
if(svc) {
svc->StartService();
}
//启动外卖
FMPBaseInterface *svcTakeout = FMP::GetService<FMPTakeoutInterface>();
if(svcTakeout) {
svcTakeout->StartService();
}
q->_inited = true;
return FMP_SUCCESS;
}
......@@ -148,19 +154,19 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
}
}
FMPBaseInterface *svc = 0;
FMPBaseInterface* svc = nullptr;
if(btnName == "payment") {
svc = q->GetService<FMPePayInterface>(q->_ctx);
svc = FMP::GetService<FMPePayInterface>();
} else if(btnName == "vip") {
svc = q->GetService<FMPVipInterface>(q->_ctx);
svc = FMP::GetService<FMPVipInterface>();
// q->blink((FMPluginInterface*)svc, ":/image/float_remind.png");
} else if(btnName == "takeout") {
svc = q->GetService<FMPTakeoutInterface>(q->_ctx);
svc = FMP::GetService<FMPTakeoutInterface>();
} else if(btnName == "coupons") {
// FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx);
// e->StartService();
} else if(btnName == "tool") {
svc = q->GetService<FMPSettingsInterface>(q->_ctx);
svc = FMP::GetService<FMPSettingsInterface>();
}
if (svc) {
......
......@@ -42,7 +42,7 @@ public:
private:
NavWindow *_navWindow;
FMPSettingsInterface *_settings;
FMPSettingsInterface* settings;
bool _isLogining;
};
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 17
#define VER_BUILD 19
//! Convert version numbers to string
#define _STR(S) #S
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment