#include "BSettings.h"

#include <qcolordialog.h>
#include <qfontdialog.h>
#include <qlabel.h>

void DesktopClockPreferences::setSettings( void * s)
{
	BSettings * settings = (BSettings*)s;
	showWMCheckBox->setChecked(settings->showWM);   
	showAHCheckBox->setChecked(settings->showAH);
	stayOnTopCheckBox->setChecked(settings->stayOnTop);
	showDateCheckBox->setChecked(settings->showDate);
	showTimeCheckBox->setChecked(settings->showTime);
	showSecondsCheckBox->setChecked(settings->showSeconds);
	showGlareCheckBox->setChecked(settings->showGlare);
	dateStringFormat->setText(settings->dateFormat);
	timeStringFormat->setText(settings->timeFormat);
	fontLabel->setText(settings->fontFormat);
	hourColorLabel->setPaletteBackgroundColor(QColor(settings->hourColor));
	secondColorLabel->setPaletteBackgroundColor(QColor(settings->secondColor));
}


void DesktopClockPreferences::getSettings( void* s)
{
	BSettings * settings = (BSettings*)s;
	settings->showWM = showWMCheckBox->isChecked();
	settings->showAH = showAHCheckBox->isChecked();
	settings->stayOnTop = stayOnTopCheckBox->isChecked();
	settings->showDate = showDateCheckBox->isChecked();
	settings->showTime = showTimeCheckBox->isChecked();
	settings->showSeconds = showSecondsCheckBox->isChecked();
	settings->showGlare = showGlareCheckBox->isChecked();
	settings->dateFormat = dateStringFormat->text();
	settings->timeFormat = timeStringFormat->text();
	settings->fontFormat = fontLabel->text();
	settings->hourColor = hourColorLabel->paletteBackgroundColor().name();
	settings->secondColor = secondColorLabel->paletteBackgroundColor().name();
}



void DesktopClockPreferences::selectHourColor()
{
	hourColorLabel->setPaletteBackgroundColor(QColorDialog::getColor(hourColorLabel->paletteBackgroundColor()));
}


void DesktopClockPreferences::selectSecondColor()
{
	secondColorLabel->setPaletteBackgroundColor(QColorDialog::getColor(secondColorLabel->paletteBackgroundColor()));
}


void DesktopClockPreferences::selectFont()
{
    bool ok;
    QFont fnt = QFontDialog::getFont(&ok, font(), this);
    if (ok)
	    fontLabel->setText(fnt.toString());
    else
	    return;
}
