Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Custom font for clock plugin applied correctly #438

Merged
merged 2 commits into from

2 participants

Kuzma Shapran Alec Moskvin
Kuzma Shapran
Collaborator

When panel clock plugin is used with custom fonts, they aren't applied correclty on panel start due to conflict and race condition with qss theme. When settings are changed fonts are set correctly.

Using delayed initialisation this patch fixes the problem.

Alec Moskvin

This doesn't look right... You're creating a copy of the timeLabel's font, and then you're immediately replacing with a new font from settings.

Also, why do you have the empty brace blocks?

Collaborator

font is not replaced. Its parts are actually used as default values when reading from settings. Settings can be empty, in this case font is not changed.

Empty brace blocks are here just to reuse variable font and use constructor initialisation instead of assignment, but since Qt uses COW it's not really necessary. I can rewrite it if you want.

Collaborator
Collaborator

Ok, I'll improve this part ASAP.

Collaborator
Collaborator
Alec Moskvin
Collaborator

This doesn't fix it when theme is changed in the Appearance Configuration.

You should be able to use RazorSettings::globalSettings() to detect this.

Kuzma Shapran
Collaborator

Now it reacts on theme change.

Alec Moskvin amoskvin merged commit 74dfe02 into from
Alec Moskvin
Collaborator
Kuzma Shapran
Collaborator

90% of the time

this is weird. As you can see, the plugin has special ClockLabel fakeThemedLabel object which detects font changes caused by theme change and then settings reapplied to real QLabels. Could you please debug it and find out where exactly it works not as expected, since it works fine all the time for me.

Expected sequence on theme change is:
1. Theme change causes 'ClockLabel::event' to be called with (event->type() == QEvent::FontChange)
2. it emits fontChanged() signal which in its turn raises RazorClock::fontChanged() slot
3. new font merged with custom font and applied to QLabels

Thank you!

Alec Moskvin
Collaborator
Kuzma Shapran
Collaborator
Kuzma Shapran kuzmas referenced this pull request
Merged

Panel clock fixes #445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 13, 2012
  1. Kuzma Shapran
Commits on Oct 14, 2012
  1. Kuzma Shapran
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 13 deletions.
  1. +9 −13 razorqt-panel/plugin-clock/razorclock.cpp
22 razorqt-panel/plugin-clock/razorclock.cpp
View
@@ -28,9 +28,6 @@
* END_COMMON_COPYRIGHT_HEADER */
-#ifndef RAZORCLOCK_CPP
-#define RAZORCLOCK_CPP
-
#include "razorclock.h"
#include "calendar_utils.h"
@@ -65,7 +62,7 @@ RazorClock::RazorClock(const RazorPanelPluginStartInfo* startInfo, QWidget* pare
setObjectName("Clock");
clockFormat = "hh:mm";
- fakeThemedLabel = new ClockLabel(this);
+ fakeThemedLabel = new ClockLabel(content);
fakeThemedLabel->setVisible(false);
timeLabel = new QLabel(this);
@@ -92,12 +89,13 @@ RazorClock::RazorClock(const RazorPanelPluginStartInfo* startInfo, QWidget* pare
content->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
this->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
- settingsChanged();
connect(fakeThemedLabel, SIGNAL(fontChanged()), this, SLOT(fontChanged()));
clocktimer = new QTimer(this);
connect (clocktimer, SIGNAL(timeout()), this, SLOT(updateTime()));
clocktimer->start(1000);
+
+ QTimer::singleShot(0, this, SLOT(settingsChanged()));
}
/**
@@ -169,22 +167,22 @@ void RazorClock::fontChanged()
{
{
QFont font(timeLabel->font());
- timeLabel->setFont(QFont(
+ font = QFont(
settings().value("timeFont/family", font.family()).toString(),
settings().value("timeFont/pointSize", font.pointSize()).toInt(),
settings().value("timeFont/weight", font.weight()).toInt(),
- settings().value("timeFont/italic", font.italic()).toBool() ));
- font = timeLabel->font();
+ settings().value("timeFont/italic", font.italic()).toBool() );
+ timeLabel->setFont(font);
}
{
QFont font(dateLabel->font());
- dateLabel->setFont(QFont(
+ font = QFont(
settings().value("dateFont/family", font.family()).toString(),
settings().value("dateFont/pointSize", font.pointSize()).toInt(),
settings().value("dateFont/weight", font.weight()).toInt(),
- settings().value("dateFont/italic", font.italic()).toBool() ));
- font = dateLabel->font();
+ settings().value("dateFont/italic", font.italic()).toBool() );
+ dateLabel->setFont(font);
}
}
@@ -382,5 +380,3 @@ bool ClockLabel::event(QEvent *event)
return QLabel::event(event);
}
-
-#endif
Something went wrong with that request. Please try again.