Use desktop icon for Show Desktop entry in TabBox

For the normal TabBox the TabBoxClient's icon method is
adjusted to use the "user-desktop" icon instead of the
window icon.

For the effects a method to set the caption is extended
to also set the icon on the caption frame.

REVIEW: 104444
icc-effect-5.14.5
Martin Gräßlin 2012-03-30 08:12:23 +02:00
parent 68acc0692f
commit c16550f728
5 changed files with 12 additions and 6 deletions

View File

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kglobal.h> #include <kglobal.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <KDE/KIcon>
#include <kwinglutils.h> #include <kwinglutils.h>
@ -579,7 +580,6 @@ void CoverSwitchEffect::slotTabBoxAdded(int mode)
captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height())); captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height()));
// And initial contents // And initial contents
updateCaption(); updateCaption();
captionFrame->setIcon(selected_window->icon());
} }
effects->addRepaintFull(); effects->addRepaintFull();
@ -659,7 +659,6 @@ void CoverSwitchEffect::slotTabBoxUpdated()
selected_window = effects->currentTabBoxWindow(); selected_window = effects->currentTabBoxWindow();
currentWindowList = effects->currentTabBoxWindowList(); currentWindowList = effects->currentTabBoxWindowList();
updateCaption(); updateCaption();
captionFrame->setIcon(selected_window->icon());
} }
} }
effects->addRepaintFull(); effects->addRepaintFull();
@ -1009,8 +1008,11 @@ void CoverSwitchEffect::updateCaption()
if (selected_window->isDesktop()) { if (selected_window->isDesktop()) {
captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows", captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows",
"Show Desktop")); "Show Desktop"));
static QPixmap pix = KIcon("user-desktop").pixmap(captionFrame->iconSize());
captionFrame->setIcon(pix);
} else { } else {
captionFrame->setText(selected_window->caption()); captionFrame->setText(selected_window->caption());
captionFrame->setIcon(selected_window->icon());
} }
} }

View File

@ -69,6 +69,7 @@ private:
/** /**
* Updates the caption of the caption frame. * Updates the caption of the caption frame.
* Taking care of rewording the desktop client. * Taking care of rewording the desktop client.
* As well sets the icon for the caption frame.
**/ **/
void updateCaption(); void updateCaption();

View File

@ -566,7 +566,6 @@ void FlipSwitchEffect::slotTabBoxUpdated()
} }
m_selectedWindow = effects->currentTabBoxWindow(); m_selectedWindow = effects->currentTabBoxWindow();
updateCaption(); updateCaption();
m_captionFrame->setIcon(m_selectedWindow->icon());
} }
} }
effects->addRepaintFull(); effects->addRepaintFull();
@ -664,7 +663,6 @@ void FlipSwitchEffect::setActive(bool activate, FlipSwitchMode mode)
m_captionFrame->setGeometry(frameRect); m_captionFrame->setGeometry(frameRect);
m_captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height())); m_captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height()));
updateCaption(); updateCaption();
m_captionFrame->setIcon(m_selectedWindow->icon());
effects->addRepaintFull(); effects->addRepaintFull();
} else { } else {
// only deactivate if mode is current mode // only deactivate if mode is current mode
@ -888,7 +886,6 @@ void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e)
} }
if (found) { if (found) {
updateCaption(); updateCaption();
m_captionFrame->setIcon(m_selectedWindow->icon());
scheduleAnimation(DirectionForward); scheduleAnimation(DirectionForward);
} }
break; break;
@ -916,7 +913,6 @@ void FlipSwitchEffect::grabbedKeyboardEvent(QKeyEvent* e)
} }
if (found) { if (found) {
updateCaption(); updateCaption();
m_captionFrame->setIcon(m_selectedWindow->icon());
scheduleAnimation(DirectionBackward); scheduleAnimation(DirectionBackward);
} }
break; break;
@ -981,8 +977,11 @@ void FlipSwitchEffect::updateCaption()
if (m_selectedWindow->isDesktop()) { if (m_selectedWindow->isDesktop()) {
m_captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows", m_captionFrame->setText(i18nc("Special entry in alt+tab list for minimizing all windows",
"Show Desktop")); "Show Desktop"));
static QPixmap pix = KIcon("user-desktop").pixmap(m_captionFrame->iconSize());
m_captionFrame->setIcon(pix);
} else { } else {
m_captionFrame->setText(m_selectedWindow->caption()); m_captionFrame->setText(m_selectedWindow->caption());
m_captionFrame->setIcon(m_selectedWindow->icon());
} }
} }

View File

@ -80,6 +80,7 @@ private:
/** /**
* Updates the caption of the caption frame. * Updates the caption of the caption frame.
* Taking care of rewording the desktop client. * Taking care of rewording the desktop client.
* As well sets the icon for the caption frame.
**/ **/
void updateCaption(); void updateCaption();
QQueue< SwitchingDirection> m_scheduledDirections; QQueue< SwitchingDirection> m_scheduledDirections;

View File

@ -308,6 +308,9 @@ QString TabBoxClientImpl::caption() const
QPixmap TabBoxClientImpl::icon(const QSize& size) const QPixmap TabBoxClientImpl::icon(const QSize& size) const
{ {
if (m_client->isDesktop()) {
return KIcon("user-desktop").pixmap(size);
}
return m_client->icon(size); return m_client->icon(size);
} }