/*
    This file is part of kenvy24 KDE multimedia utility
    Copyright (c) 2007  Valentin RUSU kenvy24@rusu.info

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License or (at
    your option) version 3 or, at the discretion of KDE e.V. (which shall
    act as a proxy as in section 14 of the GPLv3), any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _VOLUMEIMPL_H_INCLUDED_
#define _VOLUMEIMPL_H_INCLUDED_

#include <qobject.h>
#include <ui_volume.h>
#include "envystructs.h"

class KConfigGroup;

class VolumeImpl : public QWidget, Ui_Volume {
  Q_OBJECT

    private:
        int index;
        LeftRight channel;
        bool inSlotFlag;
        bool inEventFlag;

        struct ExclusiveFlag {
            bool& slotFlag;
            ExclusiveFlag( bool& flag ) : slotFlag( flag) { flag = true; }
            ~ExclusiveFlag() { slotFlag = false; }
        };

    public:

        VolumeImpl( QWidget* parent, const char * name =0 );

        void setCaption( const QString& );
        void setIndexAndChannel( int index, LeftRight channel ) { this->index = index; this->channel = channel; }
        /**
         * Pan value goes from PAN_LEFT to PAN_RIGHT
         */
        void setPan( int );
        void setVolume( int );
        void setMute( bool );
        void setAdjustment( MixerAdjustement );

        void saveToConfig( KConfigGroup& );
        void loadFromConfig( KConfigGroup& );

    public slots:
        void mixerUpdateMuteSwitch( int, LeftRight, bool );
        void mixerUpdatePlaybackVolume( int index, LeftRight channel, MixerAdjustement );
        void muteToggled(bool);
        void volumeChanged(int);
        void panChanged(int);

    signals:
        /**
         * m is true if MUTE button is ON
         */
        void muted( int index, LeftRight channel, bool m );
        void adjusted( int index, LeftRight channel, int volume, int pan );
};


#endif // _VOLUMEIMPL_H_INCLUDED_
