0 Star 2 Fork 1

Cadaqs/XStudio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
inputdlg.xcsm 2.76 KB
一键复制 编辑 原始数据 按行查看 历史
Cadaqs 提交于 2020-11-28 21:28 +08:00 . 9233
//xlang Source, Name:gotoline.xcsm
//Date: Sun Sep 19:06:03 2018
class InputDialog : QDialog {
public static class onInputListener{
public bool onInputOk(@NotNilptr String text);
public bool onInputCancel();
public bool onSelectOk(int id){
return false;
}
public String getTitle();
public String getTips();
public String getDefault();
};
public onInputListener listener;
public InputDialog(onInputListener intputlis){
listener = intputlis;
}
QPushButton btnOk, btnCancel;
QLineEdit edtLine;
String result = nilptr;
public void onAttach()override{
setWindowFlags(Constant.CustomizeWindowHint | Constant.WindowCloseButtonHint);
setFixedSize(width(), height());
btnOk = (QPushButton)attachByName(new QPushButton(), "btnOk");
btnCancel = (QPushButton)attachByName(new QPushButton(), "btnCancel");
edtLine = (QLineEdit)attachByName(new QLineEdit(), "edtLine");
QLabel label = (QLabel)attachByName(new QLabel(), "label");
if (label != nilptr){
edtLine.setText(listener.getDefault());
btnOk.setOnClickListener(
new onClickListener(){
void onClick(QObject obj, bool checked)override{
String text = edtLine.getText();
if (listener.onInputOk(text)){
result = text;
close();
}
}
});
btnCancel.setOnClickListener(
new onClickListener(){
void onClick(QObject obj, bool checked)override{
if (listener.onInputCancel()){
close();
}
}
});
label.setText(listener.getTips());
setWindowTitle(listener.getTitle());
setModal(true);
edtLine.setFocus();
}
}
public static void requestInput(onInputListener lis){
QDialog newDlg = new QDialog();
if (newDlg.load(UIManager.getUIData(__xPackageResource("ui/goto.ui"))) == false){
return ;
}
InputDialog wizard = new InputDialog(lis);
wizard.attach(newDlg);
wizard.show();
}
public static String requestInputDlg(onInputListener lis){
QDialog newDlg = new QDialog();
if (newDlg.load(UIManager.getUIData(__xPackageResource("ui/goto.ui"))) == false){
return nilptr;
}
InputDialog wizard = new InputDialog(lis);
wizard.attach(newDlg);
wizard.exec();
return wizard.result;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/ixlang/XStudio.git
[email protected]:ixlang/XStudio.git
ixlang
XStudio
XStudio
master

搜索帮助