mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-30 23:04:13 +02:00
Persist QColorDialog custom colors across application restarts
Qt's QColorDialog loads custom colors from QSettings on startup but never writes them back, so user-defined colors in the color picker are lost when the application exits. Save and load the 16 custom color slots explicitly via QSettings in QETApp's constructor (after initStyle) and destructor (before other settings are flushed). This covers every QColorDialog usage in the application transparently. Also fixes a QColorDialog memory leak in DiagramView.
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "NameList/nameslist.h"
|
||||
#include "elementdialog.h"
|
||||
#include <QDropEvent>
|
||||
#include <QPointer>
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -122,7 +123,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
||||
ConductorProperties initial_properties = edited_conductor->properties();
|
||||
|
||||
// prepare a color dialog showing the initial conductor color
|
||||
QColorDialog *color_dialog = new QColorDialog(this);
|
||||
QPointer<QColorDialog> color_dialog = new QColorDialog(this);
|
||||
color_dialog->setWindowTitle(tr("Choisir la nouvelle couleur de ce conducteur"));
|
||||
#ifdef Q_OS_MACOS
|
||||
color_dialog -> setWindowFlags(Qt::Sheet);
|
||||
@@ -150,6 +151,8 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
||||
LastUsedStyle::setConductorColor(new_color);
|
||||
}
|
||||
}
|
||||
if (color_dialog)
|
||||
delete color_dialog;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user