| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2024, KylinSoft Co., Ltd. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 3 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this library. If not, see <https://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* Authors: Zhenyu Wang <[email protected]> |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "widget.h" |
| 23 |
#include "kdragwidget.h" |
| 24 |
#include "kiconbar.h" |
| 25 |
#include "ktoolbutton.h" |
| 26 |
#include <QComboBox> |
| 27 |
#include <QDebug> |
| 28 |
#include <QFileDialog> |
| 29 |
#include <QFont> |
| 30 |
#include <QPaintEvent> |
| 31 |
#include <QPainter> |
| 32 |
#include <QPen> |
| 33 |
#include <QPushButton> |
| 34 |
#include <QStringList> |
| 35 |
#include <QStringListModel> |
| 36 |
#include <QStyleOptionFrame> |
| 37 |
#include <QVBoxLayout> |
| 38 |
|
| 39 |
using namespace kdk; |
| 40 |
Widget::Widget(QWidget *parent) |
| 41 |
: QWidget(parent) |
| 42 |
{ |
| 43 |
QVBoxLayout *mainlayout = new QVBoxLayout(this); |
| 44 |
|
| 45 |
QLabel *label1 = new QLabel(); |
| 46 |
label1->setText("添加过滤文件"); |
| 47 |
KDragWidget *widget1 = new KDragWidget(); |
| 48 |
widget1->iconButton()->setIcon(QIcon::fromTheme("list-add.symbolic")); |
| 49 |
widget1->textLabel()->setText("选择或者拖放文件夹识别路径"); |
| 50 |
QStringList list; |
| 51 |
list << "JPEG Files(*.jpg)" |
| 52 |
<< "PNG Files(*.png)" |
| 53 |
<< "PGM Files(*.pgm)"; |
| 54 |
widget1->setNameFilters(list); |
| 55 |
|
| 56 |
mainlayout->addWidget(label1); |
| 57 |
mainlayout->addWidget(widget1); |
| 58 |
|
| 59 |
QLabel *label2 = new QLabel(); |
| 60 |
label2->setText("添加所有文件"); |
| 61 |
KDragWidget *widget2 = new KDragWidget(); |
| 62 |
widget2->iconButton()->setIcon(QIcon::fromTheme("list-add.symbolic")); |
| 63 |
widget2->textLabel()->setText("选择或者拖放文件夹识别路径"); |
| 64 |
|
| 65 |
mainlayout->addWidget(label2); |
| 66 |
mainlayout->addWidget(widget2); |
| 67 |
|
| 68 |
connect(widget1, &KDragWidget::getPath, [=](QString str) { |
| 69 |
qDebug() << "widget1 " << str; |
| 70 |
}); |
| 71 |
connect(widget2, &KDragWidget::getPath, [=](QString str) { |
| 72 |
qDebug() << "widget2 " << str; |
| 73 |
}); |
| 74 |
|
| 75 |
setMinimumSize(600, 480); |
| 76 |
} |
| 77 |
|
| 78 |
Widget::~Widget() |
| 79 |
{ |
| 80 |
} |