Debian Codegraph @

kysdk-qtwidgets/test/testDialog/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
25 #include <QBoxLayout>
26 #include <QPushButton>
27
28 #include "kaboutdialog.h"
29 #include "kdialog.h"
30 #include "kuninstalldialog.h"
31
32 Widget::Widget(QWidget *parent)
33 : KWidget(parent)
34 {
35 QVBoxLayout *vLayout = new QVBoxLayout;
36 QPushButton *pBtn1 = new QPushButton("对话框", this);
37 QPushButton *pBtn2 = new QPushButton("卸载对话框", this);
38 QPushButton *pBtn3 = new QPushButton("关于对话框", this);
39 KDialog *dialog = new KDialog();
40 // 设置标题
41 dialog->setWindowTitle("对话框");
42 // 设置icon
43 dialog->setWindowIcon("kylin-music");
44 // 显示最小化和最大化按钮
45 dialog->maximumButton()->show();
46 dialog->minimumButton()->show();
47
48 KUninstallDialog *uninstallDialog = new KUninstallDialog("browser360-cn-stable", "104", this);
49 KAboutDialog *aboutDialog = new KAboutDialog(this, QIcon::fromTheme("kylin-music"), "麒麟音乐", tr("版本:2020.1.0"));
50 aboutDialog->setBodyText("关于对话框,包含的主要内容有:应用图标,应用名称,版本号,团队邮箱以及具体的应用描述,注意,默认应用描述是不显示的。");
51 aboutDialog->setBodyTextVisiable(true);
52 vLayout->addStretch();
53 vLayout->addWidget(pBtn1);
54 vLayout->addWidget(pBtn2);
55 vLayout->addWidget(pBtn3);
56 vLayout->addStretch();
57 connect(pBtn1, &QPushButton::clicked, this, [=]() {
58 dialog->show();
59 });
60 connect(pBtn2, &QPushButton::clicked, this, [=]() {
61 uninstallDialog->show();
62 });
63 connect(pBtn3, &QPushButton::clicked, this, [=]() {
64 aboutDialog->show();
65 });
66 // QHBoxLayout* tmpLayout = dynamic_cast<QHBoxLayout*>(windowButtonBar()->layout());
67 // QPushButton* btn = new QPushButton("btn",this);
68 // tmpLayout->insertWidget(1,btn);
69 QHBoxLayout *hLayout = new QHBoxLayout(dialog);
70 QPushButton *pBtn5 = new QPushButton("对话框", dialog);
71 hLayout->addWidget(pBtn5);
72 dialog->mainWidget()->setLayout(hLayout); // 获取主内容区,通过setLayout()添加内容
73 dialog->menuButton()->show(); // 获取下拉菜单按钮,默认是隐藏的,不显示
74 // dialog->closeButton()->show();//获取关闭按钮。
75 baseBar()->setLayout(vLayout);
76 }
77
78 Widget::~Widget()
79 {
80 }