QColorDialogOptions: delete QSettings code and stop saving globally
[ChangeLog][QtGui][QColorDialogOptions] The class no longer automatically saves settings such as the custom colors to a global QSettings("QtProject") shared by all applications and no longer restores custom colors from there. Applications that wish to retain the custom color settings should use customColors() and setCustomColor() with their own settings files. Task-number: QTBUG-133805 Pick-to: 6.9 Change-Id: I49cd7312054f41ca4cdbfffdcb60d6ea242393fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
a9f26c3f9a
commit
9a753fa656
@ -8,9 +8,6 @@
|
||||
#if QT_CONFIG(regularexpression)
|
||||
#include <QtCore/QRegularExpression>
|
||||
#endif
|
||||
#if QT_CONFIG(settings)
|
||||
#include <QtCore/QSettings>
|
||||
#endif
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QColor>
|
||||
@ -241,8 +238,6 @@ public:
|
||||
enum { CustomColorCount = 16, StandardColorCount = 6 * 8 };
|
||||
|
||||
QColorDialogStaticData();
|
||||
inline void readSettings();
|
||||
inline void writeSettings() const;
|
||||
|
||||
QRgb customRgb[CustomColorCount];
|
||||
QRgb standardRgb[StandardColorCount];
|
||||
@ -257,31 +252,6 @@ QColorDialogStaticData::QColorDialogStaticData() : customSet(false)
|
||||
for (int b = 0; b < 3; ++b)
|
||||
standardRgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
|
||||
std::fill(customRgb, customRgb + CustomColorCount, 0xffffffff);
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void QColorDialogStaticData::readSettings()
|
||||
{
|
||||
#if QT_CONFIG(settings)
|
||||
const QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
|
||||
for (int i = 0; i < int(CustomColorCount); ++i) {
|
||||
const QVariant v = settings.value("Qt/customColors/"_L1 + QString::number(i));
|
||||
if (v.isValid())
|
||||
customRgb[i] = v.toUInt();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QColorDialogStaticData::writeSettings() const
|
||||
{
|
||||
#if QT_CONFIG(settings)
|
||||
if (customSet) {
|
||||
const_cast<QColorDialogStaticData*>(this)->customSet = false;
|
||||
QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
|
||||
for (int i = 0; i < int(CustomColorCount); ++i)
|
||||
settings.setValue("Qt/customColors/"_L1 + QString::number(i), customRgb[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData)
|
||||
@ -290,8 +260,6 @@ class QColorDialogOptionsPrivate
|
||||
{
|
||||
public:
|
||||
QColorDialogOptionsPrivate() = default;
|
||||
// Write out settings around destruction of dialogs
|
||||
~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); }
|
||||
QColorDialogOptionsPrivate(const QColorDialogOptionsPrivate &) = default;
|
||||
QColorDialogOptionsPrivate(QColorDialogOptionsPrivate &&) = default;
|
||||
QColorDialogOptionsPrivate &operator=(const QColorDialogOptionsPrivate &) = delete;
|
||||
|
Loading…
x
Reference in New Issue
Block a user