Refactor DialogManager.2
This commit is contained in:
51
src/dialogs/DateSelectDialog.cpp
Normal file
51
src/dialogs/DateSelectDialog.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by Krad on 2022/3/24.
|
||||
//
|
||||
|
||||
#include "DateSelectDialog.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDate>
|
||||
#include "components/DateSlidePickerBox.h"
|
||||
DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
|
||||
this->setFixedSize(460, 380);
|
||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||
box = new DateSlidePickerBox(mFormWidget);
|
||||
box->setObjectName("slidePicker");
|
||||
box->setSelectedValue("1990-01-01");
|
||||
lbl_error = new QLabel(this);
|
||||
lbl_error->setObjectName("warn");
|
||||
lbl_error->setVisible(false);
|
||||
lbl_error->setText(tr("Date exceeded!"));
|
||||
layout->addWidget(box);
|
||||
layout->addWidget(lbl_error);
|
||||
}
|
||||
|
||||
DateSelectDialog::~DateSelectDialog() {
|
||||
|
||||
}
|
||||
|
||||
QString DateSelectDialog::getSelectedValue() {
|
||||
|
||||
return box->getSelectedValue();
|
||||
}
|
||||
|
||||
void DateSelectDialog::setSelectedValue(const QString &val) {
|
||||
box->setSelectedValue(val);
|
||||
box->resizeLabel();
|
||||
}
|
||||
|
||||
bool DateSelectDialog::updateReferenceData() {
|
||||
if (onlyBackward){
|
||||
QDate v = QDate::fromString(box->getSelectedValue(),"yyyy-MM-dd");
|
||||
bool flag = QDate::currentDate()>=v;
|
||||
this->setFixedHeight(flag? 380:410);
|
||||
lbl_error->setVisible(!flag);
|
||||
return flag;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DateSelectDialog::showEvent(QShowEvent * event) {
|
||||
QDialog::showEvent(event);
|
||||
}
|
||||
Reference in New Issue
Block a user