4141#include < ufe/selectionNotification.h>
4242
4343#include < QtCore/QPointer>
44+ #include < QtCore/QString>
45+ #include < QtCore/QVariant>
4446#include < QtGui/QPalette>
4547#include < QtWidgets/QApplication>
4648#include < QtWidgets/QWidget>
@@ -124,8 +126,10 @@ class MayaCompositionEditorHost : public Adsk::UsdDebug::ApplicationHost
124126 switch (color) {
125127 case ThemeColors::DisabledForeground:
126128 return QApplication::palette ().color (QPalette::Disabled, QPalette::WindowText);
129+ default :
130+ // All other roles use the base host's themed defaults.
131+ return ApplicationHost::themeColor (color);
127132 }
128- return QColor ();
129133 }
130134
131135 bool executeInCmd (
@@ -148,8 +152,34 @@ class MayaCompositionEditorHost : public Adsk::UsdDebug::ApplicationHost
148152 return edit ();
149153 }
150154
155+ float uiScale () const override { return static_cast <float >(MQtUtil::dpiScale (1 .0f )); }
156+
157+ QVariant loadPersistentData (const QString& group, const QString& key) const override
158+ {
159+ const MString varName = optionVarName (group, key);
160+ if (!MGlobal::optionVarExists (varName)) {
161+ return QVariant ();
162+ }
163+
164+ return QVariant (QString::fromUtf8 (MGlobal::optionVarStringValue (varName).asChar ()));
165+ }
166+
167+ void
168+ savePersistentData (const QString& group, const QString& key, const QVariant& value) override
169+ {
170+ // Store every value as a string optionVar
171+ const MString varName = optionVarName (group, key);
172+ MGlobal::setOptionVarValue (varName, MString (value.toString ().toUtf8 ().constData ()));
173+ }
174+
151175protected:
152176 MayaCompositionEditorHost () { injectInstance (this ); }
177+
178+ static MString optionVarName (const QString& group, const QString& key)
179+ {
180+ const QString name = QStringLiteral (" mayaUsd_CompositionEditor_%1_%2" ).arg (group, key);
181+ return MString (name.toUtf8 ().constData ());
182+ }
153183};
154184
155185bool workspaceControlExists ()
@@ -257,7 +287,9 @@ MStatus CompositionEditorCmd::doIt(const MArgList& args)
257287 // First invocation: create the workspace control wrapper, then create
258288 // the widget inside it. -retain false + -deleteLater false combined
259289 // with -uiScript matches the Layer Editor pattern so the widget is
260- // rebuilt on layout save/restore.
290+ // rebuilt on layout save/restore. The workspace control persists its own
291+ // size across sessions, so -initialWidth/-initialHeight only seed the
292+ // first-launch geometry.
261293 MString createCmd;
262294 createCmd.format (
263295 " workspaceControl"
0 commit comments