[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.6] plugins/textshape/dialogs: Make sure we actually apply strikethrough and und
From:       C. Boemann <cbo () boemann ! dk>
Date:       2013-01-30 20:59:44
Message-ID: 20130130205944.84C17A6091 () git ! kde ! org
[Download RAW message or body]

Git commit 097104374d4bd8f7b126aca2423e0d98a0ca1ea1 by C. Boemann.
Committed on 30/01/2013 at 21:44.
Pushed by boemann into branch 'calligra/2.6'.

Make sure we actually apply strikethrough and underline styles from character dialog
typ
There were several logical errors in the previous code. Basically you had to select
both a type and a style in order to apply. Now selecting a type implies you have also \
selected a style.

M  +37   -42   plugins/textshape/dialogs/CharacterHighlighting.cpp
M  +2    -5    plugins/textshape/dialogs/CharacterHighlighting.h
M  +24   -6    plugins/textshape/dialogs/CharacterHighlighting.ui

http://commits.kde.org/calligra/097104374d4bd8f7b126aca2423e0d98a0ca1ea1

diff --git a/plugins/textshape/dialogs/CharacterHighlighting.cpp \
b/plugins/textshape/dialogs/CharacterHighlighting.cpp index c2477fd..5c78c69 100644
--- a/plugins/textshape/dialogs/CharacterHighlighting.cpp
+++ b/plugins/textshape/dialogs/CharacterHighlighting.cpp
@@ -58,14 +58,14 @@ CharacterHighlighting::CharacterHighlighting(bool \
uniqueFormat,QWidget* parent)  
     widget.positionList->addItems(fontLayoutPositionList());
 
-    widget.strikethroughStyle->addItems(KoText::underlineTypeList()); //TODO make \
KoText consistent: either add strikethroughTypeList, or change from underlineTypeList \
to lineTypeList +    widget.strikethroughType->addItems(KoText::underlineTypeList()); \
//TODO make KoText consistent: either add strikethroughTypeList, or change from \
                underlineTypeList to lineTypeList
     widget.strikethroughLineStyle->addItems(KoText::underlineStyleList()); //TODO \
idem  
     connect(widget.underlineStyle, SIGNAL(activated(int)), this, \
                SLOT(underlineTypeChanged(int)));
     connect(widget.underlineLineStyle, SIGNAL(activated(int)), this, \
                SLOT(underlineStyleChanged(int)));
     connect(widget.underlineColor, SIGNAL(changed(QColor)), this, \
SLOT(underlineColorChanged(QColor)));  
-    connect(widget.strikethroughStyle, SIGNAL(activated(int)), this, \
SLOT(strikethroughTypeChanged(int))); +    connect(widget.strikethroughType, \
                SIGNAL(activated(int)), this, SLOT(strikethroughTypeChanged(int)));
     connect(widget.strikethroughLineStyle, SIGNAL(activated(int)), this, \
                SLOT(strikethroughStyleChanged(int)));
     connect(widget.strikethroughColor, SIGNAL(changed(QColor)), this, \
SLOT(strikethroughColorChanged(QColor)));  
@@ -182,7 +182,7 @@ void CharacterHighlighting::underlineTypeChanged(int item)
 {
     widget.underlineLineStyle->setEnabled(item > 0);
     widget.underlineColor->setEnabled(item > 0);
-    m_underlineTypeInherited = false;
+    m_underlineInherited = false;
     emit underlineChanged(indexToLineType(item), \
indexToLineStyle(widget.underlineLineStyle->currentIndex()), \
widget.underlineColor->color());  emit charStyleChanged();
 }
@@ -191,7 +191,7 @@ void CharacterHighlighting::underlineStyleChanged(int item)
 {
     if (widget.underlineStyle->currentIndex())
         emit underlineChanged(indexToLineType(widget.underlineStyle->currentIndex()), \
                indexToLineStyle(item), widget.underlineColor->color());
-    m_underlineStyleInherited = false;
+    m_underlineInherited = false;
     emit charStyleChanged();
 }
 
@@ -199,6 +199,7 @@ void CharacterHighlighting::underlineColorChanged(QColor color)
 {
     if (widget.underlineStyle->currentIndex())
         emit underlineChanged(indexToLineType(widget.underlineStyle->currentIndex()), \
indexToLineStyle(widget.underlineLineStyle->currentIndex()), color); +    \
m_underlineInherited = false;  emit charStyleChanged();
 }
 
@@ -206,24 +207,24 @@ void CharacterHighlighting::strikethroughTypeChanged(int item)
 {
     widget.strikethroughLineStyle->setEnabled(item > 0);
     widget.strikethroughColor->setEnabled(item > 0);
-    m_strikeoutTypeInherited = false;
+    m_strikeoutInherited = false;
     emit strikethroughChanged(indexToLineType(item), \
indexToLineStyle(widget.strikethroughLineStyle->currentIndex()), \
widget.strikethroughColor->color());  emit charStyleChanged();
 }
 
 void CharacterHighlighting::strikethroughStyleChanged(int item)
 {
-    if (widget.strikethroughStyle->currentIndex())
-        emit strikethroughChanged(indexToLineType(widget.strikethroughStyle->currentIndex()), \
                indexToLineStyle(item), widget.strikethroughColor->color());
-    m_strikeoutStyleInherited = false;
+    if (widget.strikethroughType->currentIndex())
+        emit strikethroughChanged(indexToLineType(widget.strikethroughType->currentIndex()), \
indexToLineStyle(item), widget.strikethroughColor->color()); +    \
m_strikeoutInherited = false;  emit charStyleChanged();
 }
 
 void CharacterHighlighting::strikethroughColorChanged(QColor color)
 {
-    if (widget.strikethroughStyle->currentIndex())
-        emit strikethroughChanged(indexToLineType(widget.strikethroughStyle->currentIndex()), \
                indexToLineStyle(widget.strikethroughLineStyle->currentIndex()), \
                color);
-    m_strikeoutcolorInherited = false;
+    if (widget.strikethroughType->currentIndex())
+        emit strikethroughChanged(indexToLineType(widget.strikethroughType->currentIndex()), \
indexToLineStyle(widget.strikethroughLineStyle->currentIndex()), color); +    \
m_strikeoutInherited = false;  emit charStyleChanged();
 }
 
@@ -321,11 +322,12 @@ void CharacterHighlighting::setDisplay(KoCharacterStyle *style)
         widget.positionList->setCurrentIndex(-1);
     }
 
-    m_underlineStyleInherited = \
                !style->hasProperty(KoCharacterStyle::UnderlineStyle);
-    m_underlineTypeInherited = !style->hasProperty(KoCharacterStyle::UnderlineType);
-    m_strikeoutStyleInherited = \
                !style->hasProperty(KoCharacterStyle::StrikeOutStyle);
-    m_strikeoutTypeInherited = !style->hasProperty(KoCharacterStyle::StrikeOutType);
-    m_strikeoutcolorInherited = \
!style->hasProperty(KoCharacterStyle::StrikeOutColor); +    m_underlineInherited = \
!style->hasProperty(KoCharacterStyle::UnderlineStyle) +                            && \
!style->hasProperty(KoCharacterStyle::UnderlineType) +                            && \
!style->hasProperty(QTextFormat::TextUnderlineColor); +    m_strikeoutInherited = \
!style->hasProperty(KoCharacterStyle::StrikeOutStyle) +                            && \
!style->hasProperty(KoCharacterStyle::StrikeOutType) +                            && \
!style->hasProperty(KoCharacterStyle::StrikeOutColor);  m_mixedCaseInherited = \
!style->hasProperty(QFont::MixedCase);  m_smallCapsInherited = \
!style->hasProperty(QFont::SmallCaps);  m_allUpperCaseInherited = \
!style->hasProperty(QFont::AllUppercase); @@ -344,13 +346,13 @@ void \
CharacterHighlighting::setDisplay(KoCharacterStyle *style)  \
widget.underlineColor->setColor(style->underlineColor());  
     //set the strikethrough up
-    widget.strikethroughStyle->setCurrentIndex(1);
+    widget.strikethroughType->setCurrentIndex(1);
     widget.strikethroughLineStyle->setCurrentIndex(lineStyleToIndex(style->strikeOutStyle()));
  if (m_uniqueFormat)
-        widget.strikethroughStyle->setCurrentIndex(lineTypeToIndex(style->strikeOutType()));
 +        widget.strikethroughType->setCurrentIndex(lineTypeToIndex(style->strikeOutType()));
  else
-        widget.strikethroughStyle->setCurrentIndex(-1);
-    strikethroughTypeChanged(widget.strikethroughStyle->currentIndex());
+        widget.strikethroughType->setCurrentIndex(-1);
+    strikethroughTypeChanged(widget.strikethroughType->currentIndex());
     widget.strikethroughColor->setColor(style->strikeOutColor());
 
     //Now set the capitalisation
@@ -416,33 +418,26 @@ void CharacterHighlighting::save(KoCharacterStyle *style)
         style->setFontItalic(m_fontChooser->font().italic()); //TODO should set \
style instead of italic  }
 
-    if (widget.underlineStyle->currentIndex() == 0) {
-        style->setUnderlineType(KoCharacterStyle::NoLineType);
-        style->setUnderlineStyle(KoCharacterStyle::NoLineStyle);
-    } else if (widget.underlineStyle->currentIndex() > 0) {
-        if (!m_underlineTypeInherited) {
-            style->setUnderlineType(indexToLineType(widget.underlineStyle->currentIndex()));
                
-        }
-        if (!m_underlineStyleInherited) {
-            style->setUnderlineStyle(indexToLineStyle(widget.underlineLineStyle->currentIndex()));
                
-        }
+    if (!m_underlineInherited) {
+        style->setUnderlineStyle(indexToLineStyle(widget.underlineLineStyle->currentIndex()));
  style->setUnderlineColor(widget.underlineColor->color());
+        style->setUnderlineType(indexToLineType(widget.underlineStyle->currentIndex()));
 +        if (widget.underlineStyle->currentIndex() == 0) {
+            style->setUnderlineStyle(KoCharacterStyle::NoLineStyle);
+        }
     }
 
-    if (widget.strikethroughStyle->currentIndex() == 0) {
-        style->setStrikeOutType(KoCharacterStyle::NoLineType);
-        style->setStrikeOutStyle(KoCharacterStyle::NoLineStyle);
-    } else if (widget.strikethroughStyle->currentIndex() > 0) {
-        if (!m_strikeoutTypeInherited) {
-            style->setStrikeOutType(indexToLineType(widget.strikethroughStyle->currentIndex()));
                
-        }
-        if (!m_strikeoutStyleInherited) {
-            style->setStrikeOutStyle(indexToLineStyle(widget.strikethroughLineStyle->currentIndex()));
                
-        }
-        if (!m_strikeoutcolorInherited) {
-            style->setStrikeOutColor(widget.strikethroughColor->color());
+
+    if (!m_strikeoutInherited) {
+        style->setStrikeOutStyle(indexToLineStyle(widget.strikethroughLineStyle->currentIndex()));
 +        style->setStrikeOutColor(widget.strikethroughColor->color());
+        style->setStrikeOutType(indexToLineType(widget.strikethroughType->currentIndex()));
 +        if (widget.strikethroughType->currentIndex() == 0) {
+            style->setStrikeOutStyle(KoCharacterStyle::NoLineStyle);
         }
     }
+
+
     if (m_uniqueFormat || widget.capitalizationList->currentIndex() >= 0) {
         if (widget.capitalizationList->currentIndex() == 0 && !m_mixedCaseInherited)
             style->setFontCapitalization(QFont::MixedCase);
diff --git a/plugins/textshape/dialogs/CharacterHighlighting.h \
b/plugins/textshape/dialogs/CharacterHighlighting.h index bb1e13c..2c67338 100644
--- a/plugins/textshape/dialogs/CharacterHighlighting.h
+++ b/plugins/textshape/dialogs/CharacterHighlighting.h
@@ -80,11 +80,8 @@ private:
      KFontChooser *m_fontChooser;
 
     bool m_uniqueFormat;
-    bool m_underlineStyleInherited;
-    bool m_underlineTypeInherited;
-    bool m_strikeoutStyleInherited;
-    bool m_strikeoutcolorInherited;
-    bool m_strikeoutTypeInherited;
+    bool m_underlineInherited;
+    bool m_strikeoutInherited;
     bool m_mixedCaseInherited;
     bool m_smallCapsInherited;
     bool m_allUpperCaseInherited;
diff --git a/plugins/textshape/dialogs/CharacterHighlighting.ui \
b/plugins/textshape/dialogs/CharacterHighlighting.ui index ed91e39..6427b15 100644
--- a/plugins/textshape/dialogs/CharacterHighlighting.ui
+++ b/plugins/textshape/dialogs/CharacterHighlighting.ui
@@ -46,6 +46,12 @@
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
         </spacer>
        </item>
       </layout>
@@ -84,6 +90,12 @@
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
         </spacer>
        </item>
       </layout>
@@ -93,7 +105,7 @@
    <item>
     <layout class="QFormLayout">
      <item row="0" column="0">
-      <widget class="QLabel">
+      <widget class="QLabel" name="label">
        <property name="text">
         <string>Underlining:</string>
        </property>
@@ -124,19 +136,19 @@
       </layout>
      </item>
      <item row="1" column="0">
-      <widget class="QLabel">
+      <widget class="QLabel" name="label">
        <property name="text">
         <string>Strikethrough:</string>
        </property>
        <property name="buddy">
-        <cstring>strikethroughStyle</cstring>
+        <cstring>strikethroughType</cstring>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
       <layout class="QHBoxLayout">
        <item>
-        <widget class="QComboBox" name="strikethroughStyle"/>
+        <widget class="QComboBox" name="strikethroughType"/>
        </item>
        <item>
         <widget class="QComboBox" name="strikethroughLineStyle">
@@ -155,7 +167,7 @@
       </layout>
      </item>
      <item row="2" column="0">
-      <widget class="QLabel">
+      <widget class="QLabel" name="label">
        <property name="text">
         <string>Capitalization:</string>
        </property>
@@ -168,7 +180,7 @@
       <widget class="QComboBox" name="capitalizationList"/>
      </item>
      <item row="3" column="0">
-      <widget class="QLabel">
+      <widget class="QLabel" name="label">
        <property name="text">
         <string>Position:</string>
        </property>
@@ -187,6 +199,12 @@
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>0</width>
+       <height>0</height>
+      </size>
+     </property>
     </spacer>
    </item>
   </layout>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic