| 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 "ktranslucentfloor.h" |
| 25 |
#include <QDebug> |
| 26 |
#include <QHBoxLayout> |
| 27 |
#include <QLabel> |
| 28 |
#include <QPushButton> |
| 29 |
|
| 30 |
using namespace kdk; |
| 31 |
Widget::Widget(QWidget *parent) |
| 32 |
: QWidget(parent) |
| 33 |
{ |
| 34 |
QHBoxLayout *mainLayout = new QHBoxLayout(this); |
| 35 |
QPushButton *button1 = new QPushButton("常规效果", this); |
| 36 |
QPushButton *button2 = new QPushButton("毛玻璃效果", this); |
| 37 |
mainLayout->addWidget(button1); |
| 38 |
mainLayout->addWidget(button2); |
| 39 |
|
| 40 |
KTranslucentFloor *floor1 = new KTranslucentFloor(); |
| 41 |
floor1->setEnableBlur(false); |
| 42 |
floor1->setFixedSize(400, 300); |
| 43 |
floor1->setShadow(true); |
| 44 |
QHBoxLayout *layout1 = new QHBoxLayout(floor1); |
| 45 |
QPushButton *subBtn1 = new QPushButton("关闭", this); |
| 46 |
layout1->addWidget(subBtn1); |
| 47 |
|
| 48 |
KTranslucentFloor *floor2 = new KTranslucentFloor(); |
| 49 |
floor2->setEnableBlur(true); |
| 50 |
floor2->setFixedSize(400, 300); |
| 51 |
floor2->setShadow(true); |
| 52 |
QHBoxLayout *layout2 = new QHBoxLayout(floor2); |
| 53 |
QPushButton *subBtn2 = new QPushButton("关闭", this); |
| 54 |
layout2->addWidget(subBtn2); |
| 55 |
|
| 56 |
connect(subBtn1, &QPushButton::clicked, this, [=]() { |
| 57 |
floor1->close(); |
| 58 |
}); |
| 59 |
connect(subBtn2, &QPushButton::clicked, this, [=]() { |
| 60 |
floor2->close(); |
| 61 |
}); |
| 62 |
connect(button1, &QPushButton::clicked, this, [=]() { |
| 63 |
floor1->show(); |
| 64 |
}); |
| 65 |
connect(button2, &QPushButton::clicked, this, [=]() { |
| 66 |
floor2->show(); |
| 67 |
}); |
| 68 |
} |
| 69 |
|
| 70 |
Widget::~Widget() |
| 71 |
{ |
| 72 |
} |