| 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 "kmessagebox.h" |
| 25 |
#include <QPushButton> |
| 26 |
#include <QVBoxLayout> |
| 27 |
|
| 28 |
using namespace kdk; |
| 29 |
|
| 30 |
Widget::Widget(QWidget *parent) |
| 31 |
: QWidget(parent) |
| 32 |
{ |
| 33 |
QVBoxLayout *layout = new QVBoxLayout; |
| 34 |
|
| 35 |
QPushButton *btn_1 = new QPushButton(this); |
| 36 |
btn_1->setText("TestDemoOne"); |
| 37 |
QObject::connect(btn_1, &QPushButton::clicked, this, [=]() { |
| 38 |
KMessageBox w; |
| 39 |
w.setCustomIcon(QIcon::fromTheme("dialog-error")); |
| 40 |
w.setText("打印测试失败,建议修改驱动后重试"); |
| 41 |
|
| 42 |
QPushButton *btn1 = new QPushButton("修改驱动"); |
| 43 |
QPushButton *btn2 = new QPushButton("取消"); |
| 44 |
w.addButton(btn1, KMessageBox::YesRole); |
| 45 |
w.addButton(btn2, KMessageBox::NoRole); |
| 46 |
|
| 47 |
w.exec(); |
| 48 |
}); |
| 49 |
|
| 50 |
QPushButton *btn_2 = new QPushButton(this); |
| 51 |
btn_2->setText("TestDemoTwo"); |
| 52 |
QObject::connect(btn_2, &QPushButton::clicked, this, [=]() { |
| 53 |
KMessageBox w; |
| 54 |
w.setCustomIcon(QIcon::fromTheme("ukui-dialog-success")); |
| 55 |
w.setText("添加成功,是否打印测试页?"); |
| 56 |
|
| 57 |
QPushButton *btn1 = new QPushButton("打印测试页"); |
| 58 |
QPushButton *btn2 = new QPushButton("查看设备"); |
| 59 |
w.addButton(btn1, KMessageBox::YesRole); |
| 60 |
w.addButton(btn2, KMessageBox::NoRole); |
| 61 |
|
| 62 |
w.exec(); |
| 63 |
}); |
| 64 |
|
| 65 |
layout->addWidget(btn_1); |
| 66 |
layout->addWidget(btn_2); |
| 67 |
|
| 68 |
this->setLayout(layout); |
| 69 |
this->setFixedSize(300, 200); |
| 70 |
} |
| 71 |
|
| 72 |
Widget::~Widget() |
| 73 |
{ |
| 74 |
} |