[lokalize] src: Add an option to display separators

Simon Depiets null at kde.org
Wed Sep 26 08:25:21 BST 2018


Git commit 938de1bd201f688cf2c3ef5c33fa3dc5d2ca5a98 by Simon Depiets.
Committed on 26/09/2018 at 07:23.
Pushed by sdepiets into branch 'master'.

Add an option to display separators

FEATURE: 274236
CCMAIL: ykatabam at redhat.com
GUI:

M  +5    -0    src/editorview.cpp
M  +3    -0    src/prefs/lokalize.kcfg
M  +7    -0    src/prefs/prefs_editor.ui
M  +13   -0    src/xlifftextedit.cpp
M  +1    -0    src/xlifftextedit.h

https://commits.kde.org/lokalize/938de1bd201f688cf2c3ef5c33fa3dc5d2ca5a98

diff --git a/src/editorview.cpp b/src/editorview.cpp
index b17a8ed..b7af613 100644
--- a/src/editorview.cpp
+++ b/src/editorview.cpp
@@ -113,6 +113,9 @@ EditorView::EditorView(QWidget *parent, Catalog* catalog/*,keyEventHandler* kh*/
                                         "of the currently displayed entry.</p></qt>"));
     m_sourceTextEdit->viewport()->setBackgroundRole(QPalette::Background);
 
+    m_sourceTextEdit->setVisualizeSeparators(Settings::self()->visualizeSeparators());
+    m_targetTextEdit->setVisualizeSeparators(Settings::self()->visualizeSeparators());
+
 
     connect(m_targetTextEdit, &TranslationUnitTextEdit::contentsModified, this, &EditorView::resetFindForCurrent);
     connect(m_targetTextEdit, &TranslationUnitTextEdit::toggleApprovementRequested, this, &EditorView::toggleApprovement);
@@ -164,6 +167,8 @@ void EditorView::settingsChanged()
     //Settings::self()->config()->setGroup("Editor");
     m_sourceTextEdit->document()->setDefaultFont(Settings::msgFont());
     m_targetTextEdit->document()->setDefaultFont(Settings::msgFont());
+    m_sourceTextEdit->setVisualizeSeparators(Settings::self()->visualizeSeparators());
+    m_targetTextEdit->setVisualizeSeparators(Settings::self()->visualizeSeparators());
 #ifndef NOKDE
     if (m_leds) m_leds->setVisible(Settings::leds());
     else if (Settings::leds()) {
diff --git a/src/prefs/lokalize.kcfg b/src/prefs/lokalize.kcfg
index 0204e86..e91a0b5 100644
--- a/src/prefs/lokalize.kcfg
+++ b/src/prefs/lokalize.kcfg
@@ -91,6 +91,9 @@
     <entry name="AutoSpellcheck"  type="Bool">
         <default>true</default>
     </entry>
+    <entry name="VisualizeSeparators"  type="Bool">
+        <default>false</default>
+    </entry>
     <entry name="MouseWheelGo"  type="Bool">
         <default>false</default>
     </entry>
diff --git a/src/prefs/prefs_editor.ui b/src/prefs/prefs_editor.ui
index da48740..e440f4e 100644
--- a/src/prefs/prefs_editor.ui
+++ b/src/prefs/prefs_editor.ui
@@ -81,6 +81,13 @@
     </layout>
    </item>
    <item row="3" column="0">
+    <widget class="QCheckBox" name="kcfg_VisualizeSeparators">
+     <property name="text">
+      <string>Visualize separators such as spaces, tabs and new lines in the editor</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
     <layout class="QHBoxLayout">
      <item>
       <widget class="QLabel" name="l2">
diff --git a/src/xlifftextedit.cpp b/src/xlifftextedit.cpp
index 1a75b2f..d84b713 100644
--- a/src/xlifftextedit.cpp
+++ b/src/xlifftextedit.cpp
@@ -148,6 +148,19 @@ void TranslationUnitTextEdit::setSpellCheckingEnabled(bool enable)
     SettingsController::instance()->dirty = true;
 }
 
+void TranslationUnitTextEdit::setVisualizeSeparators(bool enable)
+{
+    if (enable) {
+        QTextOption textoption = document()->defaultTextOption();
+        textoption.setFlags(textoption.flags() | QTextOption::ShowLineAndParagraphSeparators | QTextOption::ShowTabsAndSpaces);
+        document()->setDefaultTextOption(textoption);
+    } else {
+        QTextOption textoption = document()->defaultTextOption();
+        textoption.setFlags(textoption.flags() & (!QTextOption::ShowLineAndParagraphSeparators) & (!QTextOption::ShowTabsAndSpaces));
+        document()->setDefaultTextOption(textoption);
+    }
+}
+
 
 void TranslationUnitTextEdit::fileLoaded()
 {
diff --git a/src/xlifftextedit.h b/src/xlifftextedit.h
index 1c2ce55..3a993a0 100644
--- a/src/xlifftextedit.h
+++ b/src/xlifftextedit.h
@@ -57,6 +57,7 @@ public:
         return m_enabled;
     }
     void setSpellCheckingEnabled(bool enable);
+    void setVisualizeSeparators(bool enable);
     bool shouldBlockBeSpellChecked(const QString &block) const
     {
         Q_UNUSED(block);


More information about the kde-doc-english mailing list