Commit 3910cb7d by gujin.wang

程序启动时,检查配置文件,如果没有门店号和pos编号,则提示用户输入

parent 2bda5445
No preview for this file type
......@@ -14,6 +14,7 @@ SUBDIRS += fmp_manager \
fmp_printer \
FreemudPOS \
FreemudSyncer \
fmp_redeem
fmp_redeem \
fmp_keyboard
CONFIG += ordered
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
#include "fmp_keyboard.h"
#include "fmp_logger_i.h"
#include "fmp_pe_handlers.h"
FMPKeyBoard::FMPKeyBoard(const FMPContext context)
:FMPKeyBoardInterface(),
_context(context),
_inited(false),
_keyboard(new KeyBoard),
_ste_handler(new FMPStartEventHandler(this))
{
}
FMPKeyBoard::~FMPKeyBoard()
{
StopService();
}
void FMPKeyBoard::InitService()
{
if (_inited) return;
_inited = true;
}
void FMPKeyBoard::UninitService()
{
if(_keyboard)
{
_keyboard->close();
delete _keyboard;
_keyboard = nullptr;
}
_inited = false;
}
void FMPKeyBoard::ShowKeyBoard(QWidget *parent)
{
Q_ASSERT(parent != nullptr);
_keyboard->setGeometry(parent->geometry().x() + parent->width(), parent->geometry().y(), _keyboard->width(), _keyboard->height());
_keyboard->setWindowModality(Qt::WindowModal);
_keyboard->show();
}
void FMPKeyBoard::HideKeyBoard()
{
Q_ASSERT(_keyboard != nullptr);
_keyboard->hide();
}
void FMPKeyBoard::setLineEdit(QLineEdit *lineEdit)
{
Q_ASSERT(_keyboard != nullptr);
_keyboard->setLineEdit(lineEdit);
}
#ifndef FMP_KEYBOARD_H
#define FMP_KEYBOARD_H
#include "fmp_keyboard_i.h"
#include "fmp_settings_i.h"
#include "keyboard.h"
#include <QPointer>
class FMPStartEventHandler;
class FMPKeyBoard : public FMPKeyBoardInterface
{
Q_OBJECT
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface)
Q_INTERFACES(FMPKeyBoardInterface)
public:
explicit FMPKeyBoard(const FMPContext context);
virtual ~FMPKeyBoard();
virtual void ShowKeyBoard(QWidget* parent);
virtual void HideKeyBoard();
virtual void setLineEdit(QLineEdit* lineEdit);
protected:
const FMPContext GetContext() const { return _context; }
protected slots:
void InitService();
void UninitService();
private:
bool _inited;
const FMPContext _context;
QPointer<FMPStartEventHandler> _ste_handler;
KeyBoard* _keyboard;
};
#endif // FMP_KEYBOARD_H
TEMPLATE = lib
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
unix {
target.path = /usr/lib
INSTALLS += target
}
#Target name
VER = $$system($$PWD/../fmprc.bat $$TARGET)
ORIGIN_TARGET = $$TARGET
TARGET = $${TARGET}_$${VER}
#Header path
INCLUDEPATH += $$PWD/../include/ctk \
+= $$PWD/../include/interface \
#Library path
win32 {
LIBS += -luser32
}
LIBS += -L$$PWD/../lib
CONFIG(debug, debug|release) {
#Linking library
LIBS += -lCTKCored -lCTKPluginFrameworkd
#Destination path
DESTDIR = $$PWD/../debug/plugins
} else {
LIBS += -lCTKCore -lCTKPluginFramework
DESTDIR = $$PWD/../release/plugins
}
RESOURCES += \
res/$${ORIGIN_TARGET}.qrc \
res/fmp_keyboard.qrc \
res/img.qrc
win32 {
RC_FILE += res/$${ORIGIN_TARGET}.rc
system($$PWD/../fmprc.bat $$PWD/version.h $$ORIGIN_TARGET)
}
else {
system($$PWD/../fmprc.sh $$PWD/version.h $$ORIGIN_TARGET)
}
FORMS += \
keyboard.ui
HEADERS += \
fmp_pe_handlers.h \
fmp_keyboard_i.h \
fmp_keyboard.h \
fmp_keyboard_plugin_p.h \
keyboard.h
SOURCES += \
fmp_pe_handlers.cpp \
fmp_keyboard.cpp \
fmp_keyboard_plugin.cpp \
keyboard.cpp
DISTFILES +=
#ifndef FMP_KEYBOARD_I_H
#define FMP_KEYBOARD_I_H
#include <fmp_plugin_i.h>
#include <QLineEdit>
/**
* 业务插件接口,必须继承自 FMPluginInterface
* @brief The FMPRedeemInterface class
*/
class FMPKeyBoardInterface : public QObject, public FMPluginInterface
{
Q_OBJECT
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface)
public:
explicit FMPKeyBoardInterface() : FMPluginInterface()
{
connect(this, &FMPKeyBoardInterface::TriggerInit, this, &FMPKeyBoardInterface::OnTriggerInit);
connect(this, &FMPKeyBoardInterface::TriggerUninit, this, &FMPKeyBoardInterface::OnTriggerUninit);
}
virtual void ShowKeyBoard(QWidget* parent) = 0;
virtual void HideKeyBoard() = 0;
virtual void setLineEdit(QLineEdit* lineEdit) = 0;
signals:
void TriggerInit();
void TriggerUninit();
protected slots:
void OnTriggerInit() { FMPluginInterface::OnTriggerInit(); }
void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
};
Q_DECLARE_INTERFACE(FMPKeyBoardInterface, "fmp.keyboard")
#endif // FMP_KEYBOARD_I_H
#include "fmp_keyboard_plugin_p.h"
#include "fmp_keyboard.h"
FMKeyBoardPlugin::FMKeyBoardPlugin()
:_keyboard_service(0)
{
}
void FMKeyBoardPlugin::start(ctkPluginContext *context)
{
_keyboard_service = new FMPKeyBoard(context);
context->registerService<FMPKeyBoardInterface>( _keyboard_service);
}
void FMKeyBoardPlugin::stop(ctkPluginContext *context)
{
Q_UNUSED(context)
if (_keyboard_service)
{
delete _keyboard_service;
_keyboard_service = 0;
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2(fmp_keyboard, FMKeyBoardPlugin)
#endif
#ifndef FMP_KEYBOARD_PLUGIN_H
#define FMP_KEYBOARD_PLUGIN_H
#include <ctkPluginActivator.h>
class FMPKeyBoard;
class FMKeyBoardPlugin : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
Q_PLUGIN_METADATA(IID "com_fmp_keyboard")
#endif
public:
explicit FMKeyBoardPlugin();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
FMPKeyBoard* _keyboard_service;
};
#endif // FMP_KEYBOARD_PLUGIN_H
#include <fmp_logger_i.h>
#include "fmp_pe_handlers.h"
#include "fmp_keyboard.h"
FMPStartEventHandler::FMPStartEventHandler(FMPKeyBoard *keyboard)
: FMPKeyBoardEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/" + QString::number(keyboard->GetPluginId()), keyboard)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
FMP::RegisterService<ctkEventHandler>(this, props);
}
void FMPStartEventHandler::handleEvent(const ctkEvent &event)
{
if (_keyboard) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
_keyboard->TriggerInit();
}
else {
FMP_WARN() << "Refused start request" << event.getTopic();
}
}
else {
FMP_DEBUG() << "No handler instance for event" << event.getTopic();
}
}
FMPNetWorkEventHandler::FMPNetWorkEventHandler(FMPKeyBoard *keyboard)
: FMPKeyBoardEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/" + QString::number(keyboard->GetPluginId()), keyboard)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
FMP::RegisterService<ctkEventHandler>(this, props);
}
void FMPNetWorkEventHandler::handleEvent(const ctkEvent &event)
{
if (_keyboard) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
_keyboard->TriggerInit();
}
else {
FMP_WARN() << "Refused start request" << event.getTopic();
}
}
else {
FMP_DEBUG() << "No handler instance for event" << event.getTopic();
}
}
\ No newline at end of file
#ifndef FMP_PE_HANDLERS_H
#define FMP_PE_HANDLERS_H
#include <QObject>
#include <service/event/ctkEventConstants.h>
#include <service/event/ctkEventHandler.h>
class FMPKeyBoard;
class FMPKeyBoardEventHandler : public ctkEventHandler
{
public:
explicit FMPKeyBoardEventHandler(const QString &topic, FMPKeyBoard *keyboard) : _keyboard(keyboard), _topic(topic) {}
protected:
FMPKeyBoard* _keyboard;
const QString _topic;
};
/**
* 升级事件处理类
* @brief The FMPUpgradeEventHandler class
*/
class FMPStartEventHandler : public QObject, public FMPKeyBoardEventHandler
{
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPStartEventHandler(FMPKeyBoard *keyboard);
void handleEvent(const ctkEvent &event);
};
/**
* 升级事件处理类(网络)
* @brief TheNetWorkFMPUpgradeEventHandler class
*/
class FMPNetWorkEventHandler : public QObject, public FMPKeyBoardEventHandler
{
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPNetWorkEventHandler(FMPKeyBoard *keyboard);
void handleEvent(const ctkEvent &event);
};
#endif // FMP_PE_HANDLERS_H
<RCC>
<qresource prefix="/">
<file>res/img/dlt01.png</file>
<file>res/img/dlt02.png</file>
<file>res/img/dot01.png</file>
<file>res/img/dot02.png</file>
</qresource>
</RCC>
#include "keyboard.h"
#include "ui_keyboard.h"
#include <QLineEdit>
KeyBoard::KeyBoard(QWidget *parent) :
QWidget(parent),
ui(new Ui::KeyBoard),
_lineEdit(nullptr)
{
ui->setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
connect(ui->no0, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no1, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no2, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no3, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no4, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no5, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no6, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no7, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no8, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->no9, &QPushButton::clicked, this, &KeyBoard::on_digit_clicked);
connect(ui->dot, &QPushButton::clicked, this, &KeyBoard::on_dot_btn_clicked);
}
KeyBoard::~KeyBoard()
{
delete ui;
}
void KeyBoard::on_digit_clicked()
{
QString num_str = qobject_cast<QPushButton*>(sender())->text();
if(_lineEdit) {
_lineEdit->insert(num_str);
_lineEdit->setFocus();
}
emit digit_click(num_str);
}
void KeyBoard::on_backspace_btn_clicked()
{
if(_lineEdit) {
_lineEdit->backspace();
_lineEdit->setFocus();
}
emit digit_delete();
}
void KeyBoard::on_clear_btn_clicked()
{
if(_lineEdit) {
_lineEdit->clear();
_lineEdit->setFocus();
}
emit digit_clear();
}
void KeyBoard::on_confirm_btn_clicked()
{
emit digit_confirm();
}
void KeyBoard::setLineEdit(QLineEdit *lineEdit)
{
this->_lineEdit = lineEdit;
}
void KeyBoard::on_dot_btn_clicked()
{
QString dot_str = ".";
if(_lineEdit) {
_lineEdit->insert(dot_str);
_lineEdit->setFocus();
}
emit digit_click(dot_str);
}
#ifndef FMNUMPAD_H
#define FMNUMPAD_H
#include <QWidget>
#include <QLineEdit>
namespace Ui {
class KeyBoard;
}
class KeyBoard : public QWidget
{
Q_OBJECT
public:
explicit KeyBoard(QWidget *parent = 0);
~KeyBoard();
void setLineEdit(QLineEdit* lineEdit);
signals:
void digit_click(QString keynum);
void digit_delete();
void digit_clear();
void digit_confirm();
private slots:
void on_digit_clicked();
void on_backspace_btn_clicked();
void on_clear_btn_clicked();
void on_confirm_btn_clicked();
void on_dot_btn_clicked();
private:
Ui::KeyBoard *ui;
QLineEdit* _lineEdit;
};
#endif // FMNUMPAD_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KeyBoard</class>
<widget class="QWidget" name="KeyBoard">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>246</width>
<height>234</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font: normal 22px &quot;Microsoft YaHei&quot;;
color: rgb(90,90,90);
}
#KeyBoard {
background-color: rgb(249, 249, 249);
border: 1 solid silver;
}
QPushButton {
min-width: 50px; min-height: 50px;
max-width: 50px; max-height: 50px;
background-color: rgb(255, 255, 255);
font: 75 18pt &quot;微软雅黑&quot;;
border-radius: 12px;
border: 1 solid silver;
color: rgb(57, 57, 57);
}
QPushButton:hover {
background-color: rgb(249, 249, 249);
border:2px solid rgb(99, 148, 235);
border-radius:12px;
color: rgb(99, 148, 235);
padding: 2 0 0 2;
}
#no0 {
min-width: 106px;
max-width: 106px;
}
#backspace_btn, #clear_btn {
font: normal 16px &quot;Microsoft YaHei&quot;;
}
#backspace_btn {
image: url(:/img/dlt02.png);
}
#backspace_btn:hover {
image: url(:/img/dlt01.png);
}
#dot
{
background-color: rgb(255, 255, 255);
image: url(:/img/dot01.png);
}
#dot:hover
{
background-color: rgb(249, 249, 249);
image: url(:/img/dot02.png);
}
#confirm_btn {
background: rgb(93,144,237);
font: 400 16px &quot;Microsoft YaHei&quot;;
color: white;
min-height: 106px;
max-height: 106px;
border: 0 solid white;
border-right: 1 solid silver;
}
#confirm_btn:hover {
padding: 2 0 0 2;
background-color: rgb(249, 249, 249);
border:2px solid rgb(99, 148, 235);
border-radius:12px;
color: rgb(99, 148, 235);
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<item row="1" column="3">
<widget class="QPushButton" name="clear_btn">
<property name="text">
<string>清空</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="no0">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="no9">
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="no6">
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="2" column="3" rowspan="2">
<widget class="QPushButton" name="confirm_btn">
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="no1">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="no2">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="no3">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="no5">
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="no4">
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="backspace_btn">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="dot">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="no7">
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="no8">
<property name="text">
<string>8</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<RCC>
<qresource prefix="/">
<file>img/dlt01.png</file>
<file>img/dlt02.png</file>
<file>img/dot01.png</file>
<file>img/dot02.png</file>
</qresource>
</RCC>
......@@ -3,6 +3,7 @@
#include "consumptiondialog.h"
#include "consumokdialog.h"
#include "errcodedialog.h"
#include "storedialog.h"
#include "fmp_logger_i.h"
#include "fmp_pe_handlers.h"
#include "fmp_settings_i.h"
......@@ -53,6 +54,7 @@ void FMPRedeem::InitService()
void FMPRedeem::UninitService()
{
_inited = false;
}
QJsonValue FMPRedeem::SearchJsonObject(QJsonObject& searchJson, QString searchKey)
......@@ -126,13 +128,33 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
_url = settings.value(FMP_INIKEY_EPAYURL).toString();
_partner_id = settings.value(FMP_INIKEY_LOGINPARTNERID).toInt();
if(_store_id.isEmpty() || _station_id.isEmpty())
{
StoreDialog storeDialog;
if(storeDialog.exec() == QDialog::Accepted)
{
_store_id = storeDialog.storeId;
_station_id = storeDialog.posId;
settings.setValue(FMP_INIKEY_LOGINSTOREID, _store_id);
settings.setValue(FMP_INIKEY_LOGINPOSID, _station_id);
}
else
{
QJsonObject ret;
ret["statusCode"] = FM_API_WINDOWCLOSE;
ret["msg"] = QString::fromLocal8Bit("窗口关闭");
FMP_DEBUG() << QJsonDocument(ret).toJson(QJsonDocument::Compact);
return ret;
}
}
//显示扫码界面获取券码
ScanningDialog scanningDialog;
if(scanningDialog.exec() != QDialog::Accepted)
{
QJsonObject ret;
ret["statusCode"] = FM_API_WINDOWCLOSE;
ret["msg"] = "窗口关闭";
ret["msg"] = QString::fromLocal8Bit("窗口关闭");
FMP_DEBUG() << QJsonDocument(ret).toJson(QJsonDocument::Compact);
return ret;
}
......
......@@ -61,7 +61,8 @@ HEADERS += \
couponkeypad.h \
errcodedialog.h \
scanningdialog.h \
fmp_pe_handlers.h
fmp_pe_handlers.h \
storedialog.h
SOURCES += \
fmp_redeem.cpp \
......@@ -71,11 +72,13 @@ SOURCES += \
couponkeypad.cpp \
errcodedialog.cpp \
scanningdialog.cpp \
fmp_pe_handlers.cpp
fmp_pe_handlers.cpp \
storedialog.cpp
FORMS += \
consumokdialog.ui \
consumptiondialog.ui \
couponkeypad.ui \
errcodedialog.ui \
scanningdialog.ui
\ No newline at end of file
scanningdialog.ui \
storedialog.ui
\ No newline at end of file
......@@ -16,5 +16,8 @@
<file>img/folat_be_invalid.png</file>
<file>img/ma_bg.png</file>
<file>img/scanning_bar.png</file>
<file>img/cancel.png</file>
<file>img/ok.png</file>
<file>img/keyboard.png</file>
</qresource>
</RCC>
#include "storedialog.h"
#include "ui_storedialog.h"
#include "fmp_keyboard_i.h"
#include <Windows.h>
#include <QTimer>
StoreDialog::StoreDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::StoreDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setAttribute(Qt::WA_QuitOnClose, false);
ui->okBtn->setEnabled(false);
_is_show = false;
connect(ui->storeIdEdit, &QLineEdit::textChanged, this, &StoreDialog::textChanged);
connect(ui->posIdEdit, &QLineEdit::textChanged, this, &StoreDialog::textChanged);
connect(ui->okBtn, &QPushButton::clicked, this, &StoreDialog::GetId);
connect(ui->cancelBtn, &QPushButton::clicked, this, &StoreDialog::CloseKeyBoard);
connect(ui->keyBtn, &QPushButton::clicked, this, &StoreDialog::ShowKeyBoard);
ui->storeIdEdit->installEventFilter(this);
ui->posIdEdit->installEventFilter(this);
QTimer::singleShot(1000, this, &StoreDialog::timeOut);
}
StoreDialog::~StoreDialog()
{
delete ui;
}
#ifdef Q_OS_WIN
//!命名冲突
#undef StartService
#endif
void StoreDialog::ShowKeyBoard()
{
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService();
if(_is_show)
{
keyboard->HideKeyBoard();
}
else
{
keyboard->ShowKeyBoard(this);
keyboard->setLineEdit(ui->storeIdEdit);
}
_is_show = !_is_show;
}
void StoreDialog::GetId()
{
storeId = ui->storeIdEdit->text();
posId = ui->posIdEdit->text();
this->accept();
}
void StoreDialog::textChanged(const QString &text)
{
Q_UNUSED(text);
if(ui->storeIdEdit->text().isEmpty() || ui->posIdEdit->text().isEmpty())
{
ui->okBtn->setEnabled(false);
}
else
{
ui->okBtn->setEnabled(true);
}
}
void StoreDialog::timeOut()
{
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow((HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
setFocus();
ui->storeIdEdit->setFocus();
}
bool StoreDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui->storeIdEdit) {
if (event->type() == QEvent::FocusIn) {
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService();
keyboard->setLineEdit(ui->storeIdEdit);
}
return false;
}
else if(obj == ui->posIdEdit)
{
if(event->type() == QEvent::FocusIn)
{
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService();
keyboard->setLineEdit(ui->posIdEdit);
}
return false;
}
else {
return QDialog::eventFilter(obj, event);
}
}
void StoreDialog::CloseKeyBoard()
{
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService();
keyboard->HideKeyBoard();
this->reject();
}
#ifndef STOREDIALOG_H
#define STOREDIALOG_H
#include <QDialog>
namespace Ui {
class StoreDialog;
}
class StoreDialog : public QDialog
{
Q_OBJECT
public:
explicit StoreDialog(QWidget *parent = 0);
~StoreDialog();
protected:
bool eventFilter(QObject *obj, QEvent *event);
private slots:
void ShowKeyBoard();
void GetId();
void textChanged(const QString& text);
void timeOut();
void CloseKeyBoard();
public:
QString storeId;
QString posId;
private:
Ui::StoreDialog *ui;
bool _is_show;
};
#endif // STOREDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StoreDialog</class>
<widget class="QDialog" name="StoreDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>202</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#StoreDialog
{
background-color:rgb(255, 255, 255);
}
#title
{
color: yellow;
font: 75 18pt &quot;微软雅黑&quot;;
background: rgb(231,68,59);
}
#storeIdLabel,#posIdLabel
{
font: 75 15pt &quot;微软雅黑&quot;;
color: rgb(57, 57, 57);
}
QPushButton {
min-width: 70px; min-height: 50px;
max-width: 70px; max-height: 50px;
background-color: rgb(255, 255, 255);
font: 75 15pt &quot;微软雅黑&quot;;
border-radius: 12px;
border: 1 solid silver;
color: rgb(57, 57, 57);
}
QPushButton:hover {
background-color: rgb(249, 249, 249);
border:2px solid rgb(99, 148, 235);
border-radius:12px;
color: rgb(99, 148, 235);
padding: 2 0 0 2;
}
QPushButton:!enabled {
min-width: 70px; min-height: 50px;
max-width: 70px; max-height: 50px;
background-color: rgb(169, 169, 169);
font: 75 15pt &quot;微软雅黑&quot;;
border-radius: 12px;
border: 1 solid silver;
color: rgb(57, 57, 57);
}</string>
</property>
<widget class="QLabel" name="title">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>请输入门店号和POS编号</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="storeIdLabel">
<property name="geometry">
<rect>
<x>5</x>
<y>48</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>门店号</string>
</property>
</widget>
<widget class="QLineEdit" name="storeIdEdit">
<property name="geometry">
<rect>
<x>120</x>
<y>48</y>
<width>161</width>
<height>32</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="posIdLabel">
<property name="geometry">
<rect>
<x>5</x>
<y>97</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>POS编号</string>
</property>
</widget>
<widget class="QLineEdit" name="posIdEdit">
<property name="geometry">
<rect>
<x>120</x>
<y>98</y>
<width>161</width>
<height>32</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="keyBtn">
<property name="geometry">
<rect>
<x>290</x>
<y>42</y>
<width>72</width>
<height>52</height>
</rect>
</property>
<property name="text">
<string>键盘</string>
</property>
</widget>
<widget class="QPushButton" name="okBtn">
<property name="geometry">
<rect>
<x>124</x>
<y>140</y>
<width>72</width>
<height>52</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<widget class="QPushButton" name="cancelBtn">
<property name="geometry">
<rect>
<x>210</x>
<y>140</y>
<width>72</width>
<height>52</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
No preview for this file type
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