1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/* This file is part of the KDE project
* Copyright (C) 2007 Thomas Zander <zander@kde.org>
* Copyright (C) 2009 Pierre Stirnweiss <pstirnweiss@googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "CharacterGeneral.h"
#include "CharacterHighlighting.h"
#include "LanguageTab.h"
#include "FontDecorations.h"
#include "FormattingPreview.h"
#include <KoStyleManager.h>
#include <KoCharacterStyle.h>
#include "kdebug.h"
CharacterGeneral::CharacterGeneral(QWidget *parent)
: QWidget(parent),
m_blockSignals(false),
m_style(0)
{
widget.setupUi(this);
m_characterHighlighting = new CharacterHighlighting(true, this);
connect(m_characterHighlighting, SIGNAL(underlineChanged(KoCharacterStyle::LineType, KoCharacterStyle::LineStyle, QColor)), this, SLOT(slotUnderlineChanged(KoCharacterStyle::LineType, KoCharacterStyle::LineStyle, QColor)));
connect(m_characterHighlighting, SIGNAL(strikethroughChanged(KoCharacterStyle::LineType, KoCharacterStyle::LineStyle, QColor)), this, SLOT(slotStrikethroughChanged(KoCharacterStyle::LineType, KoCharacterStyle::LineStyle, QColor)));
connect(m_characterHighlighting, SIGNAL(capitalizationChanged(QFont::Capitalization)), this, SLOT(slotCapitalizationChanged(QFont::Capitalization)));
connect(m_characterHighlighting, SIGNAL(fontChanged(const QFont &)), this, SLOT(slotFontSelected(const QFont &)));
connect(m_characterHighlighting, SIGNAL(backgroundColorChanged(QColor)), this, SLOT(slotBackgroundColorChanged(QColor)));
connect(m_characterHighlighting, SIGNAL(textColorChanged(QColor)), this, SLOT(slotTextColorChanged(QColor)));
m_languageTab = new LanguageTab(true, this);
widget.tabs->addTab(m_characterHighlighting, i18n("Font"));
m_languageTab->setVisible(false);
connect(widget.name, SIGNAL(textChanged(const QString &)), this, SIGNAL(nameChanged(const QString&)));
connect(widget.name, SIGNAL(textChanged(const QString &)), this, SLOT(setName(const QString&)));
}
void CharacterGeneral::hideStyleName(bool hide)
{
if (hide) {
disconnect(widget.name, SIGNAL(textChanged(const QString &)), this, SIGNAL(nameChanged(const QString&)));
disconnect(widget.name, SIGNAL(textChanged(const QString &)), this, SLOT(setName(const QString&)));
widget.tabs->removeTab(0);
m_nameHidden = true;
}
}
void CharacterGeneral::setStyle(KoCharacterStyle *style)
{
m_style = style;
if (m_style == 0)
return;
m_blockSignals = true;
if (!m_nameHidden)
widget.name->setText(style->name());
m_characterHighlighting->setDisplay(style);
//m_languageTab->setDisplay(style);
m_blockSignals = false;
}
void CharacterGeneral::save(KoCharacterStyle *style)
{
KoCharacterStyle *savingStyle;
if (style == 0) {
if (m_style == 0)
return;
else
savingStyle = m_style;
}
else
savingStyle = style;
m_characterHighlighting->save(savingStyle);
//m_languageTab->save(savingStyle);
emit styleAltered(savingStyle);
}
void CharacterGeneral::switchToGeneralTab()
{
widget.tabs->setCurrentIndex(0);
}
void CharacterGeneral::setName(const QString &name)
{
m_style->setName(name);
}
void CharacterGeneral::slotCapitalizationChanged(QFont::Capitalization capitalisation)
{
widget.preview->setFontCapitalisation(capitalisation);
}
void CharacterGeneral::slotFontSelected(const QFont &font)
{
widget.preview->setFont(font);
}
void CharacterGeneral::slotBackgroundColorChanged(QColor color)
{
widget.preview->setBackgroundColor(color);
}
void CharacterGeneral::slotTextColorChanged(QColor color)
{
widget.preview->setTextColor(color);
}
void CharacterGeneral::slotUnderlineChanged(KoCharacterStyle::LineType lineType, KoCharacterStyle::LineStyle lineStyle, QColor lineColor)
{
widget.preview->setUnderline(lineType, lineStyle, lineColor);
}
void CharacterGeneral::slotStrikethroughChanged(KoCharacterStyle::LineType lineType, KoCharacterStyle::LineStyle lineStyle, QColor lineColor)
{
widget.preview->setStrikethrough(lineType, lineStyle, lineColor);
}
#include <CharacterGeneral.moc>
|