#pragma once

#include <tqmap.h>
#include <tdemainwindow.h>

#include "../model/audiodevice.h"

class PulseModel;
class KTabWidget;
class TQHBoxLayout;
class TQWidgetStack;
class TQToolButton;
class DevicesPage;
class TQResizeEvent;
class TQLabel;
class TDEGlobalAccel;

class MixerWindow : public TDEMainWindow
{
    TQ_OBJECT

public:
    explicit MixerWindow( PulseModel *model, TQWidget *parent = 0 );
    ~MixerWindow() {}

    struct Tab {
        TQWidget      *scroll;
        TQWidget      *page;
        TQHBoxLayout  *layout;
        int           count;
    };

protected:
    bool queryClose();
    bool eventFilter( TQObject *obj, TQEvent *e );
    void showEvent( TQShowEvent *e );
    void hideEvent( TQHideEvent *e );

signals:
    void settingsChanged();

public slots:
    void bringToFront();
    void showDevices();

private slots:
    void onDeviceAdded( AudioDevice *dev );
    void onDeviceRemoved( AudioDevice *dev );
    void onDefaultOutputChanged( AudioDevice *dev );
    void showAbout();
    void showPreferences();
    void applySettings();
    void quit();
    void onAppAboutToQuit();
    void toggleDevices();
    void slotVolumeUp();
    void slotVolumeDown();
    void slotToggleMute();
    void slotToggleInputMute();
    void slotConfigureGlobalShortcuts();

private:
    Tab &tabForCategory( AudioDevice::Category cat );
    void rebuildView();
    void updateDevicesButton();
    void repositionDevicesBtn();

    PulseModel        *m_model;
    AudioDevice       *m_defaultDevice;
    TDEGlobalAccel    *m_globalAccel;
    KTabWidget        *m_tabs;
    class PreferencesDlg *m_prefsDlg;
    TQWidgetStack  *m_outerStack;
    TQWidgetStack  *m_stack;
    TQWidget       *m_allPage;
    TQWidget       *m_allStrip;
    TQHBoxLayout   *m_allLayout;
    int            m_allCount;
    class TmixTray *m_tray;
    TQToolButton   *m_devicesBtn;
    DevicesPage   *m_devicesPage;
    bool           m_devicesInTabs;
    bool           m_quitting;
    int            m_totalDevCount;
    TQLabel        *m_waitLabel;

    Tab m_output;
    Tab m_input;
    Tab m_playback;
    Tab m_recording;

    TQMap<AudioDevice*, TQWidget*> m_widgets;
};
