View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017274 | Scribus | User Interface | public | 2024-09-17 00:47 | 2024-09-21 10:02 |
Reporter | BN_Dev | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | x86_64 | OS | Linux/macOS | OS Version | All |
Product Version | 1.7.0.svn | ||||
Summary | 0017274: Page prefixes | ||||
Description | InDesign, QuarkXPress, and Scribus 1.6.2 supported the concept of Page Prefixes. In 1.7.0svn this feature has gone. It looks like some work on the Page pallet has removed it, which is quite useful for efficient layout productivity. Attached is a proposal to restore the functionality, visible in attachment scribus_1.7.0.png. InDesign has a specific field for the prefix, but QuarkXPress and Scribus extract it from the page name text. Previously Scribus used a regexp which was a little slow and opaque, but the current method of extracting any prefix is a bit simpler. I would add, on a 4K screen the whole program can be hit-and-miss with the scaling so the proposed font-size might be a bit too much, although internal user testing also said that the page numbers were a little on the small side too. Previously in Scribus they formed part of the page preview icon itself which seems to be easier to read. But of course it's all subjective. | ||||
Tags | No tags attached. | ||||
Patch | Yes | ||||
|
pageprefix.patch (1,540 bytes)
Index: scribus/ui/pagepalette_widgets.cpp =================================================================== --- scribus/ui/pagepalette_widgets.cpp (revision 26292) +++ scribus/ui/pagepalette_widgets.cpp (working copy) @@ -701,11 +701,30 @@ painter.setPen(QPen( labelColor )); painter.drawText(rectCell, Qt::AlignHCenter|Qt::AlignBottom | Qt::TextWordWrap, QString::number(tile->pageNumber + 1)); - // Draw Page Name + // Determine if Page Name contains a Page Prefix + QString pagePrefix = ""; + 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) + pagePrefix = tmp; + } + + // Draw Page Name or Page Prefix painter.setBackgroundMode(Qt::OpaqueMode); painter.setBackground(QColor(0,0,0,128)); painter.setPen(QPen(Qt::white)); - painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft |Qt::TextWordWrap, tile->pageName); + if (pagePrefix.isEmpty ()) + { + painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft |Qt::TextWordWrap, tile->pageName); + } else { + font.setPointSize(m_fontSize * 2); + painter.setFont(font); + painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignCenter | Qt::AlignCenter, pagePrefix); + } // Draw Master Page Color // painter.setPen(Qt::NoPen); |
|
I suggest to add the following documentation to the code above:/*** Master page names can have a 1 to 4 letters prefix, terminated by a dash; If defined, the prefix is displayed at the double of the normal size */ (If I understood correctly what the patch does...) This having been said, personally, I prefer explicit fields to hard to find hidden shortcuts... But, yes, adding a field to the Master Page dialog and to the .sla file format is much more work... |
|
Thanks ale, yes I've add that in new attachment now. I also realized the C style was for a different project so I tidied that up. I think you're fully correct that a dedicated field is the "best" solution, but practically speaking it's a lot more work as you mention. Only professional teams would really use such a feature, and I do prefer the QuarkXPress approach of "if you know they're a thing then use them" and if not most users will carry on oblivious it even exists. When we were evaluating Scribus 1.6.2 people instinctively started using prefixes and they Just Worked™ which was great; that's why we were quite surprised they disappeared from the latest svn. It looks like that file has undergone a lot of refactoring since 1.6.2 and there's a bit of dead code in the general vicinity. I also found during testing that maybe it's worth considering putting some sensible limits on page names, because at the moment one can create pages names that are just variable lengths of whitespace. It should probably be trimmed before being accepted as it looks like it could be the source of unintended results if users start entering odd things. I was going to discuss that in the forum because there are some other considerations regarding it. Many thanks! pageprefix-2.patch (1,647 bytes)
Index: scribus/ui/pagepalette_widgets.cpp =================================================================== --- scribus/ui/pagepalette_widgets.cpp (revision 26292) +++ scribus/ui/pagepalette_widgets.cpp (working copy) @@ -701,11 +701,33 @@ painter.setPen(QPen( labelColor )); painter.drawText(rectCell, Qt::AlignHCenter|Qt::AlignBottom | Qt::TextWordWrap, QString::number(tile->pageNumber + 1)); - // Draw Page Name + /*** + Master page names can have a 1 to 4 letters prefix, terminated by a dash; + If defined, the prefix is displayed at the double of the normal size + */ + QString pagePrefix = ""; + 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) + pagePrefix = tmp; + } + + // Draw Page Name or Page Prefix painter.setBackgroundMode(Qt::OpaqueMode); painter.setBackground(QColor(0,0,0,128)); painter.setPen(QPen(Qt::white)); - painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft |Qt::TextWordWrap, tile->pageName); + if (pagePrefix.isEmpty ()) + { + painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, tile->pageName); + } else { + font.setPointSize(m_fontSize * 2); + painter.setFont(font); + painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignCenter | Qt::AlignCenter, pagePrefix); + } // Draw Master Page Color // painter.setPen(Qt::NoPen); |
|
Good catch. Looks like I accidentally removed the prefix logic when reimplementing the page layout widget. Is it really necessary to have a different text style just for the prefix? To me, this looks very inconsistent. It could be rendered in the same style as the full label. Just a few ideas: 1. We can limit the label length for the labels rendered on the page, see https://doc.qt.io/qt-6/qfontmetrics.html#elidedText (the width can be based on the width of the thumbnail. Currently, three different preview sizes are available) 2. Maybe it is better to place the master page label somewhere else than in the preview. We could place it in () next to the page number. Surely it is also good to render the label as elided text. |
|
Thanks Martin. From the end user feedback I got they cared about just 3 things: 1. Page number 2. Page prefix 3. Speed of seeing both the above The raison d'etre for page prefixes is at-a-glance clarity of what template is in use and where. If the font is too small it's a little self-defeating, they want it to be clearly visible to help them quickly work through the document and lay it out according to the layout plan. The preview images themselves are nice but the professional layout job is driven more by page number and template. I mention in my ticket we're using 4K screens and the text looks quite small in most places. The QT_SCALE_FACTOR env var affects a lot of stuff but doesn't seem to make much difference to the preview icons, hence picking double font size, it seemed to also look closer to how 1.6.2 looked. If the prefix does end up after the page number I think wrapping it in brackets may clutter it and make it harder to read, it would be better for the text to be "1 A" rather than "1 (A)". I also think it's worth noting that users who don't use/care about this feature won't see any difference with my proposed patch. The professionals that do use it will want items 1-3 and as it will be an all-or-nothing approach (they are unlikely to mix prefixed and non-prefixed pages), it will look uniform when they are all prefixed. Totally open to suggestions on the best way to proceed; but wondering if a user preference to control this is maybe a bit overkill? |
|
What about this? The font size for page numbers and prefix is equal to the UI font size. Only if the page name has no prefix, it applies a down scale to 80%. BTW: my patch file is larger than it should be. I have no idea why so many changes are detected in the header file. pagepreview_2024-09-17_01.patch (12,252 bytes)
Index: scribus/ui/pagepalette_widgets.cpp =================================================================== --- scribus/ui/pagepalette_widgets.cpp (Revision 26292) +++ scribus/ui/pagepalette_widgets.cpp (Arbeitskopie) @@ -11,6 +11,7 @@ #include <QDrag> #include <QElapsedTimer> #include <QEvent> +#include <QFontMetrics> #include <QHeaderView> #include <QLabel> #include <QList> @@ -673,7 +674,7 @@ update(); } -void PageGrid::drawTile(QPainter &painter, QPoint cellPosition, PageCell *tile, bool selected, bool hovered, QColor labelColor) +void PageGrid::drawTile(QPainter &painter, QPoint cellPosition, PageCell *tile, bool selected, bool hovered, QColor labelColor, bool isRight) { if (tile == nullptr) @@ -680,10 +681,25 @@ return; QFont font(this->font().family(), m_fontSize, QFont::Normal); + QFont fontName(this->font().family(), m_fontSize * 0.8, QFont::Normal); + QFontMetrics fm(font); QRect rectPage(cellPosition.x(), cellPosition.y(), tile->pageWidthByHeight(pageHeight()), pageHeight()); QRect rectCell(cellPosition.x(), cellPosition.y(), tile->pageWidthByHeight(pageHeight()), m_rowHeight); // QRect rectMasterPageMarker(cellPosition.x(), cellPosition.y() + rectPage.height(), rectPage.width(), 4); + 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; + } + +// pageName = fm.elidedText(pageName, Qt::TextElideMode::ElideRight, rectPage.adjusted(1, 1, 0, 0).width()); + painter.save(); // Draw Page @@ -703,9 +719,10 @@ // Draw Page Name painter.setBackgroundMode(Qt::OpaqueMode); - painter.setBackground(QColor(0,0,0,128)); + painter.setBackground(QColor(102, 102, 102)); + painter.setFont((pageNameHyphen > 0) ? font : fontName); painter.setPen(QPen(Qt::white)); - painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft |Qt::TextWordWrap, tile->pageName); + painter.drawText(rectPage.adjusted(1, 1, 0, 0), Qt::AlignTop | ((isRight) ? Qt::AlignRight : Qt::AlignLeft) |Qt::TextWordWrap, pageName); // Draw Master Page Color // painter.setPen(Qt::NoPen); @@ -820,7 +837,8 @@ if (id == m_selectedPage) selectedPageRect = QRect(x, y, cell->pageWidthByHeight(pageHeight()), pageHeight() ); QPoint pos(x,y); - drawTile(painter, pos, cell, (id == m_selectedPage) ? true : false, (id == m_hoveredPage) ? true : false, foregroundColor); + bool isRightPage = (m_cellsInGroup == c + 1 && m_cellsInGroup > 1); + drawTile(painter, pos, cell, (id == m_selectedPage) ? true : false, (id == m_hoveredPage) ? true : false, foregroundColor, isRightPage); // add space only between pages if ((c + 1) % m_cellsInGroup == 0 || count == pageCount() + m_pageOffset -1) Index: scribus/ui/pagepalette_widgets.h =================================================================== --- scribus/ui/pagepalette_widgets.h (Revision 26292) +++ scribus/ui/pagepalette_widgets.h (Arbeitskopie) @@ -78,186 +78,186 @@ }; -struct SCRIBUS_API PageCell +struct SCRIBUS_API PageCell { - QString pageName; - uint pageNumber; - QPixmap pagePreview; - QColor masterPageColor; - double pageRatio; - - 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; + uint pageNumber; + QPixmap pagePreview; + QColor masterPageColor; + double pageRatio; + + 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 +{ Q_OBJECT - friend class PageViewer; - + friend class PageViewer; + public: - explicit PageGrid(QWidget *parent = nullptr); + explicit PageGrid(QWidget *parent = nullptr); - void setPageInGroup(int amount); + void setPageInGroup(int amount); - void setDocumentPageSize(QSizeF pageSize); - - void setRowHeight(int size); - 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; - - 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; - QSizeF m_documentPageSize; - int m_rowHeight {96}; - int m_cellGap {1}; - int m_groupSpace {16}; - int m_rowSpace {12}; - int m_fontSize {8}; // 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; - 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; - - 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); - 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; - + void setDocumentPageSize(QSizeF pageSize); + + void setRowHeight(int size); + 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; + + 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; + QSizeF m_documentPageSize; + int m_rowHeight {96}; + 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; + 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; + + 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; - QScrollArea* m_scroll; - - virtual void keyPressEvent(QKeyEvent* event); - + PageGrid *m_pageGrid; + QScrollArea* m_scroll; + + virtual void keyPressEvent(QKeyEvent* event); + }; -/* ********************************************************************************* * - * - * Trash bin - * - * ********************************************************************************* */ - +/* ********************************************************************************* * + * + * Trash bin + * + * ********************************************************************************* */ + class SCRIBUS_API TrashBin : public QLabel { Q_OBJECT |
|
It looks really nice with the opposing justifications. I will ask people to look at it tomorrow. The feedback I got earlier in order of importance was: Number Prefix Preview But the screencap above is in order of legibility: Preview Number Prefix I think going back to what was mentioned; if the user is using a prefix they aren't as interested (if at all) in the preview itself. I think it would be great if the size of the text scaled with the size of the preview itself; although I note when choosing between Small/Medium/Large the font size is staying the same. Perhaps that could scale too? Or maybe an easy novel solution would be to add another preview size of "Off" that just displayed the prefixes and no pictures at all so it's super legible? |
|
I thought about it further. For the small page view, we could remove the page preview completely. That way, you would only have the page name/prefix and the page number. With such a small view, a preview doesn't really make sense anyway. Small: page number + page name Medium/Large: page number + page name + preview The small view would then be more like the old implementation from 1.6.2 and earlier. In addition, you could save the view size in the preferences so that you don't have to change it every time. |
|
I got some feedback on your last screencap above plus what you proposed regarding the small previews, and everyone thought that was a great idea. Personally I also think being able to save your preferred view mode in prefs is gold-star UX. Will the prefixes still display in the medium and large previews as per your screencap too? |
|
since we're talking about the preferences / document settings... : - ) what about being able to enable the mp name prefix in the preferences and also being able to define which character is being used? (the dash being the default, of course) ... the feature would be a bit more discoverable and people writing in a language that uses dashes more often (like french) do not risk to have bad surprises... |
|
That's a really good point. But if adding a field for the prefix delimiter wouldn't it makes sense to just add a field for the prefix itself? But that's so much more work and affects the .sla format as mentioned. As the feature using 1-4 chars followed by a dash isn't new in Scribus and has been around for a long while (same with QXP and ID), it doesn't look like anybody has complained it's been a problem before. If it ever was a problem, it's such an easy one to sidestep too. |
|
Changes to preferences UI, and the preferences and document file format are fine for 1.7.x. Its a development series. |
|
The selected size is stored in the preferences file. I see no reason to store this information directly in the sla file. pagepreview_2024-09-18_01.patch (19,278 bytes)
Index: scribus/ui/pagepalette_pages.cpp =================================================================== --- scribus/ui/pagepalette_pages.cpp (Revision 26306) +++ scribus/ui/pagepalette_pages.cpp (Arbeitskopie) @@ -191,22 +191,39 @@ return; } -// qDebug() << Q_FUNC_INFO << "- start page preview update"; + 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(); - PageToPixmapFlags flags = Pixmap_DrawFrame | Pixmap_DrawBackground | Pixmap_DontReloadImages | Pixmap_NoCanvasModeChange; - QMap<int, QImage> previews = currView->PagesToPixmap(pageViewWidget->pageGrid()->pageHeight(), -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() * qApp->devicePixelRatio(), -1, flags); - for (int i = 0; i < currView->m_doc->DocPages.count(); ++i) - { - if (previews.contains(i) && i < pageViewWidget->pageGrid()->pageList.count()) + for (int i = 0; i < currView->m_doc->DocPages.count(); ++i) { - 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(); + 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()); - 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; + } } } Index: scribus/ui/pagepalette_widgets.cpp =================================================================== --- scribus/ui/pagepalette_widgets.cpp (Revision 26306) +++ scribus/ui/pagepalette_widgets.cpp (Arbeitskopie) @@ -23,6 +23,7 @@ #include "iconmanager.h" #include "pagepalette_widgets.h" +#include "prefsfile.h" #include "prefsmanager.h" #include "scribusapp.h" #include "util_gui.h" @@ -224,6 +225,10 @@ calculateSize(); initContextMenu(); + PrefsContext *prefTileSize = PrefsManager::instance().prefsFile->getContext("PagePalette"); + int size = prefTileSize->getInt("pagePreviewSize", m_rowHeight); + setRowHeight(size); + // connect(this, &PageGrid::customContextMenuRequested, this, &PageGrid::showContextMenu); } @@ -244,19 +249,24 @@ m_documentPageSize = pageSize; } -void PageGrid::setRowHeight(int size) +void PageGrid::setRowHeight(int height) { - // clamp size from 48 to 256) - m_rowHeight = qBound(48, size, 256); + // clamp sizes + m_rowHeight = qBound(64, height, 128); + m_rowSpace = qBound(8, height / 8, 16); + // updateTileSize(); calculateSize(); update(); + + PrefsContext *prefTileSize = PrefsManager::instance().prefsFile->getContext("PagePalette"); + prefTileSize->set("pagePreviewSize", height); + PrefsManager::instance().prefsFile->write(); } void PageGrid::setFontSize(int size) { m_fontSize = size; - // updateTileSize(); update(); } @@ -297,18 +307,6 @@ update(); } -//void PageGrid::setPageList(const QList<PageCell *> list) -//{ -// m_pageList = list; -// calculateSize(); -// // update(); -//} - -//QList<PageCell *> PageGrid::pageList() const -//{ -// return m_pageList; -//} - int PageGrid::pageId(int r, int c, bool clampId) { @@ -673,7 +671,7 @@ update(); } -void PageGrid::drawTile(QPainter &painter, QPoint cellPosition, PageCell *tile, bool selected, bool hovered, QColor labelColor) +void PageGrid::drawTile(QPainter &painter, QPoint cellPosition, PageCell *tile, bool selected, bool hovered, QColor labelColor, bool isRight) { if (tile == nullptr) @@ -680,38 +678,54 @@ return; QFont font(this->font().family(), m_fontSize, 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); - // QRect rectMasterPageMarker(cellPosition.x(), cellPosition.y() + rectPage.height(), rectPage.width(), 4); + 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 - painter.setBrush(Qt::NoBrush); - // painter.setPen( QPen(Qt::black, 1) ); - painter.drawPixmap(rectPage, tile->pagePreview, tile->pagePreview.rect()); - // painter.drawRect(rectPage); + 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.setRenderHint(QPainter::TextAntialiasing, true); painter.setFont(font); // Draw Page Number - //painter.setPen(QPen(palette().windowText().color())); painter.setPen(QPen( labelColor )); painter.drawText(rectCell, Qt::AlignHCenter|Qt::AlignBottom | Qt::TextWordWrap, QString::number(tile->pageNumber + 1)); - // Draw Page Name - painter.setBackgroundMode(Qt::OpaqueMode); - painter.setBackground(QColor(0,0,0,128)); - painter.setPen(QPen(Qt::white)); - painter.drawText(rectPage.adjusted(2,2,-2,-2), Qt::AlignTop | Qt::AlignLeft |Qt::TextWordWrap, tile->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 Master Page Color - // painter.setPen(Qt::NoPen); - // painter.fillRect(rectMasterPageMarker, tile->masterPageColor()); - // Draw selection // if(selected) // { @@ -731,11 +745,6 @@ painter.drawRect(rectPage); } - // tmp border - // painter.setPen( Qt::magenta ); - // painter.setBrush(Qt::NoBrush); - // painter.drawRect(rectCell); - painter.restore(); } @@ -745,25 +754,17 @@ m_contextMenu->clear(); m_contextMenu->addAction(tr("&Small Preview"), [this]() { - m_rowSpace = 8; - setRowHeight(64); + setRowHeight(QVariant(TileSize::Small).toInt()); emit previewSizeChanged(); }); m_contextMenu->addAction(tr("&Medium Preview"), [this]() { - m_rowSpace = 12; - setRowHeight(96); + setRowHeight(QVariant(TileSize::Medium).toInt()); emit previewSizeChanged(); }); m_contextMenu->addAction(tr("&Large Preview"), [this]() { - m_rowSpace = 16; - setRowHeight(128); + setRowHeight(QVariant(TileSize::Large).toInt()); emit previewSizeChanged(); }); -// m_contextMenu->addAction(tr("&Extra Large Preview"), [this]() { -// m_rowSpace = 20; -// setRowHeight(196); -// emit previewSizeChanged(); -// }); } void PageGrid::showContextMenu(QPoint pos) @@ -820,7 +821,8 @@ if (id == m_selectedPage) selectedPageRect = QRect(x, y, cell->pageWidthByHeight(pageHeight()), pageHeight() ); QPoint pos(x,y); - drawTile(painter, pos, cell, (id == m_selectedPage) ? true : false, (id == m_hoveredPage) ? true : false, foregroundColor); + bool isRightPage = (m_cellsInGroup == c + 1 && m_cellsInGroup > 1); + drawTile(painter, pos, cell, (id == m_selectedPage) ? true : false, (id == m_hoveredPage) ? true : false, foregroundColor, isRightPage); // add space only between pages if ((c + 1) % m_cellsInGroup == 0 || count == pageCount() + m_pageOffset -1) Index: scribus/ui/pagepalette_widgets.h =================================================================== --- scribus/ui/pagepalette_widgets.h (Revision 26306) +++ scribus/ui/pagepalette_widgets.h (Arbeitskopie) @@ -66,198 +66,205 @@ 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 m_mousePos {QPoint()}; bool m_mousePressed {false}; bool m_thumb {false}; }; -struct SCRIBUS_API PageCell +struct SCRIBUS_API PageCell { - QString pageName; - uint pageNumber; - QPixmap pagePreview; - QColor masterPageColor; - double pageRatio; - - 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()}; + 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 +{ Q_OBJECT - friend class PageViewer; - + friend class PageViewer; + public: - explicit PageGrid(QWidget *parent = nullptr); - void setPageInGroup(int amount); + enum TileSize { + Small = 64, + Medium = 96, + Large = 128 + }; - void setDocumentPageSize(QSizeF pageSize); - - void setRowHeight(int size); - 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; - - 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; - QSizeF m_documentPageSize; - int m_rowHeight {96}; - int m_cellGap {1}; - int m_groupSpace {16}; - int m_rowSpace {12}; - int m_fontSize {8}; // 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; - 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; - - 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); - 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; - QScrollArea* m_scroll; - - 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 @@ -266,17 +273,17 @@ TrashBin( QWidget * parent ); ~TrashBin() {}; - void dragEnterEvent( QDragEnterEvent *e ); - void dragLeaveEvent( QDragLeaveEvent * ); - void dropEvent( QDropEvent * e ); - + void dragEnterEvent( QDragEnterEvent *e ); + void dragLeaveEvent( QDragLeaveEvent * ); + void dropEvent( QDropEvent * e ); + protected: - QPixmap normal; - QPixmap open; + QPixmap normal {QPixmap()}; + QPixmap open {QPixmap()}; protected slots: void iconSetChange(); - + signals: void delPageRequest(int); void delMasterRequest(QString); |
|
That looks great! |
|
Patch committed |
Date Modified | Username | Field | Change |
---|---|---|---|
2024-09-17 00:47 | BN_Dev | New Issue | |
2024-09-17 00:47 | BN_Dev | File Added: qxppageprefix.png | |
2024-09-17 00:47 | BN_Dev | File Added: scribus_1.6.2.png | |
2024-09-17 00:47 | BN_Dev | File Added: scribus_1.7.0.png | |
2024-09-17 00:47 | BN_Dev | File Added: pageprefix.patch | |
2024-09-17 07:26 | ale | Note Added: 0051357 | |
2024-09-17 12:05 | BN_Dev | Note Added: 0051359 | |
2024-09-17 12:05 | BN_Dev | File Added: pageprefix-2.patch | |
2024-09-17 14:18 | nitramr | Note Added: 0051360 | |
2024-09-17 15:18 | BN_Dev | Note Added: 0051361 | |
2024-09-17 17:32 | nitramr | Note Added: 0051362 | |
2024-09-17 17:32 | nitramr | File Added: Bildschirmfoto vom 2024-09-17 19-11-23.png | |
2024-09-17 17:32 | nitramr | File Added: pagepreview_2024-09-17_01.patch | |
2024-09-17 20:37 | BN_Dev | Note Added: 0051365 | |
2024-09-18 08:17 | nitramr | Note Added: 0051367 | |
2024-09-18 12:37 | BN_Dev | Note Added: 0051368 | |
2024-09-18 13:42 | ale | Note Added: 0051370 | |
2024-09-18 14:09 | BN_Dev | Note Added: 0051371 | |
2024-09-18 18:56 | cbradney | Note Added: 0051372 | |
2024-09-18 18:56 | cbradney | Note Edited: 0051372 | |
2024-09-18 19:02 | nitramr | Note Added: 0051373 | |
2024-09-18 19:02 | nitramr | File Added: pagepreview_2024-09-18_01.patch | |
2024-09-18 19:02 | nitramr | File Added: large.png | |
2024-09-18 19:02 | nitramr | File Added: medium.png | |
2024-09-18 19:02 | nitramr | File Added: small.png | |
2024-09-19 11:12 | BN_Dev | Note Added: 0051376 | |
2024-09-21 10:02 | cbradney | Note Added: 0051377 |