View Issue Details

IDProjectCategoryView StatusLast Update
0017282ScribusGeneralpublic2024-10-23 18:42
Reporternitramr Assigned Tonitramr  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformDesktop PCOSUbuntuOS Version24.04 64-bit
Product Version1.7.0.svn 
Target Version1.7.0Fixed in Version1.7.0.svn 
Summary0017282: Page preview don't support section numbers
DescriptionThe new page preview widget doesn't show section number as page numbers.

I fixed that issue.
Steps To Reproduce1. Create a new document
2. Add a couple of pages
3. Go to File -> document settings -> sections
4. Add a new section and select e.g. roman numbers
5. Confirm dialog and go to page arrange palette
Bug: page numbers still all integer
TagsNo tags attached.
PatchYes

Activities

nitramr

2024-09-28 13:13

developer  

pagepreview_2024-09-28_01.patch (17,528 bytes)   
Index: scribus/ui/pagepalette_pages.cpp
===================================================================
--- scribus/ui/pagepalette_pages.cpp	(Revision 26311)
+++ scribus/ui/pagepalette_pages.cpp	(Arbeitskopie)
@@ -191,39 +191,39 @@
 		return;
 	}
 
-	if (pageViewWidget->pageGrid()->rowHeight() == PageGrid::Small)
-	{
-		for (int i = 0; i < currView->m_doc->DocPages.count(); ++i)
-		{
-			if (i < pageViewWidget->pageGrid()->pageList.count())
-			{
-				ScPage page = *currView->m_doc->DocPages.at(i);
-				double pageRatio = page.width() / page.height();
+	if (pageViewWidget->pageGrid()->rowHeight() == PageGrid::Small)
+	{
+		for (int i = 0; i < currView->m_doc->DocPages.count(); ++i)
+		{
+			if (i < pageViewWidget->pageGrid()->pageList.count())
+			{
+				ScPage page = *currView->m_doc->DocPages.at(i);
+				double pageRatio = page.width() / page.height();
 
-				PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i);
-				pc->pagePreview = QPixmap();
-				pc->pageRatio = pageRatio;
-			}
-		}
-	}
-	else
-	{
-		PageToPixmapFlags flags = Pixmap_DrawFrame | Pixmap_DrawBackground | Pixmap_DontReloadImages | Pixmap_NoCanvasModeChange;
-		QMap<int, QImage> previews = currView->PagesToPixmap(pageViewWidget->pageGrid()->pageHeight() * qApp->devicePixelRatio(), -1, flags);
+				PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i);
+				pc->pagePreview = QPixmap();
+				pc->pageRatio = pageRatio;
+			}
+		}
+	}
+	else
+	{
+		PageToPixmapFlags flags = Pixmap_DrawFrame | Pixmap_DrawBackground | Pixmap_DontReloadImages | Pixmap_NoCanvasModeChange;
+		QMap<int, QImage> previews = currView->PagesToPixmap(pageViewWidget->pageGrid()->pageHeight() * devicePixelRatio(), -1, flags);
 
-		for (int i = 0; i < currView->m_doc->DocPages.count(); ++i)
+		for (int i = 0; i < currView->m_doc->DocPages.count(); ++i)
 		{
-			if (previews.contains(i) && i < pageViewWidget->pageGrid()->pageList.count())
-			{
-				ScPage page = *currView->m_doc->DocPages.at(i);
-				double pageRatio = page.width() / page.height();
-				QPixmap pix = ( previews.contains(i) ) ? QPixmap::fromImage( previews.value(i) ) : QPixmap();
-				pix.setDevicePixelRatio(qApp->devicePixelRatio());
+			if (previews.contains(i) && i < pageViewWidget->pageGrid()->pageList.count())
+			{
+				ScPage page = *currView->m_doc->DocPages.at(i);
+				double pageRatio = page.width() / page.height();
+				QPixmap pix = ( previews.contains(i) ) ? QPixmap::fromImage( previews.value(i) ) : QPixmap();
+				pix.setDevicePixelRatio(devicePixelRatio());
 
-				PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i);
-				pc->pagePreview = pix;
-				pc->pageRatio = pageRatio;
-			}
+				PageCell *pc = pageViewWidget->pageGrid()->pageList.at(i);
+				pc->pagePreview = pix;
+				pc->pageRatio = pageRatio;
+			}
 		}
 	}
 
@@ -385,15 +385,16 @@
 	for (int i = 0; i < currView->m_doc->DocPages.count(); ++i)
 	{
 		ScPage page = *currView->m_doc->DocPages.at(i);
+		QString sectionNumber(currView->m_doc->getSectionPageNumberForPageIndex(i));
+		if (sectionNumber.isEmpty())
+			sectionNumber = sectionNumber.setNum(i + 1);
 
-		QString str = page.masterPageName();
-		double pageRatio = page.width() / page.height();
-		QPixmap pix = (previews.contains(i)) ? QPixmap::fromImage(previews.value(i)) : QPixmap();
-
-		// empty page
-		PageCell *pc = new PageCell(str, i,
-									pix,// QPixmap can replace with real page preview
-									pageRatio);
+		PageCell *pc = new PageCell(
+			page.masterPageName(),
+			i, sectionNumber,
+			(previews.contains(i)) ? QPixmap::fromImage(previews.value(i)) : QPixmap(),
+			page.width() / page.height()
+		);
 		pageViewWidget->pageGrid()->pageList.append(pc);
 	}
 
Index: scribus/ui/pagepalette_widgets.cpp
===================================================================
--- scribus/ui/pagepalette_widgets.cpp	(Revision 26311)
+++ scribus/ui/pagepalette_widgets.cpp	(Arbeitskopie)
@@ -678,52 +678,52 @@
 		return;
 
 	QFont font(this->font().family(), m_fontSize, QFont::Normal);
-	QFont fontName(this->font().family(), m_fontSize * 0.8, QFont::Normal);
+	QFont fontName(this->font().family(), m_fontSize * 0.8, QFont::Normal);
 	QRect rectPage(cellPosition.x(), cellPosition.y(), tile->pageWidthByHeight(pageHeight()), pageHeight());
 	QRect rectCell(cellPosition.x(), cellPosition.y(), tile->pageWidthByHeight(pageHeight()), m_rowHeight);
 
-	QString pageName = tile->pageName;
-	int pageNameHyphen = tile->pageName.indexOf("-");
-	// Fail fast if no hyphen or nothing to the left of it
-	if (pageNameHyphen > 0)
-	{
-		// Trim whitespace and ensure at least 1-4 chars or ignore it
-		QString tmp = tile->pageName.left(pageNameHyphen).trimmed();
-		if (tmp.length() > 0 && tmp.length() < 5)
-			pageName = tmp;
-	}
-
+	QString pageName = tile->pageName;
+	int pageNameHyphen = tile->pageName.indexOf("-");
+	// Fail fast if no hyphen or nothing to the left of it
+	if (pageNameHyphen > 0)
+	{
+		// Trim whitespace and ensure at least 1-4 chars or ignore it
+		QString tmp = tile->pageName.left(pageNameHyphen).trimmed();
+		if (tmp.length() > 0 && tmp.length() < 5)
+			pageName = tmp;
+	}
+
 	painter.save();
 
 	// Draw Page
-	if (m_rowHeight == TileSize::Small)
-		painter.fillRect(rectPage, QBrush(Qt::white));
-	else
-		painter.drawPixmap(rectPage, tile->pagePreview, tile->pagePreview.rect());
+	if (m_rowHeight == TileSize::Small)
+		painter.fillRect(rectPage, QBrush(Qt::white));
+	else
+		painter.drawPixmap(rectPage, tile->pagePreview, tile->pagePreview.rect());
 
 	// Setup painter for text drawing
-	painter.setBrush(Qt::NoBrush);
+	painter.setBrush(Qt::NoBrush);
 	painter.setRenderHint(QPainter::TextAntialiasing, true);
 	painter.setFont(font);
 
 	// Draw Page Number
 	painter.setPen(QPen( labelColor ));
-	painter.drawText(rectCell, Qt::AlignHCenter|Qt::AlignBottom | Qt::TextWordWrap, QString::number(tile->pageNumber + 1));
+	painter.drawText(rectCell, Qt::AlignHCenter|Qt::AlignBottom | Qt::TextWordWrap, tile->pageNumberDisplay);
 
-	// Draw Page Name	
-	painter.setFont((pageNameHyphen > 0) ? font : fontName);
-	if (m_rowHeight == TileSize::Small)
-	{
-		painter.setPen(Qt::black);
-		painter.drawText(rectPage.adjusted(1, 1, 0, 0), Qt::AlignVCenter | Qt::AlignCenter |Qt::TextWordWrap, pageName);
-	}
-	else
-	{
-		painter.setBackgroundMode(Qt::OpaqueMode);
-		painter.setBackground(QColor(102, 102, 102));
-		painter.setPen(Qt::white);
-		painter.drawText(rectPage.adjusted(1, 1, 0, 0), Qt::AlignTop | ((isRight) ? Qt::AlignRight : Qt::AlignLeft) |Qt::TextWordWrap, pageName);
-	}
+	// Draw Page Name	
+	painter.setFont((pageNameHyphen > 0) ? font : fontName);
+	if (m_rowHeight == TileSize::Small)
+	{
+		painter.setPen(Qt::black);
+		painter.drawText(rectPage.adjusted(1, 1, 0, 0), Qt::AlignVCenter | Qt::AlignCenter |Qt::TextWordWrap, pageName);
+	}
+	else
+	{
+		painter.setBackgroundMode(Qt::OpaqueMode);
+		painter.setBackground(QColor(102, 102, 102));
+		painter.setPen(Qt::white);
+		painter.drawText(rectPage.adjusted(1, 1, 0, 0), Qt::AlignTop | ((isRight) ? Qt::AlignRight : Qt::AlignLeft) |Qt::TextWordWrap, pageName);
+	}
 
 
 	// Draw selection
Index: scribus/ui/pagepalette_widgets.h
===================================================================
--- scribus/ui/pagepalette_widgets.h	(Revision 26311)
+++ scribus/ui/pagepalette_widgets.h	(Arbeitskopie)
@@ -66,205 +66,206 @@
 	void delMasterRequest(QString);
 
 protected:
-	void mouseReleaseEvent(QMouseEvent *m);
-	void mousePressEvent(QMouseEvent* e);
-	void mouseMoveEvent(QMouseEvent* e);
-	virtual void keyPressEvent(QKeyEvent* e);
-
+	void mouseReleaseEvent(QMouseEvent *m);
+	void mousePressEvent(QMouseEvent* e);
+	void mouseMoveEvent(QMouseEvent* e);
+	virtual void keyPressEvent(QKeyEvent* e);
+
 	QListWidgetItem *m_currItem {nullptr};
-	QPoint m_mousePos {QPoint()};
+	QPoint m_mousePos {QPoint()};
 	bool m_mousePressed {false};
 	bool m_thumb {false};
 
 };
 
-struct SCRIBUS_API PageCell
+struct SCRIBUS_API PageCell
 {
-	QString pageName {QString()};
-	uint pageNumber {1};
-	QPixmap pagePreview {QPixmap()};
-	QColor masterPageColor {QColor()};
-	double pageRatio {1.4142}; // IsoA
-
-	PageCell(const QString& text, uint nr, const QPixmap& pix, double pageRatio, const QColor color = Qt::black) :
-		pageName(text), pageNumber(nr), pagePreview(pix), masterPageColor(color), pageRatio(pageRatio) {}
-
-	int pageWidthByHeight(int height) { return qCeil(height * pageRatio); }
-
-};
-
-/* ********************************************************************************* *
- *
- * Page Grid
- *
- * ********************************************************************************* */
-
-class SCRIBUS_API PageGrid : public QWidget
-{
+	QString pageName {QString()};
+	QString pageNumberDisplay;
+	uint pageNumber {1};
+	QPixmap pagePreview {QPixmap()};
+	QColor masterPageColor {QColor()};
+	double pageRatio {1.4142}; // IsoA
+
+	PageCell(const QString& text, uint nr, const QString &nrDisplay, const QPixmap& pix, double pageRatio, const QColor color = Qt::black) :
+		pageName(text), pageNumber(nr), pageNumberDisplay(nrDisplay), pagePreview(pix), masterPageColor(color), pageRatio(pageRatio) {}
+
+	int pageWidthByHeight(int height) { return qCeil(height * pageRatio); }
+
+};
+
+/* ********************************************************************************* *
+ *
+ * Page Grid
+ *
+ * ********************************************************************************* */
+
+class SCRIBUS_API PageGrid : public QWidget
+{
 	Q_OBJECT
 
-	friend class PageViewer;
-
+	friend class PageViewer;
+
 public:
 
-	enum TileSize {
-		Small = 64,
-		Medium = 96,
-		Large = 128
-	};
+	enum TileSize {
+		Small = 64,
+		Medium = 96,
+		Large = 128
+	};
 
-	explicit PageGrid(QWidget *parent = nullptr);
-
-	void setPageInGroup(int amount);
-
-	void setDocumentPageSize(QSizeF pageSize);
-
-	void setRowHeight(int height);
-	int rowHeight() { return m_rowHeight; };
-
-	void setFontSize(int size);
-	int fontSize() { return m_fontSize; };
-
-	void setSelectionColor(QColor color);
-	QColor selectionColor() { return m_colorSelection; };
-
-	void setPageLayout(PageLayout layout);
-	PageLayout pageLayout() { return m_pageLayout; };
-
-	void setPageOffset(int pageCount);
-	int pageOffset() { return m_pageOffset; };
-
-	QList<PageCell*> pageList {QList<PageCell*>()};
-
-	int pageId(int r, int c, bool clampId = true);
-	int pageId(QPoint pos, bool clampId = true);
-
-	PageCell* getPageItem(int pageIndex);
-
-	int pageCount();
-	int pageHeight();
-
-	void setSelectedPage(int pageID);
-	int selectedPage() { return m_selectedPage; };
-
-	void deleteSelectedPage();
-	void clear();
-	void calculateSize();
-
-private:
-
-	enum State {
-		None = 0,
-		StartDrag = 1,
-		StartSelection = 2
-	};
-
-	enum Mode {
-		Invalid = 0,
-		Insert = 1,
-		Add = 2,
-		Hover = 3
-	};
-
-	QSize m_pageSize {QSize()};
-	QSizeF m_documentPageSize {QSizeF()};
-	int m_rowHeight {QVariant(TileSize::Medium).toInt()};
-	int m_cellGap {1};
-	int m_groupSpace {16};
-	int m_rowSpace {12};
-	int m_fontSize {QFont().pointSize()}; // font size of number label and masterpage label
-	int m_labelGap {8}; // gap between page and number label
-	QRect m_rectInsert {QRect()};
-	QRect m_rectSelection {QRect()};
-	QRect m_rectAdd {QRect()};
-	QColor m_colorSelection;
-	int m_selectedPage {-1};
-	int m_hoveredPage {-1};
-	bool m_enableSelection {false};
-	QPoint m_mousePos {QPoint()};
-	State m_state {State::None};
-	PageLayout m_pageLayout {PageLayout::singlePage};
-	int m_cellsInGroup {1}; // 1 for single page
-	int m_pageOffset {0};
-	QMenu *m_contextMenu {nullptr};
-
-	int columns();
-	int rows();
-
-	int columnAt(QPoint pos);
-	int rowAt(QPoint pos);
-	int rowWidth(int rowId);
-	QRect rectAt(int row, int col);
-
-	QSize dummyPageSize();
-
-	QPoint mapPosToCell(QPoint pos, Mode &mode);
-	QPoint pagePosition(int pageId);
-
-	int clampPageId(int pageID, bool allowPlusOne = false);
-
-	void updateSelectedPage(QPoint pos);
-	void updateModeMarker(QPoint pos);
-	void clearUi();
-	void drawTile(QPainter &painter, QPoint cellPosition, PageCell * tile, bool selected, bool hovered, QColor labelColor, bool isRight);
-	void initContextMenu();
-
-private slots:
-	void showContextMenu(QPoint pos);
-
-protected:
-
-	void paintEvent(QPaintEvent *event) override;
-	void resizeEvent(QResizeEvent *event) override;
-
-	void dropEvent(QDropEvent * event) override;
-	void dragEnterEvent(QDragEnterEvent *event) override;
-	void dragLeaveEvent(QDragLeaveEvent *event) override;
-	void dragMoveEvent(QDragMoveEvent *event) override;
-	void mouseReleaseEvent(QMouseEvent *event) override;
-	void mousePressEvent(QMouseEvent* event) override;
-	void mouseMoveEvent(QMouseEvent* event) override;
-
+	explicit PageGrid(QWidget *parent = nullptr);
+
+	void setPageInGroup(int amount);
+
+	void setDocumentPageSize(QSizeF pageSize);
+
+	void setRowHeight(int height);
+	int rowHeight() { return m_rowHeight; };
+
+	void setFontSize(int size);
+	int fontSize() { return m_fontSize; };
+
+	void setSelectionColor(QColor color);
+	QColor selectionColor() { return m_colorSelection; };
+
+	void setPageLayout(PageLayout layout);
+	PageLayout pageLayout() { return m_pageLayout; };
+
+	void setPageOffset(int pageCount);
+	int pageOffset() { return m_pageOffset; };
+
+	QList<PageCell*> pageList {QList<PageCell*>()};
+
+	int pageId(int r, int c, bool clampId = true);
+	int pageId(QPoint pos, bool clampId = true);
+
+	PageCell* getPageItem(int pageIndex);
+
+	int pageCount();
+	int pageHeight();
+
+	void setSelectedPage(int pageID);
+	int selectedPage() { return m_selectedPage; };
+
+	void deleteSelectedPage();
+	void clear();
+	void calculateSize();
+
+private:
+
+	enum State {
+		None = 0,
+		StartDrag = 1,
+		StartSelection = 2
+	};
+
+	enum Mode {
+		Invalid = 0,
+		Insert = 1,
+		Add = 2,
+		Hover = 3
+	};
+
+	QSize m_pageSize {QSize()};
+	QSizeF m_documentPageSize {QSizeF()};
+	int m_rowHeight {QVariant(TileSize::Medium).toInt()};
+	int m_cellGap {1};
+	int m_groupSpace {16};
+	int m_rowSpace {12};
+	int m_fontSize {QFont().pointSize()}; // font size of number label and masterpage label
+	int m_labelGap {8}; // gap between page and number label
+	QRect m_rectInsert {QRect()};
+	QRect m_rectSelection {QRect()};
+	QRect m_rectAdd {QRect()};
+	QColor m_colorSelection;
+	int m_selectedPage {-1};
+	int m_hoveredPage {-1};
+	bool m_enableSelection {false};
+	QPoint m_mousePos {QPoint()};
+	State m_state {State::None};
+	PageLayout m_pageLayout {PageLayout::singlePage};
+	int m_cellsInGroup {1}; // 1 for single page
+	int m_pageOffset {0};
+	QMenu *m_contextMenu {nullptr};
+
+	int columns();
+	int rows();
+
+	int columnAt(QPoint pos);
+	int rowAt(QPoint pos);
+	int rowWidth(int rowId);
+	QRect rectAt(int row, int col);
+
+	QSize dummyPageSize();
+
+	QPoint mapPosToCell(QPoint pos, Mode &mode);
+	QPoint pagePosition(int pageId);
+
+	int clampPageId(int pageID, bool allowPlusOne = false);
+
+	void updateSelectedPage(QPoint pos);
+	void updateModeMarker(QPoint pos);
+	void clearUi();
+	void drawTile(QPainter &painter, QPoint cellPosition, PageCell * tile, bool selected, bool hovered, QColor labelColor, bool isRight);
+	void initContextMenu();
+
+private slots:
+	void showContextMenu(QPoint pos);
+
+protected:
+
+	void paintEvent(QPaintEvent *event) override;
+	void resizeEvent(QResizeEvent *event) override;
+
+	void dropEvent(QDropEvent * event) override;
+	void dragEnterEvent(QDragEnterEvent *event) override;
+	void dragLeaveEvent(QDragLeaveEvent *event) override;
+	void dragMoveEvent(QDragMoveEvent *event) override;
+	void mouseReleaseEvent(QMouseEvent *event) override;
+	void mousePressEvent(QMouseEvent* event) override;
+	void mouseMoveEvent(QMouseEvent* event) override;
+
 signals:
-	void useTemplate(QString, int);
-	void newPage(int, QString);
+	void useTemplate(QString, int);
+	void newPage(int, QString);
 	void movePage(int, int);
-	void click(int, int);
+	void click(int, int);
 	void delPageRequest(int);
-	void previewSizeChanged();
-};
+	void previewSizeChanged();
+};
 
-/* ********************************************************************************* *
- *
- * Page Viewer
- *
- * ********************************************************************************* */
-
-class SCRIBUS_API PageViewer : public QWidget
-{
-
-public:
-	PageViewer(QWidget *parent = nullptr);
-	~PageViewer() {};
-
-	PageGrid *pageGrid();
-	void scrollToPage(int pageId);
-
-
+/* ********************************************************************************* *
+ *
+ * Page Viewer
+ *
+ * ********************************************************************************* */
+
+class SCRIBUS_API PageViewer : public QWidget
+{
+
+public:
+	PageViewer(QWidget *parent = nullptr);
+	~PageViewer() {};
+
+	PageGrid *pageGrid();
+	void scrollToPage(int pageId);
+
+
 protected:
-	PageGrid *m_pageGrid {nullptr};
-	QScrollArea* m_scroll {nullptr};
-
-	virtual void keyPressEvent(QKeyEvent* event);
-
+	PageGrid *m_pageGrid {nullptr};
+	QScrollArea* m_scroll {nullptr};
+
+	virtual void keyPressEvent(QKeyEvent* event);
+
 };
 
-/* ********************************************************************************* *
- *
- * Trash bin
- *
- * ********************************************************************************* */
-
+/* ********************************************************************************* *
+ *
+ * Trash bin
+ *
+ * ********************************************************************************* */
+
 class SCRIBUS_API TrashBin : public QLabel
 {
 	Q_OBJECT
pagepreview_2024-09-28_01.patch (17,528 bytes)   
section_numbers.png (36,064 bytes)   
section_numbers.png (36,064 bytes)   

Issue History

Date Modified Username Field Change
2024-09-28 13:13 nitramr New Issue
2024-09-28 13:13 nitramr File Added: pagepreview_2024-09-28_01.patch
2024-09-28 13:13 nitramr File Added: section_numbers.png
2024-09-29 14:43 cbradney Assigned To => nitramr
2024-09-29 14:43 cbradney Status new => resolved
2024-09-29 14:43 cbradney Resolution open => fixed
2024-09-29 14:43 cbradney Fixed in Version => 1.7.0.svn
2024-10-23 18:42 cbradney Status resolved => closed