From 84fc233313c9ec1fdaf9d3afcfb2a88df19dff44 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 23 Jul 2023 05:52:55 +0300 Subject: [PATCH] generic: port to the new KCalendarWidget class Signed-off-by: Ivailo Monev --- kcontrol/dateandtime/dateandtime.ui | 8 ++++---- kcontrol/dateandtime/dtime.cpp | 6 ++++-- kdialog/widgets.cpp | 7 ++++--- kfind/kdatecombo.cpp | 24 +++++++++++++----------- kfind/kdatecombo.h | 10 +++++----- libs/plasmaclock/clockapplet.cpp | 1 - 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/kcontrol/dateandtime/dateandtime.ui b/kcontrol/dateandtime/dateandtime.ui index 181e1745..f5ea6296 100644 --- a/kcontrol/dateandtime/dateandtime.ui +++ b/kcontrol/dateandtime/dateandtime.ui @@ -78,7 +78,7 @@ - + Here you can change the system date's day of the month, month and year. @@ -191,9 +191,9 @@
kseparator.h
- KDatePicker - QFrame -
kdatepicker.h
+ KCalendarWidget + QCalendarWidget +
kcalendarwidget.h
diff --git a/kcontrol/dateandtime/dtime.cpp b/kcontrol/dateandtime/dtime.cpp index ee6bfd48..afb8d8d8 100644 --- a/kcontrol/dateandtime/dtime.cpp +++ b/kcontrol/dateandtime/dtime.cpp @@ -106,7 +106,9 @@ Dtime::Dtime(QWidget * parent) timeEdit->setWhatsThis( wtstr ); connect( timeEdit, SIGNAL(timeChanged(QTime)), SLOT(set_time()) ); - connect( cal, SIGNAL(dateChanged(QDate)), SLOT(changeDate(QDate))); + cal->setContentsMargins(2, 2, 2, 2); + connect( cal, SIGNAL(activated(QDate)), SLOT(changeDate(QDate))); + connect( cal, SIGNAL(clicked(QDate)), SLOT(changeDate(QDate))); connect( &internalTimer, SIGNAL(timeout()), SLOT(timeout()) ); @@ -193,7 +195,7 @@ oceania.pool.ntp.org")).split(',', QString::SkipEmptyParts)); // Reset to the current date and time time = QTime::currentTime(); date = QDate::currentDate(); - cal->setDate(date); + cal->setSelectedDate(date); // start internal timer internalTimer.start( 1000 ); diff --git a/kdialog/widgets.cpp b/kdialog/widgets.cpp index 39e0faf5..1b4b3a62 100644 --- a/kdialog/widgets.cpp +++ b/kdialog/widgets.cpp @@ -20,7 +20,6 @@ // Own #include "widgets.h" -#include // Qt #include @@ -40,6 +39,7 @@ #include #include #include +#include // Local #include "klistboxdialog.h" @@ -356,14 +356,15 @@ bool Widgets::calendar( QWidget *parent, const QString &title, const QString &te QLabel label (vbox); label.setText (text); - KDatePicker dateWidget( vbox ); + KCalendarWidget dateWidget( vbox ); + dateWidget.setContentsMargins(2, 2, 2, 2); dateWidget.setFocus(); handleXGeometry(&dlg); const bool retcode = (dlg.exec() == QDialog::Accepted); if (retcode) - result = dateWidget.date(); + result = dateWidget.selectedDate(); return retcode; } diff --git a/kfind/kdatecombo.cpp b/kfind/kdatecombo.cpp index 609f9d20..68095040 100644 --- a/kfind/kdatecombo.cpp +++ b/kfind/kdatecombo.cpp @@ -20,15 +20,15 @@ #include "moc_kdatecombo.cpp" -#include +#include //Added by qt3to4: #include -#include +#include +#include #include #include -#include -#include +#include #include KDateCombo::KDateCombo(QWidget *parent) : KComboBox(parent) @@ -49,16 +49,18 @@ KDateCombo::KDateCombo(const QDate & date, QWidget *parent) : KComboBox(parent) void KDateCombo::initObject(const QDate & date) { setValidator(0); - popupFrame = new KPopupFrame(this); + popupFrame = new QMenu(this); popupFrame->installEventFilter(this); - datePicker = new KDatePicker(date, popupFrame); + datePicker = new KCalendarWidget(date, popupFrame); datePicker->setMinimumSize(datePicker->sizeHint()); datePicker->installEventFilter(this); - popupFrame->setMainWidget(datePicker); + QWidgetAction* popupAction = new QWidgetAction(popupFrame); + popupAction->setDefaultWidget(datePicker); + popupFrame->addAction(popupAction); setDate(date); - connect(datePicker, SIGNAL(dateSelected(QDate)), this, SLOT(dateEnteredEvent(QDate))); - connect(datePicker, SIGNAL(dateEntered(QDate)), this, SLOT(dateEnteredEvent(QDate))); + connect(datePicker, SIGNAL(activated(QDate)), this, SLOT(dateEnteredEvent(QDate))); + connect(datePicker, SIGNAL(clicked(QDate)), this, SLOT(dateEnteredEvent(QDate))); } KDateCombo::~KDateCombo() @@ -98,7 +100,7 @@ void KDateCombo::dateEnteredEvent(const QDate &newDate) { QDate tempDate = newDate; if (!tempDate.isValid()) - tempDate = datePicker->date(); + tempDate = datePicker->selectedDate(); popupFrame->hide(); setDate(tempDate); } @@ -111,7 +113,7 @@ void KDateCombo::mousePressEvent (QMouseEvent * e) { QDate tempDate; getDate(& tempDate); - datePicker->setDate(tempDate); + datePicker->setSelectedDate(tempDate); popupFrame->popup(mapToGlobal(QPoint(0, height()))); } } diff --git a/kfind/kdatecombo.h b/kfind/kdatecombo.h index 0051ea48..2be28a0e 100644 --- a/kfind/kdatecombo.h +++ b/kfind/kdatecombo.h @@ -20,7 +20,8 @@ #define KDATECOMBO_H #include -#include +#include +#include #include @@ -28,8 +29,7 @@ *@author Beppe Grimaldi */ -class KDatePicker; -class KPopupFrame; +class KCalendarWidget; class KDateCombo : public KComboBox { Q_OBJECT @@ -43,8 +43,8 @@ public: bool setDate(const QDate & newDate); private: - KPopupFrame * popupFrame; - KDatePicker * datePicker; + QMenu * popupFrame; + KCalendarWidget * datePicker; void initObject(const QDate & date); diff --git a/libs/plasmaclock/clockapplet.cpp b/libs/plasmaclock/clockapplet.cpp index 5823e928..0f00c42e 100644 --- a/libs/plasmaclock/clockapplet.cpp +++ b/libs/plasmaclock/clockapplet.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include