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 Change-Id: I49cd7312054f41ca4cdbfffdcb60d6ea242393fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 9a753fa656a9bcae4193ceb38cfaf6e21641ddc2) Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
This commit is contained in:
parent
cc6074c543
commit
0777144b45
@ -8,9 +8,6 @@
|
||||
#if QT_CONFIG(regularexpression)
|
||||
#include <QtCore/QRegularExpression>
|
||||
#endif
|
||||
#if QT_CONFIG(settings)
|
||||
#include <QtCore/QSettings>
|
||||
#endif
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QVariant>
|
||||
@ -242,8 +239,6 @@ public:
|
||||
enum { CustomColorCount = 16, StandardColorCount = 6 * 8 };
|
||||
|
||||
QColorDialogStaticData();
|
||||
inline void readSettings();
|
||||
inline void writeSettings() const;
|
||||
|
||||
QRgb customRgb[CustomColorCount];
|
||||
QRgb standardRgb[StandardColorCount];
|
||||
@ -258,31 +253,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)
|
||||
@ -291,8 +261,6 @@ class QColorDialogOptionsPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QColorDialogOptionsPrivate() = default;
|
||||
// Write out settings around destruction of dialogs
|
||||
~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); }
|
||||
|
||||
QColorDialogOptions::ColorDialogOptions options;
|
||||
QString windowTitle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user