ADTF Qt5
Loading...
Searching...
No Matches
adtf::ui::IQtXSystem::IWindowState Class Referenceabstract

#include <qtxsystem_intf.h>

Inherited by adtf::ui::v1::cQtWindow.

Public Types

enum  StateFlags : uint32_t { Content = 0x01 , Layout = 0x02 , Interactive = 0x04 }
 State flags indicating the reason of the call and folder location within OnLoadState and OnSaveState. More...
 

Public Member Functions

virtual QString GetStateIdentifier () const=0
 
virtual void OnLoadState (const QString &strStateFolder, uint32_t ui32LoadStateFlags)=0
 
virtual void OnSaveState (const QString &strStateFolder, uint32_t ui32SaveStateFlags) const=0
 

Protected Member Functions

 ~IWindowState ()=default
 protected DTOR
 

Detailed Description

Window state callback interface.

While registering a window with IQtXSystem::CreateWindow you are allowed to use the window creation flag WCF_HasWindowState. The implementation of parameter pWindow must derive by IWindow and IWindowState.

Remarks

Member Enumeration Documentation

◆ StateFlags

State flags indicating the reason of the call and folder location within OnLoadState and OnSaveState.

The window state is defined by 2 different parts:

  • Content: The actual data shown within the window(s), e.g. selected items, filter parameters, etc.
  • Layout: The arrangement of the window, e.g. size, position, docked state, etc.

Runlevel changes are always called with both StateFlags::Content and StateFlags::Layout set, while perspective changes are called with StateFlags::Layout calls only. Concrete user interactions to load a state while importing are additionally indicated by StateFlags::Interactive.

Enumerator
Content 

If state exists restore or save it partially. Content in the meaning of:

  • The actual data shown within the window(s), e.g. selected items, filter parameters, etc.
  • Current history, signal paths , etc.
Layout 

If state exists update or save layout of existing views only. Layout in the meaning of:

  • The arrangement of the window, e.g. size, position, docked state, etc.
  • table column and row sizes, splitter states, tree expansions etc.
Interactive 

State folder was created on export/import actions by user interaction.

  • This indicates that the user actively requested to load or save a state.

Member Function Documentation

◆ GetStateIdentifier()

virtual QString adtf::ui::v1::IQtXSystem::IWindowState::GetStateIdentifier ( ) const
pure virtual

Returns The user defined window state identifier.

Returns
The state identifier.
See also
adtf::ui::riddler::qt_ui_filter::GetStateIdentifier, adtf::ui::riddler::qt_ui_service::GetStateIdentifier

◆ OnLoadState()

virtual void adtf::ui::v1::IQtXSystem::IWindowState::OnLoadState ( const QString & strStateFolder,
uint32_t ui32LoadStateFlags )
pure virtual

Callback function to load the internal window state from the given folder strStateFolder. We recommend to use QSettings to save and load a UI View Settings file.

void cMyFilter::OnLoadState(const QString& strStateFolder, uint32_t ui32LoadStateFlags)
{
const auto strUISettingsFile = strStateFolder + "/my_ui_view.settings";
if (QFileInfo(strUISettingsFile).exists())
{
QSettings oSettings(strUISettingsFile, QSettings::IniFormat);
oSettings.beginGroup("my_window");
// read your state from the UI View Settings file as created within OnSaveState
oSettings.endGroup();
}
else
{
if (ui32LoadStateFlags & Interactive)
{
THROW_ERROR_DESC(ERR_INVALID_FILE, "UI View Settings file not found: %s",
strUISettingsFile.toStdString().c_str());
}
}
}
@ Interactive
State folder was created on export/import actions by user interaction.
Definition qtxsystem_intf.h:453
Parameters
[in]strStateFolderThe folder to save the UI View Settings files to.
[in]ui32LoadStateFlagsFlags indicating the reason of the call and folder location. Only the StateFlags::Interactive indicates an user interactions with the view. An exception during this interaction will result in a error message box, while all other calls will and only log the tResult error.
Remarks
If no UI View Settings file is found you may throw ERR_INVALID_FILE, unless the state folder was recently created, while initializing the very first time on runlevel changes. The exception will be ignored in this case.
Use StateFlags to check reason of call on ui32LoadStateFlags.
throw ERR_CANCEL to indicate the loading was cancelled on purpose.
See also
StateFlags

◆ OnSaveState()

virtual void adtf::ui::v1::IQtXSystem::IWindowState::OnSaveState ( const QString & strStateFolder,
uint32_t ui32SaveStateFlags ) const
pure virtual

Callback function to save the internal window state to the given folder strStateFolder. We recommend to use QSettings to save and load a UI View Settings file.

void cMyFilter::OnSaveState(const QString& strStateFolder,[[maybe_unused]] uint32_t ui32SaveStateFlags) const
{
QSettings oSettings(strStateFolder + "/my_ui_view.settings", QSettings::IniFormat);
oSettings.beginGroup("my_window");
// save your window state to the UI View Settings file.
oSettings.endGroup();
}
Parameters
[in]strStateFolderThe folder to save the UI View Settings files to.
[in]ui32SaveStateFlagsFlags indicating the reason of the call and folder location.
Remarks
You may throw within a tResult to indicate an error during saving. An ERR_CANCLED indicates the saving was cancelled on purpose.
See also
StateFlags

The documentation for this class was generated from the following file: