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

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1124758 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent ba91edcc60
commit 13c0220b02

@ -112,7 +112,7 @@ KMixDockWidget::createMasterVolWidget()
// In case that there is no mixer installed, there will be no newVolumeLevels() signal's // In case that there is no mixer installed, there will be no newVolumeLevels() signal's
// Thus we prepare the dock areas manually // Thus we prepare the dock areas manually
setVolumeTip(); setVolumeTip();
updatePixmap(); updatePixmap(false);
return; return;
} }
// create devices // create devices
@ -126,7 +126,7 @@ KMixDockWidget::createMasterVolWidget()
The call to m_mixer->readSetFromHWforceUpdate() is most likely superfluous, even if we don't use QSocketNotifier (e.g. in backends OSS, Solaris, ...) The call to m_mixer->readSetFromHWforceUpdate() is most likely superfluous, even if we don't use QSocketNotifier (e.g. in backends OSS, Solaris, ...)
*/ */
setVolumeTip(); setVolumeTip();
updatePixmap(); updatePixmap(false);
/* We are setting up 3 connections: /* We are setting up 3 connections:
* Refreshig the _dockAreaPopup (not anymore neccesary, because ViewBase already does it) * Refreshig the _dockAreaPopup (not anymore neccesary, because ViewBase already does it)
* Refreshing the Tooltip * Refreshing the Tooltip
@ -135,9 +135,13 @@ KMixDockWidget::createMasterVolWidget()
*/ */
// connect( m_mixer, SIGNAL(newVolumeLevels()), _dockAreaPopup, SLOT(refreshVolumeLevels()) ); // connect( m_mixer, SIGNAL(newVolumeLevels()), _dockAreaPopup, SLOT(refreshVolumeLevels()) );
connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(setVolumeTip() ) ); connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(setVolumeTip() ) );
connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(updatePixmap() ) ); connect( m_mixer, SIGNAL(newVolumeLevels()), this, SLOT(slotUpdatePixmap() ) );
} }
void KMixDockWidget::slotUpdatePixmap()
{
updatePixmap(false);
}
void KMixDockWidget::selectMaster() void KMixDockWidget::selectMaster()
{ {
@ -208,7 +212,7 @@ KMixDockWidget::setVolumeTip()
} }
void void
KMixDockWidget::updatePixmap() KMixDockWidget::updatePixmap(bool force)
{ {
MixDevice *md = 0; MixDevice *md = 0;
if ( _dockAreaPopup != 0 ) { if ( _dockAreaPopup != 0 ) {
@ -228,17 +232,29 @@ KMixDockWidget::updatePixmap()
newPixmapType = 'd'; newPixmapType = 'd';
} }
if (( newPixmapType != _oldPixmapType ) || (force == true)) {
if ( newPixmapType != _oldPixmapType ) {
// Pixmap must be changed => do so // Pixmap must be changed => do so
// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
QPixmap origpixmap;
QPixmap scaledpixmap;
QImage newIcon;
switch ( newPixmapType ) { switch ( newPixmapType ) {
case 'e': setPixmap( loadIcon( "kmixdocked_error" ) ); break; case 'e': origpixmap = loadSizedIcon( "kmixdocked_error", width() ); break;
case 'm': setPixmap( loadIcon( "kmixdocked_mute" ) ); break; case 'm': origpixmap = loadSizedIcon( "kmixdocked_mute" , width() ); break;
case 'd': setPixmap( loadIcon( "kmixdocked" ) ); break; case 'd': origpixmap = loadSizedIcon( "kmixdocked" , width() ); break;
} }
newIcon = origpixmap;
newIcon = newIcon.smoothScale(width(), height());
scaledpixmap = newIcon;
setPixmap(scaledpixmap);
_oldPixmapType = newPixmapType;
} }
}
_oldPixmapType = newPixmapType; void KMixDockWidget::resizeEvent ( QResizeEvent * )
{
updatePixmap(true);
} }
void void
@ -260,7 +276,7 @@ KMixDockWidget::mousePressEvent(QMouseEvent *me)
// Case 2: User wants to show volume popup // Case 2: User wants to show volume popup
if ( _dockAreaPopup->justHidden() ) if ( _dockAreaPopup->justHidden() )
return; return;
if ( _dockAreaPopup->isVisible() ) if ( _dockAreaPopup->isVisible() )
{ {
_dockAreaPopup->hide(); _dockAreaPopup->hide();

@ -56,7 +56,8 @@ class KMixDockWidget : public KSystemTray {
public slots: public slots:
void setVolumeTip(); void setVolumeTip();
void updatePixmap(); void updatePixmap(bool force);
void slotUpdatePixmap();
protected: protected:
void createMasterVolWidget(); void createMasterVolWidget();
@ -66,6 +67,7 @@ class KMixDockWidget : public KSystemTray {
void wheelEvent(QWheelEvent *); void wheelEvent(QWheelEvent *);
void contextMenuAboutToShow( KPopupMenu* menu ); void contextMenuAboutToShow( KPopupMenu* menu );
void toggleMinimizeRestore(); void toggleMinimizeRestore();
void resizeEvent ( QResizeEvent * );
private: private:
bool _playBeepOnVolumeChange; bool _playBeepOnVolumeChange;

Loading…
Cancel
Save