| 1 |
/* |
| 2 |
* libkysdk-qtwidgets's Library |
| 3 |
* |
| 4 |
* Copyright (C) 2023, KylinSoft Co., Ltd. |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 3 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this library. If not, see <https://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
* Authors: SiSheng He <[email protected]> |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef KSECURITYQUESTIONDIALOG_H |
| 24 |
#define KSECURITYQUESTIONDIALOG_H |
| 25 |
|
| 26 |
#include "gui_g.h" |
| 27 |
#include "kdialog.h" |
| 28 |
#include "kpushbutton.h" |
| 29 |
#include <QBoxLayout> |
| 30 |
#include <QComboBox> |
| 31 |
#include <QDialog> |
| 32 |
#include <QLineEdit> |
| 33 |
|
| 34 |
namespace kdk |
| 35 |
{ |
| 36 |
|
| 37 |
class KSecurityQuestionDialogPrivate; |
| 38 |
|
| 39 |
/** |
| 40 |
* @brief 继承自 KDialog, |
| 41 |
* @since 2.4.1.0 |
| 42 |
*/ |
| 43 |
class GUI_EXPORT KSecurityQuestionDialog : public KDialog |
| 44 |
{ |
| 45 |
Q_OBJECT |
| 46 |
|
| 47 |
public: |
| 48 |
explicit KSecurityQuestionDialog(QWidget *parent = nullptr); |
| 49 |
~KSecurityQuestionDialog(); |
| 50 |
|
| 51 |
/** |
| 52 |
* @brief 设置对话框标题 |
| 53 |
* |
| 54 |
* @param text 标题 |
| 55 |
*/ |
| 56 |
void setTitleText(const QString &text); |
| 57 |
|
| 58 |
/** |
| 59 |
* @brief 添加安全问题控件 |
| 60 |
*Label combox |
| 61 |
*Label lineedit |
| 62 |
* tipsLabel |
| 63 |
* @param count 控件个数 |
| 64 |
* @param mutex 是否开启下拉框互斥校验,若开启后,已被选择项,在其他下拉框中被置灰 |
| 65 |
*/ |
| 66 |
void addSecurityQuestionItem(const int count, bool mutex); |
| 67 |
|
| 68 |
/** |
| 69 |
* @brief 添加安全问题控件 |
| 70 |
*Label combox/lineedit |
| 71 |
*Label lineedit |
| 72 |
* tipsLabel |
| 73 |
* @param count 控件个数 |
| 74 |
* @param mutex 是否开启下拉框互斥校验,若开启后,已被选择项,在其他下拉框中被置灰 |
| 75 |
* @param isVerify 是否为校验窗口 |
| 76 |
*/ |
| 77 |
void addSecurityQuestionItem(const int count, bool mutex, bool isVerify); |
| 78 |
|
| 79 |
/** |
| 80 |
* @brief 添加下拉框选项列表 |
| 81 |
* |
| 82 |
* @param questionlist |
| 83 |
*/ |
| 84 |
void initQustionCombox(const QStringList &questionlist); |
| 85 |
|
| 86 |
/** |
| 87 |
* @brief 获取下拉框左侧Label |
| 88 |
* |
| 89 |
* @param questionIndex item索引 [0,count) |
| 90 |
* @return QLabel 下拉框左侧Label,若未获取到,返回nullptr |
| 91 |
*/ |
| 92 |
QLabel *questionLabel(const int questionIndex); |
| 93 |
|
| 94 |
/** |
| 95 |
* @brief 获取combox |
| 96 |
* |
| 97 |
* @param questionIndex item索引 [0,count) |
| 98 |
* @return QComboBox 下拉框,若未获取到,返回nullptr |
| 99 |
*/ |
| 100 |
QComboBox *questionCombox(const int questionIndex); |
| 101 |
|
| 102 |
/** |
| 103 |
* @brief 获取lineedit左侧label |
| 104 |
* |
| 105 |
* @param answerIndex item索引 [0,count) |
| 106 |
* @return QLabel lineedit左侧label,若未获取到,返回nullptr |
| 107 |
*/ |
| 108 |
QLabel *answerLabel(const int answerIndex); |
| 109 |
|
| 110 |
/** |
| 111 |
* @brief 获取 lineedit |
| 112 |
* |
| 113 |
* @param answerIndex item索引 [0,count) |
| 114 |
* @return QLineEdit lineedit,若未获取到,返回nullptr |
| 115 |
*/ |
| 116 |
QLineEdit *answerLineedit(const int answerIndex); |
| 117 |
|
| 118 |
/** |
| 119 |
* @brief 获取提示 label |
| 120 |
* |
| 121 |
* @param index item 索引 [0,count) |
| 122 |
* @return QLabel 提示label,若未获取到,返回nullptr |
| 123 |
*/ |
| 124 |
QLabel *tipsLabel(const int index); |
| 125 |
|
| 126 |
/** |
| 127 |
* @brief 获取取消按钮 |
| 128 |
* |
| 129 |
* @return KPushButton |
| 130 |
*/ |
| 131 |
KPushButton *cancelButton(); |
| 132 |
|
| 133 |
/** |
| 134 |
* @brief 获取确认按钮 |
| 135 |
* |
| 136 |
* @return KPushButton |
| 137 |
*/ |
| 138 |
KPushButton *confirmButton(); |
| 139 |
|
| 140 |
protected: |
| 141 |
void keyPressEvent(QKeyEvent *); |
| 142 |
|
| 143 |
private: |
| 144 |
Q_DECLARE_PRIVATE(KSecurityQuestionDialog) |
| 145 |
KSecurityQuestionDialogPrivate *const d_ptr; |
| 146 |
}; |
| 147 |
} |
| 148 |
/** |
| 149 |
* @example testsecurityquestiondialog/main.cpp |
| 150 |
* @} |
| 151 |
*/ |
| 152 |
#endif // KSECURITYQUESTIONDIALOG_H |