38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
|
#include "lodateselector.h"
|
||
|
#include <QDialog>
|
||
|
#include <QVBoxLayout>
|
||
|
#include <QCalendarWidget>
|
||
|
|
||
|
LoDateSelector::LoDateSelector(QWidget *parent) : QPushButton(parent) {
|
||
|
setStyleSheet(R"rrr(
|
||
|
LoDateSelector {
|
||
|
background-color: transparent;
|
||
|
image: url(:/res/ProgramManager/EditProgram/DateSelect_enable.png);
|
||
|
padding: 0;
|
||
|
max-width: 32px;
|
||
|
max-height: 32px;
|
||
|
}
|
||
|
LoDateSelector:!enabled{
|
||
|
image: url(:/res/ProgramManager/EditProgram/DateSelect_e.png);
|
||
|
}
|
||
|
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();
|
||
|
});
|
||
|
}
|