| 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: Zhenyu Wang <[email protected]> |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "widget.h" |
| 24 |
#include "kpressbutton.h" |
| 25 |
#include "kwidget.h" |
| 26 |
#include <QHBoxLayout> |
| 27 |
#include <QVBoxLayout> |
| 28 |
using namespace kdk; |
| 29 |
|
| 30 |
Widget::Widget(QWidget *parent) |
| 31 |
: QWidget(parent) |
| 32 |
{ |
| 33 |
KPressButton *button1 = new KPressButton(); |
| 34 |
button1->setIcon(QIcon::fromTheme("stock-people-symbolic")); |
| 35 |
button1->setBorderRadius(20); |
| 36 |
button1->setTranslucent(true); |
| 37 |
button1->setChecked(true); |
| 38 |
|
| 39 |
KPressButton *button2 = new KPressButton(); |
| 40 |
button2->setCheckable(false); |
| 41 |
|
| 42 |
QHBoxLayout *layout = new QHBoxLayout(); |
| 43 |
layout->addWidget(button1); |
| 44 |
layout->addWidget(button2); |
| 45 |
|
| 46 |
KPressButton *button3 = new KPressButton(this); |
| 47 |
KPressButton *button4 = new KPressButton(); |
| 48 |
button4->setFixedSize(36, 36); |
| 49 |
button4->setButtonType(KPressButton::CircleType); |
| 50 |
button4->setIcon(QIcon::fromTheme("system-computer-symbolic")); |
| 51 |
|
| 52 |
QHBoxLayout *layout1 = new QHBoxLayout(); |
| 53 |
layout1->addWidget(button3); |
| 54 |
layout1->addWidget(button4); |
| 55 |
|
| 56 |
KPressButton *button5 = new KPressButton(); |
| 57 |
button5->setLoaingStatus(true); |
| 58 |
button5->setChecked(true); |
| 59 |
|
| 60 |
KPressButton *button6 = new KPressButton(); |
| 61 |
|
| 62 |
QHBoxLayout *layout2 = new QHBoxLayout(); |
| 63 |
layout2->addWidget(button5); |
| 64 |
layout2->addWidget(button6); |
| 65 |
|
| 66 |
QVBoxLayout *vlayout = new QVBoxLayout(this); |
| 67 |
vlayout->addLayout(layout); |
| 68 |
vlayout->addLayout(layout1); |
| 69 |
vlayout->addLayout(layout2); |
| 70 |
|
| 71 |
connect(button4, &KPressButton::clicked, this, [=]() { |
| 72 |
if (button4->isChecked()) |
| 73 |
button4->setLoaingStatus(true); |
| 74 |
else |
| 75 |
button4->setLoaingStatus(false); |
| 76 |
}); |
| 77 |
connect(button5, &KPressButton::clicked, this, [=]() { |
| 78 |
if (button5->isChecked()) |
| 79 |
button5->setLoaingStatus(true); |
| 80 |
else |
| 81 |
button5->setLoaingStatus(false); |
| 82 |
}); |
| 83 |
|
| 84 |
connect(button2, &KPressButton::clicked, this, [=](bool flag) { |
| 85 |
qDebug() << flag << button2->isChecked() << button2->isCheckable(); |
| 86 |
}); |
| 87 |
} |
| 88 |
|
| 89 |
Widget::~Widget() |
| 90 |
{ |
| 91 |
} |