//
//   File : optw_userlist.cpp
//   Creation date : Sat Aug 11 2001 03:29:52 CEST by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2001 Szymon Stefanek (pragma at kvirc dot net)
//
//   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 opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "optw_userlist.h"

#include <tqlayout.h>

#include "kvi_options.h"
#include "kvi_locale.h"
#include "kvi_userlistview.h"

//#warning "Info tips"

KviUserListLookOptionsWidget::KviUserListLookOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"userlistlook_options_widget")
{
}

KviUserListLookOptionsWidget::~KviUserListLookOptionsWidget()
{
}



//////////////////////////////////////////////////////////////////////////////////////////////////////


KviUserListLookForegroundOptionsWidget::KviUserListLookForegroundOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"userlistlook_foreground_options_widget")
{
	createLayout(2,2);

	addFontSelector(0,0,1,0,__tr2qs_ctx("Font:","options"),KviOption_fontUserListView);
	
	KviTalGroupBox * g = addGroupBox(0,1,1,1,1,TQt::Horizontal,__tr2qs_ctx("Nickname Colors","options"));
	addColorSelector(g,__tr2qs_ctx("Normal:","options"),KviOption_colorUserListViewNormalForeground);
	addColorSelector(g,__tr2qs_ctx("Selected:","options"),KviOption_colorUserListViewSelectionForeground);
	addColorSelector(g,__tr2qs_ctx("Channel owner:","options"),KviOption_colorUserListViewChanOwnerForeground);
	addColorSelector(g,__tr2qs_ctx("Channel admin:","options"),KviOption_colorUserListViewChanAdminForeground);
	addColorSelector(g,__tr2qs_ctx("Op:","options"),KviOption_colorUserListViewOpForeground);
	addColorSelector(g,__tr2qs_ctx("Half-op:","options"),KviOption_colorUserListViewHalfOpForeground);
	addColorSelector(g,__tr2qs_ctx("Voice:","options"),KviOption_colorUserListViewVoiceForeground);
	addColorSelector(g,__tr2qs_ctx("User-op:","options"),KviOption_colorUserListViewUserOpForeground);
	addColorSelector(g,__tr2qs_ctx("Away:","options"),KviOption_colorUserListViewAwayForeground);
	
	KviTalHBox * hb = new KviTalHBox(g);
	hb->setSpacing(4);
	KviBoolSelector * b = addBoolSelector(hb,__tr2qs_ctx("Use different color for own nick:","options"),KviOption_boolUseDifferentColorForOwnNick);
	KviColorSelector * s = addColorSelector(hb,"",KviOption_colorUserListViewOwnForeground,KVI_OPTION_BOOL(KviOption_boolUseDifferentColorForOwnNick));
	connect(b,TQ_SIGNAL(toggled(bool)),s,TQ_SLOT(setEnabled(bool)));

	addRowSpacer(0,3,0,3);
}

KviUserListLookForegroundOptionsWidget::~KviUserListLookForegroundOptionsWidget()
{
}

KviUserListGridOptionsWidget::KviUserListGridOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent)
{
	createLayout(5,1);
	KviBoolSelector* b = addBoolSelector(0,0,0,0,__tr2qs_ctx("Draw nickname grid","options"),KviOption_boolUserListViewDrawGrid);

	KviColorSelector* s = addColorSelector(0,1,0,1,__tr2qs_ctx("Grid color:","options"),KviOption_colorUserListViewGrid,KVI_OPTION_BOOL(KviOption_boolUserListViewDrawGrid));
	connect(b,TQ_SIGNAL(toggled(bool)),s,TQ_SLOT(setEnabled(bool)));

	KviTalHBox* hb = new KviTalHBox(this);
	addWidgetToLayout(hb,0,2,0,2);
	hb->setSpacing(4);

	TQLabel * l = new TQLabel(__tr2qs_ctx("Grid type:","options"),hb);
	l->setEnabled(KVI_OPTION_BOOL(KviOption_boolUserListViewDrawGrid));
	connect(b,TQ_SIGNAL(toggled(bool)),l,TQ_SLOT(setEnabled(bool)));
	m_pGridTypeCombo = new TQComboBox(false,hb);
	m_pGridTypeCombo->insertItem(__tr2qs_ctx("3D Grid","options"));
	m_pGridTypeCombo->insertItem(__tr2qs_ctx("3D Buttons","options"));
	m_pGridTypeCombo->insertItem(__tr2qs_ctx("Plain Grid","options"));
	m_pGridTypeCombo->insertItem(__tr2qs_ctx("Dotted Grid","options"));
	m_pGridTypeCombo->setCurrentItem(KVI_OPTION_UINT(KviOption_uintUserListViewGridType));
	m_pGridTypeCombo->setEnabled(KVI_OPTION_BOOL(KviOption_boolUserListViewDrawGrid));
	connect(b,TQ_SIGNAL(toggled(bool)),m_pGridTypeCombo,TQ_SLOT(setEnabled(bool)));
	addRowSpacer(0,3,0,3);
}

KviUserListGridOptionsWidget::~KviUserListGridOptionsWidget()
{
}

void KviUserListGridOptionsWidget::commit()
{
	KviOptionsWidget::commit();
	KVI_OPTION_UINT(KviOption_uintUserListViewGridType) = m_pGridTypeCombo->currentItem();
	if(KVI_OPTION_UINT(KviOption_uintUserListViewGridType) > KVI_USERLISTVIEW_GRIDTYPE_MAXIMUM)
		KVI_OPTION_UINT(KviOption_uintUserListViewGridType) = KVI_USERLISTVIEW_GRIDTYPE_DEFAULT;
	
}

//////////////////////////////////////////////////////////////////////////////////////////////////////

KviUserListLookBackgroundOptionsWidget::KviUserListLookBackgroundOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"userlistlook_background_options_widget")
{
	createLayout(3,2);

	KviTalGroupBox * g = addGroupBox(0,0,1,0,1,TQt::Horizontal,__tr2qs_ctx("Background Colors","options"));
	addColorSelector(g,__tr2qs_ctx("Normal:","options"),KviOption_colorUserListViewBackground);
	addColorSelector(g,__tr2qs_ctx("Selected:","options"),KviOption_colorUserListViewSelectionBackground);


	addPixmapSelector(0,1,1,1,__tr2qs_ctx("Background image:","options"),KviOption_pixmapUserListViewBackground);

	addLabel(0,2,0,2,__tr2qs_ctx("Horizontal Alignment:","options"));
	m_pHorizontalAlign=new TQComboBox(this);
	addWidgetToLayout(m_pHorizontalAlign,1,2,1,2);
	
	addLabel(0,3,0,3,__tr2qs_ctx("Vertical Alignment:","options"));
	m_pVerticalAlign=new TQComboBox(this);
	addWidgetToLayout(m_pVerticalAlign,1,3,1,3);
	
	m_pHorizontalAlign->insertItem(__tr2qs_ctx("Tile","options"));
	m_pHorizontalAlign->insertItem(__tr2qs_ctx("Left","options"));
	m_pHorizontalAlign->insertItem(__tr2qs_ctx("Right","options"));
	m_pHorizontalAlign->insertItem(__tr2qs_ctx("Center","options"));
	
	m_pVerticalAlign->insertItem(__tr2qs_ctx("Tile","options"));
	m_pVerticalAlign->insertItem(__tr2qs_ctx("Top","options"));
	m_pVerticalAlign->insertItem(__tr2qs_ctx("Bottom","options"));
	m_pVerticalAlign->insertItem(__tr2qs_ctx("Center","options"));
	
	switch( KVI_OPTION_UINT(KviOption_uintUserListPixmapAlign) & TQt::AlignHorizontal_Mask)
	{
		case TQt::AlignLeft:
			m_pHorizontalAlign->setCurrentItem(1);
			break;
		case TQt::AlignRight:
			m_pHorizontalAlign->setCurrentItem(2);
			break;
		case TQt::AlignHCenter:
			m_pHorizontalAlign->setCurrentItem(3);
			break;
		default:
			m_pHorizontalAlign->setCurrentItem(0);
	}
	
	switch( KVI_OPTION_UINT(KviOption_uintUserListPixmapAlign) & TQt::AlignVertical_Mask)
	{
		case TQt::AlignTop:
			m_pVerticalAlign->setCurrentItem(1);
			break;
		case TQt::AlignBottom:
			m_pVerticalAlign->setCurrentItem(2);
			break;
		case TQt::AlignVCenter:
			m_pVerticalAlign->setCurrentItem(3);
			break;
		default:
			m_pVerticalAlign->setCurrentItem(0);
	}



	//layout()->setColStretch(0,1);
	layout()->setRowStretch(1,1);
}

KviUserListLookBackgroundOptionsWidget::~KviUserListLookBackgroundOptionsWidget()
{
}


void KviUserListLookBackgroundOptionsWidget::commit()
{
	KviOptionsWidget::commit();

	int iFlags=0;
	switch(m_pHorizontalAlign->currentItem())
	{
		case 1:
			iFlags|=TQt::AlignLeft;
			break;
		case 2:
			iFlags|=TQt::AlignRight;
			break;
		case 3:
			iFlags|=TQt::AlignHCenter;
			break;
	}
	switch(m_pVerticalAlign->currentItem())
	{
		case 1:
			iFlags|=TQt::AlignTop;
			break;
		case 2:
			iFlags|=TQt::AlignBottom;
			break;
		case 3:
			iFlags|=TQt::AlignVCenter;
			break;
	}
	
	KVI_OPTION_UINT(KviOption_uintUserListPixmapAlign)=iFlags;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////


KviUserListFeaturesOptionsWidget::KviUserListFeaturesOptionsWidget(TQWidget * parent)
: KviOptionsWidget(parent,"userlistfeatures_options_widget")
{
	createLayout(7,1);

	KviBoolSelector *b = addBoolSelector(0,0,0,0,__tr2qs_ctx("Show gender icons","options"),KviOption_boolDrawGenderIcons);
	b = addBoolSelector(0,1,0,1,__tr2qs_ctx("Show user channel icons","options"),KviOption_boolShowUserChannelIcons);
	b = addBoolSelector(0,2,0,2,__tr2qs_ctx("Show user channel activity indicator","options"),KviOption_boolShowUserChannelState);
	b = addBoolSelector(0,3,0,3,__tr2qs_ctx("Hide users label","options"),KviOption_boolDisableUserListLabel);
	b = addBoolSelector(0,4,0,4,__tr2qs_ctx("Enable user tooltips","options"),KviOption_boolShowUserListViewToolTips);
	b = addBoolSelector(0,5,0,5,__tr2qs_ctx("Hide avatars","options"),KviOption_boolDisableAvatars);

	addRowSpacer(0,6,0,6);
}

KviUserListFeaturesOptionsWidget::~KviUserListFeaturesOptionsWidget()
{
}

#include "optw_userlist.moc"
