mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 13:24:14 +02:00
9af562fcbd
Picking a sheet (folio) background colour in the diagram editor was lost on every restart. Diagram::background_color is a static initialised to white and PaletteGraphicsView's s_custom_bg a static bool, and neither was ever written anywhere -- Diagram::toXml() carries no colour attribute either -- so closing and reopening a project always came back on the default and the choice had to be made again. Store it in QSettings under diagrameditor/sheet_background_* as a pair of values rather than one: the colour, and whether it was picked explicitly. Both halves are needed. "#ffffff, follow the system" and "#ffffff, always white" are the same colour and two behaviours -- the first is what the views invert on a dark palette -- so keeping only the colour would silently turn one into the other on the next start, which is the reported problem one step removed. The colour is written as HexRgb on purpose. The SVG export gives Diagram::background_color an alpha of 0 to render a transparent background and never puts it back, and that transient value must not be persisted as a permanently transparent sheet. Applied from main() after the headless export and scripting branch -- those return before reaching it and must keep rendering on plain white, the rule ProjectPrintWindow already enforces for printing -- and before QETApp is constructed, since that constructor already loads the projects given on the command line. The GUI export dialog is left alone: it renders through drawBackground(), so what you see is what you export, as it already was within a session. Saved at the moment the colour is applied rather than at shutdown, so neither the print window's temporary white nor the SVG export's alpha can reach it. The button's constructor now mirrors the stored state instead of always claiming "system colour", and the "recently used" list is stored alongside it. Covered by tst_sheetbackgroundsetting, which pins the custom flag and the dropped alpha -- the two rules a single stored colour would lose.
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef QETSETTINGS_H
|
|
#define QETSETTINGS_H
|
|
|
|
#include <Qt>
|
|
#include <QColor>
|
|
#include <QStringList>
|
|
|
|
/**
|
|
*Interface to use QSettings in QElectroTech
|
|
*Prefer use this namespace instead of directly QSettings
|
|
*It's notably useful when some QSettings value are used in
|
|
*different part of QElectroTech source code
|
|
*/
|
|
namespace QetSettings
|
|
{
|
|
void setHdpiScaleFactorRoundingPolicy(const QString &policy_str);
|
|
void setHdpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy);
|
|
Qt::HighDpiScaleFactorRoundingPolicy hdpiScaleFactorRoundingPolicy(
|
|
Qt::HighDpiScaleFactorRoundingPolicy default_policy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
|
|
|
bool scriptingEnabled();
|
|
void setScriptingEnabled(bool enabled);
|
|
bool scriptingForcedByEnvironment();
|
|
|
|
/**
|
|
@brief The sheet (folio) background the diagram editors draw.
|
|
|
|
Both halves are needed, not just the colour: with custom == false
|
|
the sheet follows the system ("Couleur systeme") and the views are
|
|
free to invert the lightness on a dark palette, while the very same
|
|
#ffffff with custom == true is an explicit "always white" that
|
|
must not be inverted. Storing only the colour would collapse the
|
|
two on the next start.
|
|
*/
|
|
struct SheetBackground
|
|
{
|
|
QColor color;
|
|
bool custom = false;
|
|
};
|
|
|
|
SheetBackground sheetBackground();
|
|
void setSheetBackground(const SheetBackground &background);
|
|
|
|
QStringList sheetBackgroundRecentColors();
|
|
void setSheetBackgroundRecentColors(const QStringList &colors);
|
|
}
|
|
|
|
#endif // QETSETTINGS_H
|