2022-08-25 18:37:24 +08:00
|
|
|
#include "lodateselector.h"
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QCalendarWidget>
|
|
|
|
|
|
|
|
LoDateSelector::LoDateSelector(QWidget *parent) : QPushButton(parent) {
|
|
|
|
setStyleSheet(R"rrr(
|
|
|
|
LoDateSelector {
|
|
|
|
background-color: transparent;
|
2023-04-18 14:14:46 +08:00
|
|
|
image: url(:/res/program/DateSelect_enable.png);
|
2022-08-25 18:37:24 +08:00
|
|
|
padding: 0;
|
|
|
|
max-width: 32px;
|
|
|
|
max-height: 32px;
|
|
|
|
}
|
|
|
|
LoDateSelector:!enabled{
|
2023-04-18 14:14:46 +08:00
|
|
|
image: url(:/res/program/DateSelect_e.png);
|
2022-08-25 18:37:24 +08:00
|
|
|
}
|
|
|
|
LoDateSelector:pressed {
|
|
|
|
margin-top: 1px;
|
|
|
|
margin-left: 1px;
|
|
|
|
margin-bottom: -1px;
|
|
|
|
margin-right: -1px;
|
|
|
|
}
|
|
|
|
)rrr");
|
|
|
|
connect(this, &QPushButton::clicked, this, [this] {
|
|
|
|
QDialog dlg(this);
|
|
|
|
dlg.setWindowTitle(tr("Date selector"));
|
|
|
|
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
|
auto vBox = new QVBoxLayout(&dlg);
|
|
|
|
vBox->setContentsMargins(0,0,0,0);
|
|
|
|
auto calendar = new QCalendarWidget();
|
|
|
|
connect(calendar, &QCalendarWidget::clicked, &dlg, &QDialog::accept);
|
|
|
|
connect(calendar, &QCalendarWidget::clicked, this, &LoDateSelector::sDateSelected);
|
|
|
|
vBox->addWidget(calendar);
|
|
|
|
dlg.exec();
|
|
|
|
});
|
|
|
|
}
|