/***************************************************************************
 * optionsmusictheory.cpp: implementation of OptionsMusicTheory 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 "optionsmusictheory.h"

#include <KLocale>
#include <KMessageBox>

OptionsMusicTheory::OptionsMusicTheory(KConfig* conf, QWidget* parent)
: OptionsPage(conf, parent)
{
	QHBoxLayout* box      = new QHBoxLayout(this);
	QVBoxLayout* chordbox = new QVBoxLayout();
	
	// Dominant 7th name selection group
	//
	mMaj7Group = new QVBoxLayout();
	mMaj7[0] = new QRadioButton("7M");
	mMaj7[1] = new QRadioButton("maj7");
	mMaj7[2] = new QRadioButton("dom7");
	
	for (int i = 0; i < 3; i++)
		mMaj7Group->addWidget(mMaj7[i]);
	
	chordbox->addLayout(mMaj7Group);
	
	// Chord step alterations selection group
	//
	mFlatGroup = new QVBoxLayout();
	mFlat[0] = new QRadioButton(i18n("-/+ symbols"));
	mFlat[1] = new QRadioButton(i18n("b/# symbols"));
	
	for (int i = 0; i < 2; i++)
		mFlatGroup->addWidget(mFlat[i]);
	
	chordbox->addLayout(mFlatGroup);
	
	box->addLayout(chordbox);
	
	// Note naming conventions
	//
	mNoteNameGroup = new QVBoxLayout();
	mNoteName[0] = new QRadioButton(i18n("American, sharps"));
	mNoteName[1] = new QRadioButton(i18n("American, flats"));
	mNoteName[2] = new QRadioButton(i18n("American, mixed"));
	mNoteName[3] = new QRadioButton(i18n("European, sharps"));
	mNoteName[4] = new QRadioButton(i18n("European, flats"));
	mNoteName[5] = new QRadioButton(i18n("European, mixed"));
	mNoteName[6] = new QRadioButton(i18n("Jazz, sharps"));
	mNoteName[7] = new QRadioButton(i18n("Jazz, flats"));
	mNoteName[8] = new QRadioButton(i18n("Jazz, mixed"));
	
	for (int i = 0; i < 9; i++)
		mNoteNameGroup->addWidget(mNoteName[i]);
	
	box->addLayout(mNoteNameGroup);
	
	setLayout(box);
	
	connect(mNoteName[6], SIGNAL(clicked()), this, SLOT(jazzWarning()));
	connect(mNoteName[7], SIGNAL(clicked()), this, SLOT(jazzWarning()));
	connect(mNoteName[8], SIGNAL(clicked()), this, SLOT(jazzWarning()));
	
	// Fill in current config
	//
/*	config->setGroup("General");
	mMaj7Group->setButton(config->readNumEntry("Maj7", 0));
	mFlatGroup->setButton(config->readNumEntry("FlatPlus", 0));
	mNoteNameGroup->setButton(config->readNumEntry("NoteNames", 2));*/
}

void OptionsMusicTheory::defaultBtnClicked()
{
/*	mMaj7Group->setButton(0);
	mFlatGroup->setButton(0);
	mNoteNameGroup->setButton(2);*/
}

void OptionsMusicTheory::applyBtnClicked()
{
/*	config->setGroup("General");
	config->writeEntry("Maj7", mMaj7Group->id(mMaj7Group->selected()));
	config->writeEntry("FlatPlus", mFlatGroup->id(mFlatGroup->selected()));
	config->writeEntry("NoteNames", mNoteNameGroup->id(mNoteNameGroup->selected()));*/
}

bool OptionsMusicTheory::jazzWarning()
{
	return KMessageBox::warningYesNo(this,
		i18n("Jazz note names are very special and should be\n"
			"used only if really know what you do. Usage of jazz\n"
			"note names without a purpose would confuse or mislead\n"
			"anyone reading the music who did not have a knowledge\n"
			"of jazz note naming.\n\n"
			"Are you sure you want to use jazz notes?")) == KMessageBox::Yes;
}

#include "optionsmusictheory.moc"
