995 lines
24 KiB
C++
995 lines
24 KiB
C++
#ifndef UITOOLS_H
|
|
#define UITOOLS_H
|
|
|
|
#include <QPushButton>
|
|
#include <QListWidgetItem>
|
|
#include <QLineEdit>
|
|
#include <QMessageBox>
|
|
#include <QString>
|
|
#include <QColor>
|
|
#include <QDialog>
|
|
#include <QVBoxLayout>
|
|
#include <QFormLayout>
|
|
#include <QLabel>
|
|
#include <QApplication>
|
|
#include <QWidget>
|
|
#include <QRadioButton>
|
|
#include <QDateTimeEdit>
|
|
#include <QStackedWidget>
|
|
#include <QTimer>
|
|
#include <QComboBox>
|
|
|
|
#include "LineEditWithKeyboard.h"
|
|
#include "BackstageInterfaceForUi.h"
|
|
|
|
class WidgetWithBackstageInterface : public QWidget
|
|
{
|
|
protected:
|
|
BackstageInterfaceForUi* m_backstageIf;
|
|
|
|
public:
|
|
WidgetWithBackstageInterface(QWidget *parent = nullptr);
|
|
virtual ~WidgetWithBackstageInterface();
|
|
virtual void setBackstageUiinterface(BackstageInterfaceForUi* interface);
|
|
//virtual void reset() = 0;
|
|
};
|
|
|
|
class PageAcceptMouseAndTouch : public WidgetWithBackstageInterface
|
|
{
|
|
public:
|
|
explicit PageAcceptMouseAndTouch(QWidget *parent = nullptr);
|
|
|
|
private:
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
bool event(QEvent *event);
|
|
};
|
|
|
|
class PureColorPage : public PageAcceptMouseAndTouch
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit PureColorPage(unsigned int color, unsigned char tran = 255, bool drawRect = false, QWidget *parent = nullptr);
|
|
~PureColorPage();
|
|
|
|
signals:
|
|
public slots:
|
|
private:
|
|
unsigned m_color;
|
|
unsigned char m_tran;
|
|
bool m_drawRect;
|
|
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class MyWidgetWithMainStyleColor : public WidgetWithBackstageInterface
|
|
{
|
|
public:
|
|
explicit MyWidgetWithMainStyleColor(QWidget *parent = nullptr);
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class MyWidgetWithSubStyleColor : public WidgetWithBackstageInterface
|
|
{
|
|
public:
|
|
explicit MyWidgetWithSubStyleColor(QWidget *parent = nullptr);
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class CustomDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit CustomDialog(const QString& okBtnText, QObject *bgWidget = nullptr, const QString& cancelBtnText = tr("取消"), int timeout = 0);
|
|
virtual ~CustomDialog();
|
|
|
|
signals:
|
|
void signalShowShadowPage(bool show);
|
|
|
|
public slots:
|
|
void slotCancleBtnClicked();
|
|
virtual void slotConfirmBtnClicked();
|
|
|
|
protected:
|
|
QHBoxLayout* hbtmLayout;
|
|
int dialogWidth;
|
|
int dialogHeight;
|
|
|
|
PureColorPage* m_wBg;
|
|
QTimer *m_timer = nullptr;
|
|
|
|
private:
|
|
QPushButton* m_btn_ok = nullptr;
|
|
QPushButton* m_btn_cancle = nullptr;
|
|
const int m_timeout = 0;
|
|
|
|
void paintEvent(QPaintEvent *event);
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
bool event(QEvent *event);
|
|
};
|
|
|
|
#if 1
|
|
class PasswordDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
PasswordDialog(const QString& title, const QString& tip1, int timeout, QObject *bgWidget = nullptr, const QString& pwd = "",
|
|
const QString& tip0 = QString(), const QString& okBtn = tr("确定"), const QString& cancelBtn = tr("取消"));
|
|
virtual ~PasswordDialog();
|
|
const QString& getPwd() const;
|
|
|
|
public slots:
|
|
void slotPwdVisableBtnClicked();
|
|
void slotRestoreBtnClicked();
|
|
void slotConfirmBtnClicked();
|
|
|
|
signals:
|
|
void signalRestoreFactory();
|
|
|
|
private:
|
|
LineEditWithKeyboard* m_lineEdit_pwd;
|
|
QPushButton* m_btn_visable;
|
|
QPushButton* m_btn_factory;
|
|
QObject *m_bgWidget;
|
|
|
|
QString m_pwd;
|
|
int m_mode = 0;
|
|
};
|
|
|
|
class QuestionDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit QuestionDialog(const QString& question, QObject *bgWidget = nullptr, const QString& btnText = tr("确定"));
|
|
|
|
signals:
|
|
public slots:
|
|
};
|
|
|
|
class InfoDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit InfoDialog(const QString& info, QObject *bgWidget = nullptr, const QString& btnText = tr("知道了"), int timeout = 0);
|
|
|
|
signals:
|
|
public slots:
|
|
};
|
|
|
|
class SliderDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit SliderDialog(int current, int min, int max, const QString& tip, QObject *bgWidget = nullptr);
|
|
~SliderDialog();
|
|
int getValueSet() const;
|
|
|
|
signals:
|
|
public slots:
|
|
void slotValueChanged(int value);
|
|
|
|
private:
|
|
QLabel* m_labelCurrent;
|
|
QSlider* m_slider;
|
|
int m_iCurrent;
|
|
};
|
|
|
|
class DateTimeDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DateTimeDialog(const QDateTime& dateTime, QObject *bgWidget = nullptr, bool needDate = true, bool needTime = true);
|
|
QDateTime getValueSet() const;
|
|
|
|
signals:
|
|
public slots:
|
|
void slotConfirmBtnClicked();
|
|
|
|
private:
|
|
QDateTimeEdit* m_dateTimeSet;
|
|
QDateTime m_dataTimeVal;
|
|
};
|
|
|
|
class RadioBtnChooseDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
QLabel* m_label_title;
|
|
QRadioButton* m_rdo;
|
|
QVBoxLayout* vLayout;
|
|
|
|
public:
|
|
explicit RadioBtnChooseDialog(const QVector<QString>& labels, QObject *bgWidget = nullptr, const int choose = 0, const QVector<bool> *config = nullptr, const QString& title = "");
|
|
virtual ~RadioBtnChooseDialog();
|
|
int getChoosedIndex() const;
|
|
|
|
public slots:
|
|
void slotRadioButtonPressed();
|
|
|
|
private:
|
|
int m_option_num;
|
|
int m_chooseIndex;
|
|
};
|
|
|
|
class LineEditInputDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
QFormLayout* formLayout;
|
|
QVBoxLayout* vLayout;
|
|
|
|
LineEditWithKeyboard* m_editRow;
|
|
QString* m_stringRowInput;
|
|
int m_rowNum;
|
|
|
|
protected slots:
|
|
void slotConfirmBtnClicked();
|
|
|
|
public:
|
|
LineEditInputDialog(const QStringList& labels, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
|
|
LineEditInputDialog(const QString& label, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
|
|
virtual ~LineEditInputDialog();
|
|
|
|
QString getRow(const int) const ;
|
|
void fillRow(const int, const QString&, bool readOnly = false);
|
|
|
|
private:
|
|
void init(const QStringList& labels);
|
|
};
|
|
|
|
class MsgDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MsgDialog(const QString& msg, QObject *bgWidget = nullptr);
|
|
};
|
|
|
|
class ComSelectDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
QFormLayout* formLayout;
|
|
QVBoxLayout* vLayout;
|
|
|
|
QVector<QComboBox*> m_cbSels;
|
|
int m_rowNum;
|
|
|
|
protected slots:
|
|
|
|
public:
|
|
ComSelectDialog(const QStringList& titles, const QVector<QStringList>& sels, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
|
|
virtual ~ComSelectDialog();
|
|
|
|
int getRow(int) const ;
|
|
void setRow(int row, int set, bool readOnly = false);
|
|
|
|
private:
|
|
};
|
|
|
|
class IpInputDialog : public LineEditInputDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
|
|
protected slots:
|
|
void slotTextChanged(const QString &);
|
|
void slotConfirmBtnClicked();
|
|
|
|
public:
|
|
IpInputDialog(const QStringList& ips, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
|
|
IpInputDialog(const QString& ip, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
|
|
virtual ~IpInputDialog();
|
|
|
|
private:
|
|
};
|
|
#endif
|
|
|
|
class MyMessageBox : public QMessageBox
|
|
{
|
|
public:
|
|
MyMessageBox();
|
|
|
|
protected:
|
|
void showEvent(QShowEvent* event);
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class myListWidget : public QWidget
|
|
{
|
|
public:
|
|
typedef enum
|
|
{
|
|
enSwitch,
|
|
enMoreArrow,
|
|
enRedWord,
|
|
enTick,
|
|
enIndent1
|
|
}_enProp;
|
|
|
|
typedef enum
|
|
{
|
|
enPropertyNull,
|
|
enPropertySwitch = 1 << enSwitch,
|
|
enPropertyMoreArrow = 1 << enMoreArrow,
|
|
enPropertyRedWord = 1 << enRedWord,
|
|
enPropertyTick = 1 << enTick,
|
|
enPropertyIndent1 = 1 << enIndent1
|
|
}enProperty;
|
|
|
|
class SetOpnCfg
|
|
{
|
|
public:
|
|
const QString m_sOpn;
|
|
const QString m_sVal;
|
|
const enProperty m_prop;
|
|
SetOpnCfg(const QString& opn, const QString& val, const enProperty prop) : m_sOpn(opn), m_sVal(val), m_prop(prop){}
|
|
SetOpnCfg(const QString& opn, const QString& val) : m_sOpn(opn), m_sVal(val), m_prop(myListWidget::enPropertyNull){}
|
|
SetOpnCfg(const QString& opn) : m_sOpn(opn), m_sVal(""), m_prop(myListWidget::enPropertyNull){}
|
|
SetOpnCfg() : m_sOpn(""), m_sVal(""), m_prop(myListWidget::enPropertyNull){}
|
|
SetOpnCfg& operator= (const SetOpnCfg& obj){Q_UNUSED(obj) return *this;}
|
|
};
|
|
|
|
myListWidget(const SetOpnCfg& cfg, QWidget* parent = nullptr);
|
|
~myListWidget();
|
|
|
|
void updateLabel(const QString& val);
|
|
void updateIcon(const QString& icon, int scale_w=0, int scale_h=0);
|
|
void setLeftIcon(const QString& icon, int scale_w, int scale_h);
|
|
const QString getLabelString() const;
|
|
const QString getOpnLabelString() const;
|
|
const QString getOptionLabel() const;
|
|
|
|
private:
|
|
QLabel* m_label_leftIcon;
|
|
QLabel* m_label_left;
|
|
QLabel* m_label_right;
|
|
QLabel* m_label_icon;
|
|
QHBoxLayout* m_hbLayout;
|
|
int m_layoutObjQty = 0;
|
|
bool m_hasIndent = false;
|
|
};
|
|
|
|
class SwitchListWidget : public QWidget
|
|
{
|
|
private:
|
|
QLabel* m_label_left;
|
|
QLabel* m_label_right;
|
|
QLabel* m_label_icon;
|
|
|
|
bool m_Res;
|
|
|
|
public:
|
|
SwitchListWidget(const QString& left, const QString& right, const QString& icon, QWidget*parent);
|
|
~SwitchListWidget();
|
|
|
|
void updateLabel(const QString& label);
|
|
void updateIcon(const QString& icon);
|
|
void updateIcon(bool bFlag);
|
|
bool getSwitchRes();
|
|
const QString getLabelString() const;
|
|
};
|
|
|
|
class FourListWidget : public QWidget
|
|
{
|
|
private:
|
|
QLabel* m_label_left;
|
|
QLabel* m_label_right;
|
|
QLabel* m_label_icon;
|
|
QPushButton* m_btn_mid;
|
|
|
|
public:
|
|
FourListWidget(const QString& left, const QString& right, const QString& btnText, const QString& icon, QWidget*parent);
|
|
~FourListWidget();
|
|
|
|
void updateLabel(const QString& label);
|
|
void updateIcon(const QString& icon);
|
|
void updateBtnText(const QString& text);
|
|
|
|
QPushButton* getPushButton();
|
|
|
|
const QString getLabelString() const;
|
|
};
|
|
|
|
class setPushButton : public QWidget
|
|
{
|
|
public:
|
|
setPushButton(QPushButton* pPushButton, const QString& tip, const QString& icon, const QSize& size);
|
|
~setPushButton();
|
|
|
|
private:
|
|
QVBoxLayout* _pVBoxLayoutDevice;
|
|
QLabel* _pLabelIcon;
|
|
};
|
|
|
|
void setLanguage(QApplication&, const QString&);
|
|
void setFont(QApplication& app, const QString&, const int fontSize, const int);
|
|
|
|
void setLineEditFontColor(QLineEdit* edit, const QColor& color);
|
|
void setLineEditStyle(QLineEdit* edit);
|
|
void setButtonBackImage(QPushButton *button, QString image, int sizeW = 0, int sizeH = 0);
|
|
QListWidgetItem* setListWidgetItem(QListWidgetItem* item, const QString text = "", const QString image = "");
|
|
|
|
class TimerUpdate : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TimerUpdate(QLabel* pLabel, QWidget *parent = nullptr);
|
|
TimerUpdate(QLabel* labelTime, QLabel* labelDate, QWidget *parent = nullptr, int timeType = 0, int dateType = 0, int weekType = 0);
|
|
~TimerUpdate();
|
|
void timerEvent(QTimerEvent *event);
|
|
void enableUpdate(bool enable);
|
|
|
|
signals:
|
|
void signalNewDay();
|
|
|
|
private:
|
|
int _timerID;
|
|
QLabel* _labelTime;
|
|
QLabel* _labelDate;
|
|
int m_timeType;
|
|
int m_dateType;
|
|
int m_weekType;
|
|
|
|
bool m_enableUpdate = true;
|
|
|
|
void init();
|
|
};
|
|
|
|
QPixmap PixmapToRound(QPixmap &src, int radius);
|
|
QImage ScaleImage(const QImage& image, const QSize& size);
|
|
QImage ScaleImage2Label(const QImage& qImage, const QLabel& label);
|
|
QPixmap ScalePixmap(const QPixmap& pixmap, const QSize& size);
|
|
QPixmap ScalePixmap2Label(const QPixmap& pixmap, const QLabel& label);
|
|
|
|
class MyLineEdit:public QLineEdit
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MyLineEdit(QWidget *parent = nullptr);
|
|
~MyLineEdit();
|
|
protected:
|
|
//添加并重写鼠标点击事件函数
|
|
virtual void mousePressEvent(QMouseEvent *event);
|
|
signals:
|
|
//点击信号函数
|
|
void clicked();
|
|
};
|
|
|
|
class LocalFourListWidget : public QWidget
|
|
{
|
|
private:
|
|
QLabel* m_label_left;
|
|
QLabel* m_label_mid;
|
|
QLabel* m_label_right;
|
|
QLabel* m_label_icon;
|
|
|
|
|
|
public:
|
|
LocalFourListWidget(const QString& left, const QString& mid, const QString& right, const QString& icon, QWidget*parent);
|
|
|
|
~LocalFourListWidget();
|
|
|
|
void updateLabel(const QString& label);
|
|
|
|
void updateRight(const QString& text);
|
|
|
|
void updateIcon(const QString& icon);
|
|
|
|
const QString getLabelString() const;
|
|
};
|
|
|
|
bool checkip(const QString& ip);
|
|
bool checkMask(const QString& mask);
|
|
|
|
//判断是否在同一网段
|
|
bool isSameNetwork(const QString& ip, const QString& mask, const QString& gateway);
|
|
|
|
bool getIpFromUserInput(const QString& lineEdit, const QString& initIp, QString& newIp, QObject *bgWidget = nullptr);
|
|
bool getMaskFromUserInput(const QString& lineEdit, const QString& initIp, QString& newIp, QObject *bgWidget = nullptr);
|
|
bool getNumFromUserInput(const QString& lineEdit, const QString& initNum, QString& newValue, const int min, const int max, QObject *bgWidget = nullptr);
|
|
|
|
QString GBK2UTF8(const QString &inStr);
|
|
QString UTF82GBK(const QString &inStr);
|
|
std::string gbk2utf8(const QString &inStr);
|
|
QString utf82gbk(const std::string &inStr);
|
|
void gbkToUtf8(char *gbkstr);
|
|
|
|
class ProgressWidget : public QWidget
|
|
{
|
|
public:
|
|
explicit ProgressWidget(const QString& title);
|
|
~ProgressWidget();
|
|
void setMsg(const unsigned current, const unsigned all);
|
|
|
|
private:
|
|
QLabel* m_label_title;
|
|
QLabel* m_label_msg;
|
|
QSlider* m_slider_progess;
|
|
};
|
|
|
|
class SettingUiPage : public MyWidgetWithMainStyleColor
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
typedef myListWidget::SetOpnCfg SetOpn;
|
|
explicit SettingUiPage(const QVector<SetOpn>& config, QWidget *parent = nullptr);
|
|
|
|
protected:
|
|
const QVector<SetOpn> config;
|
|
QListWidget* m_listWidget;
|
|
|
|
void controlListWidgetItemShow(const bool sw, int option);
|
|
|
|
signals:
|
|
void signalShowPage(int, const QString title = "");
|
|
|
|
protected slots:
|
|
virtual void slotItemClicked(QListWidgetItem* item) = 0;
|
|
};
|
|
|
|
class MsgListWidgetItem : public QWidget
|
|
{
|
|
public:
|
|
typedef enum
|
|
{
|
|
enBold,
|
|
enGreyWord,
|
|
enGreenWord,
|
|
enRedWord
|
|
}_enProp;
|
|
|
|
typedef enum
|
|
{
|
|
enPropertyNull,
|
|
enPropertyBold = 1 << enBold,
|
|
enPropertyGreyWord = 1 << enGreyWord,
|
|
enPropertyGreenWord = 1 << enGreenWord,
|
|
enPropertyRedWord = 1 << enRedWord
|
|
}enProperty;
|
|
|
|
typedef struct
|
|
{
|
|
QString m_sMsg;
|
|
enProperty m_eProp;
|
|
}stMsgOpn;
|
|
|
|
class MsgSet
|
|
{
|
|
public:
|
|
const QString m_sPic;
|
|
const QVector<stMsgOpn> m_vMsgs;
|
|
MsgSet() : m_sPic(""){}
|
|
MsgSet(const QString& pic, const QVector<stMsgOpn>& msgs) : m_sPic(pic), m_vMsgs(msgs){}
|
|
MsgSet& operator=(const MsgSet& obj){Q_UNUSED(obj) return *this;}
|
|
};
|
|
|
|
MsgListWidgetItem(QWidget* parent);
|
|
~MsgListWidgetItem();
|
|
|
|
void showMsg(const QString& pic, const QVector<stMsgOpn>& msgs);
|
|
private:
|
|
const int m_msgOpnQty = 4;
|
|
|
|
QLabel* labelPic;
|
|
QVector<QLabel*> labelMsg;
|
|
};
|
|
|
|
class PersonMsgUiPage : public MyWidgetWithMainStyleColor
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
typedef MsgListWidgetItem::stMsgOpn MsgOpn;
|
|
typedef MsgListWidgetItem::enProperty MsgOpnProp;
|
|
typedef MsgListWidgetItem::MsgSet MsgSet;
|
|
|
|
const unsigned m_itemQty = 5;
|
|
|
|
explicit PersonMsgUiPage(QWidget *parent = nullptr);
|
|
void showMsg(const QVector<MsgSet>& msgs);
|
|
void clearMsg();
|
|
void setPageControlBarHide(bool hide, int min = 0, int max = 0, int current = 0);
|
|
void showMoreSearchOpn();
|
|
|
|
protected:
|
|
#define SEARCH_OPN_QTY 2
|
|
enum{
|
|
enSearchOpnName,
|
|
enSearchOpnTime
|
|
};
|
|
QLineEdit* m_editSearch[SEARCH_OPN_QTY];
|
|
QPushButton* m_btnClearSearch[SEARCH_OPN_QTY];
|
|
QLabel* m_labelTip[SEARCH_OPN_QTY];
|
|
QPushButton* m_btnMore;
|
|
|
|
QStackedWidget* m_stackWgt;
|
|
QListWidget* m_listWidget;
|
|
QLabel* m_labelPage;
|
|
QLabel* m_labelMin;
|
|
QLabel* m_labelMax;
|
|
QPushButton* m_btnPrePage;
|
|
QPushButton* m_btnNextPage;
|
|
QSlider* m_sliderPage;
|
|
|
|
int m_toPageNum;
|
|
QString m_sSearchName;
|
|
QString m_sSearchtime;
|
|
|
|
protected slots:
|
|
virtual void slotTextChanged(const QString& text) = 0;
|
|
virtual void slotBtnClicked();
|
|
virtual void slotSliderReleased() = 0;
|
|
virtual void slotItemClicked(QListWidgetItem *item);
|
|
void slotValueChanged(int value);
|
|
};
|
|
|
|
class ItemChoosePage : public SettingUiPage
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ItemChoosePage(const QVector<SetOpn>& config, int choose, QWidget *parent = nullptr);
|
|
int getChoosedIndex() const;
|
|
|
|
public slots:
|
|
void slotItemClicked(QListWidgetItem*);
|
|
|
|
private:
|
|
int m_chooseIndex;
|
|
};
|
|
|
|
class ItemChooseDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
ItemChoosePage* m_ItemsPage;
|
|
QVBoxLayout* vLayout;
|
|
|
|
public:
|
|
explicit ItemChooseDialog(const QVector<QString>& items, const int choose, QObject *bgWidget = nullptr);
|
|
virtual ~ItemChooseDialog();
|
|
int getChoosedIndex() const;
|
|
|
|
public slots:
|
|
};
|
|
|
|
class CalendarDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit CalendarDialog(bool isEn, QObject *bgWidget = nullptr);
|
|
QDate getDateChoose() const;
|
|
|
|
signals:
|
|
public slots:
|
|
void slotConfirmBtnClicked();
|
|
|
|
private:
|
|
QCalendarWidget* m_wgtCal;
|
|
QDate m_date;
|
|
};
|
|
|
|
class LineEditWithDialog : public QLineEdit
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
LineEditWithDialog(int dialogType, QObject *bgWidget = nullptr, QWidget *parent = nullptr);
|
|
~LineEditWithDialog();
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
signals:
|
|
|
|
private:
|
|
int m_dialogType;
|
|
QObject *m_bgWidget;
|
|
};
|
|
|
|
class WifiListWidget : public QWidget
|
|
{
|
|
public:
|
|
WifiListWidget(const QString& ssid, bool connected, bool withLock, int sigLevel, bool isTargetNet, QWidget* parent);
|
|
~WifiListWidget();
|
|
|
|
void updateStatus(bool connected);
|
|
QString getSsid() const;
|
|
bool isTargetNet() const;
|
|
bool isConnected() const;
|
|
bool getLockStatus() const;
|
|
void clearStatus();
|
|
|
|
private:
|
|
QLabel* m_label_conn;
|
|
QLabel* m_label_ssid;
|
|
const bool m_isLock;
|
|
bool m_isTargetNet;
|
|
bool m_isConnected;
|
|
};
|
|
|
|
class WifiAccPointDialog : public LineEditInputDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void slotConfirmBtnClicked();
|
|
|
|
public:
|
|
WifiAccPointDialog(QObject *bgWidget = nullptr);
|
|
virtual ~WifiAccPointDialog();
|
|
|
|
QString getEncType() const;
|
|
|
|
private:
|
|
QComboBox* m_comBox_encType;
|
|
QString m_sEncType;
|
|
};
|
|
|
|
int GrabFullScreen(const QString& picName, int rotate = 0);
|
|
|
|
class DrawPage : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
struct DrawPara
|
|
{
|
|
QList<QPoint> points;
|
|
};
|
|
|
|
QPushButton* m_btnClear;
|
|
QPushButton* m_btnExit;
|
|
|
|
QList<DrawPara> m_drawList;
|
|
DrawPara m_current;
|
|
|
|
void draw(QPainter& painter, DrawPara& param);
|
|
void append(QPoint p);
|
|
|
|
signals:
|
|
void signalClosed();
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *evt);
|
|
void mouseMoveEvent(QMouseEvent *evt);
|
|
void mouseReleaseEvent(QMouseEvent *evt);
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
public slots:
|
|
void slotClearBtnClicked();
|
|
void slotExitBtnClicked();
|
|
|
|
public:
|
|
DrawPage(int w, int h, QWidget *parent = 0);
|
|
~DrawPage();
|
|
};
|
|
|
|
class UserPwdDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
QString m_pwd;
|
|
explicit UserPwdDialog();
|
|
|
|
signals:
|
|
public slots:
|
|
void slotBtnClicked();
|
|
|
|
private:
|
|
enum{NUM_BTNS_QTY = 10};
|
|
QLineEdit* m_editPwd;
|
|
QPushButton* m_btnsNum[NUM_BTNS_QTY];
|
|
QPushButton* m_btnBack;
|
|
QPushButton* m_btnClear;
|
|
QPushButton* m_btnBackspace;
|
|
QPushButton* m_btnConfirm;
|
|
};
|
|
|
|
class QPasswordLineEdit : public QLineEdit
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QPasswordLineEdit(QWidget *parent, const QString& ch = "•", int timeout = 300);
|
|
~QPasswordLineEdit();
|
|
private slots:
|
|
void DisplayPasswordAfterEditSlot(int,int);
|
|
void DisplayPasswordSlot();
|
|
void GetRealTextSlot(const QString&);
|
|
|
|
public:
|
|
QString GetPassword() const;
|
|
void SetTimeout(int msec);
|
|
int GetTimeout() const;
|
|
|
|
private:
|
|
QString GetMaskString();
|
|
|
|
private:
|
|
const QString m_ch;
|
|
int m_Timeout;
|
|
QString m_LineEditText;
|
|
int m_LastCharCount = 0;
|
|
QTimer* m_timer;
|
|
};
|
|
|
|
class RoundedWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit RoundedWidget(QWidget *parent = nullptr);
|
|
|
|
private:
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class StyleItemChooseDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
|
|
public:
|
|
explicit StyleItemChooseDialog(const QString& title, const QStringList& items, BackstageInterfaceForUi* backstageIf);
|
|
virtual ~StyleItemChooseDialog();
|
|
int getChoosedIndex() const;
|
|
|
|
public slots:
|
|
void slotItemClicked(QListWidgetItem* item);
|
|
void slotTimeout();
|
|
|
|
private:
|
|
enum{
|
|
TIMEOUT = 1000,
|
|
BACKSTAGE_PROC_OVERTIME = 5,
|
|
PROC_OVERTIME = 10
|
|
};
|
|
BackstageInterfaceForUi* m_backstageIf;
|
|
QListWidget* m_listWidget;
|
|
int m_chooseIndex = 0;
|
|
int m_timeCnt = 0;
|
|
|
|
void paintEvent(QPaintEvent *event);
|
|
};
|
|
|
|
class SelectionDialog : public CustomDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit SelectionDialog(const QString& tips, const QString& sel0, const QString& sel1, QObject *bgWidget = nullptr);
|
|
int selecion() const;
|
|
signals:
|
|
public slots:
|
|
|
|
private:
|
|
int m_sel = 0;
|
|
};
|
|
|
|
class TimeWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TimeWidget(bool enType, int timeSize, int dateSize, QWidget *parent = nullptr);
|
|
void enableUpdate(bool enable);
|
|
|
|
public slots:
|
|
|
|
private:
|
|
TimerUpdate* m_timerUpdate;
|
|
};
|
|
|
|
class DateTimeWidgetClassical : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DateTimeWidgetClassical(int fontSize, QWidget *parent = nullptr);
|
|
|
|
signals:
|
|
void signalNewDay();
|
|
};
|
|
|
|
class BtListWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
//BtListWidget(const QString& devId, const QString& devName, bool isPaired, int devStat);
|
|
BtListWidget(BluetoothDev_t &rBtDev/*, bool isPaired = false*/);
|
|
~BtListWidget();
|
|
|
|
void refreshWidget();
|
|
void getDevInfo(BluetoothDev_t &dev);
|
|
void updateDev(BluetoothDev_t &rBtDev);
|
|
|
|
signals:
|
|
void signalClickSet(BluetoothDev_t btDev);
|
|
|
|
public slots:
|
|
void slotBtnSetClick();
|
|
|
|
private:
|
|
QLabel* m_label_btIcon = nullptr;
|
|
QLabel* m_label_dev = nullptr;
|
|
//QLabel* m_label_pairedIcon;
|
|
//QLabel* m_label_stat;
|
|
QPushButton *m_pushButton_set = nullptr;
|
|
#if 0
|
|
QString m_devId;//设备唯一标识
|
|
QString m_devName;
|
|
int m_devStat;
|
|
#endif
|
|
BluetoothDev_t m_btDev;
|
|
//bool m_isPaired;//是否已配对的蓝牙设备
|
|
|
|
};
|
|
|
|
class IpInputBar : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
IpInputBar(bool isMask, QWidget *parent = nullptr);
|
|
bool isEmpty() const;
|
|
QString getIp() const;
|
|
|
|
protected slots:
|
|
void slotTextChanged(const QString &t);
|
|
void slotBackspacePressed();
|
|
|
|
private:
|
|
const bool m_isMask;
|
|
QVector<LineEditWithKeyboard *> m_edits;
|
|
};
|
|
|
|
class IpInputBarDialog : public CustomDialog {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
IpInputBarDialog(const QStringList &options, const QVector<bool> &required, const QVector<bool> &isMask,
|
|
QObject *bgWidget);
|
|
QString getRow(int row) const;
|
|
|
|
protected slots:
|
|
void slotConfirmBtnClicked();
|
|
|
|
private:
|
|
QVector<IpInputBar *> m_bars;
|
|
const QVector<bool> m_required;
|
|
};
|
|
|
|
class SearchBarCandidate : public ItemChoosePage
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
using ItemChoosePage::ItemChoosePage;
|
|
QString getCurrentChooseText();
|
|
|
|
signals:
|
|
void signalItemChoosed(int);
|
|
|
|
public slots:
|
|
void slotItemClicked(QListWidgetItem*);
|
|
};
|
|
|
|
class ImgPlayer : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ImgPlayer(int width, int height, QWidget *parent = nullptr);
|
|
|
|
signals:
|
|
|
|
public slots:
|
|
void slotImgLoad(QImage);
|
|
|
|
private:
|
|
QImage m_img;
|
|
int m_width;
|
|
int m_height;
|
|
QRectF m_targetRct;
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
};
|
|
|
|
#endif // _UITOOLS_H_
|