Index: scribus/canvas.cpp =================================================================== --- scribus/canvas.cpp (revision 27829) +++ scribus/canvas.cpp (working copy) @@ -964,7 +964,7 @@ img.setDevicePixelRatio(devicePixelRatioF()); auto painter = std::make_unique(&img, img.width(), img.height(), 1.0, 0); - painter->clear(PrefsManager::instance().appPrefs.displayPrefs.scratchColor); + painter->clear(PrefsManager::instance().scratchColor()); painter->newPath(); painter->moveTo(0, 0); painter->lineTo(clipw, 0); Index: scribus/prefsmanager.cpp =================================================================== --- scribus/prefsmanager.cpp (revision 27829) +++ scribus/prefsmanager.cpp (working copy) @@ -270,6 +270,7 @@ appPrefs.opToolPrefs.constrain = 15.0; appPrefs.displayPrefs.paperColor = QColor(Qt::white); appPrefs.displayPrefs.scratchColor = QApplication::palette().color(QPalette::Active, QPalette::Window); + appPrefs.displayPrefs.scratchColorFollowsTheme = true; appPrefs.displayPrefs.showPageShadow = true; appPrefs.displayPrefs.showVerifierWarningsOnCanvas = true; appPrefs.displayPrefs.showAutosaveClockOnCanvas = false; @@ -1325,6 +1326,13 @@ return appPrefs.displayPrefs.displayScale; } +QColor PrefsManager::scratchColor() const +{ + if (appPrefs.displayPrefs.scratchColorFollowsTheme) + return QApplication::palette().color(QPalette::Active, QPalette::Window); + return appPrefs.displayPrefs.scratchColor; +} + const QString& PrefsManager::uiLanguage() const { return appPrefs.uiPrefs.language; @@ -1486,6 +1494,7 @@ deDisplay.setAttribute("ShowPageShadow", static_cast(appPrefs.displayPrefs.showPageShadow)); deDisplay.setAttribute("PageColor", appPrefs.displayPrefs.paperColor.name()); deDisplay.setAttribute("ScratchColor", appPrefs.displayPrefs.scratchColor.name()); + deDisplay.setAttribute("ScratchColorFollowsTheme", static_cast(appPrefs.displayPrefs.scratchColorFollowsTheme)); deDisplay.setAttribute("FrameSelectedColor", appPrefs.displayPrefs.frameColor.name()); deDisplay.setAttribute("FrameNormColor", appPrefs.displayPrefs.frameNormColor.name()); deDisplay.setAttribute("FrameGroupColor", appPrefs.displayPrefs.frameGroupColor.name()); @@ -2147,6 +2156,25 @@ appPrefs.displayPrefs.scratchColor = QColor(dc.attribute("ScratchColor")); else appPrefs.displayPrefs.scratchColor = QApplication::palette().color(QPalette::Active, QPalette::Window); + + if (dc.hasAttribute("ScratchColorFollowsTheme")) + appPrefs.displayPrefs.scratchColorFollowsTheme = static_cast(dc.attribute("ScratchColorFollowsTheme", "1").toInt()); + else + { + // Legacy preferences stored only an RGB value. Migrate known Scribus + // theme defaults once, while preserving all other values as custom. + const QColor currentWindowColor = QApplication::palette().color(QPalette::Active, QPalette::Window); + bool followsTheme = (appPrefs.displayPrefs.scratchColor == currentWindowColor); + + QStyle* fusionStyle = QStyleFactory::create("Fusion"); + if (fusionStyle) + { + followsTheme |= (appPrefs.displayPrefs.scratchColor == fusionStyle->standardPalette().color(QPalette::Active, QPalette::Window)); + delete fusionStyle; + } + followsTheme |= (appPrefs.displayPrefs.scratchColor == QColor(53, 53, 53)); + appPrefs.displayPrefs.scratchColorFollowsTheme = followsTheme; + } appPrefs.displayPrefs.frameColor = QColor(dc.attribute("FrameSelectedColor", "#ff0000")); appPrefs.displayPrefs.frameNormColor = QColor(dc.attribute("FrameNormColor", "#000000")); appPrefs.displayPrefs.frameGroupColor = QColor(dc.attribute("FrameGroupColor", "#008080")); Index: scribus/prefsmanager.h =================================================================== --- scribus/prefsmanager.h (revision 27829) +++ scribus/prefsmanager.h (working copy) @@ -141,6 +141,7 @@ int mouseWheelJump() const; //! \brief Get the user set display scale double displayScale() const; + QColor scratchColor() const; //! \brief Get the GUI language from preferences const QString& uiLanguage() const; //! \brief Get the GUI style from preferences Index: scribus/prefsstructs.h =================================================================== --- scribus/prefsstructs.h (revision 27829) +++ scribus/prefsstructs.h (working copy) @@ -376,7 +376,8 @@ bool marginColored; //! Indicates if the margin to edge of page area will be colored in some other color or not bool showPageShadow; //! Show a shadow around the pages QColor paperColor; //! Color of paper (onscreen only) - QColor scratchColor; //! Color of scratch space (onscreen only) + QColor scratchColor; //! Custom color of scratch space (onscreen only) + bool scratchColorFollowsTheme; //! Use the application theme Window color for scratch space QColor frameColor; //! Color of frame border (onscreen only) QColor frameNormColor; //! Color of normal frame border (onscreen only) QColor frameGroupColor; //! Color of border of grouped frames (onscreen only) Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (revision 27829) +++ scribus/scribus.cpp (working copy) @@ -6581,9 +6581,9 @@ LocaleManager::instance().setUserPreferredLocale(m_prefsManager.appPrefs.uiPrefs.userPreferredLocale); ScQApp->setLocale(); - bool useDefaultScratchColor = false; - if (m_prefsManager.appPrefs.displayPrefs.scratchColor == QApplication::palette().color(QPalette::Active, QPalette::Window)) - useDefaultScratchColor = true; + const bool scratchColorSettingChanged = + (oldPrefs.displayPrefs.scratchColorFollowsTheme != m_prefsManager.appPrefs.displayPrefs.scratchColorFollowsTheme) || + (oldPrefs.displayPrefs.scratchColor != m_prefsManager.appPrefs.displayPrefs.scratchColor); #if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)) QString newUIStylePalette = m_prefsManager.appPrefs.uiPrefs.stylePalette; @@ -6620,8 +6620,10 @@ // m_prefsManager.appPrefs.uiPrefs.style = oldPrefs.uiPrefs.style; } - if (useDefaultScratchColor) - m_prefsManager.appPrefs.displayPrefs.scratchColor = QApplication::palette().color(QPalette::Active, QPalette::Window); + const bool scratchColorThemeChanged = + m_prefsManager.appPrefs.displayPrefs.scratchColorFollowsTheme && + ((oldPrefs.uiPrefs.stylePalette != m_prefsManager.appPrefs.uiPrefs.stylePalette) || + (oldPrefs.uiPrefs.style != m_prefsManager.appPrefs.uiPrefs.style)); QString newIconSet = m_prefsManager.guiIconSet(); // Recreate icons if icon set or GUI changed. For GUI change the icon recreation will automatically detect light and dark themes @@ -6647,6 +6649,10 @@ else mdiArea->setViewMode(QMdiArea::SubWindowView); bool shadowChanged = oldPrefs.displayPrefs.showPageShadow != m_prefsManager.showPageShadow(); + const bool scratchColorChanged = scratchColorSettingChanged || scratchColorThemeChanged; + if (scratchColorChanged) + pagePalette->refreshPageGrid(); + QList windows = mdiArea->subWindowList(); if (!windows.isEmpty()) { @@ -6671,8 +6677,10 @@ scw_v->zoom((scw_v->scale() / oldPrefs.displayPrefs.displayScale) * m_prefsManager.displayScale()); zoomSpinBox->setMaximum(doc->opToolPrefs().magMax); } - if (shadowChanged) - scw->view()->DrawNew(); + if (scratchColorChanged) + scw_v->refreshScratchColor(); + if (shadowChanged || scratchColorChanged) + scw_v->DrawNew(); } } Index: scribus/scribusview.cpp =================================================================== --- scribus/scribusview.cpp (revision 27829) +++ scribus/scribusview.cpp (working copy) @@ -123,9 +123,7 @@ m_vhRulerHW = Hruler::rulerHeight(); setObjectName("s"); - QPalette p = palette(); - p.setBrush(QPalette::Window, PrefsManager::instance().appPrefs.displayPrefs.scratchColor); - setPalette(p); + refreshScratchColor(); setAttribute(Qt::WA_StaticContents); setAttribute(Qt::WA_InputMethodEnabled, true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -2255,6 +2253,20 @@ zoom(zoomPointX, zoomPointY, newScale, preservePoint); } +void ScribusView::refreshScratchColor() +{ + if (PrefsManager::instance().appPrefs.displayPrefs.scratchColorFollowsTheme) + { + // Clear explicit palette roles so future application palette changes propagate. + setPalette(QPalette()); + return; + } + + QPalette p = palette(); + p.setBrush(QPalette::Window, PrefsManager::instance().scratchColor()); + setPalette(p); +} + void ScribusView::DrawNew() { // qDebug("ScribusView::DrawNew"); Index: scribus/scribusview.h =================================================================== --- scribus/scribusview.h (revision 27829) +++ scribus/scribusview.h (working copy) @@ -158,6 +158,7 @@ FPoint m_mousePointDoc; void updatesOn(bool on); + void refreshScratchColor(); //CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it //does NOT create a page anymore. ScPage* addPage(int nr, bool mov = true); Index: scribus/ui/pagepalette.cpp =================================================================== --- scribus/ui/pagepalette.cpp (revision 27829) +++ scribus/ui/pagepalette.cpp (working copy) @@ -165,6 +165,12 @@ } +void PagePalette::refreshPageGrid() +{ + if (m_pageWidget) + m_pageWidget->refreshPageGrid(); +} + bool PagePalette::masterPageMode() { PagePalette_MasterPages* mpWidget = dynamic_cast(this->currentWidget()); Index: scribus/ui/pagepalette.h =================================================================== --- scribus/ui/pagepalette.h (revision 27829) +++ scribus/ui/pagepalette.h (working copy) @@ -68,6 +68,7 @@ void markPage(uint nr); void updateMasterPageList(); void updatePagePreviews(); + void refreshPageGrid(); void languageChange(); Index: scribus/ui/pagepalette_pages.cpp =================================================================== --- scribus/ui/pagepalette_pages.cpp (revision 27829) +++ scribus/ui/pagepalette_pages.cpp (working copy) @@ -240,6 +240,11 @@ } +void PagePalette_Pages::refreshPageGrid() +{ + pageViewWidget->pageGrid()->update(); +} + void PagePalette_Pages::updatePagePreview() { if (currView == nullptr || pageViewWidget->pageGrid()->pageList.empty()) Index: scribus/ui/pagepalette_pages.h =================================================================== --- scribus/ui/pagepalette_pages.h (revision 27829) +++ scribus/ui/pagepalette_pages.h (working copy) @@ -27,6 +27,7 @@ public: PagePalette_Pages(QWidget* parent); ~PagePalette_Pages() {}; + void refreshPageGrid(); public slots: void setView(ScribusView *view); Index: scribus/ui/pagepalette_widgets.cpp =================================================================== --- scribus/ui/pagepalette_widgets.cpp (revision 27829) +++ scribus/ui/pagepalette_widgets.cpp (working copy) @@ -803,12 +803,12 @@ int y = m_rowSpace; int offset = 0; QRect selectedPageRect; - QColor foregroundColor( PrefsManager::instance().appPrefs.displayPrefs.scratchColor.lightness() <= 128 ? Qt::white : Qt::black); + QColor foregroundColor( PrefsManager::instance().scratchColor().lightness() <= 128 ? Qt::white : Qt::black); QPainter painter(this); // Draw background - painter.fillRect(rect(), PrefsManager::instance().appPrefs.displayPrefs.scratchColor); + painter.fillRect(rect(), PrefsManager::instance().scratchColor()); if (pageCount() == 0) return; Index: scribus/ui/preferences/prefs_display.cpp =================================================================== --- scribus/ui/preferences/prefs_display.cpp (revision 27829) +++ scribus/ui/preferences/prefs_display.cpp (working copy) @@ -30,6 +30,7 @@ m_icon = "pref-display"; buttonRestoreDPI->setIcon(IconManager::instance().loadIcon("pref-display")); + scratchSpaceColorResetButton->setIcon(IconManager::instance().loadIcon("reset")); connect(pageFillColorButton, SIGNAL(clicked()), this, SLOT(changePaperColor())); connect(showRulersRelativeToPageCheckBox, &QCheckBox::toggled, this, [this](bool on) { if (on) showRulersRelativeToEachPageCheckBox->setChecked(false); }); @@ -38,6 +39,7 @@ if (m_doc == nullptr && !ScCore->primaryMainWindow()->HaveDoc) { connect(scratchSpaceColorButton, SIGNAL(clicked()), this, SLOT(changeScratchColor())); + connect(scratchSpaceColorResetButton, &QToolButton::clicked, this, &Prefs_Display::resetScratchColor); connect(frameSelectedColorButton, SIGNAL(clicked()), this, SLOT(changeFrameColor())); connect(frameColorButton, SIGNAL(clicked()), this, SLOT(changeNormFrameColor())); connect(frameGroupedColorButton, SIGNAL(clicked()), this, SLOT(changeGroupFrameColor())); @@ -53,6 +55,7 @@ else { scratchSpaceColorButton->setEnabled(false); + scratchSpaceColorResetButton->setEnabled(false); frameSelectedColorButton->setEnabled(false); frameColorButton->setEnabled(false); frameGroupedColorButton->setEnabled(false); @@ -73,6 +76,8 @@ void Prefs_Display::languageChange() { pageFillColorButton->setToolTip( "" + tr( "Color for paper (onscreen)" ) + ""); + scratchSpaceColorButton->setToolTip("" + tr("Set a custom scratch space color") + ""); + scratchSpaceColorResetButton->setToolTip("" + tr("Use the interface theme color
for scratch space") + "
"); showUnprintableAreaInMarginColorCheckBox->setToolTip( "" + tr( "Mask the area outside the margins in the margin color" ) + "" ); showTextChainsCheckBox->setToolTip( "" + tr("Enable or disable the display of linked frames") + ""); showControlCharsCheckBox->setToolTip( "" + tr("Display non-printing characters such as paragraph markers in text frames") + ""); @@ -140,10 +145,10 @@ pageFillColorButton->setText( QString() ); pageFillColorButton->setIcon(pm); - pm.fill(prefsData->displayPrefs.scratchColor); colorScratch = prefsData->displayPrefs.scratchColor; + m_scratchColorFollowsTheme = prefsData->displayPrefs.scratchColorFollowsTheme; scratchSpaceColorButton->setText( QString() ); - scratchSpaceColorButton->setIcon(pm); + updateScratchColorControls(); pm.fill(prefsData->displayPrefs.frameColor); colorFrame = prefsData->displayPrefs.frameColor; @@ -296,18 +301,38 @@ } } +void Prefs_Display::updateScratchColorControls() +{ + const QColor displayColor = m_scratchColorFollowsTheme + ? QApplication::palette().color(QPalette::Active, QPalette::Window) + : colorScratch; + + QPixmap pm(100, 30); + pm.fill(displayColor); + scratchSpaceColorButton->setIcon(pm); + scratchSpaceColorResetButton->setEnabled(scratchSpaceColorButton->isEnabled() && !m_scratchColorFollowsTheme); +} + void Prefs_Display::changeScratchColor() { - QColor newColor(QColorDialog::getColor(colorScratch, this)); + const QColor initialColor = m_scratchColorFollowsTheme + ? QApplication::palette().color(QPalette::Active, QPalette::Window) + : colorScratch; + QColor newColor(QColorDialog::getColor(initialColor, this)); if (newColor.isValid()) { - QPixmap pm(100, 30); - pm.fill(newColor); colorScratch = newColor; - scratchSpaceColorButton->setIcon(pm); + m_scratchColorFollowsTheme = false; + updateScratchColorControls(); } } +void Prefs_Display::resetScratchColor() +{ + m_scratchColorFollowsTheme = true; + updateScratchColorControls(); +} + void Prefs_Display::changeFrameColor() { QColor newColor(QColorDialog::getColor(colorFrame, this)); @@ -434,6 +459,7 @@ prefsData->displayPrefs.paperColor = colorPaper; prefsData->displayPrefs.scratchColor = colorScratch; + prefsData->displayPrefs.scratchColorFollowsTheme = m_scratchColorFollowsTheme; prefsData->displayPrefs.frameColor = colorFrame; prefsData->displayPrefs.frameNormColor = colorFrameNorm; prefsData->displayPrefs.frameGroupColor = colorFrameGroup; Index: scribus/ui/preferences/prefs_display.h =================================================================== --- scribus/ui/preferences/prefs_display.h (revision 27829) +++ scribus/ui/preferences/prefs_display.h (working copy) @@ -51,6 +51,8 @@ */ virtual void changePaperColor(); virtual void changeScratchColor(); + void resetScratchColor(); + void updateScratchColorControls(); virtual void changeFrameColor(); virtual void changeNormFrameColor(); virtual void changeGroupFrameColor(); @@ -74,6 +76,7 @@ QColor colorFrameAnnotation; QColor colorPageBorder; QColor colorControlChars; + bool m_scratchColorFollowsTheme { true }; double displayScale; ScribusDoc* m_doc; Index: scribus/ui/preferences/prefs_displaybase.ui =================================================================== --- scribus/ui/preferences/prefs_displaybase.ui (revision 27829) +++ scribus/ui/preferences/prefs_displaybase.ui (working copy) @@ -437,11 +437,37 @@ - - - + + + 6 - + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + Index: scribus/ui/widgets/pagesizepreview.cpp =================================================================== --- scribus/ui/widgets/pagesizepreview.cpp (revision 27829) +++ scribus/ui/widgets/pagesizepreview.cpp (working copy) @@ -11,7 +11,7 @@ void PageSizePreview::paintEvent(QPaintEvent *event) { QColor colPage = PrefsManager::instance().appPrefs.displayPrefs.paperColor; - QColor colBackground = PrefsManager::instance().appPrefs.displayPrefs.scratchColor; + QColor colBackground = PrefsManager::instance().scratchColor(); QColor colMargin = PrefsManager::instance().appPrefs.guidesPrefs.marginColor; QColor colBleed(Qt::gray); QColor colFrame(Qt::black);