/***************************************************************************
                           kdetvsettingswidgetimpl.cpp
                           ------------------------------
    begin                : Sun Oct 19 2003
    copyright            : (C) 2003 by Dirk Ziegelmeier
    email                : dziegel@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kdebug.h>
#include <klocale.h>
#include <kwindowsystem.h>
#include <qcombobox.h>
#include <qcheckbox.h>

#include "mainwindow.h"
#include "kdetvsettingswidgetimpl.h"


KdetvSettingsWidgetImpl::KdetvSettingsWidgetImpl(QWidget* parent, MainWindow* mw)
    : QWidget(parent),
      SettingsDialogPage(i18n("User Interface"),
                         i18n("Configure GUI Options"),
                         "kcmkwm"),
      _mw(mw)
{
    setupUi(this);
}

KdetvSettingsWidgetImpl::~KdetvSettingsWidgetImpl()
{
}

void KdetvSettingsWidgetImpl::setup()
{
    _disableScreenSaver->setChecked(_mw->_disableSaver);
    _saverCombo->setCurrentItem(_mw->_screenSaverMode);
    _stayOnTop->setChecked(_mw->_staysOnTop);
    _sticky->setChecked(_mw->_sticky);
    _noStickyFull->setChecked(_mw->_noStickyFull);

    _hideNormal->setChecked(_mw->_hideTBNormal);
    _hideFull->setChecked(_mw->_hideTBFull);
    _hideTV->setChecked(_mw->_hideTBTV);

    _enableNormal->setChecked(_mw->_viewNormalEnabled);
    _enableFull->setChecked(_mw->_viewFullEnabled);
    _enableTV->setChecked(_mw->_viewTVEnabled);
    //    _enableDesktop->setChecked(_mw->_viewDesktopEnabled);
}

void KdetvSettingsWidgetImpl::defaults()
{
    _disableScreenSaver->setChecked(true);
    _saverCombo->setCurrentItem(1);
    _stayOnTop->setChecked(false);
    _sticky->setChecked(false);
    _noStickyFull->setChecked(true);

    _hideNormal->setChecked(false);
    _hideFull->setChecked(false);
    _hideTV->setChecked(false);

    _enableNormal->setChecked(true);
    _enableFull->setChecked(true);
    _enableTV->setChecked(true);
    //    _enableDesktop->setChecked(true);
}

void KdetvSettingsWidgetImpl::apply()
{
    _mw->_disableSaver    = _disableScreenSaver->isChecked();
    _mw->_screenSaverMode = _saverCombo->currentItem();
    _mw->checkScreenSaver();

    _mw->_noStickyFull = _noStickyFull->isChecked();
    _mw->_staysOnTop   = _stayOnTop->isChecked();
    _mw->_sticky       = _sticky->isChecked();
    _mw->_wasSticky    = _mw->_sticky;

    _mw->_hideTBNormal = _hideNormal->isChecked();
    _mw->_hideTBFull   = _hideFull->isChecked();
    _mw->_hideTBTV     = _hideTV->isChecked();
    _mw->updateTaskbarButton();

    _mw->_viewNormalEnabled = _enableNormal->isChecked();
    _mw->_viewFullEnabled   = _enableFull->isChecked();
    _mw->_viewTVEnabled     = _enableTV->isChecked();
    //    _mw->_viewDesktopEnabled = _enableDesktop->isChecked();

    // Ensure at least one is selected
    if (!_mw->_viewNormalEnabled &&
        !_mw->_viewFullEnabled &&
        !_mw->_viewTVEnabled) {
        //	!_mw->_viewDesktopEnabled) {
        _mw->_viewNormalEnabled = true;
    }

}

#include "kdetvsettingswidgetimpl.moc"
