Part of batch commit to enable true tasktray resize support for Trinity applications

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1124757 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent 4d3847fc45
commit 5ccb957341

@ -62,12 +62,12 @@ KIconConfig::KIconConfig(QWidget *parent, const char *name)
QPushButton *push;
push = addPreviewIcon(0, i18n("Default"), this, g_lay);
connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup0()));
push = addPreviewIcon(1, i18n("Active"), this, g_lay);
connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup1()));
push = addPreviewIcon(2, i18n("Disabled"), this, g_lay);
connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup2()));
mPreviewButton1 = addPreviewIcon(0, i18n("Default"), this, g_lay);
connect(mPreviewButton1, SIGNAL(clicked()), SLOT(slotEffectSetup0()));
mPreviewButton2 = addPreviewIcon(1, i18n("Active"), this, g_lay);
connect(mPreviewButton2, SIGNAL(clicked()), SLOT(slotEffectSetup1()));
mPreviewButton3 = addPreviewIcon(2, i18n("Disabled"), this, g_lay);
connect(mPreviewButton3, SIGNAL(clicked()), SLOT(slotEffectSetup2()));
m_pTab1 = new QWidget(this, "General Tab");
top->addWidget(m_pTab1, 0, 1);
@ -278,12 +278,6 @@ void KIconConfig::read()
mpKickerConfig->setGroup("General");
mQuickLaunchSize = mpKickerConfig->readNumEntry("panelIconWidth", KIcon::SizeLarge);
// FIXME
// Due to issues with the system tray handling code, mpSysTraySizeBox should be be disabled
// This should be fixed ASAP
// Specifically, kicker does not automatically reconfigure the system tray icon sizes on its configure() DCOP call
//mpSysTraySizeBox->setEnabled(false);
}
void KIconConfig::apply()
@ -455,6 +449,11 @@ void KIconConfig::save()
}
}
// Reload kicker/systray configuration files; we have no way of knowing if any other parameters changed
// from initial read to this write request
mpSystrayConfig->reparseConfiguration();
mpKickerConfig->reparseConfiguration();
mpSystrayConfig->setGroup("System Tray");
mpSystrayConfig->writeEntry("systrayIconWidth", mSysTraySize);
mpKickerConfig->setGroup("General");
@ -478,6 +477,9 @@ void KIconConfig::save()
// Signal kicker to reload icon configuration
kapp->dcopClient()->send("kicker", "kicker", "configure()", QByteArray());
// Signal system tray to reload icon configuration
kapp->dcopClient()->send("kicker", "SystemTrayApplet", "iconSizeChanged()", QByteArray());
}
void KIconConfig::defaults()
@ -496,27 +498,35 @@ void KIconConfig::slotUsage(int index)
mpSizeBox->setEnabled(true);
mpDPCheck->setEnabled(false);
mpAnimatedCheck->setEnabled(false);
mPreviewButton1->setEnabled(false);
mPreviewButton2->setEnabled(false);
mPreviewButton3->setEnabled(false);
}
else if (mpUsageList->text(index) == i18n("System Tray Icons")) {
// FIXME
// Due to issues with the system tray handling code, mpSysTraySizeBox should be be disabled
// This should be fixed ASAP
// Specifically, kicker does not automatically reconfigure the system tray icon sizes on its configure() DCOP call
mpSizeBox->setEnabled(false);
mpSizeBox->setEnabled(true);
mpDPCheck->setEnabled(false);
mpAnimatedCheck->setEnabled(false);
mPreviewButton1->setEnabled(false);
mPreviewButton2->setEnabled(false);
mPreviewButton3->setEnabled(false);
}
else if ( mUsage == KIcon::Panel || mUsage == KIcon::LastGroup )
{
mpSizeBox->setEnabled(false);
mpDPCheck->setEnabled(false);
mpAnimatedCheck->setEnabled( mUsage == KIcon::Panel );
mPreviewButton1->setEnabled(true);
mPreviewButton2->setEnabled(true);
mPreviewButton3->setEnabled(true);
}
else
{
mpSizeBox->setEnabled(true);
mpDPCheck->setEnabled(true);
mpAnimatedCheck->setEnabled( mUsage == KIcon::Desktop );
mPreviewButton1->setEnabled(true);
mPreviewButton2->setEnabled(true);
mPreviewButton3->setEnabled(true);
}
apply();

@ -115,6 +115,7 @@ private:
QCheckBox *mpDPCheck, *wordWrapCB, *underlineCB, *mpAnimatedCheck;
QTabWidget *m_pTabWidget;
QWidget *m_pTab1;
QPushButton *mPreviewButton1, *mPreviewButton2, *mPreviewButton3;
};
class KIconEffectSetupDialog: public KDialogBase
@ -152,6 +153,6 @@ private:
QImage mExample;
QGroupBox *mpEffectGroup;
QLabel *mpPreview, *mpEffectLabel, *mpEffectColor, *mpEffectColor2;
};
};
#endif

@ -51,7 +51,7 @@ KRandRSystemTray::KRandRSystemTray(QWidget* parent, const char *name)
, m_popupUp(false)
, m_help(new KHelpMenu(this, KGlobal::instance()->aboutData(), false, actionCollection()))
{
setPixmap(KSystemTray::loadIcon("randr"));
setPixmap(KSystemTray::loadSizedIcon("randr", width()));
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
connect(this, SIGNAL(quitSelected()), kapp, SLOT(quit()));
QToolTip::add(this, i18n("Screen resize & rotate"));
@ -88,6 +88,19 @@ KRandRSystemTray::KRandRSystemTray(QWidget* parent, const char *name)
}
}
void KRandRSystemTray::resizeEvent ( QResizeEvent * )
{
// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
QPixmap origpixmap;
QPixmap scaledpixmap;
QImage newIcon;
origpixmap = KSystemTray::loadSizedIcon( "randr", width() );
newIcon = origpixmap;
newIcon = newIcon.smoothScale(width(), height());
scaledpixmap = newIcon;
setPixmap(scaledpixmap);
}
void KRandRSystemTray::mousePressEvent(QMouseEvent* e)
{
// Popup the context menu with left-click

@ -59,6 +59,7 @@ protected slots:
protected:
void mousePressEvent( QMouseEvent *e );
void resizeEvent ( QResizeEvent * );
private:
void populateMenu(KPopupMenu* menu);

@ -5,6 +5,7 @@ Copyright (c) 2000-2001 Matthias Ettrich <ettrich@kde.org>
2001 Carsten Pfeiffer <pfeiffer@kde.org>
2001 Martijn Klingens <mklingens@yahoo.com>
2004 Aaron J. Seigo <aseigo@kde.org>
2010 Timothy Pearson <kb9vqf@pearsoncomputing.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -79,6 +80,7 @@ SystemTrayApplet::SystemTrayApplet(const QString& configFile, Type type, int act
m_iconSize(24),
m_layout(0)
{
DCOPObject::setObjId("SystemTrayApplet");
loadSettings();
setBackgroundOrigin(AncestorOrigin);
@ -399,6 +401,24 @@ void SystemTrayApplet::orientationChange( Orientation /*orientation*/ )
refreshExpandButton();
}
void SystemTrayApplet::iconSizeChanged() {
loadSettings();
updateVisibleWins();
layoutTray();
TrayEmbedList::iterator emb = m_shownWins.begin();
while (emb != m_shownWins.end()) {
(*emb)->setFixedSize(m_iconSize, m_iconSize);
++emb;
}
emb = m_hiddenWins.begin();
while (emb != m_hiddenWins.end()) {
(*emb)->setFixedSize(m_iconSize, m_iconSize);
++emb;
}
}
void SystemTrayApplet::loadSettings()
{
// set our defaults
@ -406,6 +426,7 @@ void SystemTrayApplet::loadSettings()
m_showFrame = false;
KConfig *conf = config();
conf->reparseConfiguration();
conf->setGroup("General");
if (conf->readBoolEntry("ShowPanelFrame", false))
@ -517,7 +538,6 @@ void SystemTrayApplet::updateVisibleWins()
{
for (; emb != lastEmb; ++emb)
{
//(*emb)->hide();
(*emb)->setBackground();
(*emb)->show();
}
@ -841,7 +861,7 @@ void SystemTrayApplet::layoutTray()
// to avoid nbrOfLines=0 we ensure heightWidth >= iconWidth!
heightWidth = heightWidth < iconWidth ? iconWidth : heightWidth;
nbrOfLines = heightWidth / iconWidth;
if (showExpandButton)
{
m_layout->addMultiCellWidget(m_expandButton,
@ -858,9 +878,8 @@ void SystemTrayApplet::layoutTray()
emb != lastEmb; ++emb)
{
line = i % nbrOfLines;
//(*emb)->hide();
(*emb)->show();
m_layout->addWidget(*emb, col, line,
m_layout->addWidget((*emb), col, line,
Qt::AlignHCenter | Qt::AlignVCenter);
if ((line + 1) == nbrOfLines)
@ -877,9 +896,8 @@ void SystemTrayApplet::layoutTray()
emb != lastEmb; ++emb)
{
line = i % nbrOfLines;
//(*emb)->hide();
(*emb)->show();
m_layout->addWidget(*emb, col, line,
m_layout->addWidget((*emb), col, line,
Qt::AlignHCenter | Qt::AlignVCenter);
if ((line + 1) == nbrOfLines)
@ -912,9 +930,8 @@ void SystemTrayApplet::layoutTray()
for (TrayEmbedList::const_iterator emb = m_hiddenWins.begin(); emb != lastEmb; ++emb)
{
line = i % nbrOfLines;
//(*emb)->hide();
(*emb)->show();
m_layout->addWidget(*emb, line, col,
m_layout->addWidget((*emb), line, col,
Qt::AlignHCenter | Qt::AlignVCenter);
if ((line + 1) == nbrOfLines)
@ -931,9 +948,8 @@ void SystemTrayApplet::layoutTray()
emb != lastEmb; ++emb)
{
line = i % nbrOfLines;
//(*emb)->hide();
(*emb)->show();
m_layout->addWidget(*emb, line, col,
m_layout->addWidget((*emb), line, col,
Qt::AlignHCenter | Qt::AlignVCenter);
if ((line + 1) == nbrOfLines)
@ -973,6 +989,8 @@ TrayEmbed::TrayEmbed( bool kdeTray, QWidget* parent )
: QXEmbed( parent ), kde_tray( kdeTray )
{
hide();
m_scaledWidget = new QWidget(parent);
m_scaledWidget->hide();
}
void TrayEmbed::getIconSize(int defaultIconSize)

@ -63,6 +63,7 @@ public:
k_dcop:
void loadSettings();
void iconSizeChanged();
protected:
void resizeEvent(QResizeEvent*);
@ -121,6 +122,7 @@ public:
void getIconSize(int defaultIconSize);
private:
bool kde_tray;
QWidget *m_scaledWidget;
};
#endif

@ -196,7 +196,9 @@ KlipperWidget::KlipperWidget( QWidget *parent, KConfig* config )
connect( poll, SIGNAL( clipboardChanged( bool ) ),
this, SLOT( newClipData( bool ) ) );
m_pixmap = KSystemTray::loadIcon( "klipper" );
m_pixmap = KSystemTray::loadSizedIcon( "klipper", width() );
m_iconOrigWidth = width();
m_iconOrigHeight = height();
adjustSize();
globalKeys = new KGlobalAccel(this);
@ -290,11 +292,19 @@ void KlipperWidget::mousePressEvent(QMouseEvent *e)
void KlipperWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
int x = (width() - m_pixmap.width()) / 2;
int y = (height() - m_pixmap.height()) / 2;
// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
if ((m_iconOrigWidth != width()) || (m_iconOrigHeight != height())) {
QImage newIcon;
m_pixmap = KSystemTray::loadSizedIcon( "klipper", width() );
newIcon = m_pixmap;
newIcon = newIcon.smoothScale(width(), height());
m_scaledpixmap = newIcon;
}
int x = (width() - m_scaledpixmap.width()) / 2;
int y = (height() - m_scaledpixmap.height()) / 2;
if ( x < 0 ) x = 0;
if ( y < 0 ) y = 0;
p.drawPixmap(x , y, m_pixmap);
p.drawPixmap(x, y, m_scaledpixmap);
p.end();
}

@ -173,6 +173,9 @@ private:
KAction* configureAction;
KAction* quitAction;
QPixmap m_pixmap;
QPixmap m_scaledpixmap;
int m_iconOrigWidth;
int m_iconOrigHeight;
bool bPopupAtMouse :1;
bool bKeepContents :1;
bool bURLGrabber :1;

Loading…
Cancel
Save