mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-12 21:22:55 -07:00
[VDE] Separate layout settings for visual deck editor (#6595)
This commit is contained in:
@@ -266,19 +266,19 @@ void TabDeckEditorVisual::refreshShortcuts()
|
|||||||
void TabDeckEditorVisual::loadLayout()
|
void TabDeckEditorVisual::loadLayout()
|
||||||
{
|
{
|
||||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||||
auto layoutState = layouts.getDeckEditorLayoutState();
|
auto layoutState = layouts.getVisualDeckEditorLayoutState();
|
||||||
if (layoutState.isNull()) {
|
if (layoutState.isNull()) {
|
||||||
restartLayout();
|
restartLayout();
|
||||||
} else {
|
} else {
|
||||||
restoreState(layoutState);
|
restoreState(layoutState);
|
||||||
restoreGeometry(layouts.getDeckEditorGeometry());
|
restoreGeometry(layouts.getVisualDeckEditorGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = dockToActions.constKeyValueBegin(); it != dockToActions.constKeyValueEnd(); ++it) {
|
for (auto it = dockToActions.constKeyValueBegin(); it != dockToActions.constKeyValueEnd(); ++it) {
|
||||||
auto dockWidget = it->first;
|
auto dockWidget = it->first;
|
||||||
auto actions = it->second;
|
auto actions = it->second;
|
||||||
|
|
||||||
QSize size = layouts.getDeckEditorWidgetSize(dockWidget->objectName(), actions.defaultSize);
|
QSize size = layouts.getVisualDeckEditorWidgetSize(dockWidget->objectName(), actions.defaultSize);
|
||||||
dockWidget->setMinimumSize(size);
|
dockWidget->setMinimumSize(size);
|
||||||
dockWidget->setMaximumSize(size);
|
dockWidget->setMaximumSize(size);
|
||||||
}
|
}
|
||||||
@@ -344,11 +344,11 @@ bool TabDeckEditorVisual::eventFilter(QObject *o, QEvent *e)
|
|||||||
{
|
{
|
||||||
if (o == this && e->type() == QEvent::Hide) {
|
if (o == this && e->type() == QEvent::Hide) {
|
||||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||||
layouts.setDeckEditorLayoutState(saveState());
|
layouts.setVisualDeckEditorLayoutState(saveState());
|
||||||
layouts.setDeckEditorGeometry(saveGeometry());
|
layouts.setVisualDeckEditorGeometry(saveGeometry());
|
||||||
|
|
||||||
for (auto dockWidget : dockToActions.keys()) {
|
for (auto dockWidget : dockToActions.keys()) {
|
||||||
layouts.setDeckEditorWidgetSize(dockWidget->objectName(), dockWidget->size());
|
layouts.setVisualDeckEditorWidgetSize(dockWidget->objectName(), dockWidget->size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const static QString SIZE_PROP = "widgetSize";
|
|||||||
|
|
||||||
const static QString GROUP_MAIN_WINDOW = "mainWindow";
|
const static QString GROUP_MAIN_WINDOW = "mainWindow";
|
||||||
const static QString GROUP_DECK_EDITOR = "deckEditor";
|
const static QString GROUP_DECK_EDITOR = "deckEditor";
|
||||||
|
const static QString GROUP_VISUAL_DECK_EDITOR = "visualDeckEditor";
|
||||||
const static QString GROUP_DECK_EDITOR_DB = "deckEditorDb";
|
const static QString GROUP_DECK_EDITOR_DB = "deckEditorDb";
|
||||||
const static QString GROUP_SETS_DIALOG = "setsDialog";
|
const static QString GROUP_SETS_DIALOG = "setsDialog";
|
||||||
const static QString GROUP_TOKEN_DIALOG = "tokenDialog";
|
const static QString GROUP_TOKEN_DIALOG = "tokenDialog";
|
||||||
@@ -58,6 +59,37 @@ QSize LayoutsSettings::getDeckEditorWidgetSize(const QString &widgetName, const
|
|||||||
return previous == QVariant() ? defaultValue : previous.toSize();
|
return previous == QVariant() ? defaultValue : previous.toSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray LayoutsSettings::getVisualDeckEditorLayoutState()
|
||||||
|
{
|
||||||
|
return getValue(STATE_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setVisualDeckEditorLayoutState(const QByteArray &value)
|
||||||
|
{
|
||||||
|
setValue(value, STATE_PROP, GROUP_VISUAL_DECK_EDITOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray LayoutsSettings::getVisualDeckEditorGeometry()
|
||||||
|
{
|
||||||
|
return getValue(GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR).toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setVisualDeckEditorGeometry(const QByteArray &value)
|
||||||
|
{
|
||||||
|
setValue(value, GEOMETRY_PROP, GROUP_VISUAL_DECK_EDITOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setVisualDeckEditorWidgetSize(const QString &widgetName, const QSize &value)
|
||||||
|
{
|
||||||
|
setValue(value, widgetName, GROUP_VISUAL_DECK_EDITOR, SIZE_PROP);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize LayoutsSettings::getVisualDeckEditorWidgetSize(const QString &widgetName, const QSize &defaultValue)
|
||||||
|
{
|
||||||
|
QVariant previous = getValue(widgetName, GROUP_VISUAL_DECK_EDITOR, SIZE_PROP);
|
||||||
|
return previous == QVariant() ? defaultValue : previous.toSize();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray LayoutsSettings::getDeckEditorDbHeaderState()
|
QByteArray LayoutsSettings::getDeckEditorDbHeaderState()
|
||||||
{
|
{
|
||||||
return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray();
|
return getValue(STATE_PROP, GROUP_DECK_EDITOR_DB, "header").toByteArray();
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public:
|
|||||||
void setDeckEditorGeometry(const QByteArray &value);
|
void setDeckEditorGeometry(const QByteArray &value);
|
||||||
void setDeckEditorWidgetSize(const QString &widgetName, const QSize &value);
|
void setDeckEditorWidgetSize(const QString &widgetName, const QSize &value);
|
||||||
|
|
||||||
|
void setVisualDeckEditorLayoutState(const QByteArray &value);
|
||||||
|
void setVisualDeckEditorGeometry(const QByteArray &value);
|
||||||
|
void setVisualDeckEditorWidgetSize(const QString &widgetName, const QSize &value);
|
||||||
|
|
||||||
void setDeckEditorDbHeaderState(const QByteArray &value);
|
void setDeckEditorDbHeaderState(const QByteArray &value);
|
||||||
void setSetsDialogHeaderState(const QByteArray &value);
|
void setSetsDialogHeaderState(const QByteArray &value);
|
||||||
void setSetsDialogGeometry(const QByteArray &value);
|
void setSetsDialogGeometry(const QByteArray &value);
|
||||||
@@ -42,6 +46,10 @@ public:
|
|||||||
QByteArray getDeckEditorGeometry();
|
QByteArray getDeckEditorGeometry();
|
||||||
QSize getDeckEditorWidgetSize(const QString &widgetName, const QSize &defaultValue = {});
|
QSize getDeckEditorWidgetSize(const QString &widgetName, const QSize &defaultValue = {});
|
||||||
|
|
||||||
|
QByteArray getVisualDeckEditorLayoutState();
|
||||||
|
QByteArray getVisualDeckEditorGeometry();
|
||||||
|
QSize getVisualDeckEditorWidgetSize(const QString &widgetName, const QSize &defaultValue = {});
|
||||||
|
|
||||||
QByteArray getDeckEditorDbHeaderState();
|
QByteArray getDeckEditorDbHeaderState();
|
||||||
QByteArray getSetsDialogHeaderState();
|
QByteArray getSetsDialogHeaderState();
|
||||||
QByteArray getSetsDialogGeometry();
|
QByteArray getSetsDialogGeometry();
|
||||||
|
|||||||
Reference in New Issue
Block a user