mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-03 04:40:49 -06:00
Persist the geometry of PdmUiPropertyViewDialog and RiuPropertyViewTabWidget to the application settings on close and restore it on the next show. Restoring is done in showEvent rather than the constructor so it is applied reliably for a modal dialog. The settings key includes the bound object class keyword so distinct dialogs that share a window title do not collide. This behaviour is gated behind a new "Remember Dialog Size" experimental feature, disabled by default. PdmUiPropertyViewDialog cannot access RiaPreferencesSystem, so the application pushes the current setting via the static enableGeometryPersistence(), following the existing pattern used for class-name display. RiuPropertyViewTabWidget queries the feature directly.
93 lines
3.5 KiB
C++
93 lines
3.5 KiB
C++
//##################################################################################################
|
|
//
|
|
// Custom Visualization Core library
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
//
|
|
// This library may be used under the terms of either the GNU General Public License or
|
|
// the GNU Lesser General Public License as follows:
|
|
//
|
|
// GNU General Public License Usage
|
|
// This library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
|
// for more details.
|
|
//
|
|
// GNU Lesser General Public License Usage
|
|
// This library is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation; either version 2.1 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
|
// for more details.
|
|
//
|
|
//##################################################################################################
|
|
|
|
#pragma once
|
|
|
|
#include <QDialog>
|
|
#include <QDialogButtonBox>
|
|
|
|
namespace caf
|
|
{
|
|
class PdmObject;
|
|
class PdmUiPropertyView;
|
|
|
|
class PdmUiPropertyViewDialog : public QDialog
|
|
{
|
|
public:
|
|
PdmUiPropertyViewDialog( QWidget* parent, PdmObject* object, const QString& windowTitle, const QString& uiConfigName );
|
|
PdmUiPropertyViewDialog( QWidget* parent,
|
|
PdmObject* object,
|
|
const QString& windowTitle,
|
|
const QString& uiConfigName,
|
|
const QDialogButtonBox::StandardButtons& standardButtons );
|
|
~PdmUiPropertyViewDialog() override;
|
|
|
|
QDialogButtonBox* dialogButtonBox();
|
|
|
|
QSize sizeHint() const override;
|
|
QSize minimumSizeHint() const override;
|
|
|
|
// Persisting the dialog geometry to QSettings is gated behind an experimental feature. The
|
|
// application pushes the current setting via enableGeometryPersistence(). The size floor in
|
|
// sizeHint()/minimumSizeHint() is always applied, regardless of this setting.
|
|
static void enableGeometryPersistence( bool enable );
|
|
static bool isGeometryPersistenceEnabled();
|
|
|
|
protected:
|
|
void showEvent( QShowEvent* event ) override;
|
|
void done( int result ) override;
|
|
|
|
private:
|
|
void initialize( PdmObject* object, const QString& windowTitle, const QString& uiConfigName );
|
|
void setupUi();
|
|
|
|
QString settingsKey() const;
|
|
bool restoreDialogGeometry();
|
|
void saveDialogGeometry();
|
|
|
|
private:
|
|
QString m_windowTitle;
|
|
QString m_uiConfigName;
|
|
PdmObject* m_pdmObject;
|
|
PdmUiPropertyView* m_pdmUiPropertyView;
|
|
QDialogButtonBox* m_buttonBox;
|
|
bool m_geometryRestored = false;
|
|
|
|
static bool sm_geometryPersistenceEnabled;
|
|
};
|
|
|
|
} // End of namespace caf
|