[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/textshape-stylesWidget-PierreSt] plugins/textshape: A little further in the new Stylesmana
From: Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date: 2013-03-21 17:41:32
Message-ID: 20130321174132.1A65FA604F () git ! kde ! org
[Download RAW message or body]
Git commit 8199a7d09d1bd5bdeff07a7ed9ae35f6d49e58c4 by Pierre Stirnweiss.
Committed on 21/03/2013 at 18:40.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.
A little further in the new Stylesmanager dialog
M +2 -2 plugins/textshape/CMakeLists.txt
M +5 -69 plugins/textshape/dialogs/StylesModel.cpp
M +0 -17 plugins/textshape/dialogs/StylesModel.h
M +46 -53 plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
M +12 -4 plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
M +171 -77 plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
M +4 -4 plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
http://commits.kde.org/calligra/8199a7d09d1bd5bdeff07a7ed9ae35f6d49e58c4
diff --git a/plugins/textshape/CMakeLists.txt b/plugins/textshape/CMakeLists.txt
index 91e5194..1c37a9c 100644
--- a/plugins/textshape/CMakeLists.txt
+++ b/plugins/textshape/CMakeLists.txt
@@ -68,8 +68,8 @@ SET ( textshape_SRCS
dialogs/StylesFilteredModelBase.cpp
dialogs/ValidParentStylesProxyModel.cpp
dialogs/StylesDelegate.cpp
- dialogs/StyleManager.cpp
- dialogs/StyleManagerDialog.cpp
+# dialogs/StyleManager.cpp
+# dialogs/StyleManagerDialog.cpp
dialogs/ParagraphGeneral.cpp
dialogs/CharacterGeneral.cpp
dialogs/CharacterHighlighting.cpp
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModel.cpp index b09f2be..dc845a1 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModel.cpp
@@ -35,12 +35,11 @@
#include <KDebug>
StylesModel::StylesModel(KoStyleManager *manager, AbstractStylesModel::Type \
modelType, QObject *parent)
- : AbstractStylesModel(parent),
- m_styleManager(0),
- m_currentParagraphStyle(0),
- m_defaultCharacterStyle(0),
- m_styleMapper(new QSignalMapper(this)),
- m_provideStyleNone(false)
+ : AbstractStylesModel(parent)
+ , m_styleManager(0)
+ , m_currentParagraphStyle(0)
+ , m_defaultCharacterStyle(0)
+ , m_styleMapper(new QSignalMapper(this))
{
m_modelType = modelType;
setStyleManager(manager);
@@ -112,9 +111,6 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const if (paragStyle) {
return m_styleThumbnailer->thumbnail(paragStyle, data(index, \
Qt::SizeHintRole).toSize()); }
- if (!paragStyle && m_draftParStyleList.contains(id)) {
- return m_styleThumbnailer->thumbnail(m_draftParStyleList[id], \
data(index, Qt::SizeHintRole).toSize());
- }
}
else {
KoCharacterStyle *usedStyle = 0;
@@ -122,9 +118,6 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const if (usedStyle) {
return m_styleThumbnailer->thumbnail(usedStyle, \
m_currentParagraphStyle, data(index, Qt::SizeHintRole).toSize()); }
- if (!usedStyle && m_draftCharStyleList.contains(id)) {
- return m_styleThumbnailer->thumbnail(m_draftCharStyleList[id], \
m_currentParagraphStyle, data(index, Qt::SizeHintRole).toSize());
- }
}
break;
}
@@ -212,9 +205,6 @@ QImage StylesModel::stylePreview(const QModelIndex &index, QSize \
size) if (usedStyle) {
return m_styleThumbnailer->thumbnail(usedStyle, size);
}
- if (!usedStyle && m_draftParStyleList.contains(index.internalId())) {
- return m_styleThumbnailer->thumbnail(m_draftParStyleList[index.internalId()], \
size);
- }
}
else {
KoCharacterStyle *usedStyle = 0;
@@ -222,9 +212,6 @@ QImage StylesModel::stylePreview(const QModelIndex &index, QSize \
size) if (usedStyle) {
return m_styleThumbnailer->thumbnail(usedStyle, m_currentParagraphStyle, \
size); }
- if (!usedStyle && m_draftCharStyleList.contains(index.internalId())) {
- return m_styleThumbnailer->thumbnail(m_draftCharStyleList[index.internalId()],m_currentParagraphStyle, \
size);
- }
}
return QImage();
}
@@ -268,8 +255,6 @@ void StylesModel::addParagraphStyle(KoParagraphStyle *style)
int index = 0;
for ( ; begin != m_styleList.end(); ++begin) {
KoParagraphStyle *s = m_styleManager->paragraphStyle(*begin);;
- if (!s && m_draftParStyleList.contains(*begin))
- s = m_draftParStyleList[*begin];
// s should be found as the manager and the m_styleList should be in sync
Q_ASSERT(s);
if (KStringHandler::naturalCompare(style->name(),s->name()) < 0) {
@@ -321,8 +306,6 @@ void StylesModel::addCharacterStyle(KoCharacterStyle *style)
int index = 0;
for ( ; begin != m_styleList.end(); ++begin) {
KoCharacterStyle *s = m_styleManager->characterStyle(*begin);;
- if (!s && m_draftCharStyleList.contains(*begin))
- s = m_draftCharStyleList[*begin];
// s should be found as the manager and the m_styleList should be in sync
Q_ASSERT(s);
if (KStringHandler::naturalCompare(style->name(),s->name()) < 0) {
@@ -395,8 +378,6 @@ void StylesModel::updateName(int styleId)
int newIndex = 0;
if (m_modelType == StylesModel::ParagraphStyle) {
KoParagraphStyle *paragStyle = m_styleManager->paragraphStyle(styleId);
- if (!paragStyle && m_draftParStyleList.contains(styleId))
- paragStyle = m_draftParStyleList.value(styleId);
if (paragStyle) {
m_styleThumbnailer->removeFromCache(paragStyle);
@@ -407,8 +388,6 @@ void StylesModel::updateName(int styleId)
continue;
}
KoParagraphStyle *s = m_styleManager->paragraphStyle(*begin);
- if (!s && m_draftParStyleList.contains(*begin))
- s = m_draftParStyleList[*begin];
// s should be found as the manager and the m_styleList should \
be in sync Q_ASSERT(s);
if (KStringHandler::naturalCompare(paragStyle->name(), \
s->name()) < 0) { @@ -428,8 +407,6 @@ void StylesModel::updateName(int styleId)
}
else {
KoCharacterStyle *characterStyle = \
m_styleManager->characterStyle(styleId);
- if (!characterStyle && m_draftCharStyleList.contains(styleId))
- characterStyle = m_draftCharStyleList[styleId];
if (characterStyle) {
m_styleThumbnailer->removeFromCache(characterStyle);
@@ -440,8 +417,6 @@ void StylesModel::updateName(int styleId)
continue;
}
KoCharacterStyle *s = m_styleManager->characterStyle(*begin);
- if (!s && m_draftCharStyleList.contains(*begin))
- s = m_draftCharStyleList[*begin];
// s should be found as the manager and the m_styleList should \
be in sync Q_ASSERT(s);
if (KStringHandler::naturalCompare(characterStyle->name(), \
s->name()) < 0) { @@ -475,45 +450,6 @@ QList<int> StylesModel::StyleList()
return m_styleList;
}
-QHash<int, KoParagraphStyle *> StylesModel::draftParStyleList()
-{
- return m_draftParStyleList;
-}
-
-QHash<int, KoCharacterStyle *> StylesModel::draftCharStyleList()
-{
- return m_draftCharStyleList;
-}
-
-void StylesModel::addDraftParagraphStyle(KoParagraphStyle *style)
-{
- style->setStyleId(-(m_draftParStyleList.count()+1));
- m_draftParStyleList.insert(style->styleId(), style);
- addParagraphStyle(style);
-}
-
-void StylesModel::addDraftCharacterStyle(KoCharacterStyle *style)
-{
- if (m_draftCharStyleList.count() == 0) // we have a character style \
"m_defaultCharacterStyle" with style id -1 in style model.
- style->setStyleId(-(m_draftCharStyleList.count()+2));
- else
- style->setStyleId(-(m_draftCharStyleList.count()+1));
- m_draftCharStyleList.insert(style->styleId(), style);
- addCharacterStyle(style);
-}
-
-void StylesModel::clearDraftStyles()
-{
- foreach(KoParagraphStyle *style, m_draftParStyleList.values()) {
- removeParagraphStyle(style);
- }
- m_draftParStyleList.clear();
- foreach(KoCharacterStyle *style, m_draftCharStyleList.values()) {
- removeCharacterStyle(style);
- }
- m_draftCharStyleList.clear();
-}
-
StylesModel::Type StylesModel::stylesType() const
{
return m_modelType;
diff --git a/plugins/textshape/dialogs/StylesModel.h \
b/plugins/textshape/dialogs/StylesModel.h index d078b5f..bce1c5f 100644
--- a/plugins/textshape/dialogs/StylesModel.h
+++ b/plugins/textshape/dialogs/StylesModel.h
@@ -108,19 +108,6 @@ public:
/** Return style id list. */
QList<int> StyleList();
- /** Return new styles and their ids. */
- QHash<int, KoParagraphStyle *> draftParStyleList();
- QHash<int, KoCharacterStyle *> draftCharStyleList();
-
- /** Add a paragraph style to pargraph style list but this style is not applied. \
*/
- void addDraftParagraphStyle(KoParagraphStyle *style);
-
- /** Add a character style to character style list but this style is not applied. \
*/
- void addDraftCharacterStyle(KoCharacterStyle *style);
-
- /** we call this when we apply our unapplied styles and we clear our list. */
- void clearDraftStyles();
-
/** We call this when we want a clear style model. */
void clearStyleModel();
@@ -143,8 +130,6 @@ private:
protected:
QList<int> m_styleList; // list of style IDs
- QHash<int, KoParagraphStyle *> m_draftParStyleList; // list of new styles that \
are not applied
- QHash<int, KoCharacterStyle *> m_draftCharStyleList;
private:
KoStyleManager *m_styleManager;
@@ -153,8 +138,6 @@ private:
KoCharacterStyle *m_defaultCharacterStyle;
QSignalMapper *m_styleMapper;
-
- bool m_provideStyleNone;
};
#endif
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp \
b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp index \
cb9a38f..76ebdc3 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
@@ -116,75 +116,66 @@ void ParagraphIndentSpacingTab::slotLineSpacingEnabled(bool \
enabled) {
ui->lineSpacing->setEnabled(enabled);
ui->spacingStack->setEnabled(enabled);
- ui->useFont->setEnabled(enabled);
+ ui->useFont->setEnabled(enabled && ui->lineSpacing->currentIndex() != 5);
emit lineSpacingEnabled(enabled);
}
void ParagraphIndentSpacingTab::slotLineSpacingChanged(int item)
{
- emit lineSpacingChanged(item);
-//this does not belong here
-/* bool percent = false, custom = false;
- qreal customValue = 0.0;
+ kDebug() << "slot line spacing changed.";
+ kDebug() << "item: " << item;
+ kDebug() << "useFont: " << ui->useFont->isChecked();
+ kDebug() << "proportional value: " << ui->proportional->value();
+ kDebug() << "custom value: " << ui->custom->value();
switch (item) {
- case 0:
- case 1:
- case 2:
- break;
- case 3: // proportional
- percent = true;
- ui->proportional->setValue(m_style->lineHeightPercent());
- break;
- case 4: // additional
- custom = true;
- customValue = qMax(qreal(0.1), m_style->lineSpacing());
- break;
- case 5: // fixed
- custom = true;
- if (m_style->lineHeightAbsolute() == 0) // unset
- customValue = 12.0; // nice default value...
- else
- customValue = m_style->lineHeightAbsolute();
- break;
- case 6: // minimum
- custom = true;
- customValue = m_style->minimumLineHeight();
- break;
- default:; // other cases don't need the spinboxes
- }
-
- m_spacingInherited = false;
-
- if (custom) {
- ui->custom->setEnabled(true);
- ui->spacingStack->setCurrentWidget(ui->unitsPage);
- ui->custom->changeValue(customValue);
- } else {
- ui->spacingStack->setCurrentWidget(ui->percentPage);
- ui->proportional->setEnabled(percent);
- if (! percent)
- ui->proportional->setValue(100);
+ case 0:
+ emit lineSpacingChanged(LineHeightProportional, 120, \
ui->useFont->isChecked()); + break;
+ case 1:
+ emit lineSpacingChanged(LineHeightProportional, 180, \
ui->useFont->isChecked()); + break;
+ case 2:
+ emit lineSpacingChanged(LineHeightProportional, 240, \
ui->useFont->isChecked()); + break;
+ case 3:
+ emit lineSpacingChanged(LineHeightProportional, ui->proportional->value(), \
ui->useFont->isChecked()); + break;
+ case 4:
+ if (ui->custom->value() == 0.0) {
+ emit lineSpacingChanged(LineHeightProportional, 100, \
ui->useFont->isChecked()); //we need to save it as percentage + }
+ else {
+ emit lineSpacingChanged(LineSpacingAdditional, ui->custom->value(), \
ui->useFont->isChecked()); + }
+ break;
+ case 5:
+ emit lineSpacingChanged(LineHeightFixed, ui->custom->value(), false);
+ break;
+ case 6:
+ emit lineSpacingChanged(LineHeightMinimum, ui->custom->value(), \
ui->useFont->isChecked()); + break;
}
-
- ui->useFont->setEnabled(item != 5);
- ui->useFont->setChecked(item == 5 ? false : m_fontMetricsChecked);
- emit parStyleChanged();
-*/
}
void ParagraphIndentSpacingTab::slotLineSpacingPercentChanged(int percent)
{
- emit lineSpacingPercentChanged(percent);
+ Q_UNUSED(percent);
+ slotLineSpacingChanged(ui->lineSpacing->currentIndex());
+// emit lineSpacingPercentChanged(percent);
}
void ParagraphIndentSpacingTab::slotLineSpacingValueChanged(qreal value)
{
- emit lineSpacingValueChanged(value);
+ Q_UNUSED(value);
+ slotLineSpacingChanged(ui->lineSpacing->currentIndex());
+// emit lineSpacingValueChanged(value);
}
void ParagraphIndentSpacingTab::slotUseFontMetricsChecked(bool checked)
{
- emit useFontMetricsChecked(checked);
+ Q_UNUSED(checked);
+ slotLineSpacingChanged(ui->lineSpacing->currentIndex());
+// emit useFontMetricsChecked(checked);
}
void ParagraphIndentSpacingTab::slotTopParagraphSpacingEnabled(bool enabled)
@@ -232,9 +223,6 @@ void ParagraphIndentSpacingTab::setDisplay(KoParagraphStyle \
*style) ui->first->changeValue(style->textIndent());
//line spacing
- checked = (style->hasProperty(KoParagraphStyle::FixedLineHeight) || \
style->hasProperty(KoParagraphStyle::LineSpacing) || \
style->hasProperty(KoParagraphStyle::PercentLineHeight) \
||style->hasProperty(KoParagraphStyle::MinimumLineHeight));
- ui->lineSpacingLabel->setChecked(checked);
- slotLineSpacingEnabled(checked);
ui->proportional->setValue(style->lineHeightPercent());
if (style->hasProperty(KoParagraphStyle::FixedLineHeight) && \
style->lineHeightAbsolute() != 0) { @@ -279,6 +267,11 @@ void \
ParagraphIndentSpacingTab::setDisplay(KoParagraphStyle *style)
ui->useFont->setChecked(style->lineSpacingFromFont() && \
ui->lineSpacing->currentIndex() != 5); m_fontMetricsChecked = \
style->lineSpacingFromFont();
+ checked = (style->hasProperty(KoParagraphStyle::FixedLineHeight) || \
style->hasProperty(KoParagraphStyle::LineSpacing) || \
style->hasProperty(KoParagraphStyle::PercentLineHeight) \
||style->hasProperty(KoParagraphStyle::MinimumLineHeight)); + \
ui->lineSpacingLabel->setChecked(checked); + slotLineSpacingEnabled(checked); //we \
do this after setting the line spacing widgets because the useFontMetrics check box \
enabling depends on the line spacing type +
+
//paragraph spacing
checked = style->hasProperty(QTextFormat::BlockTopMargin);
ui->beforeLabel->setChecked(checked);
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h \
b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h index \
e5305a5..923d97f 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
@@ -34,6 +34,13 @@ class ParagraphIndentSpacingTab : public QWidget
{
Q_OBJECT
public:
+ enum LineSpacingType {
+ LineHeightProportional,
+ LineHeightFixed,
+ LineHeightMinimum,
+ LineSpacingAdditional
+ };
+
explicit ParagraphIndentSpacingTab(QWidget *parent = 0);
~ParagraphIndentSpacingTab();
// open and display the style
@@ -53,11 +60,12 @@ signals:
void firstLineIndentChanged(qreal value);
void autoTextIndentChecked(bool checked);
//line spacing signals
+ void lineSpacingChanged(ParagraphIndentSpacingTab::LineSpacingType spacingType, \
qreal value, bool useFontMetrics); void lineSpacingEnabled(bool enabled);
- void lineSpacingChanged(int item);
- void lineSpacingValueChanged(qreal value);
- void lineSpacingPercentChanged(int percent);
- void useFontMetricsChecked(bool checked);
+// void lineSpacingChanged(int item);
+// void lineSpacingValueChanged(qreal value);
+// void lineSpacingPercentChanged(int percent);
+// void useFontMetricsChecked(bool checked);
//paragraph spacing signals
void topParagraphSpacingEnabled(bool enabled);
void topParagraphSpacingChanged(qreal value);
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp \
b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp index \
321b8a3..20e0449 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
@@ -73,10 +73,7 @@ ParagraphStylesTab::ParagraphStylesTab(QWidget *parent) :
connect(ui->indentSpacing, SIGNAL(firstLineIndentChanged(qreal)), this, \
SLOT(slotFirstLineIndentChanged(qreal)));
connect(ui->indentSpacing, SIGNAL(autoTextIndentChecked(bool)), this, \
SLOT(slotAutoTextIndentChecked(bool)));
connect(ui->indentSpacing, SIGNAL(lineSpacingEnabled(bool)), this, \
SLOT(slotLineSpacingEnabled(bool)));
- connect(ui->indentSpacing, SIGNAL(lineSpacingChanged(int)), this, \
SLOT(slotLineSpacingChanged(int)));
- connect(ui->indentSpacing, SIGNAL(lineSpacingValueChanged(qreal)), this, \
SLOT(slotLineSpacingValueChanged(qreal)));
- connect(ui->indentSpacing, SIGNAL(lineSpacingPercentChanged(int)), this, \
SLOT(slotLineSpacingPercentChanged(int)));
- connect(ui->indentSpacing, SIGNAL(useFontMetricsChecked(bool)), this, \
SLOT(slotUseFontMetricsChecked(bool))); + connect(ui->indentSpacing, \
SIGNAL(lineSpacingChanged(ParagraphIndentSpacingTab::LineSpacingType,qreal,bool)), \
this, SLOT(slotLineSpacingChanged(ParagraphIndentSpacingTab::LineSpacingType,qreal,bool)));
connect(ui->indentSpacing, SIGNAL(topParagraphSpacingEnabled(bool)), this, \
SLOT(slotTopParagraphSpacingEnabled(bool)));
connect(ui->indentSpacing, SIGNAL(topParagraphSpacingChanged(qreal)), this, \
SLOT(slotTopParagraphSpacingChanged(qreal)));
connect(ui->indentSpacing, SIGNAL(bottomParagraphSpacingEnabled(bool)), this, \
SLOT(slotBottomParagraphSpacingEnabled(bool))); @@ -91,6 +88,7 @@ \
ParagraphStylesTab::~ParagraphStylesTab()
void ParagraphStylesTab::setDisplay(KoParagraphStyle *style)
{
+ ui->paragraphListView->update(ui->paragraphListView->currentIndex());
ui->characterHighlighting->setDisplay(style);
ui->indentSpacing->setDisplay(style);
}
@@ -117,8 +115,7 @@ void ParagraphStylesTab::slotStyleSelected(const QModelIndex \
&index) {
KoParagraphStyle *style = \
static_cast<KoParagraphStyle*>(index.data(AbstractStylesModel::ParagraphStylePointer).value<void*>());
if (style) {
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -127,8 +124,7 @@ void ParagraphStylesTab::slotCreateNewStyle()
KoParagraphStyle *newStyle = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->slotCreateNewStyle(ui->paragraphListView->currentIndex()));
if (newStyle) {
ui->paragraphListView->setCurrentIndex(m_paragraphStylesModel->indexForCharacterStyle(*newStyle));
- ui->characterHighlighting->setDisplay(newStyle);
- ui->indentSpacing->setDisplay(newStyle);
+ setDisplay(newStyle);
}
}
@@ -143,6 +139,8 @@ void ParagraphStylesTab::slotSaveStyle() //TODO reselect the \
style, create a sav }
/*TODOs:
+- inherit style on new style instead of cloning
+- create our own KFontChooser. the stock kde one does not allow to disable \
individual font properties
*/
/// ///////////////////CharacterHighlightingTab slots
@@ -157,9 +155,8 @@ void ParagraphStylesTab::slotCapitalizationEnabled(bool enabled)
else if (!enabled && \
style->KoCharacterStyle::hasProperty(QTextFormat::FontCapitalization)) \
{
style->KoCharacterStyle::remove(QTextFormat::FontCapitalization);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+
+ setDisplay(style);
}
}
@@ -169,9 +166,7 @@ void \
ParagraphStylesTab::slotCapitalizationChanged(QFont::Capitalization capital if \
(style) { style->KoCharacterStyle::setFontCapitalization(capitalization);
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -190,9 +185,7 @@ void ParagraphStylesTab::slotUnderlineEnabled(bool enabled)
style->KoCharacterStyle::remove(QTextFormat::TextUnderlineColor);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -204,9 +197,7 @@ void \
ParagraphStylesTab::slotUnderlineChanged(KoCharacterStyle::LineType lineTyp \
style->KoCharacterStyle::setUnderlineStyle(lineStyle); \
style->KoCharacterStyle::setUnderlineColor(lineColor);
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -225,9 +216,7 @@ void ParagraphStylesTab::slotStrikethroughEnabled(bool enabled)
style->KoCharacterStyle::remove(KoCharacterStyle::StrikeOutColor);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -239,9 +228,7 @@ void \
ParagraphStylesTab::slotStrikethroughChanged(KoCharacterStyle::LineType lin \
style->KoCharacterStyle::setStrikeOutStyle(lineStyle); \
style->KoCharacterStyle::setStrikeOutColor(lineColor);
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -255,9 +242,8 @@ void ParagraphStylesTab::slotPositionEnabled(bool enabled)
else if (!enabled && \
style->KoCharacterStyle::hasProperty(QTextFormat::TextVerticalAlignment)) \
{
style->KoCharacterStyle::remove(QTextFormat::TextVerticalAlignment);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+
+ setDisplay(style);
}
}
@@ -267,9 +253,7 @@ void \
ParagraphStylesTab::slotPositionChanged(QTextCharFormat::VerticalAlignment if \
(style) { style->KoCharacterStyle::setVerticalAlignment(alignment);
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -283,9 +267,8 @@ void ParagraphStylesTab::slotBackgroundColorEnabled(bool enabled)
else if (!enabled && \
style->KoCharacterStyle::hasProperty(QTextFormat::BackgroundBrush)) {
style->KoCharacterStyle::remove(QTextFormat::BackgroundBrush);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+
+ setDisplay(style);
}
}
@@ -295,9 +278,7 @@ void ParagraphStylesTab::slotBackgroundColorChanged(const QColor \
color) if (style) {
style->KoCharacterStyle::setBackground(QBrush(color));
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -311,9 +292,8 @@ void ParagraphStylesTab::slotTextColorEnabled(bool enabled)
else if (!enabled && \
style->KoCharacterStyle::hasProperty(QTextFormat::ForegroundBrush)) {
style->KoCharacterStyle::remove(QTextFormat::ForegroundBrush);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+
+ setDisplay(style);
}
}
@@ -323,9 +303,7 @@ void ParagraphStylesTab::slotTextColorChanged(QColor color)
if (style) {
style->KoCharacterStyle::setForeground(QBrush(color));
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -346,9 +324,7 @@ void ParagraphStylesTab::slotFontEnabled(bool enabled)
style->KoCharacterStyle::remove(QTextFormat::FontPointSize);
}
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -361,9 +337,7 @@ void ParagraphStylesTab::slotFontChanged(const QFont &font)
style->KoCharacterStyle::setFontWeight(font.weight());
style->KoCharacterStyle::setFontPointSize(font.pointSize());
- ui->paragraphListView->update(ui->paragraphListView->currentIndex());
- ui->characterHighlighting->setDisplay(style);
- ui->indentSpacing->setDisplay(style);
+ setDisplay(style);
}
}
@@ -372,82 +346,202 @@ void ParagraphStylesTab::slotFontChanged(const QFont &font)
//indentation slots
void ParagraphStylesTab::slotLeftIndentEnabled(bool enabled)
{
- kDebug() << "leftIndent enabled: " << enabled;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && !style->hasProperty(QTextFormat::BlockLeftMargin)) {
+ style->setLeftMargin(QTextLength(QTextLength::FixedLength, \
style->leftMargin())); //set the left margin of the parent/default paragraph style. \
If none exists, 0 is returned. + }
+ else if (!enabled && style->hasProperty(QTextFormat::BlockLeftMargin)) {
+ style->remove(QTextFormat::BlockLeftMargin);
+ }
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotLeftIndentChanged(qreal value)
{
- kDebug() << "new value: " << value;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setLeftMargin(QTextLength(QTextLength::FixedLength, value));
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotRightIndentEnabled(bool enabled)
{
- kDebug() << "rightIndent enabled: " << enabled;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && !style->hasProperty(QTextFormat::BlockRightMargin)) {
+ style->setRightMargin(QTextLength(QTextLength::FixedLength, \
style->rightMargin())); //set the right margin of the parent/default paragraph style. \
If none exists, 0 is returned. + }
+ else if (!enabled && style->hasProperty(QTextFormat::BlockRightMargin)) {
+ style->remove(QTextFormat::BlockRightMargin);
+ }
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotRightIndentChanged(qreal value)
{
- kDebug() << "new value: " << value;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setRightMargin(QTextLength(QTextLength::FixedLength, value));
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotFirstLineIndentEnabled(bool enabled)
{
- kDebug() << "firstLineIndent enabled: " << enabled;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && !style->hasProperty(QTextFormat::TextIndent)) {
+ style->setTextIndent(QTextLength(QTextLength::FixedLength, \
style->textIndent())); //set the first line indent of the parent/default paragraph \
style. If none exists, 0 is returned. + }
+ else if (!enabled && style->hasProperty(QTextFormat::TextIndent)) {
+ style->remove(QTextFormat::TextIndent);
+ }
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotFirstLineIndentChanged(qreal value)
{
- kDebug() << "new value: " << value;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setTextIndent(QTextLength(QTextLength::FixedLength, value));
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotAutoTextIndentChecked(bool checked)
{
- kDebug() << "checked: " << checked;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setAutoTextIndent(checked);
+
+ setDisplay(style);
+ }
}
//line spacing slots
void ParagraphStylesTab::slotLineSpacingEnabled(bool enabled)
{
- kDebug() << "leftSpacing enabled: " << enabled;
-}
-
-void ParagraphStylesTab::slotLineSpacingChanged(int item)
-{
- kDebug() << "selected item: " << item;
-}
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && (!style->hasProperty(KoParagraphStyle::FixedLineHeight) || \
!style->hasProperty(KoParagraphStyle::LineSpacing) || \
!style->hasProperty(KoParagraphStyle::PercentLineHeight) || \
!style->hasProperty(KoParagraphStyle::MinimumLineHeight))) { + \
style->setLineHeightAbsolute(style->lineHeightAbsolute()); + \
style->setLineHeightPercent(style->lineHeightPercent()); + \
style->setLineSpacing(style->lineSpacing()); + \
style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, \
style->minimumLineHeight())); + \
style->setLineSpacingFromFont(style->lineSpacingFromFont()); + }
+ else if (!enabled && (style->hasProperty(KoParagraphStyle::FixedLineHeight) \
|| style->hasProperty(KoParagraphStyle::LineSpacing) || \
style->hasProperty(KoParagraphStyle::PercentLineHeight) || \
style->hasProperty(KoParagraphStyle::MinimumLineHeight))) { + \
style->remove(KoParagraphStyle::FixedLineHeight); + \
style->remove(KoParagraphStyle::LineSpacing); + \
style->remove(KoParagraphStyle::PercentLineHeight); + \
style->remove(KoParagraphStyle::MinimumLineHeight); + }
-void ParagraphStylesTab::slotLineSpacingValueChanged(qreal value)
-{
- kDebug() << "new value: " << value;
+ setDisplay(style);
+ }
}
-void ParagraphStylesTab::slotLineSpacingPercentChanged(int percent)
+void ParagraphStylesTab::slotLineSpacingChanged(ParagraphIndentSpacingTab::LineSpacingType \
spacingType, qreal value, bool useFontMetrics) {
- kDebug() << "percent: " << percent;
-}
+ kDebug() << "slot lineSpacing changed";
+ kDebug() << "spacing type: " << spacingType;
+ kDebug() << "value: " << value;
+ kDebug() << "useFont: " << useFontMetrics;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ switch (spacingType) {
+ case ParagraphIndentSpacingTab::LineHeightProportional:
+ style->setLineHeightAbsolute(0); // since it trumps percentage based \
line heights, unset it. + \
style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, 0)); + \
style->setLineSpacing(0); + style->setLineHeightPercent(int(value));
+ style->setLineSpacingFromFont(useFontMetrics);
+ break;
+ case ParagraphIndentSpacingTab::LineSpacingAdditional:
+ style->setLineHeightAbsolute(0); // since it trumps percentage based \
line heights, unset it. + \
style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, 0)); + \
style->setLineSpacing(value); + style->setLineHeightPercent(100);
+ style->setLineSpacingFromFont(useFontMetrics);
+ break;
+ case ParagraphIndentSpacingTab::LineHeightFixed:
+ style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, 0));
+ style->setLineSpacing(0);
+ style->setLineHeightPercent(100);
+ style->setLineHeightAbsolute(style->lineHeightAbsolute());
+ style->setLineSpacingFromFont(false);
+ break;
+ case ParagraphIndentSpacingTab::LineHeightMinimum:
+ style->setLineHeightAbsolute(0); // since it trumps percentage based \
line heights, unset it. + style->setLineHeightPercent(100);
+ style->setLineSpacing(0);
+ style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, \
style->minimumLineHeight())); + style->setLineSpacingFromFont(false);
+ break;
+ }
-void ParagraphStylesTab::slotUseFontMetricsChecked(bool checked)
-{
- kDebug() << "checked: " << checked;
+ setDisplay(style);
+ }
}
//paragraph spacing slots
void ParagraphStylesTab::slotTopParagraphSpacingEnabled(bool enabled)
{
- kDebug() << "topSpacing enabled: " << enabled;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && !style->hasProperty(QTextFormat::BlockTopMargin)) {
+ style->setTopMargin(QTextLength(QTextLength::FixedLength, \
style->topMargin())); + }
+ else if (!enabled && style->hasProperty(QTextFormat::BlockTopMargin)) {
+ style->remove(QTextFormat::BlockTopMargin);
+ }
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotTopParagraphSpacingChanged(qreal value)
{
- kDebug() << "new value: " << value;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setTopMargin(QTextLength(QTextLength::FixedLength, value));
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotBottomParagraphSpacingEnabled(bool enabled)
{
- kDebug() << "bottomSpacing enabled: " << enabled;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ if (enabled && !style->hasProperty(QTextFormat::BlockBottomMargin)) {
+ style->setBottomMargin(QTextLength(QTextLength::FixedLength, \
style->bottomMargin())); + }
+ else if (!enabled && style->hasProperty(QTextFormat::BlockBottomMargin)) {
+ style->remove(QTextFormat::BlockBottomMargin);
+ }
+
+ setDisplay(style);
+ }
}
void ParagraphStylesTab::slotBottomParagraphSpacingChanged(qreal value)
{
- kDebug() << "new value: " << value;
+ KoParagraphStyle *style = \
dynamic_cast<KoParagraphStyle*>(m_paragraphStylesModel->unsavedStyle(ui->paragraphListView->currentIndex()));
+ if (style) {
+ style->setBottomMargin(QTextLength(QTextLength::FixedLength, value));
+
+ setDisplay(style);
+ }
}
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h \
b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h index 74a2212..df6b406 \
100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
@@ -20,6 +20,8 @@
#ifndef PARAGRAPHSTYLESTAB_H
#define PARAGRAPHSTYLESTAB_H
+#include "ParagraphIndentSpacingTab.h"
+
#include <KoCharacterStyle.h>
#include <KoParagraphStyle.h>
@@ -53,6 +55,7 @@ private slots:
void slotCreateNewStyle();
void slotSaveStyle();
+ //character highlighting slots
void slotCapitalizationEnabled(bool enabled);
void slotCapitalizationChanged(QFont::Capitalization capitalization);
void slotUnderlineEnabled(bool enabled);
@@ -78,10 +81,7 @@ private slots:
void slotAutoTextIndentChecked(bool checked);
//line spacing slots
void slotLineSpacingEnabled(bool enabled);
- void slotLineSpacingChanged(int item);
- void slotLineSpacingValueChanged(qreal value);
- void slotLineSpacingPercentChanged(int percent);
- void slotUseFontMetricsChecked(bool checked);
+ void slotLineSpacingChanged(ParagraphIndentSpacingTab::LineSpacingType \
spacingType, qreal value, bool useFontMetrics); //paragraph spacing slots
void slotTopParagraphSpacingEnabled(bool enabled);
void slotTopParagraphSpacingChanged(qreal value);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic