Messagelib

sendlatertimedatewidget.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
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
16using namespace MessageComposer;
17
18SendLaterTimeDateWidget::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(QLatin1StringView("time_sendlater"));
30
33 mDateComboBox->setObjectName(QLatin1StringView("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
42SendLaterTimeDateWidget::~SendLaterTimeDateWidget() = default;
43
44void SendLaterTimeDateWidget::slotDateTimeChanged()
45{
46 QDateTime dt;
47 dt.setDate(mDateComboBox->date());
48 dt.setTime(mTimeComboBox->time());
49 Q_EMIT dateTimeChanged(dt);
50}
51
52QDateTime SendLaterTimeDateWidget::dateTime() const
53{
54 QDateTime dt;
55 dt.setDate(mDateComboBox->date());
56 dt.setTime(mTimeComboBox->time());
57 return dt;
58}
59
60void SendLaterTimeDateWidget::setDateTime(const QDateTime &datetime)
61{
62 mTimeComboBox->setTime(datetime.time());
63 mDateComboBox->setDate(datetime.date());
64}
65
66#include "moc_sendlatertimedatewidget_p.cpp"
void dateChanged(const QDate &date)
void timeChanged(const QTime &time)
QString i18n(const char *text, const TYPE &arg...)
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
QDateTime addSecs(qint64 s) const const
QDateTime currentDateTime()
QDate date() const const
void setDate(QDate date)
void setTime(QTime time)
QTime time() const const
void textChanged(const QString &text)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.