コード例 #1
0
void 
UnicornVolumeSlider::installFilters()
{
    QToolButton* muteButton = findChild<QToolButton*>();
    if( muteButton )
        muteButton->installEventFilter( this );
    
    QSlider* volumeSlider = findChild<QSlider*>();
    if( volumeSlider )
    {
        volumeSlider->setOrientation( Qt::Vertical );
        volumeSlider->installEventFilter( this );
        connect( volumeSlider, SIGNAL(valueChanged(int)), SLOT(onVolumeValueChanged(int)));
    }
    
    setFixedWidth( 30 );
    layout()->setContentsMargins( 0, 10, 0, 10);
    setAutoFillBackground( false );
}
コード例 #2
0
ファイル: kmix.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KMix::createWidgets()
{
  QPixmap miniDevPM;
  QPixmap WMminiIcon = globalKIL->loadIcon("mixer_mini.xpm");

  // keep this enum local. It is really only needed here
  enum {audioIcon, bassIcon, cdIcon, extIcon, microphoneIcon,
	midiIcon, recmonIcon,trebleIcon, unknownIcon, volumeIcon };
#ifdef ALSA /* not sure if this is for ALSA in general or just my SB16 */
  char DefaultMixerIcons[]={
    volumeIcon,		bassIcon,	trebleIcon,	midiIcon,	audioIcon,
    extIcon,	microphoneIcon,	cdIcon, recmonIcon, recmonIcon, unknownIcon
  };
  const unsigned char numDefaultMixerIcons=11;
#else
  char DefaultMixerIcons[]={
    volumeIcon,		bassIcon,	trebleIcon,	midiIcon,	audioIcon,
    unknownIcon,	extIcon,	microphoneIcon,	cdIcon,		recmonIcon,
    audioIcon,		recmonIcon,	recmonIcon,	recmonIcon,	extIcon,
    extIcon,		extIcon
  };
  const unsigned char numDefaultMixerIcons=17;
#endif
  // Init DnD: Set up drop zone and drop handler
  //  dropZone = new KDNDDropZone( this, DndURL );
  //connect( dropZone, SIGNAL( dropAction( KDNDDropZone* )),
  //	   SLOT( onDrop( KDNDDropZone*)));

  // Window title
  setCaption( globalKapp->getCaption() );

  // Create a big container containing every widget of this toplevel
  Container  = new QWidget(this);
  setView(Container);
  // Create Menu
  createMenu();
  setMenu(mainmenu);
  // Create Sliders (Volume indicators)
  MixDevice *MixPtr = mix->First;
  while (MixPtr) {
    // If you encounter a relayout signal from a mixer device, obey blindly ;-)
    connect((QObject*)MixPtr, SIGNAL(relayout()), this, SLOT(placeWidgets()));

    int devnum = MixPtr->device_num;


    // Figure out default icon
    unsigned char iconnum;
    if (devnum < numDefaultMixerIcons)
      iconnum=DefaultMixerIcons[devnum];
    else
      iconnum=unknownIcon;
    switch (iconnum) {
      // TODO: Should be replaceable by user.
    case audioIcon:
      miniDevPM = globalKIL->loadIcon("mix_audio.xpm");	break;
    case bassIcon:
      miniDevPM = globalKIL->loadIcon("mix_bass.xpm");	break;
    case cdIcon:
      miniDevPM = globalKIL->loadIcon("mix_cd.xpm");	break;
    case extIcon:
      miniDevPM = globalKIL->loadIcon("mix_ext.xpm");	break;
    case microphoneIcon:
      miniDevPM = globalKIL->loadIcon("mix_microphone.xpm");break;
    case midiIcon:
      miniDevPM = globalKIL->loadIcon("mix_midi.xpm");	break;
    case recmonIcon:
      miniDevPM = globalKIL->loadIcon("mix_recmon.xpm");	break;
    case trebleIcon:
      miniDevPM = globalKIL->loadIcon("mix_treble.xpm");	break;
    case unknownIcon:
      miniDevPM = globalKIL->loadIcon("mix_unknown.xpm");	break;
    case volumeIcon:
      miniDevPM = globalKIL->loadIcon("mix_volume.xpm");	break;
    default:
      miniDevPM = globalKIL->loadIcon("mix_unknown.xpm");	break;
    }

    QLabel *qb = new QLabel(Container);
    if (! miniDevPM.isNull()) {
      qb->setPixmap(miniDevPM);
      qb->installEventFilter(this);
    }
    else
      cerr << "Pixmap missing.\n";
    MixPtr->picLabel=qb;
    qb->resize(miniDevPM.width(),miniDevPM.height());


    QSlider *VolSB = new QSlider( 0, 100, 10, MixPtr->Left->volume,\
				  QSlider::Vertical, Container, "VolL");

    MixPtr->Left->slider = VolSB;  // Remember the Slider (for the eventFilter)
    connect( VolSB, SIGNAL(valueChanged(int)), MixPtr->Left, SLOT(VolChanged(int)));
    VolSB->installEventFilter(this);
    // Create a second slider, when the current channel is a stereo channel.
    bool BothSliders = (MixPtr->is_stereo  == true );

    if ( BothSliders) {
      QSlider *VolSB2 = new QSlider( 0, 100, 10, MixPtr->Right->volume,\
				     QSlider::Vertical, Container, "VolR");
      MixPtr->Right->slider= VolSB2;  // Remember Slider (for eventFilter)
      connect( VolSB2, SIGNAL(valueChanged(int)), MixPtr->Right, SLOT(VolChanged(int)));
      VolSB2->installEventFilter(this);

    }
    MixPtr=MixPtr->Next;
    // Append MixEntry of current mixer device
  }

  // Create the Left-Right-Slider, add Tooltip and Context menu
  LeftRightSB = new QSlider( -100, 100, 25, 0,\
			     QSlider::Horizontal, Container, "RightLeft");
  connect( LeftRightSB, SIGNAL(valueChanged(int)), \
	   this, SLOT(MbalChangeCB(int)));
  LeftRightSB->installEventFilter(this);
  QToolTip::add( LeftRightSB, "Left/Right balancing" );
}