Commit dfe0183c by NitefullWind

1. 使用日志和配置插件。

parent df933c8a
...@@ -22,5 +22,8 @@ Timer=10 ...@@ -22,5 +22,8 @@ Timer=10
Server=http://115.159.226.87:20001/api/user/login Server=http://115.159.226.87:20001/api/user/login
StoreId=fm99999 StoreId=fm99999
PartnerId=1371 PartnerId=1371
;动画开关,0:关闭 1:开启 Animation=1
Animation=1 Position=510, 120
\ No newline at end of file
[Vip]
Server=http://member.freemudorder.com/member_today/service/restful/pos
...@@ -21,7 +21,8 @@ SOURCES +=\ ...@@ -21,7 +21,8 @@ SOURCES +=\
fmp_login.cpp \ fmp_login.cpp \
fmnetwork.cpp \ fmnetwork.cpp \
fmp_he_handlers.cpp \ fmp_he_handlers.cpp \
fmnumpad.cpp fmnumpad.cpp \
fmp_home_settings.cpp
HEADERS += fmp_home.h \ HEADERS += fmp_home.h \
fmp_home_plugin_p.h \ fmp_home_plugin_p.h \
...@@ -33,7 +34,8 @@ HEADERS += fmp_home.h \ ...@@ -33,7 +34,8 @@ HEADERS += fmp_home.h \
menubutton.h \ menubutton.h \
fmnetwork.h \ fmnetwork.h \
fmp_he_handlers.h \ fmp_he_handlers.h \
fmnumpad.h fmnumpad.h \
fmp_home_settings.h
FORMS += \ FORMS += \
fmp_home_navwindow.ui \ fmp_home_navwindow.ui \
......
#include "fmp_home_navwindow.h" #include "fmp_home_navwindow.h"
#include "ui_fmp_home_navwindow.h" #include "ui_fmp_home_navwindow.h"
#include "menubutton.h" #include "menubutton.h"
#include "fmp_home_settings.h"
#include <QDebug> #include <QDebug>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QParallelAnimationGroup> #include <QParallelAnimationGroup>
...@@ -10,7 +11,6 @@ ...@@ -10,7 +11,6 @@
#include <QStateMachine> #include <QStateMachine>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QMenu> #include <QMenu>
#include <fmp_settings_i.h>
NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) : NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) :
QDialog(parent), QDialog(parent),
...@@ -19,8 +19,7 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) : ...@@ -19,8 +19,7 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) :
_animationShow(new QParallelAnimationGroup(this)), _animationShow(new QParallelAnimationGroup(this)),
_stateMachine(new QStateMachine(this)), _stateMachine(new QStateMachine(this)),
_systemTrayIcon(new QSystemTrayIcon(this)), _systemTrayIcon(new QSystemTrayIcon(this)),
PI(3.1415926), PI(3.1415926)
_settings(settings)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->navMainBtn->setMovedItem(this); ui->navMainBtn->setMovedItem(this);
...@@ -32,7 +31,7 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) : ...@@ -32,7 +31,7 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) :
MenuUiProp.beginAngle = -(PI/2); MenuUiProp.beginAngle = -(PI/2);
MenuUiProp.endAngle = (PI/2); MenuUiProp.endAngle = (PI/2);
MenuUiProp.interval = (PI)/4; MenuUiProp.interval = (PI)/4;
isUseAnimation = _settings->GetBool(FMP_INIKEY_HOMEANIMATION); isUseAnimation = FMPHomeSettings::instance()->getIsUseAnimation();
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); this->setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
...@@ -40,6 +39,10 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) : ...@@ -40,6 +39,10 @@ NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) :
connect(_btn_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onMenuBtnClicked(QAbstractButton*))); connect(_btn_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onMenuBtnClicked(QAbstractButton*)));
initMenu(); initMenu();
initSystemTrayIcon(); initSystemTrayIcon();
this->move(FMPHomeSettings::instance()->getWindowPosition());
connect(ui->navMainBtn, SIGNAL(moved(QPoint)), this, SLOT(onMoved(QPoint)));
} }
NavWindow::~NavWindow() NavWindow::~NavWindow()
...@@ -102,7 +105,6 @@ void NavWindow::initMenu() ...@@ -102,7 +105,6 @@ void NavWindow::initMenu()
const int btnWidth = 60; const int btnWidth = 60;
_centerGeometry = QRect(centerX-btnWidth/2,centerY-btnWidth/2,btnWidth,btnWidth); _centerGeometry = QRect(centerX-btnWidth/2,centerY-btnWidth/2,btnWidth,btnWidth);
bool isUseAnimation = _settings->GetBool(FMP_INIKEY_HOMEANIMATION);
for(decltype(btns.size()) i = 0; i<btns.size(); ++i) { for(decltype(btns.size()) i = 0; i<btns.size(); ++i) {
std::pair<QString, QString> btnPair = btns.at(i); std::pair<QString, QString> btnPair = btns.at(i);
QAction *action = new QAction(QIcon(QString(":%1").arg(btnPair.first)), btnPair.second, this); QAction *action = new QAction(QIcon(QString(":%1").arg(btnPair.first)), btnPair.second, this);
...@@ -162,3 +164,8 @@ void NavWindow::initSystemTrayIcon() ...@@ -162,3 +164,8 @@ void NavWindow::initSystemTrayIcon()
_systemTrayIcon->setContextMenu(menus); _systemTrayIcon->setContextMenu(menus);
_systemTrayIcon->show(); _systemTrayIcon->show();
} }
void NavWindow::onMoved(QPoint point)
{
FMPHomeSettings::instance()->setWindowPosition(point);
}
...@@ -39,6 +39,7 @@ signals: ...@@ -39,6 +39,7 @@ signals:
private slots: private slots:
void onMenuBtnClicked(QAbstractButton*); void onMenuBtnClicked(QAbstractButton*);
void onMoved(QPoint point);
private: private:
Ui::NavWindow *ui; Ui::NavWindow *ui;
...@@ -73,8 +74,6 @@ private: ...@@ -73,8 +74,6 @@ private:
}; };
MenuUiProps MenuUiProp; MenuUiProps MenuUiProp;
bool isUseAnimation; bool isUseAnimation;
FMPSettingsInterface *_settings;
}; };
#endif // NAVWINDOW_H #endif // NAVWINDOW_H
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
#include <QDebug> #include <QDebug>
#include <fmp_epay_i.h> #include <fmp_epay_i.h>
#include <fmp_settings_i.h> #include <fmp_settings_i.h>
#include <QApplication>
#include "fmp_login.h" #include "fmp_login.h"
#include "fmp_he_handlers.h" #include "fmp_he_handlers.h"
#include "fmp_home_settings.h"
FMPHomePrivate::FMPHomePrivate(FMPHome *q) FMPHomePrivate::FMPHomePrivate(FMPHome *q)
: q_ptr(q), : q_ptr(q),
...@@ -25,7 +27,10 @@ FMPHomePrivate::~FMPHomePrivate() ...@@ -25,7 +27,10 @@ FMPHomePrivate::~FMPHomePrivate()
int FMPHomePrivate::Init() int FMPHomePrivate::Init()
{ {
Q_Q(FMPHome); Q_Q(FMPHome);
FMPLoggerInterface* logger = q->GetService<FMPLoggerInterface>(q->_ctx);
_settings = q->GetService<FMPSettingsInterface>(q->_ctx); _settings = q->GetService<FMPSettingsInterface>(q->_ctx);
FMPHomeSettings::instance()->init(_settings, logger);
_navWindow = new NavWindow(_settings); _navWindow = new NavWindow(_settings);
FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q); FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q);
...@@ -54,14 +59,12 @@ int FMPHomePrivate::Uninit() ...@@ -54,14 +59,12 @@ int FMPHomePrivate::Uninit()
void FMPHomePrivate::StartPlugins(const QVariantList &pids) void FMPHomePrivate::StartPlugins(const QVariantList &pids)
{ {
qDebug() << pids; HOME_DEBUG() << pids;
} }
int FMPHomePrivate::login() int FMPHomePrivate::login()
{ {
FMPLogin loginWnd(_settings->GetString(FMP_INIKEY_LOGINSERVER), FMPLogin loginWnd;
_settings->GetString(FMP_INIKEY_LOGINSTOREID),
_settings->GetString(FMP_INIKEY_LOGINPARTNERID));
loginWnd.exec(); loginWnd.exec();
if(loginWnd.isLogined()) { if(loginWnd.isLogined()) {
_isLogined = true; _isLogined = true;
...@@ -80,6 +83,7 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName) ...@@ -80,6 +83,7 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
if(btnName == "quit") { if(btnName == "quit") {
FMP_DEBUG_CTX(q->_ctx) << "Will Quit!"; FMP_DEBUG_CTX(q->_ctx) << "Will Quit!";
qApp->quit();
return; return;
} }
...@@ -93,6 +97,6 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName) ...@@ -93,6 +97,6 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
FMPePayInterface *e = q->GetService<FMPePayInterface>(q->_ctx); FMPePayInterface *e = q->GetService<FMPePayInterface>(q->_ctx);
e->StartService(); e->StartService();
} else if(btnName == "tool") { } else if(btnName == "tool") {
qDebug() << "tool menu"; HOME_DEBUG() << "tool menu";
} }
} }
#include "fmp_home_settings.h"
#include <fmp_settings_i.h>
#include <QDebug>
FMPHomeSettings::FMPHomeSettings(QObject *parent) : QObject(parent)
{
}
FMPHomeSettings *FMPHomeSettings::instance()
{
static FMPHomeSettings homeSettings;
return &homeSettings;
}
void FMPHomeSettings::init(FMPSettingsInterface *settings, FMPLoggerInterface *logger)
{
this->_settings = settings;
this->_logger = logger;
}
FMPLoggerInterface *FMPHomeSettings::getLogger()
{
return _logger;
}
bool FMPHomeSettings::getIsUseAnimation()
{
return _GetValue(FMP_INIKEY_HOMEANIMATION).toBool();
}
bool FMPHomeSettings::setIsUseAnimation(bool isUse)
{
return _SetValue(FMP_INIKEY_HOMEANIMATION, isUse);
}
QPoint FMPHomeSettings::getWindowPosition()
{
QStringList posList = _GetValue(FMP_INIKEY_HOMEPOSITION).toStringList();
if(posList.length() == 2) {
return QPoint(posList[0].toInt(), posList[1].toInt());
}
return QPoint(50, 50);
}
bool FMPHomeSettings::setWindowPosition(QPoint point)
{
QStringList posList;
posList << QString::number(point.x());
posList << QString::number(point.y());
return _SetValue(FMP_INIKEY_HOMEPOSITION, posList);
}
QString FMPHomeSettings::getServer()
{
return _GetValue(FMP_INIKEY_LOGINSERVER).toString();
}
QString FMPHomeSettings::getPartnerId()
{
return _GetValue(FMP_INIKEY_LOGINPARTNERID).toString();
}
QString FMPHomeSettings::getStroeId()
{
return _GetValue(FMP_INIKEY_LOGINSTOREID).toString();
}
QVariant FMPHomeSettings::_GetValue(const QString &key, QVariant defaultValue)
{
if (_settings) {
return _settings->GetValue(key);
}
else {
HOME_WARN() << "Settings service not available";
}
return defaultValue;
}
bool FMPHomeSettings::_SetValue(const QString &key, QVariant value)
{
if (_settings) {
_settings->SetValue(key, value);
return true;
}
else {
HOME_WARN() << "Settings service not available";
}
return false;
}
#ifndef FMP_VIP_SETTINGS_H
#define FMP_VIP_SETTINGS_H
#include <QObject>
#include <QVariant>
#include <fmp_logger_i.h>
class FMPSettingsInterface;
class FMPHomeSettings : public QObject
{
Q_OBJECT
public:
static FMPHomeSettings *instance();
void init(FMPSettingsInterface *settings, FMPLoggerInterface *logger);
FMPLoggerInterface *getLogger();
/**
* @brief getIsUseAnimation
* 获取/设置动画开关配置
* @return
*/
bool getIsUseAnimation();
bool setIsUseAnimation(bool isUse);
/**
* @brief getWindowPos
* 获取/设置窗口的位置
* @return
*/
QPoint getWindowPosition();
bool setWindowPosition(QPoint point);
/**
* @brief getServer
* 获取登录认证服务器地址
* @return
*/
QString getServer();
/**
* @brief getPartnerId
* 获取登录认证商户号
* @return
*/
QString getPartnerId();
/**
* @brief getStroeId
* 获取登录认证门店号
* @return
*/
QString getStroeId();
private:
explicit FMPHomeSettings(QObject *parent = 0);
QVariant _GetValue(const QString &key, QVariant defaultValue = 0);
bool _SetValue(const QString &key, QVariant value);
private:
FMPSettingsInterface *_settings;
FMPLoggerInterface *_logger;
};
#define HOME_DEBUG() FMP_DEBUG(FMPHomeSettings::instance()->getLogger())
#define HOME_INFO() FMP_INFO(FMPHomeSettings::instance()->getLogger())
#define HOME_WARN() FMP_WARN(FMPHomeSettings::instance()->getLogger())
#define HOME_ERROR() FMP_ERROR(FMPHomeSettings::instance()->getLogger())
#endif // FMP_VIP_SETTINGS_H
#include "fmp_login.h" #include "fmp_login.h"
#include "ui_fmp_login.h" #include "ui_fmp_login.h"
#include "fmp_home_settings.h"
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QJsonDocument> #include <QJsonDocument>
...@@ -8,14 +9,11 @@ ...@@ -8,14 +9,11 @@
#include "fmnetwork.h" #include "fmnetwork.h"
#include <QDebug> #include <QDebug>
FMPLogin::FMPLogin(QString url, QString storeId, QString partnerId, QDialog *parent) : FMPLogin::FMPLogin(QDialog *parent) :
FMPWnd(parent), FMPWnd(parent),
ui(new Ui::FMPLogin), ui(new Ui::FMPLogin),
_userName(""), _userName(""),
_errorMsg(""), _errorMsg("")
_url(url),
_storeId(storeId),
_partnerId(partnerId)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->numpad, SIGNAL(digit_confirm()), this, SLOT(on_login_btn_clicked())); connect(ui->numpad, SIGNAL(digit_confirm()), this, SLOT(on_login_btn_clicked()));
...@@ -23,6 +21,10 @@ FMPLogin::FMPLogin(QString url, QString storeId, QString partnerId, QDialog *par ...@@ -23,6 +21,10 @@ FMPLogin::FMPLogin(QString url, QString storeId, QString partnerId, QDialog *par
connect(qApp, &QApplication::focusChanged, this, &FMPLogin::onFocusChanged); connect(qApp, &QApplication::focusChanged, this, &FMPLogin::onFocusChanged);
setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_QuitOnClose, false);
_url = FMPHomeSettings::instance()->getServer();
_storeId = FMPHomeSettings::instance()->getStroeId();
_partnerId = FMPHomeSettings::instance()->getPartnerId();
} }
FMPLogin::~FMPLogin() FMPLogin::~FMPLogin()
......
...@@ -12,7 +12,7 @@ class FMPLogin : public FMPWnd ...@@ -12,7 +12,7 @@ class FMPLogin : public FMPWnd
Q_OBJECT Q_OBJECT
public: public:
explicit FMPLogin(QString url, QString storeId, QString partnerId, QDialog *parent = 0); explicit FMPLogin(QDialog *parent = 0);
~FMPLogin(); ~FMPLogin();
/** /**
...@@ -37,9 +37,9 @@ private: ...@@ -37,9 +37,9 @@ private:
QString _userName; QString _userName;
QString _errorMsg; QString _errorMsg;
const QString _url; QString _url;
const QString _storeId; QString _storeId;
const QString _partnerId; QString _partnerId;
}; };
#endif // FMP_LOGIN_H #endif // FMP_LOGIN_H
...@@ -52,6 +52,9 @@ void MenuButton::mouseReleaseEvent(QMouseEvent *e) ...@@ -52,6 +52,9 @@ void MenuButton::mouseReleaseEvent(QMouseEvent *e)
if (e->button()==Qt::LeftButton) if (e->button()==Qt::LeftButton)
{ {
_mousePress = false; _mousePress = false;
if(_canMove) {
emit moved(_movedItem->pos());
}
} }
if(!_mouseMove) if(!_mouseMove)
{ {
......
...@@ -16,6 +16,9 @@ protected: ...@@ -16,6 +16,9 @@ protected:
void mousePressEvent(QMouseEvent * e); void mousePressEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e); void mouseReleaseEvent(QMouseEvent * e);
signals:
void moved(QPoint point);
private: private:
bool _mouseMove; bool _mouseMove;
bool _mousePress; bool _mousePress;
......
...@@ -24,5 +24,6 @@ ...@@ -24,5 +24,6 @@
#define FMP_INIKEY_LOGINSTOREID "Home/StoreId" #define FMP_INIKEY_LOGINSTOREID "Home/StoreId"
#define FMP_INIKEY_LOGINPARTNERID "Home/PartnerId" #define FMP_INIKEY_LOGINPARTNERID "Home/PartnerId"
#define FMP_INIKEY_HOMEANIMATION "Home/Animation" #define FMP_INIKEY_HOMEANIMATION "Home/Animation"
#define FMP_INIKEY_HOMEPOSITION "Home/Position"
#endif // FMP_SETTINGS_DEF_H #endif // FMP_SETTINGS_DEF_H
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