Commit e32c00d4 by guanghui.cui

插件更新

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