| 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 "kbreadcrumb.h" |
| 25 |
#include "ktag.h" |
| 26 |
#include <QHBoxLayout> |
| 27 |
#include <QLineEdit> |
| 28 |
#include <QPushButton> |
| 29 |
#include <QTabBar> |
| 30 |
|
| 31 |
Widget::Widget(QWidget *parent) |
| 32 |
: KWidget(parent) |
| 33 |
{ |
| 34 |
QVBoxLayout *vLayout = new QVBoxLayout; |
| 35 |
KTag *tag1 = new KTag(this); |
| 36 |
tag1->setText("tag1"); // 设置tag文本 |
| 37 |
// tag1->setTagStyle(TagStyle::HighlightTag); |
| 38 |
KTag *tag2 = new KTag(this); |
| 39 |
tag2->setText("tag2"); |
| 40 |
tag2->setTagStyle(TagStyle::BoderTag); // 设置tag的style,有HighlightTag,BoderTag,BaseBoderTag,GrayTag四种 |
| 41 |
KTag *tag3 = new KTag(this); |
| 42 |
tag3->setText("tag3"); |
| 43 |
tag3->setTagStyle(TagStyle::BaseBoderTag); |
| 44 |
KTag *tag4 = new KTag(this); |
| 45 |
tag4->setText("tag4"); |
| 46 |
tag4->setTagStyle(TagStyle::GrayTag); |
| 47 |
QHBoxLayout *hLayout = new QHBoxLayout; |
| 48 |
hLayout->addWidget(tag1); |
| 49 |
hLayout->addWidget(tag2); |
| 50 |
hLayout->addWidget(tag3); |
| 51 |
hLayout->addWidget(tag4); |
| 52 |
vLayout->addLayout(hLayout); |
| 53 |
hLayout = new QHBoxLayout; |
| 54 |
KTag *tag5 = new KTag(this); |
| 55 |
tag5->setText("tag5"); |
| 56 |
tag5->setClosable(true); // 设置tag是否可以关闭 |
| 57 |
KTag *tag6 = new KTag(this); |
| 58 |
tag6->setClosable(true); |
| 59 |
tag6->setText("tag6"); |
| 60 |
tag6->setTagStyle(TagStyle::BoderTag); |
| 61 |
KTag *tag7 = new KTag(this); |
| 62 |
tag7->setClosable(true); |
| 63 |
tag7->setText("tag7"); |
| 64 |
tag7->setTagStyle(TagStyle::BaseBoderTag); |
| 65 |
KTag *tag8 = new KTag(this); |
| 66 |
tag8->setClosable(true); |
| 67 |
tag8->setText("tag8"); |
| 68 |
tag8->setTagStyle(TagStyle::GrayTag); |
| 69 |
hLayout->addWidget(tag5); |
| 70 |
hLayout->addWidget(tag6); |
| 71 |
hLayout->addWidget(tag7); |
| 72 |
hLayout->addWidget(tag8); |
| 73 |
vLayout->addLayout(hLayout); |
| 74 |
baseBar()->setLayout(vLayout); |
| 75 |
sideBar()->hide(); |
| 76 |
} |
| 77 |
|
| 78 |
Widget::~Widget() |
| 79 |
{ |
| 80 |
} |