Use the largest possible font for the unread display in kmail and akregator if the tray icon size is less than 22 pixels

This resolves Bug 1251
pull/21/head
Timothy Pearson 12 years ago
parent c830701a44
commit 5f8b00b956

@ -123,22 +123,34 @@ TQPixmap TrayIcon::takeScreenshot() const
return shot; // not finalShot?? -fo return shot; // not finalShot?? -fo
} }
void TrayIcon::resizeEvent(TQResizeEvent *)
{
setUnread(m_unread, true);
}
void TrayIcon::slotSetUnread(int unread) void TrayIcon::slotSetUnread(int unread)
{ {
if (unread==m_unread) setUnread(unread, false);
}
void TrayIcon::setUnread(int unread, bool force)
{
if ((unread==m_unread) && (!force))
{
return; return;
}
m_unread=unread; m_unread=unread;
TQToolTip::remove(this); TQToolTip::remove(this);
TQToolTip::add(this, i18n("Akregator - 1 unread article", "Akregator - %n unread articles", unread > 0 ? unread : 0)); TQToolTip::add(this, i18n("Akregator - 1 unread article", "Akregator - %n unread articles", unread > 0 ? unread : 0));
if (unread <= 0) if (unread <= 0)
{ {
setPixmap(m_defaultIcon); setPixmap(m_defaultIcon);
} }
else else
{ {
// from KMSystemTray // from KMSystemTray
int oldW = pixmap()->size().width(); int oldW = pixmap()->size().width();
int oldH = pixmap()->size().height(); int oldH = pixmap()->size().height();
@ -146,6 +158,17 @@ void TrayIcon::slotSetUnread(int unread)
TQString uStr=TQString::number( unread ); TQString uStr=TQString::number( unread );
TQFont f=TDEGlobalSettings::generalFont(); TQFont f=TDEGlobalSettings::generalFont();
f.setBold(true); f.setBold(true);
// increase the size of the font for the number of unread messages if the
// icon size is less than 22 pixels
// see bug 1251
int realIconHeight = height();
if (realIconHeight < 22) {
f.setPointSizeFloat( f.pointSizeFloat() * 2.0 );
}
// decrease the size of the font for the number of unread articles if the
// number doesn't fit into the available space
float pointSize=f.pointSizeFloat(); float pointSize=f.pointSizeFloat();
TQFontMetrics fm(f); TQFontMetrics fm(f);
int w=fm.width(uStr); int w=fm.width(uStr);

@ -35,27 +35,33 @@ namespace Akregator
class TrayIcon : public KSystemTray class TrayIcon : public KSystemTray
{ {
Q_OBJECT Q_OBJECT
public: public:
static TrayIcon* getInstance(); static TrayIcon* getInstance();
static void setInstance(TrayIcon* trayIcon); static void setInstance(TrayIcon* trayIcon);
TrayIcon(TQWidget *parent = 0, const char *name = 0); TrayIcon(TQWidget *parent = 0, const char *name = 0);
~TrayIcon(); ~TrayIcon();
TQPixmap takeScreenshot() const; TQPixmap takeScreenshot() const;
virtual void mousePressEvent(TQMouseEvent *); virtual void mousePressEvent(TQMouseEvent *);
public slots: public slots:
void settingsChanged(); void settingsChanged();
void slotSetUnread(int unread); void slotSetUnread(int unread);
void viewButtonClicked(); void viewButtonClicked();
protected:
void resizeEvent(TQResizeEvent *);
signals: signals:
void showPart(); void showPart();
private: private:
void setUnread(int unread, bool force);
static TrayIcon* m_instance; static TrayIcon* m_instance;
TQPixmap m_defaultIcon; TQPixmap m_defaultIcon;
TQImage m_lightIconImage; TQImage m_lightIconImage;
int m_unread; int m_unread;

@ -133,7 +133,6 @@ void KMSystemTray::buildPopupMenu()
action->plug( mPopupMenu ); action->plug( mPopupMenu );
mPopupMenu->insertSeparator(); mPopupMenu->insertSeparator();
TDEMainWindow *mainWin = ::tqqt_cast<TDEMainWindow*>(kmkernel->getKMMainWidget()->topLevelWidget());
mPopupMenu->insertItem( SmallIcon("exit"), i18n("&Quit"), this, TQT_SLOT(maybeQuit()) ); mPopupMenu->insertItem( SmallIcon("exit"), i18n("&Quit"), this, TQT_SLOT(maybeQuit()) );
} }
@ -180,6 +179,11 @@ int KMSystemTray::mode() const
return mMode; return mMode;
} }
void KMSystemTray::resizeEvent(TQResizeEvent *)
{
updateCount();
}
/** /**
* Update the count of unread messages. If there are unread messages, * Update the count of unread messages. If there are unread messages,
* overlay the count on top of a transparent version of the KMail icon. * overlay the count on top of a transparent version of the KMail icon.
@ -196,6 +200,14 @@ void KMSystemTray::updateCount()
TQFont countFont = TDEGlobalSettings::generalFont(); TQFont countFont = TDEGlobalSettings::generalFont();
countFont.setBold(true); countFont.setBold(true);
// increase the size of the font for the number of unread messages if the
// icon size is less than 22 pixels
// see bug 1251
int realIconHeight = height();
if (realIconHeight < 22) {
countFont.setPointSizeFloat( countFont.pointSizeFloat() * 2.0 );
}
// decrease the size of the font for the number of unread messages if the // decrease the size of the font for the number of unread messages if the
// number doesn't fit into the available space // number doesn't fit into the available space
float countFontSize = countFont.pointSizeFloat(); float countFontSize = countFont.pointSizeFloat();

@ -69,6 +69,7 @@ protected:
void showKMail(); void showKMail();
void buildPopupMenu(); void buildPopupMenu();
void updateCount(); void updateCount();
void resizeEvent(TQResizeEvent *);
TQString prettyName(KMFolder *); TQString prettyName(KMFolder *);

Loading…
Cancel
Save