mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
libs: drop the automatic update feature of Plasma::Calendar
only Plasma::ClockApplet uses the Plasma::Calendar class and it disables automatic updates (because the date comes from data engine). also due to7819796c55
the date is updated once a second which was updating the currently selected date thus interfering with date selection every second so the check that was removed ind7d63a156b
had to be brought back Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c17805df29
commit
de64f8e332
3 changed files with 9 additions and 34 deletions
|
@ -70,8 +70,7 @@ class CalendarPrivate
|
|||
: q(calendar),
|
||||
calendarWidget(nullptr),
|
||||
layout(nullptr),
|
||||
currentDate(QDate::currentDate()),
|
||||
automaticUpdates(true)
|
||||
currentDate(QDate::currentDate())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,6 @@ class CalendarPrivate
|
|||
Plasma::CalendarWidget *calendarWidget;
|
||||
QGraphicsLinearLayout *layout;
|
||||
QDate currentDate;
|
||||
bool automaticUpdates;
|
||||
};
|
||||
|
||||
Calendar::Calendar(const QDate &date, QGraphicsWidget *parent)
|
||||
|
@ -122,30 +120,12 @@ void CalendarPrivate::init(const QDate &initialDate)
|
|||
updateSize();
|
||||
}
|
||||
|
||||
void Calendar::showEvent(QShowEvent * event)
|
||||
{
|
||||
if (d->automaticUpdates) {
|
||||
d->currentDate = QDate::currentDate();
|
||||
}
|
||||
QGraphicsWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void Calendar::focusInEvent(QFocusEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
d->calendarWidget->setFocus();
|
||||
}
|
||||
|
||||
void Calendar::setAutomaticUpdateEnabled(bool automatic)
|
||||
{
|
||||
d->automaticUpdates = automatic;
|
||||
}
|
||||
|
||||
bool Calendar::isAutomaticUpdateEnabled() const
|
||||
{
|
||||
return d->automaticUpdates;
|
||||
}
|
||||
|
||||
void Calendar::setDate(const QDate &toDate)
|
||||
{
|
||||
// New date must be valid one
|
||||
|
@ -156,10 +136,9 @@ void Calendar::setDate(const QDate &toDate)
|
|||
return;
|
||||
}
|
||||
|
||||
// NOTE: this method is called by Plasma::ClockApplet::popupEvent() on show so updating as if
|
||||
// show event ocurred
|
||||
if (d->automaticUpdates) {
|
||||
d->currentDate = QDate::currentDate();
|
||||
// If new date is the same as old date don't actually need to do anything
|
||||
if (toDate == d->currentDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->calendarWidget->setSelectedDate(toDate);
|
||||
|
|
|
@ -57,7 +57,6 @@ Q_SIGNALS:
|
|||
void dateChanged(const QDate &newDate);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent * event);
|
||||
void focusInEvent(QFocusEvent* event);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
|
@ -124,7 +124,6 @@ public:
|
|||
if (q->config().readEntry("ShowCalendarPopup", true)) {
|
||||
if (!calendarWidget) {
|
||||
calendarWidget = new Plasma::Calendar();
|
||||
calendarWidget->setAutomaticUpdateEnabled(false);
|
||||
calendarWidget->setFlag(QGraphicsItem::ItemIsFocusable);
|
||||
}
|
||||
} else {
|
||||
|
@ -257,12 +256,7 @@ void ClockApplet::updateClockApplet()
|
|||
void ClockApplet::updateClockApplet(const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
if (d->calendarWidget) {
|
||||
bool updateSelectedDate = (d->calendarWidget->currentDate() == d->calendarWidget->date());
|
||||
d->calendarWidget->setCurrentDate(data["Date"].toDate());
|
||||
|
||||
if (updateSelectedDate){
|
||||
d->calendarWidget->setDate(d->calendarWidget->currentDate());
|
||||
}
|
||||
d->calendarWidget->setDate(data["Date"].toDate());
|
||||
}
|
||||
|
||||
d->lastTimeSeen = data["Time"].toTime();
|
||||
|
@ -506,7 +500,10 @@ void ClockApplet::popupEvent(bool show)
|
|||
{
|
||||
if (show && d->calendarWidget) {
|
||||
Plasma::DataEngine::Data data = dataEngine("time")->query(currentTimezone());
|
||||
d->calendarWidget->setDate(data["Date"].toDate());
|
||||
const QDate date = data["Date"].toDate();
|
||||
d->calendarWidget->setCurrentDate(date.addDays(-1));
|
||||
d->calendarWidget->setDate(date);
|
||||
d->calendarWidget->setCurrentDate(date);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue