View Issue Details

IDProjectCategoryView StatusLast Update
0010455ScribusUsabilitypublic2016-11-07 18:38
ReporterJLuc Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Product Version1.4.0svn 
Summary0010455: [PATCH] More efficient style import
DescriptionStyle import is very important to multiple files projects. Here is a simple request that would much easyen its use in today scribus : the style import dialog should remember the choosen "replace or rename when conflict" option.
It is very easy to forget to check it (and this will mess the file styles) all the more since in a projects, it will allways be the same.


On this same dialog there is a little cosmetic bug : when opening this dialog, all styles are checked by default, so the "select all" should be checked by default too (and thus it would be possible to use this select immediatly, when now it is not possible).



Tags#easyhack, #rottenpatch, patch
PatchYes

Activities

baazigar

2012-04-08 20:06

reporter  

betterStyleImport.diff (8,890 bytes)   
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 17419)
+++ scribus/scribusdoc.h	(working copy)
@@ -1179,6 +1179,8 @@
 	bool SnapGuides;
 	bool GuideLock;
 	bool dontResize;
+        bool importAllStyle; //memory for multiple style import
+        bool styleRenameImport;//memory for rename or replace style import
 	/** \brief Minimum and Maximum Points of Document */
 	FPoint minCanvasCoordinate;
 	FPoint maxCanvasCoordinate;
Index: scribus/ui/stylemanager.cpp
===================================================================
--- scribus/ui/stylemanager.cpp	(revision 17419)
+++ scribus/ui/stylemanager.cpp	(working copy)
@@ -334,7 +334,7 @@
 
 		Q_ASSERT(pstyle && cstyle && lstyle);
 
-		SMStyleImport *dia2 = new SMStyleImport(this, &tmpParaStyles, &tmpCharStyles, &tmpLineStyles);
+                SMStyleImport *dia2 = new SMStyleImport(this,m_doc, &tmpParaStyles, &tmpCharStyles, &tmpLineStyles);
 // end hack
 
 //#7315 		QList<QPair<QString, QString> > selected;
Index: scribus/ui/smstyleimport.cpp
===================================================================
--- scribus/ui/smstyleimport.cpp	(revision 17419)
+++ scribus/ui/smstyleimport.cpp	(working copy)
@@ -10,7 +10,7 @@
 #include "smstyleimport.h"
 
 
-SMStyleImport::SMStyleImport(QWidget* parent,
+SMStyleImport::SMStyleImport(QWidget* parent, ScribusDoc *doc,
 							 StyleSet<ParagraphStyle> *pstyleList,
 							 StyleSet<CharStyle> *cstyleList,
 							 QHash<QString, multiLine> *lstyleList)
@@ -18,13 +18,14 @@
 {
 	setupUi(this);
 	setModal(true);
+        m_doc=doc;
 	cstyleItem = new QTreeWidgetItem(styleWidget);
 	cstyleItem->setText(0, tr("Character Styles"));
 	for (int x = 0; x < cstyleList->count(); ++x)
 	{
 		CharStyle& vg ((*cstyleList)[x]);
 		QCheckBox *box = new QCheckBox(vg.name());
-		box->setChecked(true);
+                box->setChecked(getImportAllState());
 		QTreeWidgetItem *item = new QTreeWidgetItem(cstyleItem, cType);
 		styleWidget->setItemWidget(item, 0, box);
 	}
@@ -36,7 +37,7 @@
 	{
 		ParagraphStyle& vg ((*pstyleList)[x]);
 		QCheckBox *box = new QCheckBox(vg.name());
-		box->setChecked(true);
+                box->setChecked(getImportAllState());
 		QTreeWidgetItem *item = new QTreeWidgetItem(pstyleItem, pType);
 		styleWidget->setItemWidget(item, 0, box);
 	}
@@ -48,13 +49,17 @@
 	for (int x = 0; x < lkeys.count(); ++x)
 	{
 		QCheckBox *box = new QCheckBox(lkeys[x]);
-		box->setChecked(true);
+                box->setChecked(getImportAllState());
 		QTreeWidgetItem *item = new QTreeWidgetItem(lstyleItem, lType);
 		styleWidget->setItemWidget(item, 0, box);
 	}
 	styleWidget->expandItem(lstyleItem);
+        importAllCheckBox->setChecked(getImportAllState());
+        getRenameState()==true?renameButton->setChecked(true):replaceButton->setChecked(true);
 
 	connect(importAllCheckBox, SIGNAL(clicked(bool)), this, SLOT(checkAll(bool)));
+        connect(importAllCheckBox, SIGNAL(clicked(bool)), this, SLOT(setImportAllState(bool)));
+        connect(renameButton,       SIGNAL(toggled(bool)),this, SLOT(setRenameState(bool)));
 }
 
 bool SMStyleImport::clashRename()
@@ -109,3 +114,22 @@
 	}
 }
 
+void SMStyleImport::setImportAllState(bool isChecked)
+{
+    m_doc->importAllStyle=isChecked;
+}
+
+bool SMStyleImport::getImportAllState()
+{
+    return m_doc->importAllStyle;
+}
+
+void SMStyleImport::setRenameState(bool isChecked)
+{
+    m_doc->styleRenameImport=isChecked;
+}
+
+bool SMStyleImport::getRenameState()
+{
+    return m_doc->styleRenameImport;
+}
Index: scribus/ui/smstyleimport.ui
===================================================================
--- scribus/ui/smstyleimport.ui	(revision 17419)
+++ scribus/ui/smstyleimport.ui	(working copy)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>SMStyleImport</class>
- <widget class="QDialog" name="SMStyleImport" >
-  <property name="geometry" >
+ <widget class="QDialog" name="SMStyleImport">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,51 +10,54 @@
     <height>444</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Choose Styles</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout" >
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <widget class="QTreeWidget" name="styleWidget" >
-     <property name="selectionMode" >
+    <widget class="QTreeWidget" name="styleWidget">
+     <property name="selectionMode">
       <enum>QAbstractItemView::NoSelection</enum>
      </property>
-     <property name="selectionBehavior" >
+     <property name="selectionBehavior">
       <enum>QAbstractItemView::SelectItems</enum>
      </property>
      <column>
-      <property name="text" >
+      <property name="text">
        <string>Available Styles</string>
       </property>
      </column>
     </widget>
    </item>
    <item>
-    <widget class="QCheckBox" name="importAllCheckBox" >
-     <property name="text" >
+    <widget class="QCheckBox" name="importAllCheckBox">
+     <property name="text">
       <string>Select or Unselect All</string>
      </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox" >
-     <property name="title" >
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
       <string>In case of a name clash</string>
      </property>
-     <layout class="QGridLayout" >
-      <item row="0" column="0" >
-       <widget class="QRadioButton" name="renameButton" >
-        <property name="text" >
+     <layout class="QGridLayout">
+      <item row="0" column="0">
+       <widget class="QRadioButton" name="renameButton">
+        <property name="text">
          <string>&amp;Rename Imported Style</string>
         </property>
-        <property name="checked" >
+        <property name="checked">
          <bool>true</bool>
         </property>
        </widget>
       </item>
-      <item row="1" column="0" >
-       <widget class="QRadioButton" name="replaceButton" >
-        <property name="text" >
+      <item row="1" column="0">
+       <widget class="QRadioButton" name="replaceButton">
+        <property name="text">
          <string>R&amp;eplace Existing Style</string>
         </property>
        </widget>
@@ -62,11 +66,11 @@
     </widget>
    </item>
    <item>
-    <widget class="QDialogButtonBox" name="buttonBox" >
-     <property name="orientation" >
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="standardButtons" >
+     <property name="standardButtons">
       <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
      </property>
     </widget>
@@ -81,11 +85,11 @@
    <receiver>SMStyleImport</receiver>
    <slot>accept()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>252</x>
      <y>419</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>157</x>
      <y>274</y>
     </hint>
@@ -97,11 +101,11 @@
    <receiver>SMStyleImport</receiver>
    <slot>reject()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>299</x>
      <y>419</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>286</x>
      <y>274</y>
     </hint>
Index: scribus/ui/smstyleimport.h
===================================================================
--- scribus/ui/smstyleimport.h	(revision 17419)
+++ scribus/ui/smstyleimport.h	(working copy)
@@ -13,8 +13,8 @@
 #include "scribusapi.h"
 #include "styles/styleset.h"
 #include "scribusstructs.h"
+#include "scribusdoc.h"
 
-
 /*! \brief Import styles from outer sla document.
 User can choose what to import and what to do with the style
 names here.
@@ -24,14 +24,15 @@
 	Q_OBJECT
 
 	public:
-		SMStyleImport(QWidget* parent,
+                SMStyleImport(QWidget* parent, ScribusDoc *doc,
 					StyleSet<ParagraphStyle> *pstyleList,
 					StyleSet<CharStyle> *cstyleList,
 					QHash<QString, multiLine> *lstyleList);
 		~SMStyleImport() {};
 
 		//! \brief True if the rename feature is ON.
-		bool clashRename();
+                ScribusDoc *m_doc;
+                bool clashRename();
 		QStringList paragraphStyles();
 		QStringList characterStyles();
 		QStringList lineStyles();
@@ -54,6 +55,10 @@
 
 	protected slots:
 		void checkAll(bool allChecked);
+                void setImportAllState(bool isChecked);
+                bool getImportAllState();
+                void setRenameState(bool isChecked);
+                bool getRenameState();
 
 };
 
betterStyleImport.diff (8,890 bytes)   

baazigar

2012-04-08 20:16

reporter   ~0027908

Last edited: 2012-04-08 20:19

This patch improves the styles import by ->
1)the cosmetic bug removed-now the checked state is same for all styles and the select all checkbox.
2)remembers the choice of check all, rename or replace for a document.(used doc class to add memory).

I didnt test it much, but i will surely improve it later.

plinnell

2012-04-09 00:18

viewer   ~0027909

Was diff against 1.5.0.svn ?

baazigar

2012-04-09 20:26

reporter   ~0027912

yes, it was against revision 17419.

Kunda

2014-07-14 01:27

updater   ~0032730

Prepended [PATCH] to issue

Issue History

Date Modified Username Field Change
2011-12-25 21:43 JLuc New Issue
2012-04-08 20:06 baazigar File Added: betterStyleImport.diff
2012-04-08 20:16 baazigar Note Added: 0027908
2012-04-08 20:19 baazigar Note Edited: 0027908
2012-04-09 00:18 plinnell Note Added: 0027909
2012-04-09 20:26 baazigar Note Added: 0027912
2014-01-14 19:53 JLuc Tag Attached: easyhack
2014-03-23 10:13 JLuc Tag Attached: patch
2014-07-14 01:27 Kunda Note Added: 0032730
2014-07-14 01:27 Kunda Summary More efficient style import => [PATCH] More efficient style import
2014-10-15 17:07 Kunda Tag Renamed easyhack => #easyhack
2014-10-24 23:00 Kunda Patch => Yes
2016-11-07 18:38 JLuc Tag Attached: #rottenpatch
2016-11-07 18:38 JLuc Tag Attached: rot
2016-11-07 18:38 JLuc Tag Detached: rot