| 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 <QBoxLayout> |
| 25 |
|
| 26 |
Widget::Widget(QWidget *parent) |
| 27 |
: KWidget(parent) |
| 28 |
{ |
| 29 |
QVBoxLayout *mainLayout = new QVBoxLayout; |
| 30 |
|
| 31 |
KToolButton *toolbtn1 = new KToolButton(this); // 构建一个toolbutton,默认类型为Flat |
| 32 |
toolbtn1->setEnabled(false); // 设置是否可用 |
| 33 |
KToolButton *toolbtn2 = new KToolButton(this); |
| 34 |
// 默认图标为"open-menu-symbolic" |
| 35 |
// toolbtn2->setIcon(QIcon::fromTheme("camera-switch-symbolic")); //设置toolbutton的图标 |
| 36 |
KToolButton *toolbtn3 = new KToolButton(this); |
| 37 |
toolbtn3->setLoading(true); // 设置正在加载状态,仅不带箭头的toolbuttuon支持该状态 |
| 38 |
QHBoxLayout *hLayout = new QHBoxLayout(); |
| 39 |
hLayout->addWidget(toolbtn1); |
| 40 |
hLayout->addWidget(toolbtn2); |
| 41 |
hLayout->addWidget(toolbtn3); |
| 42 |
mainLayout->addLayout(hLayout); |
| 43 |
|
| 44 |
hLayout = new QHBoxLayout(); |
| 45 |
KToolButton *toolbtn4 = new KToolButton(this); |
| 46 |
toolbtn4->setEnabled(false); |
| 47 |
toolbtn4->setArrow(true); // 设置是否显示向下箭头,默认不显示 |
| 48 |
KToolButton *toolbtn5 = new KToolButton(this); |
| 49 |
toolbtn5->setArrow(true); |
| 50 |
KToolButton *toolbtn6 = new KToolButton(this); |
| 51 |
toolbtn6->setLoading(true); |
| 52 |
toolbtn6->setArrow(true); |
| 53 |
hLayout->addWidget(toolbtn4); |
| 54 |
hLayout->addWidget(toolbtn5); |
| 55 |
hLayout->addWidget(toolbtn6); |
| 56 |
mainLayout->addLayout(hLayout); |
| 57 |
|
| 58 |
hLayout = new QHBoxLayout(); |
| 59 |
KToolButton *toolbtn7 = new KToolButton(this); |
| 60 |
toolbtn7->setEnabled(false); |
| 61 |
toolbtn7->setType(KToolButtonType::SemiFlat); // 设置toolbutton类型为SemiFlat |
| 62 |
KToolButton *toolbtn8 = new KToolButton(this); |
| 63 |
toolbtn8->setType(KToolButtonType::SemiFlat); |
| 64 |
KToolButton *toolbtn9 = new KToolButton(this); |
| 65 |
toolbtn9->setLoading(true); |
| 66 |
toolbtn9->setType(KToolButtonType::SemiFlat); |
| 67 |
hLayout->addWidget(toolbtn7); |
| 68 |
hLayout->addWidget(toolbtn8); |
| 69 |
hLayout->addWidget(toolbtn9); |
| 70 |
mainLayout->addLayout(hLayout); |
| 71 |
|
| 72 |
hLayout = new QHBoxLayout(); |
| 73 |
KToolButton *toolbtn10 = new KToolButton(this); |
| 74 |
toolbtn10->setEnabled(false); |
| 75 |
toolbtn10->setType(KToolButtonType::Background); // 设置toolbutton类型为Background |
| 76 |
KToolButton *toolbtn11 = new KToolButton(this); |
| 77 |
toolbtn11->setType(KToolButtonType::Background); |
| 78 |
KToolButton *toolbtn12 = new KToolButton(this); |
| 79 |
toolbtn12->setLoading(true); |
| 80 |
toolbtn12->setType(KToolButtonType::Background); |
| 81 |
hLayout->addWidget(toolbtn10); |
| 82 |
hLayout->addWidget(toolbtn11); |
| 83 |
hLayout->addWidget(toolbtn12); |
| 84 |
mainLayout->addLayout(hLayout); |
| 85 |
|
| 86 |
baseBar()->setLayout(mainLayout); |
| 87 |
} |
| 88 |
|
| 89 |
Widget::~Widget() |
| 90 |
{ |
| 91 |
} |