Debian Codegraph @

kysdk-qtwidgets/test/testFileWidget/widget.cpp

raw
1 /*
2 *
3 * Copyright (C) 2024, KylinSoft Co., Ltd.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this library. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * Authors: Zhenyu Wang <[email protected]>
19 *
20 */
21
22 #include "widget.h"
23 #include "kfilewidget.h"
24 #include "kpressbutton.h"
25 #include <QHBoxLayout>
26 #include <QIcon>
27 #include <QObject>
28
29 Widget::Widget(QWidget *parent)
30 : KWidget(parent)
31 {
32 QVBoxLayout *layout = new QVBoxLayout();
33
34 KFileWidget *widget1 = new KFileWidget(this);
35 widget1->setFixedSize(150, 56);
36 widget1->setMainText("文档.word");
37 widget1->setSubText("大小 1MB");
38 widget1->setIcon(QIcon::fromTheme("wps-office2019-wpsmain"));
39 widget1->setBorderRadius(0, 10, 0, 10);
40 connect(widget1, &KFileWidget::clicked, this, [=] {
41 widget1->hide();
42 });
43
44 KFileWidget *widget2 = new KFileWidget(this);
45 widget2->setMainText("文档.word");
46 widget2->setIcon(QIcon::fromTheme("wps-office2019-wpsmain"));
47 widget2->setEnabled(false);
48 connect(widget2, &KFileWidget::clicked, this, [=] {
49 widget2->hide();
50 });
51
52 KFileWidget *widget3 = new KFileWidget(this);
53 widget3->setMainText("文档.word");
54 widget3->setIcon(QIcon::fromTheme("wps-office2019-wpsmain"));
55 widget3->setFixedSize(150, 56);
56 widget3->setBorderRadius(0);
57 connect(widget3, &KFileWidget::clicked, this, [=] {
58 widget3->hide();
59 });
60
61 layout->addStretch();
62 layout->addWidget(widget1);
63 layout->addWidget(widget2);
64 layout->addWidget(widget3);
65 layout->addStretch();
66
67 QHBoxLayout *hlayout = new QHBoxLayout();
68 hlayout->addLayout(layout);
69
70 baseBar()->setLayout(hlayout);
71 }
72
73 Widget::~Widget()
74 {
75 }