You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konversation/konversation/src/irccolorchooser.cpp

84 lines
2.2 KiB

/*
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.
*/
/*
dialog used to add irc colors to your messages
begin: Wed 9 July 2003
copyright: (C) 2003 by Peter Simonsson
email: psn@linux.se
*/
#include "irccolorchooser.h"
#include "irccolorchooserui.h"
#include "config/preferences.h"
#include <tqlabel.h>
#include <tqpixmap.h>
#include <tdelocale.h>
#include <kcombobox.h>
IRCColorChooser::IRCColorChooser(TQWidget* parent, const char* name)
: KDialogBase(parent, name, true, i18n("IRC Color Chooser"), Ok|Cancel, Ok)
{
m_view = new IRCColorChooserUI(this);
setMainWidget(m_view);
initColors(m_view->m_fgColorCBox);
initColors(m_view->m_bgColorCBox);
m_view->m_bgColorCBox->insertItem(i18n("None"), 0);
connect(m_view->m_fgColorCBox, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updatePreview()));
connect(m_view->m_bgColorCBox, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updatePreview()));
m_view->m_fgColorCBox->setCurrentItem(1);
m_view->m_bgColorCBox->setCurrentItem(0);
updatePreview();
}
TQString IRCColorChooser::color()
{
TQString s;
s = "%C" + TQString::number(m_view->m_fgColorCBox->currentItem());
if(m_view->m_bgColorCBox->currentItem() > 0)
{
s += ',' + TQString::number(m_view->m_bgColorCBox->currentItem() - 1);
}
return s;
}
void IRCColorChooser::updatePreview()
{
TQColor bgc;
if(m_view->m_bgColorCBox->currentItem() > 0)
{
bgc = Preferences::ircColorCode(m_view->m_bgColorCBox->currentItem() - 1);
}
else
{
bgc = Preferences::color(Preferences::TextViewBackground);
}
m_view->m_previewLbl->setBackgroundColor(bgc);
m_view->m_previewLbl->setPaletteForegroundColor(Preferences::ircColorCode(m_view->m_fgColorCBox->currentItem()));
}
void IRCColorChooser::initColors(KComboBox* combo)
{
TQPixmap pix(width(), combo->fontMetrics().height() + 4);
for (int i =0; i < 15; i++)
{
pix.fill(Preferences::ircColorCode(i));
combo->insertItem(pix, i);
}
}
#include "irccolorchooser.moc"