modify:优化
This commit is contained in:
+12
-37
@@ -3,72 +3,47 @@
|
||||
|
||||
#include "NumKeyBoard_global.h"
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
// 向前声明
|
||||
namespace Ui {
|
||||
class NumKeyDia;
|
||||
}
|
||||
class NumKeyDiaPrivate;
|
||||
|
||||
class NUMKEYBOARD_EXPORT NumKeyDia : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
// 声明私有类
|
||||
Q_DECLARE_PRIVATE(NumKeyDia)
|
||||
|
||||
public:
|
||||
explicit NumKeyDia(QWidget *parent = nullptr);
|
||||
~NumKeyDia();
|
||||
|
||||
static NumKeyDia *instance()
|
||||
{
|
||||
return singleton;
|
||||
}
|
||||
static NumKeyDia *instance();
|
||||
|
||||
void setValue(const QString &value);
|
||||
QString &getValue();
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_btn_ok_clicked();
|
||||
|
||||
void on_btn_cancel_clicked();
|
||||
|
||||
void on_btn_clear_clicked();
|
||||
|
||||
void on_btn_back_clicked();
|
||||
|
||||
void btn_input_clicked();
|
||||
|
||||
void closeKeyBoard();
|
||||
|
||||
private:
|
||||
enum class InputPage
|
||||
{
|
||||
NumberPage,
|
||||
SymbolPage
|
||||
};
|
||||
|
||||
void setInputPage(InputPage page);
|
||||
void refreshInputButtons();
|
||||
void configureInputButton(QPushButton *button,
|
||||
const QString &label,
|
||||
const QString &value,
|
||||
bool enabled,
|
||||
bool isModeSwitch = false);
|
||||
|
||||
Ui::NumKeyDia *ui;
|
||||
|
||||
// 使用 QScopedPointer 管理私有实现类
|
||||
QScopedPointer<NumKeyDiaPrivate> d_ptr;
|
||||
static NumKeyDia *singleton;
|
||||
|
||||
QString value = QString();
|
||||
|
||||
QPoint m_point;
|
||||
|
||||
bool m_firstInputFlag = true;
|
||||
InputPage m_inputPage = InputPage::NumberPage;
|
||||
// 禁用拷贝
|
||||
Q_DISABLE_COPY(NumKeyDia)
|
||||
};
|
||||
|
||||
namespace KeyBoard
|
||||
|
||||
Reference in New Issue
Block a user