Debian Codegraph @

kysdk-qtwidgets/test/testprogressdialog/widget.cpp

raw
1 /*
2 *
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: Zhen Sun <[email protected]>
20 *
21 */
22
23 #include "widget.h"
24 #include "kprogressbar.h"
25 #include <QPushButton>
26 #include <QVBoxLayout>
27
28 using namespace kdk;
29
30 Widget::Widget(QWidget *parent)
31 : KWidget(parent)
32 {
33 KProgressDialog *progressDialog = new KProgressDialog(tr("运行中"), tr("取消"), 0, 100, this);
34 progressDialog->setSubContent("正在下载..."); // 设置次级内容
35 progressDialog->setSuffix("MB"); // 设置detail的后缀
36 progressDialog->setWindowTitle("进度对话框"); // 设置窗口标题
37 progressDialog->setWindowIcon("kylin-music"); // 设置窗口图标
38 progressDialog->setValue(98); // 设置当前进度值
39 progressDialog->setShowDetail(true); // 设置是否显示详细信息
40 progressDialog->setAutoReset(false); // 设置进度条是否重置
41
42 QPushButton *pBtn = new QPushButton("显示", this);
43 QVBoxLayout *vLayout = new QVBoxLayout(this);
44 vLayout->addWidget(pBtn);
45 baseBar()->setLayout(vLayout);
46
47 connect(pBtn, &QPushButton::clicked, this, [=]() {
48 progressDialog->show();
49 });
50 }
51
52 Widget::~Widget()
53 {
54 }