View Issue Details

IDProjectCategoryView StatusLast Update
0017402ScribusUser Interfacepublic2025-02-02 09:43
Reporterale Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
Status newResolutionopen 
Product Version1.7.1.svn 
Summary0017402: [PATCH] Simplify the choice of the layout in the "New Document" dialog
DescriptionCurrently, it is rather cumbersome to create a double sided document and making sure that the correct first page is selected.

And this is a step that many (if not most) Scribus users do when creating a new document.

I suggest that we use three tool buttons for defining the layout of the document:

- single page
- double page starting left
- double page starting right

If, in the future, we add back the choice for three and four folded documents, it's probably because we have figured out how to cope with complex layouts.
If that happens, I would add a fourth button for the configuration of such less common options and keep the three existing button for fast access to the options that are mostly used.
TagsNo tags attached.
PatchYes

Activities

ale

2025-02-02 08:59

manager  

file-new-buttons.png (38,058 bytes)   
file-new-buttons.png (38,058 bytes)   

ale

2025-02-02 09:25

manager   ~0051991

Here is the patch.

It makes the UI and the code (much) simpler.

I would also like to suggest removing (for now) the ui/widgets/pagelayout.* files since they are not used anymore.
If this is done in a separate commit, with a good message attached, it will be easy to restore the files again, as soon as they are needed again.
Or at least, a good comment should be added to those files, stating what are the features in there and what they can be used for.
new-document-simplify-layout-buttons.diff (16,430 bytes)   
From ccf599d9857b9cca8f59d400927c82f7fd19421e Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sun, 2 Feb 2025 10:19:52 +0100
Subject: Simplify the choice of the layout in the "New Document" dialog by
 using tool buttons


diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index 3379f4559..d539b3185 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -2016,7 +2016,7 @@ void ScribusMainWindow::startUpDialog()
 		if (dia->tabSelected() == NewDocDialog::NewDocumentTab)
 		{
 			int facingPages = dia->choosenLayout();
-			int firstPage = dia->pageLayouts->firstPage();//firstPage->currentIndex();
+			int firstPage = dia->layoutFirstPage();
 			docSet = dia->startDocSetup->isChecked();
 			double topMargin = dia->marginGroup->margins().top();
 			double bottomMargin = dia->marginGroup->margins().bottom();
@@ -2092,7 +2092,7 @@ bool ScribusMainWindow::slotFileNew()
 		return false;
 
 	int facingPages = dia->choosenLayout();
-	int firstPage = dia->pageLayouts->firstPage();
+	int firstPage = dia->layoutFirstPage();
 	bool docSet = dia->startDocSetup->isChecked();
 	double topMargin = dia->marginGroup->margins().top();
 	double bottomMargin = dia->marginGroup->margins().bottom();
diff --git a/scribus/ui/newdocdialog.cpp b/scribus/ui/newdocdialog.cpp
index c33dbf407..2f761051b 100644
--- a/scribus/ui/newdocdialog.cpp
+++ b/scribus/ui/newdocdialog.cpp
@@ -66,6 +66,9 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
 
 	buttonVertical->setIcon(iconManager.loadIcon("page-orientation-vertical"));
 	buttonHorizontal->setIcon(iconManager.loadIcon("page-orientation-horizontal"));
+	buttonSinglePage->setIcon(iconManager.loadIcon("16/page-simple.png"));
+	buttonDoublePageLeft->setIcon(iconManager.loadIcon("page-first-left"));
+	buttonDoublePageRight->setIcon(iconManager.loadIcon("page-first-right"));
 	labelColumns->setPixmap(iconManager.loadPixmap("paragraph-columns"));
 
 	createNewDocPage();
@@ -92,6 +95,9 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
 	listPageFormats->setToolTip( tr( "Document page size, either a standard size or a custom size" ) );
 	buttonVertical->setToolTip( tr( "Vertical orientation of the document's pages" ) );
 	buttonHorizontal->setToolTip( tr( "Horizontal orientation of the document's pages" ) );
+	buttonSinglePage->setToolTip(tr("Single page document"));
+	buttonDoublePageLeft->setToolTip(tr("Double page document, with the first page on the left side"));
+	buttonDoublePageRight->setToolTip(tr("Double page document, with the first page on the right side"));
 	widthSpinBox->setToolTip( tr( "Width of the document's pages, editable if you have chosen a custom page size" ) );
 	heightSpinBox->setToolTip( tr( "Height of the document's pages, editable if you have chosen a custom page size" ) );
 	pageCountSpinBox->setToolTip( tr( "Initial number of pages of the document" ) );
@@ -105,13 +111,12 @@ NewDocDialog::NewDocDialog(QWidget* parent, const QStringList& recentDocs, bool
 	connect(buttonBox, &QDialogButtonBox::rejected, this, &NewDocDialog::reject);
 
 	connect(pageOrientationButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setOrientation);
+	connect(pageLayoutButtons, &QButtonGroup::idClicked, this, &NewDocDialog::setLayout);
 	connect(unitOfMeasureComboBox, SIGNAL(activated(int)), this, SLOT(setUnit(int)));
 	connect(Distance, SIGNAL(valueChanged(double)), this, SLOT(setDistance(double)));
 	connect(autoTextFrame, SIGNAL(clicked()), this, SLOT(handleAutoFrame()));
 	connect(listPageFormats, &PageSizeList::clicked, this, &NewDocDialog::changePageSize);
 	connect(pageSizeSelector, &PageSizeSelector::pageCategoryChanged, this, &NewDocDialog::changeCategory);
-	connect(pageLayouts, &PageLayouts::schemeChanged, this, &NewDocDialog::changeScheme);
-	connect(pageLayouts, &PageLayouts::firstPageChanged, this, &NewDocDialog::changeFirstPage);
 	connect(marginGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin);
 	connect(bleedGroup, &NewMarginWidget::marginChanged, this, &NewDocDialog::changeMargin);
 	connect(comboSortSizes, &QComboBox::currentIndexChanged, this, &NewDocDialog::changeSortMode);
@@ -142,6 +147,23 @@ void NewDocDialog::createNewDocPage()
 	pageOrientationButtons->addButton(buttonHorizontal, 1);
 	pageOrientationButtons->button(orientation)->setChecked(true);
 
+	pageLayoutButtons = new QButtonGroup();
+	pageLayoutButtons->addButton(buttonSinglePage, 0);
+	pageLayoutButtons->addButton(buttonDoublePageLeft, 1);
+	pageLayoutButtons->addButton(buttonDoublePageRight, 2);
+	if (pagePositioning == singlePage)
+	{
+		pageLayoutButtons->button(0)->setChecked(true);
+	}
+	else if (prefsManager.appPrefs.pageSets[pagePositioning].FirstPage == 0)
+	{
+		pageLayoutButtons->button(1)->setChecked(true);
+	}
+	else
+	{
+		pageLayoutButtons->button(2)->setChecked(true);
+	}
+
 	listPageFormats->setValues(pageSize, orientation, PageSizeInfo::Preferred, PageSizeList::NameAsc);
 
 	pageSizeSelector->setHasFormatSelector(false);
@@ -190,8 +212,6 @@ void NewDocDialog::createNewDocPage()
 	IconManager &iconManager = IconManager::instance();
 	pageCountLabel->setPixmap(iconManager.loadPixmap("panel-page"));
 
-	pageLayouts->updateSchemeSelector(prefsManager.appPrefs.pageSets, prefsManager.appPrefs.pageSets[pagePositioning].FirstPage);
-
 	setDocLayout(pagePositioning);
 	setSize(pageSize);
 	setOrientation(orientation);
@@ -237,7 +257,7 @@ void NewDocDialog::createNewDocPage()
 	labelGap->setLabelVisibility(m_labelVisibity);
 	pageCountLabel->setLabelVisibility(m_labelVisibity);
 	orientationLabel->setLabelVisibility(m_labelVisibity);
-	pageLayouts->toggleLabelVisibility(m_labelVisibity);
+	pageLayoutLabel->setLabelVisibility(m_labelVisibity);
 
 	// We have to install an event filter to resize the scroll container width based on the content width.
 	// The content width can change after we calculated the initial ui layout.
@@ -321,7 +341,7 @@ void NewDocDialog::setWidth(double)
 	bleedGroup->setPageWidth(m_pageWidth);
 	listPageFormats->clearSelection();
 	m_pageSize = CommonStrings::customPageSize;
-	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage());
+	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
 
 	int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage;
 	if (newOrientation != m_orientation)
@@ -343,7 +363,7 @@ void NewDocDialog::setHeight(double)
 	bleedGroup->setPageHeight(m_pageHeight);	
 	listPageFormats->clearSelection();
 	m_pageSize = CommonStrings::customPageSize;
-	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage());
+	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
 
 	int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage;
 	if (newOrientation != m_orientation)
@@ -357,12 +377,6 @@ void NewDocDialog::setHeight(double)
 	}
 }
 
-void NewDocDialog::selectItem(uint nr)
-{
-	pageLayouts->setScheme(nr);
-	pageLayouts->setFirstPage(nr);
-}
-
 void NewDocDialog::changePageSize(const QModelIndex &ic)
 {
 	int unit = ic.data(PageSizeList::Unit).toInt();
@@ -376,12 +390,6 @@ void NewDocDialog::changePageSize(const QModelIndex &ic)
 
 }
 
-void NewDocDialog::changeScheme(int ic)
-{
-	selectItem(ic);
-	setDocLayout(ic);
-}
-
 void NewDocDialog::changeSortMode(int ic)
 {
 	Q_UNUSED(ic);
@@ -504,12 +512,32 @@ void NewDocDialog::setOrientation(int ori)
 	marginGroup->setPageWidth(m_pageWidth);
 	bleedGroup->setPageHeight(m_pageHeight);
 	bleedGroup->setPageWidth(m_pageWidth);
-	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage());
+	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
 
 	connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
 	connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
 }
 
+void NewDocDialog::setLayout(int layoutId)
+{
+	switch (layoutId)
+	{
+		case 0:
+			setDocLayout(0);
+		break;
+		case 1:
+			setDocLayout(1);
+			pagePreview->setFirstPage(0);
+			setDocFirstPage(0);
+		break;
+		case 2:
+			setDocLayout(1);
+			pagePreview->setFirstPage(1);
+			setDocFirstPage(1);
+		break;
+	}
+}
+
 void NewDocDialog::setPageSize(const QString &size)
 {
 	setSize(size);
@@ -555,7 +583,7 @@ void NewDocDialog::setSize(const QString& gr)
 	marginGroup->setPageWidth(m_pageWidth);
 	bleedGroup->setPageHeight(m_pageHeight);
 	bleedGroup->setPageWidth(m_pageWidth);
-	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage());
+	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
 
 	connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double)));
 	connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double)));
@@ -567,9 +595,13 @@ void NewDocDialog::setDocLayout(int layout)
 	marginGroup->setFacingPages(layout != singlePage);
 	bleedGroup->setFacingPages(layout != singlePage);
 	m_choosenLayout = layout;
-	pageLayouts->setScheme(m_choosenLayout);
-	pageLayouts->setFirstPage(prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage);
-	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, pageLayouts->firstPage());
+	m_layoutFirstPage = prefsManager.appPrefs.pageSets[m_choosenLayout].FirstPage;
+	pagePreview->setPage(m_pageHeight, m_pageWidth, marginGroup->margins(), bleedGroup->margins(), m_pageSize, m_choosenLayout, m_layoutFirstPage);
+}
+
+void NewDocDialog::setDocFirstPage(int firstPage)
+{
+	m_layoutFirstPage = firstPage;
 }
 
 void NewDocDialog::recentDocListBox_doubleClicked()
@@ -656,11 +688,6 @@ void NewDocDialog::changeBleed(MarginStruct bleed)
 	pagePreview->setBleeds(bleed);
 }
 
-void NewDocDialog::changeFirstPage(int firstPage)
-{
-	pagePreview->setFirstPage(firstPage);
-}
-
 void NewDocDialog::changeCategory(PageSizeInfo::Category category)
 {
 	if (listPageFormats->category() == category)
diff --git a/scribus/ui/newdocdialog.h b/scribus/ui/newdocdialog.h
index 48f3f5670..a65550f3d 100644
--- a/scribus/ui/newdocdialog.h
+++ b/scribus/ui/newdocdialog.h
@@ -76,6 +76,7 @@ public:
 
 	int orientation() const { return m_orientation;}
 	int choosenLayout() const { return m_choosenLayout;}
+	int layoutFirstPage() const { return m_layoutFirstPage; }
 	double pageWidth() const { return m_pageWidth;}
 	double pageHeight() const { return m_pageHeight;}
 	double distance() const { return m_distance;}
@@ -87,14 +88,15 @@ public:
 public slots:
 	void setHeight(double v);
 	void setWidth(double v);
-	void selectItem(uint nr);	
 	void handleAutoFrame();
 	void setDistance(double v);
 	void setUnit(int u);
 	void ExitOK();
 	void setOrientation(int ori);
+	void setLayout(int layoutId);
 	void setPageSize(const QString &);
 	void setDocLayout(int layout);
+	void setDocFirstPage(int firstPage);
 	/*! Opens document on doubleclick
 	\author Petr Vanek <petr@yarpen.cz>
 	*/
@@ -111,20 +113,20 @@ public slots:
 private slots:
 	void changeMargin(MarginStruct margin);
 	void changeBleed(MarginStruct bleed);
-	void changeFirstPage(int firstPage);
 	void changeCategory(PageSizeInfo::Category category);
 	void changePageSize(const QModelIndex &ic);
-	void changeScheme(int ic);
 	void changeSortMode(int ic);
 
 protected:
 	PrefsManager& prefsManager;
 	QStringList recentDocList;
 	QButtonGroup* pageOrientationButtons;
+	QButtonGroup* pageLayoutButtons;
 
 	double m_unitRatio { 1.0 };
 	int m_orientation { 0 };
 	int m_choosenLayout { 0 };
+	int m_layoutFirstPage { 0 };
 	double m_pageWidth { 1.0 };
 	double m_pageHeight { 1.0 };
 	double m_distance { 11.0 };
diff --git a/scribus/ui/newdocdialog.ui b/scribus/ui/newdocdialog.ui
index ab7f4d8f0..53c60dcff 100644
--- a/scribus/ui/newdocdialog.ui
+++ b/scribus/ui/newdocdialog.ui
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>900</width>
+    <width>897</width>
     <height>650</height>
    </rect>
   </property>
@@ -122,9 +122,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>-53</y>
-            <width>320</width>
-            <height>588</height>
+            <y>0</y>
+            <width>267</width>
+            <height>564</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_7">
@@ -419,13 +419,64 @@
                   </spacer>
                  </item>
                  <item>
-                  <widget class="PageLayouts" name="pageLayouts" native="true">
-                   <property name="minimumSize">
-                    <size>
-                     <width>24</width>
-                     <height>0</height>
-                    </size>
+                  <widget class="FormWidget" name="pageLayoutLabel">
+                   <property name="sizePolicy">
+                    <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+                     <horstretch>0</horstretch>
+                     <verstretch>0</verstretch>
+                    </sizepolicy>
                    </property>
+                   <property name="label" stdset="0">
+                    <string>Layout</string>
+                   </property>
+                   <layout class="QHBoxLayout" name="horizontalLayout_9">
+                    <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="horizontalLayout_10">
+                      <item>
+                       <widget class="QToolButton" name="buttonSinglePage">
+                        <property name="text">
+                         <string/>
+                        </property>
+                        <property name="checkable">
+                         <bool>true</bool>
+                        </property>
+                       </widget>
+                      </item>
+                      <item>
+                       <widget class="QToolButton" name="buttonDoublePageLeft">
+                        <property name="text">
+                         <string/>
+                        </property>
+                        <property name="checkable">
+                         <bool>true</bool>
+                        </property>
+                       </widget>
+                      </item>
+                      <item>
+                       <widget class="QToolButton" name="buttonDoublePageRight">
+                        <property name="text">
+                         <string/>
+                        </property>
+                        <property name="checkable">
+                         <bool>true</bool>
+                        </property>
+                       </widget>
+                      </item>
+                     </layout>
+                    </item>
+                   </layout>
                   </widget>
                  </item>
                  <item>
@@ -781,12 +832,6 @@
    <header>ui/newmarginwidget.h</header>
    <container>1</container>
   </customwidget>
-  <customwidget>
-   <class>PageLayouts</class>
-   <extends>QWidget</extends>
-   <header location="global">ui/widgets/pagelayout.h</header>
-   <container>1</container>
-  </customwidget>
   <customwidget>
    <class>PageSizeList</class>
    <extends>QListWidget</extends>

Issue History

Date Modified Username Field Change
2025-02-02 08:59 ale New Issue
2025-02-02 08:59 ale File Added: file-new-buttons.png
2025-02-02 09:19 ale Summary [PATCH] Simplfy the choice of the layout in the "New Document" dialog => [PATCH] Simplify the choice of the layout in the "New Document" dialog
2025-02-02 09:25 ale Note Added: 0051991
2025-02-02 09:25 ale File Added: new-document-simplify-layout-buttons.diff
2025-02-02 09:43 ale Description Updated