View Issue Details

IDProjectCategoryView StatusLast Update
0017149ScribusUser Interfacepublic2024-10-07 18:21
Reporterale Assigned Tonitramr  
PrioritynormalSeverityminorReproducibilityN/A
Status assignedResolutionopen 
Product Version1.7.0.svn 
Summary0017149: create (line) styles in place
Descriptionit has been requested for many years to enable the creation of the styles based on the current selection.

i gave it a try with the simplest case: the line styles.

of course, the most interesting cases are the creation of paragraph and character styles.

another similar situation is for "fast" creating (and applying) colors.

@nitramr do you think that this type of feature can be integrated in your UI work?
Steps To Reproducein its current state the code:

- opens a modal dialog
- with the values for the currently selected line prefilled

it does not create the style itself yet (but i think i'm close to get there).
TagsNo tags attached.
PatchNo

Activities

ale

2024-01-28 17:44

manager  

create-line-style-first-draft.gif (113,934 bytes)   
create-line-style-first-draft.gif (113,934 bytes)   

ale

2024-01-29 19:27

manager   ~0050953

here is the current state of my draft code (it does not yet create the style)
create-line-style-draft.diff (35,651 bytes)   
diff --git a/Scribus.pro b/Scribus.pro
index eacc9380d..8bfc29bce 100644
--- a/Scribus.pro
+++ b/Scribus.pro
@@ -646,6 +646,7 @@ HEADERS += scribus/actionmanager.h \
            scribus/ui/splash.h \
            scribus/ui/storyeditor.h \
            scribus/ui/stylecombos.h \
+           scribus/ui/stylecreator.h \
            scribus/ui/stylemanager.h \
            scribus/ui/styleselect.h \
            scribus/ui/styleview.h \
@@ -1167,6 +1168,7 @@ FORMS += scribus/ui/aboutplugins.ui \
          scribus/ui/smtablestylewidget.ui \
          scribus/ui/spiralvectorbase.ui \
          scribus/ui/spiralwidgetbase.ui \
+         scribus/ui/stylecreator.ui \
          scribus/ui/stylemanager.ui \
          scribus/ui/tablecolumnwidthsdialog.ui \
          scribus/ui/tablerowheightsdialog.ui \
@@ -1794,6 +1796,7 @@ SOURCES += scribus/actionmanager.cpp \
            scribus/ui/splash.cpp \
            scribus/ui/storyeditor.cpp \
            scribus/ui/stylecombos.cpp \
+           scribus/ui/stylecreator.cpp \
            scribus/ui/stylemanager.cpp \
            scribus/ui/styleselect.cpp \
            scribus/ui/styleview.cpp \
diff --git a/scribus/CMakeLists_Sources.txt b/scribus/CMakeLists_Sources.txt
index 66101c2e1..3ed090862 100644
--- a/scribus/CMakeLists_Sources.txt
+++ b/scribus/CMakeLists_Sources.txt
@@ -512,6 +512,7 @@ set(SCRIBUS_SOURCES
 	ui/splash.cpp
 	ui/storyeditor.cpp
 	ui/stylecombos.cpp
+	ui/stylecreator.cpp
 	ui/stylemanager.cpp
 	ui/styleselect.cpp
 	ui/styleview.cpp
diff --git a/scribus/ui/propertiespalette_line.cpp b/scribus/ui/propertiespalette_line.cpp
index d275f442a..9d10558b0 100644
--- a/scribus/ui/propertiespalette_line.cpp
+++ b/scribus/ui/propertiespalette_line.cpp
@@ -23,8 +23,11 @@ for which a new license (GPL+exception) is in place.
 #include "scribusapp.h"
 #include "scribusdoc.h"
 #include "selection.h"
+#include "smlinestyle.h"
 #include "ui/propertiespalette_utils.h"
 #include "ui/widgets/popup_menu.h"
+#include "ui/stylecreator.h"
+#include "ui/widgets/popup_menu.h"
 #include "units.h"
 #include "util.h"
 
@@ -86,6 +89,59 @@ PropertiesPalette_Line::PropertiesPalette_Line( QWidget* parent) : QWidget(paren
 	connect(comboBlendmode, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineBlendmode(int)));
 	connect(numberOpacity, SIGNAL(valueChanged(double)), this, SLOT(handleLineOpacity(double)));
 
+	// TODO: enable and disable them as needed
+	comboLineStyles->addItem("Styles");
+	connect(buttonCreateStyle, &QToolButton::clicked, [=]() {
+		auto dialog = new StyleCreator(this);
+		dialog->setDoc(m_doc);
+        SMLineStyle *styleItem = new SMLineStyle();
+        SingleLine lineSettings{};
+        lineSettings.setLineWidth(lineWidth->value() / m_unitRatio);
+		if (lineType->currentIndex() != 37)
+        {
+            lineSettings.setDash(lineType->currentIndex()+1);
+        }
+        // TODO: defined it as a function and use it also in other places
+        auto getLineEnd = [=]() -> Qt::PenCapStyle {
+            switch (buttonsCaps->checkedId())
+            {
+            case 0:
+                return Qt::FlatCap;
+            case 1:
+                return Qt::SquareCap;
+            case 2:
+                return Qt::RoundCap;
+            }
+            return Qt::FlatCap;
+        };
+        lineSettings.setLineEnd(static_cast<int>(getLineEnd()));
+        auto getLineJoin = [=]() -> Qt::PenJoinStyle {
+            switch (buttonsJoins->checkedId())
+            {
+            case 0:
+                return Qt::MiterJoin;
+            case 1:
+                return Qt::BevelJoin;
+            case 2:
+                return Qt::RoundJoin;
+            }
+            return Qt::MiterJoin;
+        };
+        lineSettings.setLineJoin(getLineJoin());
+        PageItem* currentItem = currentItemFromSelection();
+        if (currentItem == nullptr) {
+            return;
+        }
+        // showColorValues(currentItem->lineColor(), currentItem->fillColor(), currentItem->lineShade(), currentItem->fillShade());
+        lineSettings.setColor(currentItem->lineColor());
+        lineSettings.setShade(currentItem->lineShade());
+        MultiLine lineCompound{};
+        lineCompound.push_back(lineSettings);
+		dialog->loadType(styleItem);
+        styleItem->newStyle(lineCompound);
+		dialog->show();
+		qDebug() << "clicked";
+	});
 }
 
 void PropertiesPalette_Line::changeEvent(QEvent *e)
@@ -658,6 +714,8 @@ void PropertiesPalette_Line::iconSetChange()
 	buttonCapSquare->setIcon(im.loadIcon("16/stroke-cap-square.png"));
 
 	buttonSwapMarker->setIcon(im.loadIcon("swap"));
+
+	buttonCreateStyle->setIcon(im.loadIcon("16/list-add.png"));
 }
 
 void PropertiesPalette_Line::languageChange()
diff --git a/scribus/ui/propertiespalette_linebase.ui b/scribus/ui/propertiespalette_linebase.ui
index a5299fbcd..a5afde41e 100644
--- a/scribus/ui/propertiespalette_linebase.ui
+++ b/scribus/ui/propertiespalette_linebase.ui
@@ -6,489 +6,507 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>314</width>
-    <height>344</height>
+    <width>314</width>
+    <height>344</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="spacing">
-    <number>8</number>
-   </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>8</number>
+   </property>
    <property name="leftMargin">
-    <number>8</number>
+    <number>8</number>
    </property>
    <property name="topMargin">
-    <number>8</number>
+    <number>8</number>
    </property>
    <property name="rightMargin">
-    <number>8</number>
+    <number>8</number>
    </property>
    <property name="bottomMargin">
-    <number>8</number>
+    <number>8</number>
    </property>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_3">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
      <property name="spacing">
-      <number>4</number>
+      <number>4</number>
      </property>
      <item>
-      <widget class="FormWidget" name="lineWidthLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
+      <widget class="FormWidget" name="lineWidthLabel" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
        </property>
-       <property name="label" stdset="0">
-        <string>Width</string>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_4">
-        <property name="spacing">
-         <number>4</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="ScrSpinBox" name="lineWidth">
-          <property name="maximumSize">
-           <size>
-            <width>100</width>
-            <height>16777215</height>
-           </size>
-          </property>
-          <property name="specialValueText">
-           <string>Hairline</string>
-          </property>
-          <property name="maximum">
-           <double>300.000000000000000</double>
-          </property>
-         </widget>
-        </item>
-       </layout>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
+       </property>
+       <property name="label" stdset="0">
+        <string>Width</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="ScrSpinBox" name="lineWidth">
+          <property name="maximumSize">
+           <size>
+            <width>100</width>
+            <height>16777215</height>
+           </size>
+          </property>
+          <property name="specialValueText">
+           <string>Hairline</string>
+          </property>
+          <property name="maximum">
+           <double>300.000000000000000</double>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </widget>
      </item>
      <item>
-      <widget class="FormWidget" name="lineTypeLabel">
+      <widget class="FormWidget" name="lineTypeLabel" native="true">
        <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="label" stdset="0">
-        <string>Type</string>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
        </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
+       <property name="label" stdset="0">
+        <string>Type</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_5">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="LineCombo" name="lineType"/>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboLineStyles"/>
+     </item>
+     <item>
+      <widget class="QToolButton" name="buttonCreateStyle">
+       <property name="text">
+        <string/>
        </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_5">
-        <property name="spacing">
-         <number>4</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="LineCombo" name="lineType"/>
-        </item>
-       </layout>
       </widget>
      </item>
-     <item>
-      <spacer name="horizontalSpacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>0</width>
-         <height>0</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <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>
    </item>
-   <item>
-    <widget class="DashEditor" name="dashEditor">
-     <property name="frameShape">
-      <enum>QFrame::StyledPanel</enum>
-     </property>
-     <property name="frameShadow">
-      <enum>QFrame::Raised</enum>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_10">
+   <item>
+    <widget class="DashEditor" name="dashEditor">
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Raised</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_10">
      <property name="spacing">
-      <number>16</number>
+      <number>16</number>
      </property>
      <item>
-      <widget class="FormWidget" name="lineEndLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
+      <widget class="FormWidget" name="lineEndLabel" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
+       </property>
+       <property name="label" stdset="0">
+        <string>Caps</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QToolButton" name="buttonCapFlat">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+          <property name="checked">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonCapSquare">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonCapRound">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <widget class="FormWidget" name="lineJoinLabel" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
+       </property>
+       <property name="label" stdset="0">
+        <string>Joins</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_9">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QToolButton" name="buttonJoinMiter">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonJoinRound">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonJoinBevel">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <widget class="FormWidget" name="lineMarkerLabel" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
+       </property>
+       <property name="label" stdset="0">
+        <string>Marker</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="spacing">
+         <number>4</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QToolButton" name="buttonMarkerStart">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="iconSize">
+           <size>
+            <width>20</width>
+            <height>16</height>
+           </size>
+          </property>
+          <property name="popupMode">
+           <enum>QToolButton::InstantPopup</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonSwapMarker">
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonMarkerEnd">
+          <property name="text">
+           <string/>
+          </property>
+          <property name="iconSize">
+           <size>
+            <width>20</width>
+            <height>16</height>
+           </size>
+          </property>
+          <property name="popupMode">
+           <enum>QToolButton::InstantPopup</enum>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <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>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_6">
+     <item>
+      <widget class="FormWidget" name="lineOpacityLabel" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
        </property>
-       <property name="label" stdset="0">
-        <string>Caps</string>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_2">
-        <property name="spacing">
-         <number>4</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="QToolButton" name="buttonCapFlat">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-          <property name="checked">
-           <bool>false</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonCapSquare">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonCapRound">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-       </layout>
+       <property name="label" stdset="0">
+        <string>Opacity</string>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_8">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="ScrSpinBox" name="numberOpacity">
+          <property name="focusPolicy">
+           <enum>Qt::WheelFocus</enum>
+          </property>
+          <property name="suffix">
+           <string> %</string>
+          </property>
+          <property name="decimals">
+           <number>0</number>
+          </property>
+          <property name="maximum">
+           <double>100.000000000000000</double>
+          </property>
+          <property name="value">
+           <double>100.000000000000000</double>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </widget>
      </item>
      <item>
-      <widget class="FormWidget" name="lineJoinLabel">
+      <widget class="FormWidget" name="lineBlendmodeLabel" native="true">
        <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="label" stdset="0">
-        <string>Joins</string>
+       <property name="font">
+        <font>
+         <pointsize>8</pointsize>
+        </font>
        </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
+       <property name="label" stdset="0">
+        <string>Blendmode</string>
        </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_9">
-        <property name="spacing">
-         <number>4</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="QToolButton" name="buttonJoinMiter">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonJoinRound">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonJoinBevel">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-       </layout>
+       <layout class="QHBoxLayout" name="horizontalLayout_7">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="ComboBlendMode" name="comboBlendmode"/>
+        </item>
+       </layout>
       </widget>
      </item>
-     <item>
-      <widget class="FormWidget" name="lineMarkerLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="label" stdset="0">
-        <string>Marker</string>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <property name="spacing">
-         <number>4</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="QToolButton" name="buttonMarkerStart">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="iconSize">
-           <size>
-            <width>20</width>
-            <height>16</height>
-           </size>
-          </property>
-          <property name="popupMode">
-           <enum>QToolButton::InstantPopup</enum>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonSwapMarker">
-          <property name="text">
-           <string/>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QToolButton" name="buttonMarkerEnd">
-          <property name="text">
-           <string/>
-          </property>
-          <property name="iconSize">
-           <size>
-            <width>20</width>
-            <height>16</height>
-           </size>
-          </property>
-          <property name="popupMode">
-           <enum>QToolButton::InstantPopup</enum>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_3">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>0</width>
-         <height>0</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <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>
    </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_6">
-     <item>
-      <widget class="FormWidget" name="lineOpacityLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="label" stdset="0">
-        <string>Opacity</string>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_8">
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="ScrSpinBox" name="numberOpacity">
-          <property name="suffix">
-           <string> %</string>
-          </property>
-          <property name="decimals">
-           <number>0</number>
-          </property>
-          <property name="maximum">
-           <double>100.000000000000000</double>
-          </property>
-          <property name="value">
-           <double>100.000000000000000</double>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-     </item>
-     <item>
-      <widget class="FormWidget" name="lineBlendmodeLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="label" stdset="0">
-        <string>Blendmode</string>
-       </property>
-       <property name="font">
-        <font>
-         <pointsize>8</pointsize>
-        </font>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout_7">
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="ComboBlendMode" name="comboBlendmode"/>
-        </item>
-       </layout>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <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>
+   <item>
+    <widget class="QListWidget" name="lineStyles"/>
    </item>
-   <item>
-    <widget class="QListWidget" name="lineStyles"/>
-   </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>FormWidget</class>
-   <extends>QWidget</extends>
-   <header>ui/widgets/form_widget.h</header>
-   <container>1</container>
-  </customwidget>
-  <customwidget>
    <class>ScrSpinBox</class>
    <extends>QDoubleSpinBox</extends>
    <header>ui/scrspinbox.h</header>
   </customwidget>
+  <customwidget>
+   <class>FormWidget</class>
+   <extends>QWidget</extends>
+   <header>ui/widgets/form_widget.h</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>ComboBlendMode</class>
+   <extends>QComboBox</extends>
+   <header>ui/widgets/combo_blendmode.h</header>
+  </customwidget>
   <customwidget>
    <class>LineCombo</class>
    <extends>QComboBox</extends>
@@ -500,28 +518,23 @@
    <header>ui/dasheditor.h</header>
    <container>1</container>
   </customwidget>
-  <customwidget>
-   <class>ComboBlendMode</class>
-   <extends>QComboBox</extends>
-   <header>ui/widgets/combo_blendmode.h</header>
-  </customwidget>
  </customwidgets>
- <tabstops>
-  <tabstop>lineWidth</tabstop>
-  <tabstop>lineType</tabstop>
-  <tabstop>buttonCapFlat</tabstop>
-  <tabstop>buttonCapSquare</tabstop>
-  <tabstop>buttonCapRound</tabstop>
-  <tabstop>buttonJoinMiter</tabstop>
-  <tabstop>buttonJoinRound</tabstop>
-  <tabstop>buttonJoinBevel</tabstop>
-  <tabstop>buttonMarkerStart</tabstop>
-  <tabstop>buttonSwapMarker</tabstop>
-  <tabstop>buttonMarkerEnd</tabstop>
-  <tabstop>numberOpacity</tabstop>
-  <tabstop>comboBlendmode</tabstop>
-  <tabstop>lineStyles</tabstop>
- </tabstops>
+ <tabstops>
+  <tabstop>lineWidth</tabstop>
+  <tabstop>lineType</tabstop>
+  <tabstop>buttonCapFlat</tabstop>
+  <tabstop>buttonCapSquare</tabstop>
+  <tabstop>buttonCapRound</tabstop>
+  <tabstop>buttonJoinMiter</tabstop>
+  <tabstop>buttonJoinRound</tabstop>
+  <tabstop>buttonJoinBevel</tabstop>
+  <tabstop>buttonMarkerStart</tabstop>
+  <tabstop>buttonSwapMarker</tabstop>
+  <tabstop>buttonMarkerEnd</tabstop>
+  <tabstop>numberOpacity</tabstop>
+  <tabstop>comboBlendmode</tabstop>
+  <tabstop>lineStyles</tabstop>
+ </tabstops>
  <resources/>
  <connections/>
 </ui>
diff --git a/scribus/ui/smlinestyle.cpp b/scribus/ui/smlinestyle.cpp
index 18a94e800..960b59b7d 100644
--- a/scribus/ui/smlinestyle.cpp
+++ b/scribus/ui/smlinestyle.cpp
@@ -193,6 +193,20 @@ QString SMLineStyle::newStyle()
 	return name;
 }
 
+QString SMLineStyle::newStyle(const MultiLine lineCompound)
+{
+	QString name = getUniqueName( tr("New Style"));
+	m_tmpLines[name] = lineCompound;
+    // QStringList styleNames;
+    // styleNames << name;
+    // selected(styleNames);
+    setupConnections();
+    setSelection(name);
+	// m_widget->showStyle(m_tmpLines[styleName], m_doc->PageColors);
+    
+    return name;
+}
+
 QString SMLineStyle::newStyle(const QString &fromStyle)
 {
 	Q_ASSERT(m_tmpLines.contains(fromStyle));
diff --git a/scribus/ui/smlinestyle.h b/scribus/ui/smlinestyle.h
index 42bc343fd..7dcab6136 100644
--- a/scribus/ui/smlinestyle.h
+++ b/scribus/ui/smlinestyle.h
@@ -35,6 +35,7 @@ public:
 	void toSelection(const QString &styleName) const;
 	QString newStyle();
 	QString newStyle(const QString &fromStyle);
+	QString newStyle(MultiLine lineFormat);
 	void apply();
 	bool isDefaultStyle(const QString &stylename) const;
 	void setDefaultStyle(bool ids);
create-line-style-draft.diff (35,651 bytes)   
stylecreator.cpp (1,831 bytes)   
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/

#include "stylecreator.h"
#include "smlinestyle.h"
#include "scribusdoc.h"
#include "styleitem.h"

#include <QGridLayout>
#include <QTabWidget>

StyleCreator::StyleCreator(QWidget *parent, const char *name)
	: ScDialog(parent, name)
{
	setupUi(this);
	connect(createButton, &QPushButton::clicked, this, &StyleCreator::slotOk);
}

StyleCreator::~StyleCreator()
{
	delete styleItem;
	delete layout;
}

void StyleCreator::setDoc(ScribusDoc *doc)
{
	this->doc = doc;
}

void StyleCreator::loadType(StyleItem *styleType)
{
	styleItem = styleType;
	styleItem->setCurrentDoc(doc);
	styleItem->reload();
	styleItem->editMode(true);
	auto widget = styleItem->widget();
	widget->setParent(mainFrame);
	// TODO layout should probably be a class member and be deleted in the destructor
	layout = new QGridLayout(mainFrame);
	layout->setContentsMargins(0, 0, 0, 0);
	layout->addWidget(widget, 0, 0);
	widget->resize(widget->minimumSizeHint());
	widget->setEnabled(true);
	widget->show();

	// TODO: check what slotNameChanged(QString) does...
	nameEdit->setText(styleItem->newStyle());
	nameEdit->setEnabled(true);
	nameEdit->setFocus();
	nameEdit->selectAll();

	// QString newName = fromParent.isNull() ?
	// 		m_item->newStyle() : m_item->newStyle(fromParent);
}

void StyleCreator::loadType(const QString &name)
{
	// TODO: i think that a good starting point is StyleManager::createNewStyle()
	if (name == "line") {
		styleItem = new SMLineStyle();
	} else {
		return;
	}
	loadType(styleItem);
}

void StyleCreator::slotOk()
{
	this->close();
}
stylecreator.cpp (1,831 bytes)   
stylecreator.h (959 bytes)   
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/

#ifndef STYLECREATOR_H
#define STYLECREATOR_H

#include "ui_stylecreator.h"
#include "scdialog.h"

class  ScribusDoc;
class  StyleItem;
class  QGridLayout;

class SCRIBUS_API StyleCreator : public ScDialog, Ui::StyleCreator
{
	Q_OBJECT
public:
	StyleCreator(QWidget *parent = nullptr, const char *name = "StyleCreator");
	~StyleCreator();
	void setDoc(ScribusDoc *doc);
	/** StyleItem is one of the specialized type extending StyleItem */
	void loadType(StyleItem *styleType);
	void loadType(const QString &name);
private:
	ScribusDoc *doc { nullptr };
	StyleItem *styleItem { nullptr };
	QGridLayout *layout { nullptr };
private slots:
	void slotOk();
};

#endif
stylecreator.h (959 bytes)   
stylecreator.ui (3,189 bytes)   
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>StyleCreator</class>
 <widget class="QDialog" name="StyleCreator">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>506</width>
    <height>432</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Style Creator</string>
  </property>
  <widget class="QFrame" name="editFrame">
   <property name="geometry">
    <rect>
     <x>10</x>
     <y>10</y>
     <width>485</width>
     <height>368</height>
    </rect>
   </property>
   <property name="sizePolicy">
    <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
   </property>
   <property name="frameShape">
    <enum>QFrame::NoFrame</enum>
   </property>
   <property name="frameShadow">
    <enum>QFrame::Plain</enum>
   </property>
   <property name="lineWidth">
    <number>0</number>
   </property>
   <layout class="QVBoxLayout">
    <property name="spacing">
     <number>9</number>
    </property>
    <property name="leftMargin">
     <number>0</number>
    </property>
    <property name="topMargin">
     <number>0</number>
    </property>
    <property name="rightMargin">
     <number>0</number>
    </property>
    <property name="bottomMargin">
     <number>0</number>
    </property>
    <item>
     <layout class="QHBoxLayout" name="_2">
      <item>
       <widget class="QLabel" name="nameLabel">
        <property name="text">
         <string>Name:</string>
        </property>
        <property name="wordWrap">
         <bool>false</bool>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QLineEdit" name="nameEdit">
        <property name="enabled">
         <bool>false</bool>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <widget class="QFrame" name="mainFrame">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QWidget" name="horizontalLayoutWidget">
   <property name="geometry">
    <rect>
     <x>10</x>
     <y>390</y>
     <width>481</width>
     <height>31</height>
    </rect>
   </property>
   <layout class="QHBoxLayout" name="horizontalLayout">
    <item>
     <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>40</width>
        <height>20</height>
       </size>
      </property>
     </spacer>
    </item>
    <item>
     <widget class="QPushButton" name="cancelButton">
      <property name="text">
       <string>C&amp;ancel</string>
      </property>
     </widget>
    </item>
    <item>
     <widget class="QPushButton" name="createButton">
      <property name="text">
       <string>&amp;Create</string>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>
stylecreator.ui (3,189 bytes)   

ale

2024-02-01 16:11

manager   ~0050959

@nitramr you have "picked up" this ticket...

do you want to create a patch yourself or should i continue my effort and create a "real" patch?
if i should continue, do you have any feebdack?

nitramr

2024-02-01 16:24

developer   ~0050960

I didn't have time now to check your patch. Feel free to provide something. Currently, I'm focusing implementing the new color picker + new tools required for this.

nitramr

2024-10-05 15:55

developer   ~0051412

@ale I solved it now by adding two new buttons (edit and new)
Both buttons open the style manager and execute the action automatic, like a user would do.
style_edit_new.png (4,359 bytes)   
style_edit_new.png (4,359 bytes)   

ale

2024-10-07 18:21

manager   ~0051415

ok, nice!

Issue History

Date Modified Username Field Change
2024-01-28 17:44 ale New Issue
2024-01-28 17:44 ale File Added: create-line-style-first-draft.gif
2024-01-28 19:16 nitramr Assigned To => nitramr
2024-01-28 19:16 nitramr Status new => assigned
2024-01-29 19:27 ale Note Added: 0050953
2024-01-29 19:27 ale File Added: create-line-style-draft.diff
2024-01-29 19:27 ale File Added: stylecreator.cpp
2024-01-29 19:27 ale File Added: stylecreator.h
2024-01-29 19:27 ale File Added: stylecreator.ui
2024-02-01 16:11 ale Note Added: 0050959
2024-02-01 16:24 nitramr Note Added: 0050960
2024-10-05 15:55 nitramr Note Added: 0051412
2024-10-05 15:55 nitramr File Added: style_edit_new.png
2024-10-07 18:21 ale Note Added: 0051415