[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/textshape-stylesWidget-PierreSt] /: Going a bit further in the new styles manager dialog
From: Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date: 2013-02-03 21:41:39
Message-ID: 20130203214139.79217A60EE () git ! kde ! org
[Download RAW message or body]
Git commit a1abb67a359a532cfbcdac3012c27b861005b5ed by Pierre Stirnweiss.
Committed on 03/02/2013 at 22:40.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.
Going a bit further in the new styles manager dialog
M +2 -2 libs/kotext/KoText.cpp
M +2 -2 libs/kotext/KoText.h
M +1 -0 plugins/textshape/CMakeLists.txt
M +1 -1 plugins/textshape/TextShapeFactory.cpp
M +7 -0 plugins/textshape/TextTool.cpp
M +4 -4 plugins/textshape/dialogs/CharacterHighlighting.cpp
M +2 -1 plugins/textshape/dialogs/DockerStylesComboModel.cpp
M +2 -0 plugins/textshape/dialogs/StylesFilteredModelBase.cpp
M +27 -0 plugins/textshape/dialogs/StylesModel.cpp
M +239 -147 plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.cpp
M +32 -20 plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.h
M +151 -140 plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.ui
M +217 -152 plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
M +45 -18 plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
M +104 -41 plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.ui
M +216 -4 plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
M +53 -2 plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
M +5 -0 plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.ui
M +32 -2 plugins/textshape/dialogs/stylemanager/StylesManager.cpp
M +11 -2 plugins/textshape/dialogs/stylemanager/StylesManager.h
A +150 -0 plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.cpp \
[License: LGPL (v2+)] A +79 -0 \
plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.h [License: LGPL \
(v2+)]
http://commits.kde.org/calligra/a1abb67a359a532cfbcdac3012c27b861005b5ed
diff --git a/libs/kotext/KoText.cpp b/libs/kotext/KoText.cpp
index 2f3c778..faa02cd 100644
--- a/libs/kotext/KoText.cpp
+++ b/libs/kotext/KoText.cpp
@@ -24,7 +24,7 @@
using namespace KoText;
-QStringList KoText::underlineTypeList()
+QStringList KoText::lineTypeList()
{
QStringList lst;
lst << i18nc("Underline Style", "None");
@@ -33,7 +33,7 @@ QStringList KoText::underlineTypeList()
return lst;
}
-QStringList KoText::underlineStyleList()
+QStringList KoText::lineStyleList()
{
QStringList lst;
lst << "_________"; // solid
diff --git a/libs/kotext/KoText.h b/libs/kotext/KoText.h
index 72b9820..830dce4 100644
--- a/libs/kotext/KoText.h
+++ b/libs/kotext/KoText.h
@@ -39,8 +39,8 @@
*/
namespace KoText
{
-KOTEXT_EXPORT QStringList underlineTypeList();
-KOTEXT_EXPORT QStringList underlineStyleList();
+KOTEXT_EXPORT QStringList lineTypeList();
+KOTEXT_EXPORT QStringList lineStyleList();
KOTEXT_EXPORT Qt::Alignment alignmentFromString(const QString &align);
KOTEXT_EXPORT QString alignmentToString(Qt::Alignment align);
KOTEXT_EXPORT Qt::Alignment valignmentFromString(const QString &align);
diff --git a/plugins/textshape/CMakeLists.txt b/plugins/textshape/CMakeLists.txt
index ce40a7c..91e5194 100644
--- a/plugins/textshape/CMakeLists.txt
+++ b/plugins/textshape/CMakeLists.txt
@@ -107,6 +107,7 @@ SET ( textshape_SRCS
dialogs/stylemanager/ParagraphLayoutTab.cpp
dialogs/stylemanager/ParagraphStylesTab.cpp
dialogs/stylemanager/StylesManager.cpp
+ dialogs/stylemanager/StylesManagerStylesModel.cpp
commands/ChangeListLevelCommand.cpp
commands/ShowChangesCommand.cpp
diff --git a/plugins/textshape/TextShapeFactory.cpp \
b/plugins/textshape/TextShapeFactory.cpp index 56829cb..afd4681 100644
--- a/plugins/textshape/TextShapeFactory.cpp
+++ b/plugins/textshape/TextShapeFactory.cpp
@@ -154,7 +154,7 @@ void \
TextShapeFactory::newDocumentResourceManager(KoDocumentResourceManager *man }
if (!manager->hasResource(KoText::StyleManager)) {
KoStyleManager *styleManager = new KoStyleManager(manager);
- styleManager->createDefaultSet();
+// styleManager->createDefaultSet();
variant.setValue(styleManager);
manager->setResource(KoText::StyleManager, variant);
}
diff --git a/plugins/textshape/TextTool.cpp b/plugins/textshape/TextTool.cpp
index 49d6d30..fe0dd9b 100644
--- a/plugins/textshape/TextTool.cpp
+++ b/plugins/textshape/TextTool.cpp
@@ -38,7 +38,9 @@
#include "commands/ChangeListLevelCommand.h"
#include "FontSizeAction.h"
+#include "dialogs/StylesModel.h"
#include "dialogs/stylemanager/StylesManager.h"
+#include <KoStyleThumbnailer.h>
#include <KoOdf.h>
#include <KoCanvasBase.h>
@@ -2492,6 +2494,11 @@ void TextTool::showStyleManager(int styleId)
return; //don't crash
StylesManager *dia = new StylesManager();
+ dia->setStyleManager(styleManager);
+ KoParagraphStyle *paragraphStyle = styleManager->paragraphStyle(styleId);
+ if (paragraphStyle) {
+// dia->setParagraphStyle(paragraphStyle);
+ }
dia->show();
/* StyleManagerDialog *dia = new StyleManagerDialog(canvas()->canvasWidget());
dia->setStyleManager(styleManager);
diff --git a/plugins/textshape/dialogs/CharacterHighlighting.cpp \
b/plugins/textshape/dialogs/CharacterHighlighting.cpp index f3f0fac..2bcffd4 100644
--- a/plugins/textshape/dialogs/CharacterHighlighting.cpp
+++ b/plugins/textshape/dialogs/CharacterHighlighting.cpp
@@ -55,13 +55,13 @@ CharacterHighlighting::CharacterHighlighting(bool \
uniqueFormat,QWidget* parent) widget.fontLayout->addWidget(m_fontChooser);
widget.capitalizationList->addItems(capitalizationList());
- widget.underlineStyle->addItems(KoText::underlineTypeList());
- widget.underlineLineStyle->addItems(KoText::underlineStyleList());
+ widget.underlineStyle->addItems(KoText::lineTypeList());
+ widget.underlineLineStyle->addItems(KoText::lineStyleList());
widget.positionList->addItems(fontLayoutPositionList());
- widget.strikethroughStyle->addItems(KoText::underlineTypeList()); //TODO make \
KoText consistent: either add strikethroughTypeList, or change from underlineTypeList \
to lineTypeList
- widget.strikethroughLineStyle->addItems(KoText::underlineStyleList()); //TODO \
idem + widget.strikethroughStyle->addItems(KoText::lineTypeList()); //TODO make \
KoText consistent: either add strikethroughTypeList, or change from underlineTypeList \
to lineTypeList + \
widget.strikethroughLineStyle->addItems(KoText::lineStyleList()); //TODO idem
connect(widget.underlineStyle, SIGNAL(activated(int)), this, \
SLOT(underlineTypeChanged(int)));
connect(widget.underlineLineStyle, SIGNAL(activated(int)), this, \
SLOT(underlineStyleChanged(int)));
diff --git a/plugins/textshape/dialogs/DockerStylesComboModel.cpp \
b/plugins/textshape/dialogs/DockerStylesComboModel.cpp index 70a374a..30cc819 100644
--- a/plugins/textshape/dialogs/DockerStylesComboModel.cpp
+++ b/plugins/textshape/dialogs/DockerStylesComboModel.cpp
@@ -54,7 +54,7 @@ Qt::ItemFlags DockerStylesComboModel::flags(const QModelIndex \
&index) const
if (index.internalId() == UsedStyleId || index.internalId() == UnusedStyleId) {
return (Qt::NoItemFlags);
}
- return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ return m_sourceModel->flags(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0, QModelIndex())); }
QModelIndex DockerStylesComboModel::index(int row, int column, const QModelIndex \
&parent) const @@ -66,6 +66,7 @@ QModelIndex DockerStylesComboModel::index(int row, \
int column, const QModelIndex if (row >= m_proxyToSource.count()) {
return QModelIndex();
}
+ //m_proxyToSource stores a mix of internalIds (negative, specific to this \
model) and row number in the source model return createIndex(row, column, \
(m_proxyToSource.at(row) >= 0)?int(m_sourceModel->index(m_proxyToSource.at(row), 0, \
QModelIndex()).internalId()):m_proxyToSource.at(row)); }
return QModelIndex();
diff --git a/plugins/textshape/dialogs/StylesFilteredModelBase.cpp \
b/plugins/textshape/dialogs/StylesFilteredModelBase.cpp index 0c81257..ecfa3fa 100644
--- a/plugins/textshape/dialogs/StylesFilteredModelBase.cpp
+++ b/plugins/textshape/dialogs/StylesFilteredModelBase.cpp
@@ -69,6 +69,8 @@ QVariant StylesFilteredModelBase::data(const QModelIndex &index, \
int role) const if (!index.isValid())
return QVariant();
+ return m_sourceModel->data(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0, QModelIndex()), role); +
switch (role){
case Qt::DisplayRole: {
return QVariant();
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModel.cpp index 84a6eb9..a672ccf 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModel.cpp
@@ -131,6 +131,33 @@ QVariant StylesModel::data(const QModelIndex &index, int role) \
const case Qt::SizeHintRole: {
return QVariant(QSize(250, 48));
}
+ case AbstractStylesModel::ParagraphStylePointer: {
+ if (m_modelType != AbstractStylesModel::ParagraphStyle) {
+ return QVariant();
+ }
+ KoParagraphStyle *paragStyle = m_styleManager->paragraphStyle(id);
+ if (paragStyle) {
+ QVariant variant;
+ variant.setValue<void*>(paragStyle);
+ return variant;
+ }
+ return QVariant();
+ break;
+ }
+ case AbstractStylesModel::CharacterStylePointer: {
+ if (m_modelType != AbstractStylesModel::CharacterStyle) {
+ return QVariant();
+ }
+ KoCharacterStyle *charStyle = m_styleManager->characterStyle(id);
+ if (charStyle) {
+ QVariant variant;
+ variant.setValue<void*>(charStyle);
+ return variant;
+ }
+ return QVariant();
+ break;
+
+ }
default: break;
};
return QVariant();
diff --git a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.cpp \
b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.cpp index \
9110859..2ec46db 100644
--- a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.cpp
+++ b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.cpp
@@ -48,57 +48,61 @@ CharacterHighlightingTab::CharacterHighlightingTab(QWidget* \
parent) , ui(new Ui::CharacterHighlightingTab)
{
ui->setupUi(this);
-}
-
-CharacterHighlightingTab::~CharacterHighlightingTab()
-{
- delete ui;
- ui = 0;
-}
-
-void CharacterHighlightingTab::init(bool uniqueFormat)
-{
- m_uniqueFormat = uniqueFormat;
QStringList list;
KFontChooser::getFontList(list, KFontChooser::SmoothScalableFonts);
- m_fontChooser = new KFontChooser(this, (m_uniqueFormat) ? \
KFontChooser::NoDisplayFlags : KFontChooser::ShowDifferences, list, false); + \
m_fontChooser = new KFontChooser(this, KFontChooser::NoDisplayFlags, list, false); \
m_fontChooser->setSampleBoxVisible(false); ui->fontLayout->addWidget(m_fontChooser);
+ connect(ui->fontLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotFontEnabled(bool))); + connect(m_fontChooser, SIGNAL(fontSelected(const \
QFont &)), this, SIGNAL(fontChanged(const QFont &))); + connect(m_fontChooser, \
SIGNAL(fontSelected(const QFont &)), this, SIGNAL(charStyleChanged()));
+ //capitalization
ui->capitalizationList->addItems(capitalizationList());
- ui->underlineStyle->addItems(KoText::underlineTypeList());
- ui->underlineLineStyle->addItems(KoText::underlineStyleList());
-
+ connect(ui->capitalizationList, SIGNAL(activated(int)), this, \
SLOT(slotCapitalisationChanged(int))); + connect(ui->capitalizationLabel, \
SIGNAL(toggled(bool)), this, SLOT(slotCapitalisationEnabled(bool))); +
+ //underline
+ ui->underlineStyle->addItems(KoText::lineTypeList());
+ ui->underlineLineStyle->addItems(KoText::lineStyleList());
+ connect(ui->underlineLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotUnderlineEnabled(bool))); + connect(ui->underlineStyle, \
SIGNAL(activated(int)), this, SLOT(slotUnderlineTypeChanged(int))); + \
connect(ui->underlineLineStyle, SIGNAL(activated(int)), this, \
SLOT(slotUnderlineStyleChanged(int))); + connect(ui->underlineColor, \
SIGNAL(changed(QColor)), this, SLOT(slotUnderlineColorChanged(QColor))); +
+ //position
ui->positionList->addItems(fontLayoutPositionList());
+ connect(ui->positionLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotPositionEnabled(bool))); + connect(ui->positionList, \
SIGNAL(activated(int)), this, SLOT(slotPositionChanged(int)));
- ui->strikethroughStyle->addItems(KoText::underlineTypeList()); //TODO make \
KoText consistent: either add strikethroughTypeList, or change from underlineTypeList \
to lineTypeList
- ui->strikethroughLineStyle->addItems(KoText::underlineStyleList()); //TODO idem
-
- connect(ui->underlineStyle, SIGNAL(activated(int)), this, \
SLOT(underlineTypeChanged(int)));
- connect(ui->underlineLineStyle, SIGNAL(activated(int)), this, \
SLOT(underlineStyleChanged(int)));
- connect(ui->underlineColor, SIGNAL(changed(QColor)), this, \
SLOT(underlineColorChanged(QColor))); + //strikethrough
+ ui->strikethroughStyle->addItems(KoText::lineTypeList());
+ ui->strikethroughLineStyle->addItems(KoText::lineStyleList());
+ connect(ui->strikethroughLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotStrikethroughEnabled(bool))); + connect(ui->strikethroughStyle, \
SIGNAL(activated(int)), this, SLOT(slotStrikethroughTypeChanged(int))); + \
connect(ui->strikethroughLineStyle, SIGNAL(activated(int)), this, \
SLOT(slotStrikethroughStyleChanged(int))); + connect(ui->strikethroughColor, \
SIGNAL(changed(QColor)), this, SLOT(slotStrikethroughColorChanged(QColor)));
- connect(ui->strikethroughStyle, SIGNAL(activated(int)), this, \
SLOT(strikethroughTypeChanged(int)));
- connect(ui->strikethroughLineStyle, SIGNAL(activated(int)), this, \
SLOT(strikethroughStyleChanged(int)));
- connect(ui->strikethroughColor, SIGNAL(changed(QColor)), this, \
SLOT(strikethroughColorChanged(QColor)));
-
- connect(ui->capitalizationList, SIGNAL(activated(int)), this, \
SLOT(capitalisationChanged(int)));
-
- connect(ui->positionList, SIGNAL(activated(int)), this, \
SLOT(positionChanged(int)));
-
- connect(m_fontChooser, SIGNAL(fontSelected(const QFont &)), this, \
SIGNAL(fontChanged(const QFont &)));
- connect(m_fontChooser, SIGNAL(fontSelected(const QFont &)), this, \
SIGNAL(charStyleChanged()));
const KIcon clearIcon(koIconName("edit-clear"));
+ //text color
ui->resetTextColor->setIcon(clearIcon);
+ connect(ui->textColorLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotTextColorEnabled(bool))); + connect(ui->textColor, SIGNAL(changed(const \
QColor&)), this, SLOT(slotTextColorChanged())); + connect(ui->resetTextColor, \
SIGNAL(clicked()), this, SLOT(slotClearTextColor())); +
+ //background color
ui->resetBackground->setIcon(clearIcon);
- connect(ui->textColor, SIGNAL(changed(const QColor&)), this, \
SLOT(textColorChanged()));
- connect(ui->backgroundColor, SIGNAL(changed(const QColor&)), this, \
SLOT(backgroundColorChanged()));
- connect(ui->resetTextColor, SIGNAL(clicked()), this, SLOT(clearTextColor()));
- connect(ui->resetBackground, SIGNAL(clicked()), this, \
SLOT(clearBackgroundColor()));
- connect(ui->enableText, SIGNAL(toggled(bool)), this, SLOT(textToggled(bool)));
- connect(ui->enableBackground, SIGNAL(toggled(bool)), this, \
SLOT(backgroundToggled(bool))); + connect(ui->backgroundColorLabel, \
SIGNAL(toggled(bool)), this, SLOT(slotBackgroundColorEnabled(bool))); + \
connect(ui->backgroundColor, SIGNAL(changed(const QColor&)), this, \
SLOT(slotBackgroundColorChanged())); + connect(ui->resetBackground, \
SIGNAL(clicked()), this, SLOT(slotClearBackgroundColor())); +}
+
+CharacterHighlightingTab::~CharacterHighlightingTab()
+{
+ delete ui;
+ ui = 0;
}
KoCharacterStyle::LineType CharacterHighlightingTab::indexToLineType(int index)
@@ -157,9 +161,15 @@ int \
CharacterHighlightingTab::lineStyleToIndex(KoCharacterStyle::LineStyle type) return \
index; }
-void CharacterHighlightingTab::capitalisationChanged(int item)
+void CharacterHighlightingTab::slotCapitalisationEnabled(bool enabled)
{
- if (m_uniqueFormat || ui->capitalizationList->currentIndex() >= 0) {
+ ui->capitalizationList->setEnabled(enabled);
+ emit capitalizationEnabled(enabled);
+}
+
+void CharacterHighlightingTab::slotCapitalisationChanged(int item)
+{
+// if (m_uniqueFormat || ui->capitalizationList->currentIndex() >= 0) {
switch (item) {
case 0:
emit capitalizationChanged(QFont::MixedCase);
@@ -182,110 +192,175 @@ void CharacterHighlightingTab::capitalisationChanged(int \
item) m_capitalizInherited = false;
break;
}
- }
- emit charStyleChanged();
+// }
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::positionChanged(int item)
+void CharacterHighlightingTab::slotUnderlineEnabled(bool enabled)
{
- m_positionInherited = false;
- emit charStyleChanged();
+ ui->underlineStyle->setEnabled(enabled);
+ ui->underlineColor->setEnabled(enabled && \
(ui->underlineStyle->currentIndex()>0)); + \
ui->underlineLineStyle->setEnabled(enabled && \
(ui->underlineStyle->currentIndex()>0)); + emit underlineEnabled(enabled);
}
-void CharacterHighlightingTab::underlineTypeChanged(int item)
+void CharacterHighlightingTab::slotUnderlineTypeChanged(int item)
{
- ui->underlineLineStyle->setEnabled(item > 0);
- ui->underlineColor->setEnabled(item > 0);
+ ui->underlineLineStyle->setEnabled(item > 0 && ui->underlineStyle->isEnabled());
+ ui->underlineColor->setEnabled(item > 0 && ui->underlineStyle->isEnabled());
m_underlineTypeInherited = false;
emit underlineChanged(indexToLineType(item), \
indexToLineStyle(ui->underlineLineStyle->currentIndex()), \
ui->underlineColor->color());
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::underlineStyleChanged(int item)
+void CharacterHighlightingTab::slotUnderlineStyleChanged(int item)
{
- if (ui->underlineStyle->currentIndex())
+ if (ui->underlineStyle->currentIndex()) {
emit underlineChanged(indexToLineType(ui->underlineStyle->currentIndex()), \
indexToLineStyle(item), ui->underlineColor->color()); + }
m_underlineStyleInherited = false;
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::underlineColorChanged(QColor color)
+void CharacterHighlightingTab::slotUnderlineColorChanged(QColor color)
{
- if (ui->underlineStyle->currentIndex())
+ if (ui->underlineStyle->currentIndex()) {
emit underlineChanged(indexToLineType(ui->underlineStyle->currentIndex()), \
indexToLineStyle(ui->underlineLineStyle->currentIndex()), color);
- emit charStyleChanged();
+ }
+// emit charStyleChanged();
+}
+
+void CharacterHighlightingTab::slotStrikethroughEnabled(bool enabled)
+{
+ ui->strikethroughStyle->setEnabled(enabled);
+ ui->strikethroughColor->setEnabled(enabled && \
(ui->strikethroughStyle->currentIndex()>0)); + \
ui->strikethroughLineStyle->setEnabled(enabled && \
(ui->strikethroughStyle->currentIndex()>0)); + emit strikethroughEnabled(enabled);
}
-void CharacterHighlightingTab::strikethroughTypeChanged(int item)
+void CharacterHighlightingTab::slotStrikethroughTypeChanged(int item)
{
- ui->strikethroughLineStyle->setEnabled(item > 0);
- ui->strikethroughColor->setEnabled(item > 0);
+ ui->strikethroughLineStyle->setEnabled(item > 0 && \
ui->strikethroughStyle->isEnabled()); + ui->strikethroughColor->setEnabled(item > \
0 && ui->strikethroughStyle->isEnabled()); m_strikeoutTypeInherited = false;
emit strikethroughChanged(indexToLineType(item), \
indexToLineStyle(ui->strikethroughLineStyle->currentIndex()), \
ui->strikethroughColor->color());
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::strikethroughStyleChanged(int item)
+void CharacterHighlightingTab::slotStrikethroughStyleChanged(int item)
{
- if (ui->strikethroughStyle->currentIndex())
+ if (ui->strikethroughStyle->currentIndex()) {
emit strikethroughChanged(indexToLineType(ui->strikethroughStyle->currentIndex()), \
indexToLineStyle(item), ui->strikethroughColor->color()); + }
m_strikeoutStyleInherited = false;
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::strikethroughColorChanged(QColor color)
+void CharacterHighlightingTab::slotStrikethroughColorChanged(QColor color)
{
- if (ui->strikethroughStyle->currentIndex())
+ if (ui->strikethroughStyle->currentIndex()) {
emit strikethroughChanged(indexToLineType(ui->strikethroughStyle->currentIndex()), \
indexToLineStyle(ui->strikethroughLineStyle->currentIndex()), color); + }
m_strikeoutcolorInherited = false;
- emit charStyleChanged();
+// emit charStyleChanged();
+}
+
+void CharacterHighlightingTab::slotPositionEnabled(bool enabled)
+{
+ ui->positionList->setEnabled(enabled);
+ emit positionEnabled(enabled);
+}
+
+void CharacterHighlightingTab::slotPositionChanged(int item)
+{
+ m_positionInherited = false;
+ switch(item) {
+ case 0:
+ emit positionChanged(QTextCharFormat::AlignNormal);
+ break;
+ case 1:
+ emit positionChanged(QTextCharFormat::AlignSuperScript);
+ break;
+ case 2:
+ emit positionChanged(QTextCharFormat::AlignSubScript);
+ break;
+ }
+// emit charStyleChanged();
+}
+
+void CharacterHighlightingTab::slotBackgroundColorEnabled(bool enabled)
+{
+ ui->backgroundColor->setEnabled(enabled);
+ ui->resetBackground->setEnabled(enabled);
+ emit backgroundColorEnabled(enabled);
+}
+
+void CharacterHighlightingTab::slotClearBackgroundColor()
+{
+ ui->backgroundColor->setColor(ui->backgroundColor->defaultColor());
+ m_backgroundColorReset = true;
+ emit backgroundColorChanged(QColor(Qt::transparent));
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::backgroundColorChanged()
+void CharacterHighlightingTab::slotBackgroundColorChanged()
{
m_backgroundColorReset = false; m_backgroundColorChanged = true;
- if (ui->enableBackground->isChecked() && ui->backgroundColor->color().isValid())
+// if (/*ui->enableBackground->isChecked() && \
*/ui->backgroundColor->color().isValid()) emit \
backgroundColorChanged(ui->backgroundColor->color());
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::textColorChanged()
+void CharacterHighlightingTab::slotTextColorEnabled(bool enabled)
+{
+ ui->textColor->setEnabled(enabled);
+ ui->resetTextColor->setEnabled(enabled);
+ emit textColorEnabled(enabled);
+}
+
+void CharacterHighlightingTab::slotClearTextColor()
+{
+ ui->textColor->setColor(ui->textColor->defaultColor());
+ m_textColorReset = true;
+ emit textColorChanged(QColor(Qt::black));
+// emit charStyleChanged();
+}
+
+void CharacterHighlightingTab::slotTextColorChanged()
{
m_textColorReset = false; m_textColorChanged = true;
- if (ui->enableText->isChecked() && ui->textColor->color().isValid())
+// if (/*ui->enableText->isChecked() && */ui->textColor->color().isValid())
emit textColorChanged(ui->textColor->color());
- emit charStyleChanged();
+// emit charStyleChanged();
}
-void CharacterHighlightingTab::textToggled(bool state)
+void CharacterHighlightingTab::slotFontEnabled(bool enabled)
{
- ui->textColor->setEnabled(state);
- ui->resetTextColor->setEnabled(state);
- emit charStyleChanged();
+// ui->fontChooser->setEnabled(enabled);
+ m_fontChooser->setEnabled(enabled);
+ emit fontEnabled(enabled);
}
-void CharacterHighlightingTab::backgroundToggled(bool state)
+void CharacterHighlightingTab::slotFontChanged(const QFont &font)
{
- ui->backgroundColor->setEnabled(state);
- ui->resetBackground->setEnabled(state);
- emit charStyleChanged();
+ emit slotFontChanged(font);
}
-void CharacterHighlightingTab::clearTextColor()
+/*
+void CharacterHighlightingTab::textToggled(bool state)
{
- ui->textColor->setColor(ui->textColor->defaultColor());
- m_textColorReset = true;
- emit textColorChanged(QColor(Qt::black));
+ ui->textColor->setEnabled(state);
+ ui->resetTextColor->setEnabled(state);
emit charStyleChanged();
}
-void CharacterHighlightingTab::clearBackgroundColor()
+void CharacterHighlightingTab::backgroundToggled(bool state)
{
- ui->backgroundColor->setColor(ui->backgroundColor->defaultColor());
- m_backgroundColorReset = true;
- emit backgroundColorChanged(QColor(Qt::transparent));
+ ui->backgroundColor->setEnabled(state);
+ ui->resetBackground->setEnabled(state);
emit charStyleChanged();
}
+*/
QStringList CharacterHighlightingTab::capitalizationList()
{
@@ -308,17 +383,28 @@ QStringList CharacterHighlightingTab::fontLayoutPositionList()
}
void CharacterHighlightingTab::setDisplay(KoCharacterStyle *style)
{
- if (style == 0)
+ if (style == 0) {
return;
+ }
+
+ blockSignals(true);
+ bool checked;
+ //font
QFont font = style->font();
+ checked = style->hasProperty(QTextFormat::FontFamily) || \
style->hasProperty(QTextFormat::FontItalic) || \
style->hasProperty(QTextFormat::FontWeight) || \
style->hasProperty(QTextFormat::FontPointSize); + \
ui->fontLabel->setChecked(checked); + slotFontEnabled(checked);
QFontDatabase dbase;
QStringList availableStyles = dbase.styles(font.family());
- if (font.italic() && !(availableStyles.contains(QString("Italic"))) && \
availableStyles.contains(QString("Oblique"))) + if (font.italic() && \
!(availableStyles.contains(QString("Italic"))) && \
availableStyles.contains(QString("Oblique"))) { font.setStyle(QFont::StyleOblique);
+ }
m_fontChooser->setFont(font);
+ //position
m_positionInherited = !style->hasProperty(QTextFormat::TextVerticalAlignment);
+ checked = style->hasProperty(QTextFormat::TextVerticalAlignment);
switch (style->verticalAlignment()) {
case QTextCharFormat::AlignSuperScript:
ui->positionList->setCurrentIndex(1);
@@ -330,86 +416,92 @@ void CharacterHighlightingTab::setDisplay(KoCharacterStyle \
*style) // TODO check if its custom instead.
ui->positionList->setCurrentIndex(0);
}
- if (!m_uniqueFormat){
- ui->positionList->setEnabled(false);
- ui->positionList->setCurrentIndex(-1);
- }
+ ui->positionLabel->setChecked(checked);
+ slotPositionEnabled(checked);
+ //underline
m_underlineStyleInherited = \
!style->hasProperty(KoCharacterStyle::UnderlineStyle);
m_underlineTypeInherited = !style->hasProperty(KoCharacterStyle::UnderlineType);
+
+ checked = style->hasProperty(KoCharacterStyle::UnderlineType);
+ ui->underlineStyle->setCurrentIndex(lineTypeToIndex(style->underlineType()));
+ ui->underlineLineStyle->setCurrentIndex(lineStyleToIndex(style->underlineStyle()));
+ ui->underlineColor->setColor(style->underlineColor());
+ ui->underlineLabel->setChecked(checked);
+ slotUnderlineEnabled(checked);
+
+ //strikethrough
m_strikeoutStyleInherited = \
!style->hasProperty(KoCharacterStyle::StrikeOutStyle);
m_strikeoutTypeInherited = !style->hasProperty(KoCharacterStyle::StrikeOutType);
m_strikeoutcolorInherited = \
!style->hasProperty(KoCharacterStyle::StrikeOutColor); +
+ checked = style->hasProperty(KoCharacterStyle::StrikeOutType);
+ ui->strikethroughStyle->setCurrentIndex(lineTypeToIndex(style->strikeOutType()));
+ ui->strikethroughLineStyle->setCurrentIndex(lineStyleToIndex(style->strikeOutStyle()));
+ ui->strikethroughColor->setColor(style->strikeOutColor());
+ ui->strikethroughLabel->setChecked(checked);
+ slotStrikethroughEnabled(checked);
+
+ //capitalisation
m_mixedCaseInherited = !style->hasProperty(QFont::MixedCase);
m_smallCapsInherited = !style->hasProperty(QFont::SmallCaps);
m_allUpperCaseInherited = !style->hasProperty(QFont::AllUppercase);
m_allLowerCaseInherited = !style->hasProperty(QFont::AllLowercase);
m_capitalizInherited = !style->hasProperty(QFont::Capitalize);
- //set the underline up
- ui->underlineStyle->setCurrentIndex(1);
- ui->underlineLineStyle->setCurrentIndex(lineStyleToIndex(style->underlineStyle()));
- if (m_uniqueFormat)
- ui->underlineStyle->setCurrentIndex(lineTypeToIndex(style->underlineType()));
- else
- ui->underlineStyle->setCurrentIndex(-1);
-
- underlineTypeChanged(ui->underlineStyle->currentIndex());
- ui->underlineColor->setColor(style->underlineColor());
-
- //set the strikethrough up
- ui->strikethroughStyle->setCurrentIndex(1);
- ui->strikethroughLineStyle->setCurrentIndex(lineStyleToIndex(style->strikeOutStyle()));
- if (m_uniqueFormat)
- ui->strikethroughStyle->setCurrentIndex(lineTypeToIndex(style->strikeOutType()));
- else
- ui->strikethroughStyle->setCurrentIndex(-1);
- strikethroughTypeChanged(ui->strikethroughStyle->currentIndex());
- ui->strikethroughColor->setColor(style->strikeOutColor());
-
- //Now set the capitalisation
- int index;
+ checked = style->hasProperty(QTextFormat::FontCapitalization);
switch (style->fontCapitalization()) {
- case QFont::MixedCase: ui->capitalizationList->setCurrentIndex(0);index=0; \
break;
- case QFont::SmallCaps: ui->capitalizationList->setCurrentIndex(1);index=1; \
break;
- case QFont::AllUppercase: ui->capitalizationList->setCurrentIndex(2);index=2; \
break;
- case QFont::AllLowercase: ui->capitalizationList->setCurrentIndex(3);index=3; \
break;
- case QFont::Capitalize: ui->capitalizationList->setCurrentIndex(4);index=4; \
break; + case QFont::MixedCase:
+ ui->capitalizationList->setCurrentIndex(0);
+ break;
+ case QFont::SmallCaps:
+ ui->capitalizationList->setCurrentIndex(1);
+ break;
+ case QFont::AllUppercase:
+ ui->capitalizationList->setCurrentIndex(2);
+ break;
+ case QFont::AllLowercase:
+ ui->capitalizationList->setCurrentIndex(3);
+ break;
+ case QFont::Capitalize:
+ ui->capitalizationList->setCurrentIndex(4);
+ break;
default:
ui->capitalizationList->setCurrentIndex(0);
- index =0;
break;
}
-
- if(m_uniqueFormat)
- capitalisationChanged(index);
- else{
- ui->capitalizationList->setCurrentIndex(-1);
- ui->capitalizationList->setEnabled(false);
- }
+ ui->capitalizationLabel->setChecked(checked);
+ slotCapitalisationEnabled(checked);
//Set font decoration display
- ui->enableText->setVisible(!m_uniqueFormat);
- ui->enableText->setChecked(m_uniqueFormat);
- textToggled(m_uniqueFormat);
- ui->enableBackground->setVisible(!m_uniqueFormat);
- ui->enableBackground->setChecked(m_uniqueFormat);
- backgroundToggled(m_uniqueFormat);
-
- m_textColorChanged = false;
- m_backgroundColorChanged = false;
- m_textColorReset = ! style->hasProperty(QTextFormat::ForegroundBrush);
- if (m_textColorReset || (style->foreground().style() == Qt::NoBrush)) {
- clearTextColor();
+// ui->enableText->setVisible(!m_uniqueFormat);
+// ui->enableText->setChecked(m_uniqueFormat);
+// slotTextToggled(m_uniqueFormat);
+// ui->enableBackground->setVisible(!m_uniqueFormat);
+// ui->enableBackground->setChecked(m_uniqueFormat);
+// backgroundToggled(m_uniqueFormat);
+
+ //text color
+ checked = style->hasProperty(QTextFormat::ForegroundBrush);
+ if (!style->hasProperty(QTextFormat::ForegroundBrush) || \
(style->foreground().style() == Qt::NoBrush)) { + slotClearTextColor();
} else {
ui->textColor->setColor(style->foreground().color());
}
- m_backgroundColorReset = ! style->hasProperty(QTextFormat::BackgroundBrush);
- if (m_backgroundColorReset || (style->background().style() == Qt::NoBrush)) {
- clearBackgroundColor();
+ ui->textColorLabel->setChecked(checked);
+ slotTextColorEnabled(checked);
+
+ //background color
+ checked = style->hasProperty(QTextFormat::BackgroundBrush);
+ if (!style->hasProperty(QTextFormat::BackgroundBrush) || \
(style->background().style() == Qt::NoBrush)) { + slotClearBackgroundColor();
} else {
ui->backgroundColor->setColor(style->background().color());
}
+ ui->backgroundColorLabel->setChecked(checked);
+ slotBackgroundColorEnabled(checked);
+
+ blockSignals(false);
}
void CharacterHighlightingTab::save(KoCharacterStyle *style)
@@ -486,13 +578,13 @@ void CharacterHighlightingTab::save(KoCharacterStyle *style)
}
}
- if (ui->enableBackground->isChecked() && m_backgroundColorReset)
+ if (/*ui->enableBackground->isChecked() &&*/ m_backgroundColorReset)
style->setBackground(QBrush(Qt::NoBrush));
- else if (ui->enableBackground->isChecked() && m_backgroundColorChanged)
+ else if (/*ui->enableBackground->isChecked() &&*/ m_backgroundColorChanged)
style->setBackground(QBrush(ui->backgroundColor->color()));
- if (ui->enableText->isChecked() && m_textColorReset)
+ if (/*ui->enableText->isChecked() &&*/ m_textColorReset)
style->setForeground(QBrush(Qt::NoBrush));
- else if (ui->enableText->isChecked() && m_textColorChanged)
+ else if (/*ui->enableText->isChecked() && */m_textColorChanged)
style->setForeground(QBrush(ui->textColor->color()));
}
diff --git a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.h \
b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.h index \
7ddb089..c46a9f2 100644
--- a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.h
+++ b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.h
@@ -39,41 +39,53 @@ public:
explicit CharacterHighlightingTab(QWidget* parent = 0);
~CharacterHighlightingTab();
- void init(bool uniqueFormat);
-
void setDisplay(KoCharacterStyle *style);
void save(KoCharacterStyle *style);
- QStringList capitalizationList();
- QStringList fontLayoutPositionList();
-
signals:
+ void underlineEnabled(bool);
void underlineChanged(KoCharacterStyle::LineType, KoCharacterStyle::LineStyle, \
QColor); + void strikethroughEnabled(bool);
void strikethroughChanged(KoCharacterStyle::LineType, \
KoCharacterStyle::LineStyle, QColor); + void capitalizationEnabled(bool);
void capitalizationChanged(QFont::Capitalization);
+ void fontFamilyChanged();
+ void fontEnabled(bool enabled);
void fontChanged(const QFont &font);
+ void textColorEnabled(bool);
void textColorChanged(QColor);
+ void backgroundColorEnabled(bool);
void backgroundColorChanged(QColor);
+ void positionEnabled(bool);
+ void positionChanged(QTextCharFormat::VerticalAlignment);
void charStyleChanged();
private slots:
- void underlineTypeChanged(int item);
- void underlineStyleChanged(int item);
- void underlineColorChanged(QColor color);
- void strikethroughTypeChanged(int item);
- void strikethroughStyleChanged(int item);
- void strikethroughColorChanged(QColor color);
- void capitalisationChanged(int item);
- void positionChanged(int item);
- void textToggled(bool state);
- void backgroundToggled(bool state);
- void clearTextColor();
- void clearBackgroundColor();
- void textColorChanged();
- void backgroundColorChanged();
+ void slotUnderlineEnabled(bool enabled);
+ void slotUnderlineTypeChanged(int item);
+ void slotUnderlineStyleChanged(int item);
+ void slotUnderlineColorChanged(QColor color);
+ void slotStrikethroughEnabled(bool enabled);
+ void slotStrikethroughTypeChanged(int item);
+ void slotStrikethroughStyleChanged(int item);
+ void slotStrikethroughColorChanged(QColor color);
+ void slotCapitalisationEnabled(bool enabled);
+ void slotCapitalisationChanged(int item);
+ void slotPositionEnabled(bool enabled);
+ void slotPositionChanged(int item);
+ void slotTextColorEnabled(bool enabled);
+ void slotClearTextColor();
+ void slotTextColorChanged();
+ void slotBackgroundColorEnabled(bool enabled);
+ void slotClearBackgroundColor();
+ void slotBackgroundColorChanged();
+ void slotFontEnabled(bool enabled);
+ void slotFontChanged(const QFont &font);
private:
+ QStringList capitalizationList();
+ QStringList fontLayoutPositionList();
KoCharacterStyle::LineType indexToLineType(int index);
KoCharacterStyle::LineStyle indexToLineStyle(int index);
int lineTypeToIndex(KoCharacterStyle::LineType type);
@@ -81,7 +93,7 @@ private:
Ui::CharacterHighlightingTab *ui;
- KFontChooser *m_fontChooser;
+ KFontChooser *m_fontChooser;
bool m_uniqueFormat;
bool m_underlineStyleInherited;
diff --git a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.ui \
b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.ui index \
0dcdf28..e54ac83 100644
--- a/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.ui
+++ b/plugins/textshape/dialogs/stylemanager/CharacterHighlightingTab.ui
@@ -6,187 +6,198 @@
<rect>
<x>0</x>
<y>0</y>
- <width>520</width>
- <height>456</height>
+ <width>670</width>
+ <height>438</height>
</rect>
</property>
- <layout class="QVBoxLayout">
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QGridLayout" name="fontLayout"/>
+ <widget class="QPushButton" name="fontLabel">
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout">
- <item>
- <layout class="QHBoxLayout" stretch="0,0,0,0,1">
- <item>
- <widget class="QCheckBox" name="enableText"/>
- </item>
- <item>
- <widget class="QLabel" name="textColorLabel">
- <property name="text">
- <string>Text color:</string>
- </property>
- <property name="buddy">
- <cstring>textColor</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KColorButton" name="textColor"/>
- </item>
- <item>
- <widget class="QToolButton" name="resetTextColor">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" stretch="0,0,0,0,1">
- <item>
- <widget class="QCheckBox" name="enableBackground">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="backgroundColorLabel">
- <property name="text">
- <string>Background color:</string>
- </property>
- <property name="buddy">
- <cstring>backgroundColor</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KColorButton" name="backgroundColor"/>
- </item>
- <item>
- <widget class="QToolButton" name="resetBackground">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
+ <layout class="QVBoxLayout" name="fontLayout"/>
</item>
<item>
- <layout class="QFormLayout">
- <item row="0" column="0">
- <widget class="QLabel">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="textColorLabel">
<property name="text">
- <string>Underlining:</string>
+ <string>Text color:</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
- <property name="buddy">
- <cstring>underlineStyle</cstring>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
- <layout class="QHBoxLayout">
- <item>
- <widget class="KComboBox" name="underlineStyle"/>
- </item>
- <item>
- <widget class="KComboBox" name="underlineLineStyle">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KColorButton" name="underlineColor">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="QLabel">
+ <widget class="KColorButton" name="textColor"/>
+ </item>
+ <item row="0" column="2">
+ <widget class="QToolButton" name="resetTextColor">
<property name="text">
- <string>Strikethrough:</string>
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="backgroundColorLabel">
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
</property>
- <property name="buddy">
- <cstring>strikethroughStyle</cstring>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QComboBox" name="strikethroughStyle"/>
- </item>
- <item>
- <widget class="QComboBox" name="strikethroughLineStyle">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KColorButton" name="strikethroughColor">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="0">
- <widget class="QLabel">
+ <widget class="KColorButton" name="backgroundColor"/>
+ </item>
+ <item row="1" column="2">
+ <widget class="QToolButton" name="resetBackground">
<property name="text">
- <string>Capitalization:</string>
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="underlineLabel">
+ <property name="text">
+ <string>Underlining:</string>
</property>
- <property name="buddy">
- <cstring>capitalizationList</cstring>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
+ <widget class="KComboBox" name="underlineStyle"/>
+ </item>
+ <item row="2" column="2">
+ <widget class="KComboBox" name="underlineLineStyle">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="KColorButton" name="underlineColor">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="strikethroughLabel">
+ <property name="text">
+ <string>Strikethrough:</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="strikethroughStyle"/>
+ </item>
+ <item row="3" column="2">
+ <widget class="QComboBox" name="strikethroughLineStyle">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="KColorButton" name="strikethroughColor">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="capitalizationLabel">
+ <property name="text">
+ <string>Capitalization:</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
<widget class="QComboBox" name="capitalizationList"/>
</item>
- <item row="3" column="0">
- <widget class="QLabel">
+ <item row="5" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="positionLabel">
<property name="text">
<string>Position:</string>
</property>
- <property name="buddy">
- <cstring>positionList</cstring>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="5" column="1">
<widget class="QComboBox" name="positionList"/>
</item>
</layout>
</item>
<item>
- <spacer>
+ <spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>226</height>
+ </size>
+ </property>
</spacer>
</item>
</layout>
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp \
b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp index \
3b4cf1a..cb9a38f 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.cpp
@@ -20,139 +20,120 @@
*/
#include "ParagraphIndentSpacingTab.h"
+#include "ui_ParagraphIndentSpacingTab.h"
#include <KoParagraphStyle.h>
#include <KDebug>
ParagraphIndentSpacingTab::ParagraphIndentSpacingTab(QWidget *parent)
- : QWidget(parent),
- m_fontMetricsChecked(false)
+ : QWidget(parent)
+ , ui(new Ui::ParagraphIndentSpacingTab)
+ , m_fontMetricsChecked(false)
{
- widget.setupUi(this);
+ ui->setupUi(this);
- connect(widget.first, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(firstLineMarginChanged(qreal)));
- connect(widget.left, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(leftMarginChanged(qreal)));
- connect(widget.right, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(rightMarginChanged(qreal))); + //indentation
+ connect(ui->leftLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotLeftIndentEnabled(bool))); + connect(ui->left, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotLeftIndentChanged(qreal))); + \
connect(ui->rightLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotRightIndentEnabled(bool))); + connect(ui->right, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotRightIndentChanged(qreal))); + \
connect(ui->firstLineLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotFirstLineIndentEnabled(bool))); + connect(ui->first, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotFirstLineIndentChanged(qreal))); + \
connect(ui->autoTextIndent, SIGNAL(toggled(bool)), this, \
SLOT(slotAutoTextIndentChecked(bool)));
+ //line spacing
// Keep order in sync with lineSpacingType() and display()
- widget.lineSpacing->addItem(i18nc("Line spacing value", "Single"));
- widget.lineSpacing->addItem(i18nc("Line spacing value", "1.5 Lines"));
- widget.lineSpacing->addItem(i18nc("Line spacing value", "Double"));
- widget.lineSpacing->addItem(i18nc("Line spacing type", "Proportional")); // \
called Proportional like in OO
- widget.lineSpacing->addItem(i18nc("Line spacing type", "Additional")); // \
normal distance + absolute value
- widget.lineSpacing->addItem(i18nc("Line spacing type", "Fixed"));
- widget.lineSpacing->addItem(i18nc("Line spacing type", "At least"));
-
- connect(widget.first, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(firstIndentValueChanged()));
- connect(widget.left, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(leftMarginValueChanged()));
- connect(widget.right, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(rightMarginValueChanged()));
- connect(widget.after, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(bottomMarginValueChanged()));
- connect(widget.before, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(topMarginValueChanged()));
- connect(widget.lineSpacing, SIGNAL(currentIndexChanged(int)), this, \
SLOT(lineSpacingChanged(int)));
- connect(widget.useFont, SIGNAL(toggled(bool)), this, \
SLOT(useFontMetrices(bool)));
- connect(widget.autoTextIndent, SIGNAL(stateChanged(int)), this, \
SLOT(autoTextIndentChanged(int)));
- connect(widget.proportional, SIGNAL(valueChanged(int)), this, \
SLOT(spacingPercentChanged(int)));
- connect(widget.custom, SIGNAL(valueChangedPt(qreal)), this, \
SLOT(spacingValueChanged(qreal)));
- lineSpacingChanged(0);
+ ui->lineSpacing->addItem(i18nc("Line spacing value", "Single"));
+ ui->lineSpacing->addItem(i18nc("Line spacing value", "1.5 Lines"));
+ ui->lineSpacing->addItem(i18nc("Line spacing value", "Double"));
+ ui->lineSpacing->addItem(i18nc("Line spacing type", "Proportional")); // \
called Proportional like in OO + ui->lineSpacing->addItem(i18nc("Line spacing \
type", "Additional")); // normal distance + absolute value + \
ui->lineSpacing->addItem(i18nc("Line spacing type", "Fixed")); + \
ui->lineSpacing->addItem(i18nc("Line spacing type", "At least")); + \
connect(ui->lineSpacingLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotLineSpacingEnabled(bool))); + connect(ui->lineSpacing, \
SIGNAL(currentIndexChanged(int)), this, SLOT(slotLineSpacingChanged(int))); + \
connect(ui->proportional, SIGNAL(valueChanged(int)), this, \
SLOT(slotLineSpacingPercentChanged(int))); + connect(ui->custom, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotLineSpacingValueChanged(qreal))); + \
connect(ui->useFont, SIGNAL(toggled(bool)), this, \
SLOT(slotUseFontMetricsChecked(bool))); +// blockSignals(true);
+// slotLineSpacingChanged(0);
+// blockSignals(false);
+
+ //paragraph spacing
+ connect(ui->beforeLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotTopParagraphSpacingEnabled(bool))); + connect(ui->before, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotTopParagraphSpacingChanged(qreal))); + \
connect(ui->afterLabel, SIGNAL(toggled(bool)), this, \
SLOT(slotBottomParagraphSpacingEnabled(bool))); + connect(ui->after, \
SIGNAL(valueChangedPt(qreal)), this, SLOT(slotBottomParagraphSpacingChanged(qreal))); \
}
-void ParagraphIndentSpacingTab::autoTextIndentChanged(int state)
+ParagraphIndentSpacingTab::~ParagraphIndentSpacingTab()
{
- widget.first->setEnabled(state == Qt::Unchecked);
- m_autoTextIndentInherited = false;
- emit parStyleChanged();
+ delete ui;
+ ui = 0;
}
-void ParagraphIndentSpacingTab::firstIndentValueChanged()
+
+void ParagraphIndentSpacingTab::slotLeftIndentEnabled(bool enabled)
{
- m_textIndentInherited = false;
- emit parStyleChanged();
+ ui->left->setEnabled(enabled);
+ emit leftIndentEnabled(enabled);
}
-void ParagraphIndentSpacingTab::rightMarginValueChanged()
+void ParagraphIndentSpacingTab::slotLeftIndentChanged(qreal value)
{
- m_rightMarginIngerited = false;
- emit parStyleChanged();
+ emit leftIndentChanged(value);
}
-void ParagraphIndentSpacingTab::leftMarginValueChanged()
+void ParagraphIndentSpacingTab::slotRightIndentEnabled(bool enabled)
{
- m_leftMarginInherited = false;
- emit parStyleChanged();
+ ui->right->setEnabled(enabled);
+ emit rightIndentEnabled(enabled);
}
-void ParagraphIndentSpacingTab::topMarginValueChanged()
+void ParagraphIndentSpacingTab::slotRightIndentChanged(qreal value)
{
- m_topMarginInherited = false;
- emit parStyleChanged();
+ emit rightIndentChanged(value);
}
-void ParagraphIndentSpacingTab::bottomMarginValueChanged()
+void ParagraphIndentSpacingTab::slotFirstLineIndentEnabled(bool enabled)
{
- m_bottomMarginInherited = false;
- emit parStyleChanged();
+ ui->first->setEnabled(enabled && !ui->autoTextIndent->isChecked());
+ ui->autoTextIndent->setEnabled(enabled);
+ emit firstLineIndentEnabled(enabled);
}
-void ParagraphIndentSpacingTab::setDisplay(KoParagraphStyle *style)
+void ParagraphIndentSpacingTab::slotFirstLineIndentChanged(qreal value)
{
- m_style = style;
- // TODO : handle relatives
- widget.first->changeValue(style->textIndent());
- widget.left->changeValue(style->leftMargin());
- widget.right->changeValue(style->rightMargin());
- widget.before->changeValue(style->topMargin());
- widget.after->changeValue(style->bottomMargin());
-
- m_rightMarginIngerited = !style->hasProperty(QTextFormat::BlockRightMargin);
- m_leftMarginInherited = !style->hasProperty(QTextFormat::BlockLeftMargin);
- m_topMarginInherited = !style->hasProperty(QTextFormat::BlockTopMargin);
- m_bottomMarginInherited = !style->hasProperty(QTextFormat::BlockBottomMargin);
- m_autoTextIndentInherited = \
!style->hasProperty(KoParagraphStyle::AutoTextIndent);
- m_textIndentInherited = !style->hasProperty(QTextFormat::TextIndent);
-
- widget.autoTextIndent->setChecked(style->autoTextIndent());
-
- m_spacingInherited = !(style->hasProperty(KoParagraphStyle::FixedLineHeight) || \
style->hasProperty(KoParagraphStyle::LineSpacing) || \
style->hasProperty(KoParagraphStyle::PercentLineHeight) \
||style->hasProperty(KoParagraphStyle::MinimumLineHeight));
-
- int index;
- if (style->hasProperty(KoParagraphStyle::FixedLineHeight) && \
style->lineHeightAbsolute() != 0) {
- // this is the strongest; if this is set we don't care what other properties \
there are.
- index = 5;
- } else if (style->hasProperty(KoParagraphStyle::LineSpacing) && \
style->lineSpacing() != 0) {
- // if LineSpacing is set then percent is ignored.
- index = 4;
- } else if (style->hasProperty(KoParagraphStyle::PercentLineHeight) && \
style->lineHeightPercent() != 0) {
- int percent = style->lineHeightPercent();
- if (percent == 120)
- index = 0; // single
- else if (percent == 180)
- index = 1; // 1.5
- else if (percent == 240)
- index = 2; // double
- else
- index = 3; // proportional
- } else if (style->hasProperty(KoParagraphStyle::MinimumLineHeight) && \
style->minimumLineHeight() != 0) {
- index = 6;
- } else {
- index = 0; // nothing set, default is 'single' just like for geeks.
- }
- widget.lineSpacing->setCurrentIndex(index);
- //widget.minimumLineSpacing->changeValue(style->minimumLineHeight());
- widget.useFont->setChecked(style->lineSpacingFromFont());
- m_fontMetricsChecked = style->lineSpacingFromFont();
+ emit firstLineIndentChanged(value);
+}
+
+void ParagraphIndentSpacingTab::slotAutoTextIndentChecked(bool checked)
+{
+ ui->first->setEnabled(ui->firstLineLabel->isChecked() && !checked);
+ emit autoTextIndentChecked(checked);
}
-void ParagraphIndentSpacingTab::lineSpacingChanged(int row)
+void ParagraphIndentSpacingTab::slotLineSpacingEnabled(bool enabled)
{
- bool percent = false, custom = false;
+ ui->lineSpacing->setEnabled(enabled);
+ ui->spacingStack->setEnabled(enabled);
+ ui->useFont->setEnabled(enabled);
+ 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;
- switch (row) {
+ switch (item) {
case 0:
case 1:
case 2:
break;
case 3: // proportional
percent = true;
- widget.proportional->setValue(m_style->lineHeightPercent());
+ ui->proportional->setValue(m_style->lineHeightPercent());
break;
case 4: // additional
custom = true;
@@ -175,31 +156,140 @@ void ParagraphIndentSpacingTab::lineSpacingChanged(int row)
m_spacingInherited = false;
if (custom) {
- widget.custom->setEnabled(true);
- widget.spacingStack->setCurrentWidget(widget.unitsPage);
- widget.custom->changeValue(customValue);
+ ui->custom->setEnabled(true);
+ ui->spacingStack->setCurrentWidget(ui->unitsPage);
+ ui->custom->changeValue(customValue);
} else {
- widget.spacingStack->setCurrentWidget(widget.percentPage);
- widget.proportional->setEnabled(percent);
+ ui->spacingStack->setCurrentWidget(ui->percentPage);
+ ui->proportional->setEnabled(percent);
if (! percent)
- widget.proportional->setValue(100);
+ ui->proportional->setValue(100);
}
- widget.useFont->setEnabled(row != 5);
- widget.useFont->setChecked(row == 5 ? false : m_fontMetricsChecked);
+ ui->useFont->setEnabled(item != 5);
+ ui->useFont->setChecked(item == 5 ? false : m_fontMetricsChecked);
emit parStyleChanged();
+*/
}
-void ParagraphIndentSpacingTab::spacingPercentChanged(int percent)
+void ParagraphIndentSpacingTab::slotLineSpacingPercentChanged(int percent)
{
- m_spacingInherited = false;
- emit parStyleChanged();
+ emit lineSpacingPercentChanged(percent);
}
-void ParagraphIndentSpacingTab::spacingValueChanged(qreal value)
+void ParagraphIndentSpacingTab::slotLineSpacingValueChanged(qreal value)
{
- m_spacingInherited = false;
- emit parStyleChanged();
+ emit lineSpacingValueChanged(value);
+}
+
+void ParagraphIndentSpacingTab::slotUseFontMetricsChecked(bool checked)
+{
+ emit useFontMetricsChecked(checked);
+}
+
+void ParagraphIndentSpacingTab::slotTopParagraphSpacingEnabled(bool enabled)
+{
+ ui->before->setEnabled(enabled);
+ emit topParagraphSpacingEnabled(enabled);
+}
+
+void ParagraphIndentSpacingTab::slotTopParagraphSpacingChanged(qreal value)
+{
+ emit topParagraphSpacingChanged(value);
+}
+
+void ParagraphIndentSpacingTab::slotBottomParagraphSpacingEnabled(bool enabled)
+{
+ ui->after->setEnabled(enabled);
+ emit bottomParagraphSpacingEnabled(enabled);
+}
+
+void ParagraphIndentSpacingTab::slotBottomParagraphSpacingChanged(qreal value)
+{
+ emit bottomParagraphSpacingChanged(value);
+}
+
+void ParagraphIndentSpacingTab::setDisplay(KoParagraphStyle *style)
+{
+ if (!style) {
+ return;
+ }
+ blockSignals(true);
+ bool checked;
+ // indentation
+ checked = style->hasProperty(QTextFormat::BlockLeftMargin);
+ ui->leftLabel->setChecked(checked);
+ slotLeftIndentEnabled(checked);
+ ui->left->changeValue(style->leftMargin());
+ checked = style->hasProperty(QTextFormat::BlockRightMargin);
+ ui->rightLabel->setChecked(checked);
+ slotRightIndentEnabled(checked);
+ ui->right->changeValue(style->rightMargin());
+ checked = style->hasProperty(QTextFormat::TextIndent);
+ ui->firstLineLabel->setChecked(checked);
+ ui->autoTextIndent->setChecked(style->autoTextIndent()); //set this first as \
first line indent check for this to enable/disable the spinBox + \
slotFirstLineIndentEnabled(checked); + \
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) { + // this is the strongest
+ ui->lineSpacing->setCurrentIndex(5);
+ ui->spacingStack->setCurrentWidget(ui->unitsPage);
+ ui->custom->changeValue(style->lineHeightAbsolute());
+ ui->useFont->setEnabled(false);
+ } else if (style->hasProperty(KoParagraphStyle::LineSpacing) && \
style->lineSpacing() != 0) { + // if LineSpacing is set then percent is \
ignored. + ui->lineSpacing->setCurrentIndex(4);
+ ui->spacingStack->setCurrentWidget(ui->unitsPage);
+ ui->custom->changeValue(qMax(qreal(0.1), style->lineSpacing()));
+ } else if (style->hasProperty(KoParagraphStyle::PercentLineHeight) && \
style->lineHeightPercent() != 0) { + int percent = style->lineHeightPercent();
+ if (percent == 120) {
+ ui->lineSpacing->setCurrentIndex(0); // single
+ ui->proportional->setEnabled(false);
+ }
+ else if (percent == 180) {
+ ui->lineSpacing->setCurrentIndex(1); // 1.5
+ ui->proportional->setEnabled(false);
+ }
+ else if (percent == 240) {
+ ui->lineSpacing->setCurrentIndex(2); // double
+ ui->proportional->setEnabled(false);
+ }
+ else {
+ ui->lineSpacing->setCurrentIndex(3); // proportional
+ ui->proportional->setEnabled(ui->lineSpacingLabel->isChecked());
+ }
+ ui->spacingStack->setCurrentWidget(ui->percentPage);
+ } else if (style->hasProperty(KoParagraphStyle::MinimumLineHeight) && \
style->minimumLineHeight() != 0) { + ui->lineSpacing->setCurrentIndex(6);
+ ui->spacingStack->setCurrentWidget(ui->unitsPage);
+ ui->custom->changeValue(style->minimumLineHeight());
+ } else {
+ ui->lineSpacing->setCurrentIndex(0); // nothing set, default is 'single' \
just like for geeks. + ui->proportional->setValue(120);
+ ui->proportional->setEnabled(false);
+ }
+ ui->useFont->setChecked(style->lineSpacingFromFont() && \
ui->lineSpacing->currentIndex() != 5); + m_fontMetricsChecked = \
style->lineSpacingFromFont(); +
+ //paragraph spacing
+ checked = style->hasProperty(QTextFormat::BlockTopMargin);
+ ui->beforeLabel->setChecked(checked);
+ slotTopParagraphSpacingEnabled(checked);
+ ui->before->changeValue(style->topMargin());
+ checked = style->hasProperty(QTextFormat::BlockBottomMargin);
+ ui->afterLabel->setChecked(checked);
+ slotBottomParagraphSpacingEnabled(checked);
+ ui->after->changeValue(style->bottomMargin());
+
+ blockSignals(false);
}
void ParagraphIndentSpacingTab::save(KoParagraphStyle *style)
@@ -208,83 +298,58 @@ void ParagraphIndentSpacingTab::save(KoParagraphStyle *style)
// since this dialog may be used on a copy style, which will be applied later. \
And removing // items doesn't work for that.
if (!m_textIndentInherited){
- style->setTextIndent(QTextLength(QTextLength::FixedLength, \
widget.first->value())); + \
style->setTextIndent(QTextLength(QTextLength::FixedLength, ui->first->value())); }
if (!m_leftMarginInherited){
- style->setLeftMargin(QTextLength(QTextLength::FixedLength, \
widget.left->value())); + \
style->setLeftMargin(QTextLength(QTextLength::FixedLength, ui->left->value())); }
if (!m_rightMarginIngerited){
- style->setRightMargin(QTextLength(QTextLength::FixedLength, \
widget.right->value())); + \
style->setRightMargin(QTextLength(QTextLength::FixedLength, ui->right->value())); }
if (!m_topMarginInherited){
- style->setTopMargin(QTextLength(QTextLength::FixedLength, \
widget.before->value())); + \
style->setTopMargin(QTextLength(QTextLength::FixedLength, ui->before->value())); }
if (!m_bottomMarginInherited){
- style->setBottomMargin(QTextLength(QTextLength::FixedLength, \
widget.after->value())); + \
style->setBottomMargin(QTextLength(QTextLength::FixedLength, ui->after->value())); }
if (!m_autoTextIndentInherited){
- style->setAutoTextIndent(widget.autoTextIndent->isChecked());
+ style->setAutoTextIndent(ui->autoTextIndent->isChecked());
}
if (!m_spacingInherited) {
style->setLineHeightAbsolute(0); // since it trumps percentage based line \
heights, unset it.
style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, 0));
style->setLineSpacing(0);
- switch (widget.lineSpacing->currentIndex()) {
+ switch (ui->lineSpacing->currentIndex()) {
case 0: style->setLineHeightPercent(120); break;
case 1: style->setLineHeightPercent(180); break;
case 2: style->setLineHeightPercent(240); break;
- case 3: style->setLineHeightPercent(widget.proportional->value()); break;
+ case 3: style->setLineHeightPercent(ui->proportional->value()); break;
case 4:
- if (widget.custom->value() == 0.0) { // then we need to save it \
differently. + if (ui->custom->value() == 0.0) { // then we need to save \
it differently. style->setLineHeightPercent(100);
} else {
- style->setLineSpacing(widget.custom->value());
+ style->setLineSpacing(ui->custom->value());
}
break;
case 5:
- style->setLineHeightAbsolute(widget.custom->value());
+ style->setLineHeightAbsolute(ui->custom->value());
break;
case 6:
- style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, \
widget.custom->value())); + \
style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, \
ui->custom->value())); break;
}
- style->setLineSpacingFromFont(widget.lineSpacing->currentIndex() != 5 && \
widget.useFont->isChecked()); + \
style->setLineSpacingFromFont(ui->lineSpacing->currentIndex() != 5 && \
ui->useFont->isChecked()); }
}
void ParagraphIndentSpacingTab::setUnit(const KoUnit &unit)
{
- widget.first->setUnit(unit);
- widget.left->setUnit(unit);
- widget.right->setUnit(unit);
- widget.before->setUnit(unit);
- widget.after->setUnit(unit);
- widget.custom->setUnit(unit);
-}
-
-void ParagraphIndentSpacingTab::useFontMetrices(bool on)
-{
- if (widget.lineSpacing->currentIndex() != 5)
- m_fontMetricsChecked = on;
- emit parStyleChanged();
-}
-
-void ParagraphIndentSpacingTab::firstLineMarginChanged(qreal margin)
-{
- Q_UNUSED(margin);
- emit parStyleChanged();
-}
-
-void ParagraphIndentSpacingTab::leftMarginChanged(qreal margin)
-{
- Q_UNUSED(margin);
- emit parStyleChanged();
-}
-
-void ParagraphIndentSpacingTab::rightMarginChanged(qreal margin)
-{
- Q_UNUSED(margin);
- emit parStyleChanged();
+ ui->first->setUnit(unit);
+ ui->left->setUnit(unit);
+ ui->right->setUnit(unit);
+ ui->before->setUnit(unit);
+ ui->after->setUnit(unit);
+ ui->custom->setUnit(unit);
}
#include <ParagraphIndentSpacingTab.moc>
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h \
b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h index \
18f02fb..e5305a5 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.h
@@ -20,19 +20,22 @@
#ifndef PARAGRAPHINDENTSPACINGTAB_H
#define PARAGRAPHINDENTSPACINGTAB_H
-#include <ui_ParagraphIndentSpacingTab.h>
-
#include <KoUnit.h>
#include <QWidget>
class KoParagraphStyle;
+namespace Ui {
+ class ParagraphIndentSpacingTab;
+}
+
class ParagraphIndentSpacingTab : public QWidget
{
Q_OBJECT
public:
- ParagraphIndentSpacingTab(QWidget *parent = 0);
+ explicit ParagraphIndentSpacingTab(QWidget *parent = 0);
+ ~ParagraphIndentSpacingTab();
// open and display the style
void setDisplay(KoParagraphStyle *style);
void setUnit(const KoUnit &unit);
@@ -41,25 +44,49 @@ public:
void save(KoParagraphStyle *style);
signals:
- void parStyleChanged();
+ //indentation signals
+ void leftIndentEnabled(bool enabled);
+ void leftIndentChanged(qreal value);
+ void rightIndentEnabled(bool enabled);
+ void rightIndentChanged(qreal value);
+ void firstLineIndentEnabled(bool enabled);
+ void firstLineIndentChanged(qreal value);
+ void autoTextIndentChecked(bool checked);
+ //line spacing signals
+ void lineSpacingEnabled(bool enabled);
+ 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);
+ void bottomParagraphSpacingEnabled(bool enabled);
+ void bottomParagraphSpacingChanged(qreal value);
private slots:
- void lineSpacingChanged(int);
- void spacingValueChanged(qreal value);
- void spacingPercentChanged(int percent);
- void useFontMetrices(bool);
- void autoTextIndentChanged(int state);
- void firstIndentValueChanged();
- void leftMarginValueChanged();
- void rightMarginValueChanged();
- void bottomMarginValueChanged();
- void topMarginValueChanged();
- void firstLineMarginChanged(qreal margin);
- void leftMarginChanged(qreal margin);
- void rightMarginChanged(qreal margin);
+ //indentation slots
+ void slotLeftIndentEnabled(bool enabled);
+ void slotLeftIndentChanged(qreal value);
+ void slotRightIndentEnabled(bool enabled);
+ void slotRightIndentChanged(qreal value);
+ void slotFirstLineIndentEnabled(bool enabled);
+ void slotFirstLineIndentChanged(qreal value);
+ 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);
+ //paragraph spacing slots
+ void slotTopParagraphSpacingEnabled(bool enabled);
+ void slotTopParagraphSpacingChanged(qreal value);
+ void slotBottomParagraphSpacingEnabled(bool enabled);
+ void slotBottomParagraphSpacingChanged(qreal value);
private:
- Ui::ParagraphIndentSpacingTab widget;
+ Ui::ParagraphIndentSpacingTab *ui;
KoParagraphStyle *m_style;
bool m_fontMetricsChecked;
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.ui \
b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.ui index \
288e306..ece3f1d 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.ui
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphIndentSpacingTab.ui
@@ -6,37 +6,40 @@
<rect>
<x>0</x>
<y>0</y>
- <width>449</width>
- <height>412</height>
+ <width>378</width>
+ <height>328</height>
</rect>
</property>
<property name="whatsThis">
<string><p><ul><li><b>Single</b>: The normal \
linespacing</li></ul></p> </string> </property>
- <layout class="QGridLayout">
- <item row="0" column="0">
- <widget class="QGroupBox" name="groupBox">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="indentGroupBox">
<property name="title">
<string>Indent</string>
</property>
- <layout class="QGridLayout" columnstretch="0,0,1">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="leftLabel">
<property name="text">
<string>Left:</string>
</property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
- <property name="buddy">
- <cstring>left</cstring>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KoUnitDoubleSpinBox" name="left"/>
</item>
- <item row="0" column="2" rowspan="2">
+ <item row="0" column="3" rowspan="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -49,32 +52,38 @@
</property>
</spacer>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
+ <item row="1" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="rightLabel">
<property name="text">
<string>Right:</string>
</property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
- <property name="buddy">
- <cstring>right</cstring>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KoUnitDoubleSpinBox" name="right"/>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label">
+ <item row="2" column="0" alignment="Qt::AlignRight">
+ <widget class="QPushButton" name="firstLineLabel">
<property name="text">
<string>First Line:</string>
</property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
- <property name="buddy">
- <cstring>first</cstring>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
@@ -91,16 +100,32 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox">
+ <item>
+ <widget class="QGroupBox" name="lineSpacingGroupBox">
<property name="whatsThis">
<string><p><ul><li><b>Single</b>: The normal \
linespacing</li></ul></p> </string> </property>
<property name="title">
- <string>Line Spacing</string>
+ <string/>
</property>
- <layout class="QVBoxLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0" colspan="2">
+ <widget class="QPushButton" name="lineSpacingLabel">
+ <property name="text">
+ <string>Line Spacing</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
<layout class="QHBoxLayout" stretch="0,0,1">
<property name="margin">
<number>0</number>
@@ -166,7 +191,20 @@
</item>
</layout>
</item>
- <item>
+ <item row="1" column="1" rowspan="2">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>173</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0">
<layout class="QFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
@@ -196,32 +234,57 @@
</layout>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="groupBox">
+ <item>
+ <widget class="QGroupBox" name="paragraphSpGroupBoxacing">
<property name="title">
<string>Paragraph Space</string>
</property>
- <layout class="QFormLayout">
+ <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
- <widget class="QLabel" name="label">
+ <widget class="QPushButton" name="beforeLabel">
<property name="text">
<string>Before:</string>
</property>
- <property name="buddy">
- <cstring>before</cstring>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KoUnitDoubleSpinBox" name="before"/>
</item>
+ <item row="0" column="2" rowspan="2">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>213</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item row="1" column="0">
- <widget class="QLabel" name="label">
+ <widget class="QPushButton" name="afterLabel">
<property name="text">
<string>After:</string>
</property>
- <property name="buddy">
- <cstring>after</cstring>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
</property>
</widget>
</item>
@@ -231,7 +294,7 @@
</layout>
</widget>
</item>
- <item row="3" column="0">
+ <item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp \
b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp index \
b0ac5a6..419edbb 100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.cpp
@@ -20,18 +20,230 @@
#include "ParagraphStylesTab.h"
#include "ui_ParagraphStylesTab.h"
+#include <dialogs/AbstractStylesModel.h>
+#include <dialogs/StylesDelegate.h>
+
+#include <KDebug>
+
ParagraphStylesTab::ParagraphStylesTab(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::ParagraphStylesTab)
+ QWidget(parent)
+ , ui(new Ui::ParagraphStylesTab)
+ , m_sourceModel(0)
+ , m_stylesDelegate(new StylesDelegate())
{
ui->setupUi(this);
- ui->characterHighlighting->init(true);
+ ui->paragraphListView->setItemDelegate(m_stylesDelegate);
+ connect(ui->paragraphListView, SIGNAL(activated(QModelIndex)), this, \
SLOT(slotStyleSelected(QModelIndex)));
- updateGeometry();
+ connect(ui->characterHighlighting, SIGNAL(capitalizationEnabled(bool)), this, \
SLOT(slotCapitalizationEnabled(bool))); + connect(ui->characterHighlighting, \
SIGNAL(capitalizationChanged(QFont::Capitalization)), this, \
SLOT(slotCapitalizationChanged(QFont::Capitalization))); + \
connect(ui->characterHighlighting, SIGNAL(underlineEnabled(bool)), this, \
SLOT(slotUnderlineEnabled(bool))); + connect(ui->characterHighlighting, \
SIGNAL(underlineChanged(KoCharacterStyle::LineType,KoCharacterStyle::LineStyle,QColor)), \
this, SLOT(slotUnderlineChanged(KoCharacterStyle::LineType,KoCharacterStyle::LineStyle,QColor)));
+ connect(ui->characterHighlighting, SIGNAL(strikethroughEnabled(bool)), this, \
SLOT(slotStrikethroughEnabled(bool))); + connect(ui->characterHighlighting, \
SIGNAL(strikethroughChanged(KoCharacterStyle::LineType,KoCharacterStyle::LineStyle,QColor)), \
this, SLOT(slotStrikethroughChanged(KoCharacterStyle::LineType,KoCharacterStyle::LineStyle,QColor)));
+ connect(ui->characterHighlighting, SIGNAL(positionEnabled(bool)), this, \
SLOT(slotPositionEnabled(bool))); + connect(ui->characterHighlighting, \
SIGNAL(positionChanged(QTextCharFormat::VerticalAlignment)), this, \
SLOT(slotPositionChanged(QTextCharFormat::VerticalAlignment))); + \
connect(ui->characterHighlighting, SIGNAL(backgroundColorEnabled(bool)), this, \
SLOT(slotBackgroundColorEnabled(bool))); + connect(ui->characterHighlighting, \
SIGNAL(backgroundColorChanged(QColor)), this, \
SLOT(slotBackgroundColorChanged(QColor))); + connect(ui->characterHighlighting, \
SIGNAL(textColorEnabled(bool)), this, SLOT(slotTextColorEnabled(bool))); + \
connect(ui->characterHighlighting, SIGNAL(textColorChanged(QColor)), this, \
SLOT(slotTextColorChanged(QColor))); + connect(ui->characterHighlighting, \
SIGNAL(fontEnabled(bool)), this, SLOT(slotFontEnabled(bool))); + \
connect(ui->characterHighlighting, SIGNAL(fontChanged(QFont)), this, \
SLOT(slotFontChanged(QFont))); +
+ connect(ui->indentSpacing, SIGNAL(leftIndentEnabled(bool)), this, \
SLOT(slotLeftIndentEnabled(bool))); + connect(ui->indentSpacing, \
SIGNAL(leftIndentChanged(qreal)), this, SLOT(slotLeftIndentChanged(qreal))); + \
connect(ui->indentSpacing, SIGNAL(rightIndentEnabled(bool)), this, \
SLOT(slotRightIndentEnabled(bool))); + connect(ui->indentSpacing, \
SIGNAL(rightIndentChanged(qreal)), this, SLOT(slotRightIndentChanged(qreal))); + \
connect(ui->indentSpacing, SIGNAL(firstLineIndentEnabled(bool)), this, \
SLOT(slotFirstLineIndentEnabled(bool))); + 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(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))); + connect(ui->indentSpacing, \
SIGNAL(bottomParagraphSpacingChanged(qreal)), this, \
SLOT(slotBottomParagraphSpacingChanged(qreal))); }
ParagraphStylesTab::~ParagraphStylesTab()
{
delete ui;
+ delete m_stylesDelegate;
+}
+
+void ParagraphStylesTab::setDisplay(KoParagraphStyle *style)
+{
+ ui->characterHighlighting->setDisplay(style);
+ ui->indentSpacing->setDisplay(style);
+}
+
+void ParagraphStylesTab::setStylesModel(AbstractStylesModel *model)
+{
+ m_sourceModel = model;
+ ui->paragraphListView->setModel(m_sourceModel);
+}
+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);
+ }
+}
+
+void ParagraphStylesTab::slotCapitalizationEnabled(bool enabled)
+{
+ kDebug() << "capitalization enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotCapitalizationChanged(QFont::Capitalization \
capitalization) +{
+ kDebug() << "capitalization changed: " << capitalization;
+}
+
+void ParagraphStylesTab::slotUnderlineEnabled(bool enabled)
+{
+ kDebug() << "underline enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotUnderlineChanged(KoCharacterStyle::LineType lineType, \
KoCharacterStyle::LineStyle lineStyle, QColor lineColor) +{
+ kDebug() << "underline changed type: " << lineType << " style: " << lineStyle << \
" color: " << lineColor; +}
+
+void ParagraphStylesTab::slotStrikethroughEnabled(bool enabled)
+{
+ kDebug() << "strikethrough enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotStrikethroughChanged(KoCharacterStyle::LineType \
lineType, KoCharacterStyle::LineStyle lineStyle, QColor lineColor) +{
+ kDebug() << "strikethrough changed type: " << lineType << " style: " << \
lineStyle << " color: " << lineColor; +}
+
+void ParagraphStylesTab::slotPositionEnabled(bool enabled)
+{
+ kDebug() << "position enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotPositionChanged(QTextCharFormat::VerticalAlignment \
alignment) +{
+ kDebug() << "position changed: " << alignment;
+}
+
+void ParagraphStylesTab::slotBackgroundColorEnabled(bool enabled)
+{
+ kDebug() << "backgroundColor enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotBackgroundColorChanged(QColor color)
+{
+ kDebug() << "backgroundColor changed: " << color;
+}
+
+void ParagraphStylesTab::slotTextColorEnabled(bool enabled)
+{
+ kDebug() << "textColor enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotTextColorChanged(QColor color)
+{
+ kDebug() << "textColor changed: " << color;
+}
+
+void ParagraphStylesTab::slotFontEnabled(bool enabled)
+{
+ kDebug() << "font enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotFontChanged(const QFont &font)
+{
+ kDebug() << "font changed: " << font;
+}
+
+//indentation slots
+void ParagraphStylesTab::slotLeftIndentEnabled(bool enabled)
+{
+ kDebug() << "leftIndent enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotLeftIndentChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
+}
+
+void ParagraphStylesTab::slotRightIndentEnabled(bool enabled)
+{
+ kDebug() << "rightIndent enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotRightIndentChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
+}
+
+void ParagraphStylesTab::slotFirstLineIndentEnabled(bool enabled)
+{
+ kDebug() << "firstLineIndent enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotFirstLineIndentChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
+}
+
+void ParagraphStylesTab::slotAutoTextIndentChecked(bool checked)
+{
+ kDebug() << "checked: " << checked;
+}
+
+//line spacing slots
+void ParagraphStylesTab::slotLineSpacingEnabled(bool enabled)
+{
+ kDebug() << "leftSpacing enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotLineSpacingChanged(int item)
+{
+ kDebug() << "selected item: " << item;
+}
+
+void ParagraphStylesTab::slotLineSpacingValueChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
+}
+
+void ParagraphStylesTab::slotLineSpacingPercentChanged(int percent)
+{
+ kDebug() << "percent: " << percent;
+}
+
+void ParagraphStylesTab::slotUseFontMetricsChecked(bool checked)
+{
+ kDebug() << "checked: " << checked;
+}
+
+//paragraph spacing slots
+void ParagraphStylesTab::slotTopParagraphSpacingEnabled(bool enabled)
+{
+ kDebug() << "topSpacing enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotTopParagraphSpacingChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
+}
+
+void ParagraphStylesTab::slotBottomParagraphSpacingEnabled(bool enabled)
+{
+ kDebug() << "bottomSpacing enabled: " << enabled;
+}
+
+void ParagraphStylesTab::slotBottomParagraphSpacingChanged(qreal value)
+{
+ kDebug() << "new value: " << value;
}
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h \
b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h index e5eb704..6c45486 \
100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.h
@@ -20,8 +20,15 @@
#ifndef PARAGRAPHSTYLESTAB_H
#define PARAGRAPHSTYLESTAB_H
+#include <KoCharacterStyle.h>
+#include <KoParagraphStyle.h>
+
+#include <QModelIndex>
#include <QWidget>
+class AbstractStylesModel;
+class StylesDelegate;
+
namespace Ui {
class ParagraphStylesTab;
}
@@ -29,13 +36,57 @@ class ParagraphStylesTab;
class ParagraphStylesTab : public QWidget
{
Q_OBJECT
-
+
public:
explicit ParagraphStylesTab(QWidget *parent = 0);
~ParagraphStylesTab();
-
+
+ void setStylesModel(AbstractStylesModel *model);
+ void setDisplay(KoParagraphStyle *style);
+
+private slots:
+ void slotStyleSelected(const QModelIndex &index);
+
+ void slotCapitalizationEnabled(bool enabled);
+ void slotCapitalizationChanged(QFont::Capitalization capitalization);
+ void slotUnderlineEnabled(bool enabled);
+ void slotUnderlineChanged(KoCharacterStyle::LineType lineType, \
KoCharacterStyle::LineStyle lineStyle, QColor lineColor); + void \
slotStrikethroughEnabled(bool enabled); + void \
slotStrikethroughChanged(KoCharacterStyle::LineType lineType, \
KoCharacterStyle::LineStyle lineStyle, QColor lineColor); + void \
slotPositionEnabled(bool enabled); + void \
slotPositionChanged(QTextCharFormat::VerticalAlignment alignment); + void \
slotBackgroundColorEnabled(bool enabled); + void slotBackgroundColorChanged(QColor \
color); + void slotTextColorEnabled(bool enabled);
+ void slotTextColorChanged(QColor color);
+ void slotFontEnabled(bool enabled);
+ void slotFontChanged(const QFont &font);
+
+ //indentation slots
+ void slotLeftIndentEnabled(bool enabled);
+ void slotLeftIndentChanged(qreal value);
+ void slotRightIndentEnabled(bool enabled);
+ void slotRightIndentChanged(qreal value);
+ void slotFirstLineIndentEnabled(bool enabled);
+ void slotFirstLineIndentChanged(qreal value);
+ 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);
+ //paragraph spacing slots
+ void slotTopParagraphSpacingEnabled(bool enabled);
+ void slotTopParagraphSpacingChanged(qreal value);
+ void slotBottomParagraphSpacingEnabled(bool enabled);
+ void slotBottomParagraphSpacingChanged(qreal value);
+
private:
Ui::ParagraphStylesTab *ui;
+
+ AbstractStylesModel *m_sourceModel;
+ StylesDelegate *m_stylesDelegate;
};
#endif // PARAGRAPHSTYLESTAB_H
diff --git a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.ui \
b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.ui index c91c717..056884b \
100644
--- a/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.ui
+++ b/plugins/textshape/dialogs/stylemanager/ParagraphStylesTab.ui
@@ -36,6 +36,11 @@
<property name="documentMode">
<bool>true</bool>
</property>
+ <widget class="QWidget" name="paragraphGeneral">
+ <attribute name="title">
+ <string>Page</string>
+ </attribute>
+ </widget>
<widget class="CharacterHighlightingTab" name="characterHighlighting">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
diff --git a/plugins/textshape/dialogs/stylemanager/StylesManager.cpp \
b/plugins/textshape/dialogs/stylemanager/StylesManager.cpp index 9395a39..3aac589 \
100644
--- a/plugins/textshape/dialogs/stylemanager/StylesManager.cpp
+++ b/plugins/textshape/dialogs/stylemanager/StylesManager.cpp
@@ -20,9 +20,17 @@
#include "StylesManager.h"
#include "ui_StylesManager.h"
+#include "StylesManagerStylesModel.h"
+
+#include <dialogs/StylesModel.h>
+
+#include <KoParagraphStyle.h>
+#include <KoStyleThumbnailer.h>
+
StylesManager::StylesManager(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::StylesManager)
+ QDialog(parent)
+ , ui(new Ui::StylesManager)
+ , m_styleManager(0)
{
ui->setupUi(this);
}
@@ -31,3 +39,25 @@ StylesManager::~StylesManager()
{
delete ui;
}
+
+void StylesManager::setStyleManager(KoStyleManager *styleManager)
+{
+ Q_ASSERT(styleManager);
+ if (!styleManager) {
+ return; //don't crash but should never happen
+ }
+ m_styleManager = styleManager;
+
+ StylesModel *stylesModel = new StylesModel(m_styleManager, \
AbstractStylesModel::ParagraphStyle); + KoStyleThumbnailer *thumbnailer = new \
KoStyleThumbnailer(); + stylesModel->setStyleThumbnailer(thumbnailer);
+
+ StylesManagerStylesModel *paragraphStylesModel = new StylesManagerStylesModel();
+ paragraphStylesModel->setStylesModel(stylesModel);
+ ui->paragraphTab->setStylesModel(paragraphStylesModel);
+}
+
+void StylesManager::setParagraphStyle(KoParagraphStyle *style)
+{
+ ui->paragraphTab->setDisplay(style);
+}
diff --git a/plugins/textshape/dialogs/stylemanager/StylesManager.h \
b/plugins/textshape/dialogs/stylemanager/StylesManager.h index d9493a9..489432b \
100644
--- a/plugins/textshape/dialogs/stylemanager/StylesManager.h
+++ b/plugins/textshape/dialogs/stylemanager/StylesManager.h
@@ -20,8 +20,12 @@
#ifndef STYLESMANAGER_H
#define STYLESMANAGER_H
+#include <KoParagraphStyle.h>
+
#include <QDialog>
+class KoStyleManager;
+
namespace Ui {
class StylesManager;
}
@@ -29,13 +33,18 @@ class StylesManager;
class StylesManager : public QDialog
{
Q_OBJECT
-
+
public:
explicit StylesManager(QWidget *parent = 0);
~StylesManager();
-
+
+ void setStyleManager(KoStyleManager *styleManager);
+ void setParagraphStyle(KoParagraphStyle *style);
+
private:
Ui::StylesManager *ui;
+
+ KoStyleManager *m_styleManager;
};
#endif // STYLESMANAGER_H
diff --git a/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.cpp \
b/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.cpp new file mode \
100644 index 0000000..793a7e3
--- /dev/null
+++ b/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.cpp
@@ -0,0 +1,150 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2013 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * 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 "StylesManagerStylesModel.h"
+
+#include <KLocale>
+
+#include <QImage>
+
+#include <KDebug>
+
+StylesManagerStylesModel::StylesManagerStylesModel(QObject *parent) :
+ StylesFilteredModelBase(parent)
+{
+}
+
+StylesManagerStylesModel::~StylesManagerStylesModel()
+{
+
+}
+
+Qt::ItemFlags StylesManagerStylesModel::flags(const QModelIndex &index) const
+{
+ if (index.internalId() == NewStyleId || index.internalId() == ExistingStyleId) {
+ return (Qt::NoItemFlags);
+ }
+ return m_sourceModel->flags(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0, QModelIndex())); +}
+
+QModelIndex StylesManagerStylesModel::index(int row, int column, const QModelIndex \
&parent) const +{
+ if (row < 0 || column != 0)
+ return QModelIndex();
+
+ if (!parent.isValid()) {
+ if (row >= m_proxyToSource.count()) {
+ return QModelIndex();
+ }
+ //m_proxyToSource stores a mix of internalIds (negative, specific to this \
model) and row number in the source model + return createIndex(row, column, \
(m_proxyToSource.at(row) >= 0)?int(m_sourceModel->index(m_proxyToSource.at(row), 0, \
QModelIndex()).internalId()):m_proxyToSource.at(row)); + }
+ return QModelIndex();
+}
+
+QVariant StylesManagerStylesModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ switch (role){
+ case AbstractStylesModel::isTitleRole: {
+ if (index.internalId() == NewStyleId || index.internalId() == \
ExistingStyleId) { + return true;
+ }
+ break;
+ }
+ case Qt::DisplayRole: {
+ if (index.internalId() == NewStyleId) {
+ return i18n("New Styles");
+ }
+ if (index.internalId() == ExistingStyleId) {
+ return i18n("Existing Styles");
+ }
+ break;
+ }
+ case Qt::DecorationRole: {
+ if (index.internalId() >= 0) {
+ return m_sourceModel->data(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0, QModelIndex()), role); + }
+ else {
+ /// TODO: create thumbnail for the new/unsaved style there
+ }
+ break;
+ }
+ case Qt::SizeHintRole: {
+ return QVariant(QSize(250, 48));
+ }
+ default: break;
+ };
+ if (index.internalId() >= 0) {
+ return m_sourceModel->data(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0, QModelIndex()), role); + }
+ return QVariant();
+}
+
+QModelIndex StylesManagerStylesModel::indexForCharacterStyle(const KoCharacterStyle \
&style) const +{
+ if (&style) {
+ QModelIndex sourceIndex(m_sourceModel->indexForCharacterStyle(style));
+
+ if (!sourceIndex.isValid() || (m_sourceToProxy.at(sourceIndex.row()) < 0)) {
+ return QModelIndex();
+ }
+ return createIndex(m_sourceToProxy.at(sourceIndex.row()), 0, \
int(sourceIndex.internalId())); + }
+ return QModelIndex();
+}
+
+QImage StylesManagerStylesModel::stylePreview(const QModelIndex &index, QSize size)
+{
+ if (!index.isValid()) {
+ return QImage();
+ }
+ /// TODO create preview for new/unsaved styles
+ return m_sourceModel->stylePreview(m_sourceModel->index(m_proxyToSource.at(index.row()), \
0), size); +}
+
+void StylesManagerStylesModel::createMapping()
+{
+ Q_ASSERT(m_sourceModel);
+ if (!m_sourceModel) {
+ return;
+ }
+
+ m_proxyToSource.clear();
+ m_sourceToProxy.clear();
+
+ if (!m_newStylesId.isEmpty()) {
+ m_proxyToSource << NewStyleId << m_newStylesId;
+ }
+
+ if (m_sourceModel->rowCount()) {
+ m_proxyToSource << ExistingStyleId;
+ for(int i = 0; i < m_sourceModel->rowCount(QModelIndex()); ++i) {
+ m_proxyToSource.append(i);
+ }
+ }
+ m_sourceToProxy.fill(-1, m_sourceModel->rowCount(QModelIndex()));
+ for (int i = 0; i < m_proxyToSource.count(); ++i) {
+ if (m_proxyToSource.at(i) >= 0) { //we do not need to map to the titles
+ m_sourceToProxy[m_proxyToSource.at(i)] = i;
+ }
+ }
+}
diff --git a/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.h \
b/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.h new file mode \
100644 index 0000000..1ae9132
--- /dev/null
+++ b/plugins/textshape/dialogs/stylemanager/StylesManagerStylesModel.h
@@ -0,0 +1,79 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2013 Pierre Stirnweiss <pstirnweiss@googlemail.org>
+ *
+ * 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.
+ */
+
+#ifndef STYLESMANAGERSTYLESMODEL_H
+#define STYLESMANAGERSTYLESMODEL_H
+
+#include "dialogs/StylesFilteredModelBase.h"
+
+class StylesManagerStylesModel : public StylesFilteredModelBase
+{
+ Q_OBJECT
+public:
+
+ enum StylesManagerStylesModelInternalIds {
+ NewStyleId = -32000,
+ ExistingStyleId = -32001
+ };
+
+ explicit StylesManagerStylesModel(QObject *parent = 0);
+
+ ~StylesManagerStylesModel();
+
+ /** ***************** Re-implement from QAbstractItemModel. */
+
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
+
+ virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) \
const; +
+ /** ***************** Re-implement from the AbstractStylesModel */
+
+ virtual QModelIndex indexForCharacterStyle(const KoCharacterStyle &style) const;
+
+ virtual QImage stylePreview(const QModelIndex &index, QSize size);
+
+ /** Specific methods of the StylesManagerStylesModel. */
+
+// void setStyleManager(KoStyleManager *sm);
+
+// void setInitialUsedStyles(QVector<int> usedStyles);
+
+ /** Specifies which paragraph style is currently the active one (on the current \
paragraph). This is used in order to properly preview the "As paragraph" virtual \
character style. */ +// void setCurrentParagraphStyle(int styleId);
+
+signals:
+
+public slots:
+// void slotCreateNewStyle();
+
+protected:
+ virtual void createMapping();
+
+private:
+// KoStyleManager *m_styleManager;
+// KoParagraphStyle *m_currentParagraphStyle;
+// KoCharacterStyle *m_defaultCharacterStyle;
+ QVector<int> m_newStylesId;
+// QVector<int> m_usedStyles;
+// QVector<int> m_unusedStyles;
+};
+
+#endif // STYLESMANAGERSTYLESMODEL_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic