/***************************************************************************
 * optionsscore.cpp: implementation of OptionsScore class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 * copyright (C) 2002-2003 the KGuitar development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#include "optionsscore.h"

#include <QFontDialog>

#include <KLocale>

#include "settings.h"

OptionsScore::OptionsScore(KConfig* conf, QWidget* parent)
: OptionsPage(conf, parent),
  mTitleLabel(i18n("Title")),
  mTitleText(),
  mTitleButton("..."),
  mSubTitleLabel(i18n("Subtitle")),
  mSubTitleText(),
  mSubTitleButton("..."),
  mTextAndTabLabel(i18n("Text and tab")),
  mTextAndTabText(),
  mTextAndTabButton("..."),
  mTimeSignatureLabel(i18n("Time signature")),
  mTimeSignatureText(),
  mTimeSignatureButton("..."),
  mScoreLayout(),
  mTitleLayout(),
  mSubTitleLayout(),
  mTextAndTabLayout(),
  mTimeSignatureLayout()
{
	mTitleText.setText("Title");
	mSubTitleText.setText("Subtitle");
	mTextAndTabText.setText("Text and tab");
	mTimeSignatureText.setText("Time signature");
	
	mTitleText.setReadOnly(true);
	mSubTitleText.setReadOnly(true);
	mTextAndTabText.setReadOnly(true);
	mTimeSignatureText.setReadOnly(true);
	
	QFont titleFont(Settings::getInstance()->titleFont());
	QFont subTitleFont(Settings::getInstance()->subTitleFont());
	QFont textAndTabFont(Settings::getInstance()->textAndTabFont());
	QFont timeSignatureFont(Settings::getInstance()->timeSignatureFont());
	
	mTitleText.setFont(titleFont);
	mSubTitleText.setFont(subTitleFont);
	mTextAndTabText.setFont(textAndTabFont);
	mTimeSignatureText.setFont(timeSignatureFont);
	
	mTitleLayout.addWidget(&mTitleLabel);
	mTitleLayout.addWidget(&mTitleText);
	mTitleLayout.addWidget(&mTitleButton);
	
	mSubTitleLayout.addWidget(&mSubTitleLabel);
	mSubTitleLayout.addWidget(&mSubTitleText);
	mSubTitleLayout.addWidget(&mSubTitleButton);
	
	mTextAndTabLayout.addWidget(&mTextAndTabLabel);
	mTextAndTabLayout.addWidget(&mTextAndTabText);
	mTextAndTabLayout.addWidget(&mTextAndTabButton);
	
	mTimeSignatureLayout.addWidget(&mTimeSignatureLabel);
	mTimeSignatureLayout.addWidget(&mTimeSignatureText);
	mTimeSignatureLayout.addWidget(&mTimeSignatureButton);
	
	mScoreLayout.addLayout(&mTitleLayout);
	mScoreLayout.addLayout(&mSubTitleLayout);
	mScoreLayout.addLayout(&mTextAndTabLayout);
	mScoreLayout.addLayout(&mTimeSignatureLayout);
	
	setLayout(&mScoreLayout);
	
	connect(&mTitleButton, SIGNAL(clicked()), SLOT(title()));
	connect(&mSubTitleButton, SIGNAL(clicked()), SLOT(subTitle()));
	connect(&mTextAndTabButton, SIGNAL(clicked()), SLOT(textAndTab()));
	connect(&mTimeSignatureButton, SIGNAL(clicked()), SLOT(timeSignature()));
}

void OptionsScore::defaultBtnClicked()
{
}

void OptionsScore::applyBtnClicked()
{
/*	config->setGroup("Font");
	
	config->writeEntry("titleFont", mTitleText.font().family());
	config->writeEntry("titleWeight", mTitleText.font().weight());
	config->writeEntry("titleItalic", mTitleText.font().italic());
	config->writeEntry("titeSize", mTitleText.font().pointSize());
	
	config->writeEntry("subTitleFont", mSubTitleText.font().family());
	config->writeEntry("subTitleWeight", mSubTitleText.font().weight());
	config->writeEntry("subTitleItalic", mSubTitleText.font().italic());
	config->writeEntry("subTitleSize", mSubTitleText.font().pointSize());
	
	config->writeEntry("textAndTabFont", mTextAndTabText.font().family());
	config->writeEntry("textAndTabWeight", mTextAndTabText.font().weight());
	config->writeEntry("textAndTabItalic", mTextAndTabText.font().italic());
	config->writeEntry("textAndTabSize", mTextAndTabText.font().pointSize());
	
	config->writeEntry("timeSignatureFont", mTimeSignatureText.font().family());
	config->writeEntry("timeSignatureWeight", mTimeSignatureText.font().weight());
	config->writeEntry("timeSignatureItalic", mTimeSignatureText.font().italic());
	config->writeEntry("timeSignatureSize", mTimeSignatureText.font().pointSize());*/
}

void OptionsScore::title()
{
	bool ok;
	
	QFont font = QFontDialog::getFont(&ok);
	
	if (ok) {
		mTitleText.setFont(font);
	}
}

void OptionsScore::subTitle()
{
	bool ok;
	
	QFont font = QFontDialog::getFont(&ok);
	
	if (ok) {
		mSubTitleText.setFont(font);
	}
}

void OptionsScore::textAndTab()
{
	bool ok;
	
	QFont font = QFontDialog::getFont(&ok);
	
	if (ok) {
		mTextAndTabText.setFont(font);
	}
}

void OptionsScore::timeSignature()
{
	bool ok;
	
	QFont font = QFontDialog::getFont(&ok);
	
	if (ok) {
		mTimeSignatureText.setFont(font);
	}
}

#include "optionsscore.moc"
