#pragma once

#include <kdialogbase.h>
#include <tqvaluelist.h>
#include <tqstring.h>
#include <tqstringlist.h>

class TQCheckBox;
class TQComboBox;
class TQLabel;
class TQSpinBox;
class TQWidgetStack;

#ifdef WITH_ALSA
class AlsaModel;
#endif

#ifdef WITH_OSS
class OssModel;
#endif

class PreferencesDlg : public KDialogBase
{
    TQ_OBJECT

public:
    explicit PreferencesDlg( TQWidget *parent = 0 );

#ifdef WITH_ALSA
    PreferencesDlg( AlsaModel *model, TQWidget *parent = 0 );
#endif

#ifdef WITH_OSS
    PreferencesDlg( OssModel *model, TQWidget *parent = 0 );
#endif

    void load();

signals:
    void settingsChanged();

protected slots:
    void slotOk();
    void slotApply();

private slots:
    void onPopupModeChanged( int idx );
    void onBackendComboChanged( int idx );
    void onNoTabsToggled( bool checked );

private:
    void buildGeneralPage();
    void buildBackendPage();
    void save();

    // Maps combo index → backend key ("pulse", "alsa", "oss")
    TQStringList   m_backendIds;

    // General — shared
    TQComboBox    *m_backend;
    TQCheckBox    *m_dockInTray;
    TQComboBox    *m_popupMode;
    TQSpinBox     *m_scrollStep;
    TQCheckBox    *m_confirmQuit;
    TQCheckBox    *m_middleClickMute;
    TQCheckBox    *m_startOnLogin;

    // Backend settings stack
    TQWidgetStack *m_backendStack;

    // Pulse widgets — always built, may be on the inactive stack page
    TQCheckBox *m_popupShowOutput;
    TQCheckBox *m_popupShowMic;
    TQCheckBox *m_popupShowApps;
    TQCheckBox *m_showRecTray;
    TQCheckBox *m_noTabs;
    TQLabel    *m_showTabsLabel;
    TQCheckBox *m_showOutput;
    TQCheckBox *m_showInput;
    TQCheckBox *m_showPlayback;
    TQCheckBox *m_showRecording;

#ifdef WITH_ALSA
    AlsaModel            *m_alsaModel;
    TQComboBox            *m_trayDevice;
    TQValueList<int>       m_trayCardIndices;
    TQValueList<TQString>   m_trayDeviceNames;
#endif

#ifdef WITH_OSS
    OssModel             *m_ossModel;
    TQComboBox            *m_ossTrayDevice;
    TQValueList<int>       m_ossTrayCardIndices;
    TQValueList<TQString>   m_ossTrayDeviceNames;
#endif
};
