| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "testtaskbarwindow.h" |
| 6 |
|
| 7 |
#include <QIntValidator> |
| 8 |
#include <QApplication> |
| 9 |
#include <QCloseEvent> |
| 10 |
|
| 11 |
TestTaskbarWindow::TestTaskbarWindow(QWidget *parent) |
| 12 |
: QWidget(parent) |
| 13 |
{ |
| 14 |
QHBoxLayout *pHBoxLayout_1 = new QHBoxLayout; |
| 15 |
m_pProgressBox = new QCheckBox("progress"); |
| 16 |
m_pProgress = new QSlider(Qt::Horizontal); |
| 17 |
m_pProgress->setRange(0, 100); |
| 18 |
m_pProgress->setMinimumWidth(300); |
| 19 |
pHBoxLayout_1->addWidget(m_pProgressBox); |
| 20 |
pHBoxLayout_1->addWidget(m_pProgress); |
| 21 |
|
| 22 |
QHBoxLayout *pHBoxLayout_2 = new QHBoxLayout; |
| 23 |
m_pCounterBox = new QCheckBox("counter"); |
| 24 |
m_pNumEdit = new QLineEdit; |
| 25 |
m_pNumEdit->setMinimumWidth(300); |
| 26 |
m_pNumEdit->setValidator(new QIntValidator); |
| 27 |
pHBoxLayout_2->addWidget(m_pCounterBox); |
| 28 |
pHBoxLayout_2->addWidget(m_pNumEdit); |
| 29 |
|
| 30 |
m_pUrgencyBox= new QCheckBox("test urgency"); |
| 31 |
QHBoxLayout *pHBoxLayout_3 = new QHBoxLayout; |
| 32 |
pHBoxLayout_3->addWidget(m_pUrgencyBox); |
| 33 |
|
| 34 |
QVBoxLayout *pVBoxLayout = new QVBoxLayout; |
| 35 |
setLayout(pVBoxLayout); |
| 36 |
pVBoxLayout->addStretch(); |
| 37 |
pVBoxLayout->addLayout(pHBoxLayout_1); |
| 38 |
pVBoxLayout->addSpacing(30); |
| 39 |
pVBoxLayout->addLayout(pHBoxLayout_2); |
| 40 |
pVBoxLayout->addSpacing(50); |
| 41 |
pVBoxLayout->addLayout(pHBoxLayout_3); |
| 42 |
pVBoxLayout->addStretch(); |
| 43 |
|
| 44 |
m_pTaskbarControl = new DTaskbarControl(this); |
| 45 |
m_pTaskbarControl->setProgress(false, 0); |
| 46 |
m_pTaskbarControl->setCounter(false, 0); |
| 47 |
|
| 48 |
connect(m_pProgressBox, &QCheckBox::stateChanged, this, [this] (int state) { |
| 49 |
m_pTaskbarControl->setProgress(state == Qt::Checked, static_cast<double>(m_pProgress->value()) / 100); |
| 50 |
}); |
| 51 |
|
| 52 |
connect(m_pCounterBox, &QCheckBox::stateChanged, this, [this] (int state) { |
| 53 |
m_pTaskbarControl->setCounterVisible(state == Qt::Checked); |
| 54 |
}); |
| 55 |
|
| 56 |
connect(m_pProgress, &QSlider::valueChanged, this, [this] (int value) { |
| 57 |
m_pTaskbarControl->setProgress(m_pProgressBox->checkState() == Qt::Checked, static_cast<double>(value) / 100); |
| 58 |
}); |
| 59 |
|
| 60 |
connect(m_pNumEdit, &QLineEdit::textChanged, [this] (const QString &str) { |
| 61 |
m_pTaskbarControl->setCounter(m_pCounterBox->checkState() == Qt::Checked, str.toInt()); |
| 62 |
}); |
| 63 |
|
| 64 |
connect(m_pUrgencyBox, &QCheckBox::stateChanged, this, [this] (int state) { |
| 65 |
m_pTaskbarControl->setUrgency(state == Qt::Checked); |
| 66 |
}); |
| 67 |
} |
| 68 |
|
| 69 |
TestTaskbarWindow::~TestTaskbarWindow() |
| 70 |
{ |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
void TestTaskbarWindow::closeEvent(QCloseEvent *event) |
| 75 |
{ |
| 76 |
Q_EMIT closeWindow(); |
| 77 |
event->accept(); |
| 78 |
} |