Messagelib

sendlatertimedatewidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "sendlatertimedatewidget_p.h"
8 
9 #include <KDateComboBox>
10 #include <KLocalizedString>
11 #include <KTimeComboBox>
12 #include <QLineEdit>
13 
14 #include <QHBoxLayout>
15 
16 using namespace MessageComposer;
17 
18 SendLaterTimeDateWidget::SendLaterTimeDateWidget(QWidget *parent)
19  : QWidget(parent)
20  , mTimeComboBox(new KTimeComboBox(this))
21  , mDateComboBox(new KDateComboBox(this))
22 {
23  auto lay = new QHBoxLayout(this);
24  lay->setContentsMargins({});
25 
27  t = t.addSecs(60 * 60);
28  connect(mTimeComboBox, &KTimeComboBox::timeChanged, this, &SendLaterTimeDateWidget::slotDateTimeChanged);
29  mTimeComboBox->setObjectName(QStringLiteral("time_sendlater"));
30 
33  mDateComboBox->setObjectName(QStringLiteral("date_sendlater"));
34  connect(mDateComboBox->lineEdit(), &QLineEdit::textChanged, this, &SendLaterTimeDateWidget::dateChanged);
35  mDateComboBox->setMinimumDate(t.date(), i18n("You cannot select a date prior to the current date."));
36  connect(mDateComboBox, &KDateComboBox::dateChanged, this, &SendLaterTimeDateWidget::slotDateTimeChanged);
37 
38  lay->addWidget(mDateComboBox);
39  lay->addWidget(mTimeComboBox);
40 }
41 
42 SendLaterTimeDateWidget::~SendLaterTimeDateWidget() = default;
43 
44 void SendLaterTimeDateWidget::slotDateTimeChanged()
45 {
46  QDateTime dt;
47  dt.setDate(mDateComboBox->date());
48  dt.setTime(mTimeComboBox->time());
49  Q_EMIT dateTimeChanged(dt);
50 }
51 
52 QDateTime SendLaterTimeDateWidget::dateTime() const
53 {
54  QDateTime dt;
55  dt.setDate(mDateComboBox->date());
56  dt.setTime(mTimeComboBox->time());
57  return dt;
58 }
59 
60 void SendLaterTimeDateWidget::setDateTime(const QDateTime &datetime)
61 {
62  mTimeComboBox->setTime(datetime.time());
63  mDateComboBox->setDate(datetime.date());
64 }
void setTime(const QTime &time)
QTime time() const const
void textChanged(const QString &text)
void dateChanged(const QDate &date)
void setDate(const QDate &date)
void timeChanged(const QTime &time)
QString i18n(const char *text, const TYPE &arg...)
QDateTime currentDateTime()
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
QDate date() const const
QDateTime addSecs(qint64 s) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:43 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.