Browse files

Custom font for clock plugin applied correctly

  • Loading branch information...
1 parent b51ae4d commit 3d46e7ad5ad00c96ede60a320e22eb9624d9cbcc @kuzmas committed Oct 13, 2012
Showing with 8 additions and 12 deletions.
  1. +8 −12 razorqt-panel/plugin-clock/razorclock.cpp
View
20 razorqt-panel/plugin-clock/razorclock.cpp
@@ -28,9 +28,6 @@
* END_COMMON_COPYRIGHT_HEADER */
-#ifndef RAZORCLOCK_CPP
-#define RAZORCLOCK_CPP
-
#include "razorclock.h"
#include "calendar_utils.h"
@@ -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);
}
@amoskvin
amoskvin added a line comment Oct 13, 2012

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?

@kuzmas
Owner
kuzmas added a line comment Oct 13, 2012

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.

@amoskvin
amoskvin added a line comment Oct 15, 2012
@kuzmas
Owner
kuzmas added a line comment Oct 15, 2012

Ok, I'll improve this part ASAP.

@amoskvin
amoskvin added a line comment Oct 15, 2012
@kuzmas
Owner
kuzmas added a line comment Oct 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
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

0 comments on commit 3d46e7a

Please sign in to comment.