#include <QApplication>
#include <QPaintEvent>
#include <QCoreApplication>
+#include <QVBoxLayout>
#include <utilities.h>
+
namespace
{
/*!
ProcessVoidEvent( new TEvent( mySelMgr ) );
}
+/*!
+ \class UserDefinedContent
+ \brief The class represents base class for user defined widget that
+ can be inserted to the Preferences dialog.
+*/
+
+/*!
+ \brief Constructor
+*/
+UserDefinedContent::UserDefinedContent()
+ : QWidget()
+{
+}
+
+/*!
+ \brief Called from Preferences dialog to store settings to the resource file.
+*/
+void UserDefinedContent::store()
+{
+}
+
+/*!
+ \brief Called from Preferences dialog to restore settings from the resource file.
+*/
+void UserDefinedContent::retrieve()
+{
+}
+
+/*!
+ \class SgPyQtUserDefinedContent
+ \brief A Wrapper for UserDefinedContent class.
+ \internal
+*/
+class SgPyQtUserDefinedContent: public QtxUserDefinedContent
+{
+public:
+ SgPyQtUserDefinedContent(UserDefinedContent*);
+ virtual ~SgPyQtUserDefinedContent();
+
+ void store( QtxResourceMgr*, QtxPreferenceMgr* );
+ void retrieve( QtxResourceMgr*, QtxPreferenceMgr* );
+
+private:
+ UserDefinedContent* myContent;
+};
+
+/*!
+ \brief Create custom item for Preferences dialog wrapping widget passed from Python.
+ \internal
+*/
+SgPyQtUserDefinedContent::SgPyQtUserDefinedContent(UserDefinedContent* content)
+ : QtxUserDefinedContent( 0 ), myContent( content )
+{
+ QVBoxLayout* l = new QVBoxLayout( this );
+ l->setContentsMargins( 0, 0, 0, 0 );
+ l->addWidget( myContent );
+}
+
+/*!
+ \brief Destructor.
+ \internal
+*/
+SgPyQtUserDefinedContent::~SgPyQtUserDefinedContent()
+{
+}
+
+/*!
+ \brief Called from Preferences dialog to store settings to the resource file.
+ \internal
+*/
+void SgPyQtUserDefinedContent::store( QtxResourceMgr*, QtxPreferenceMgr* )
+{
+ myContent->store();
+}
+
+/*!
+ \brief Called from Preferences dialog to restore settings from the resource file.
+ \internal
+*/
+void SgPyQtUserDefinedContent::retrieve( QtxResourceMgr*, QtxPreferenceMgr* )
+{
+ myContent->retrieve();
+}
+
/*!
\class SalomePyQt
\brief The class provides utility functions which can be used in the Python
}
}
};
- ProcessVoidEvent( new TEvent( id, prop, var) );
+ ProcessVoidEvent( new TEvent( id, prop, var ) );
+}
+
+/*!
+ \brief Set specific widget as a custom preferences item.
+ \param id preferences identifier
+ \param prop preferences property name
+ \param widget custom widget
+*/
+void SalomePyQt::setPreferencePropertyWg( const int id,
+ const QString& prop,
+ UserDefinedContent* widget )
+{
+ class TEvent: public SALOME_Event
+ {
+ int myId;
+ QString myProp;
+ UserDefinedContent* myWidget;
+ public:
+ TEvent( const int id, const QString& prop, UserDefinedContent* widget )
+ : myId( id ), myProp( prop ), myWidget( widget ) {}
+ virtual void Execute()
+ {
+ LightApp_Module* module = getActiveModule();
+ if ( module ) {
+ LightApp_Preferences* pref = module->getApp()->preferences();
+ if ( pref ) {
+ pref->setItemProperty( myProp, (qint64) new SgPyQtUserDefinedContent( myWidget ), myId );
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, prop, widget ) );
}
/*!
PT_Font = LightApp_Preferences::Font,
PT_DirList = LightApp_Preferences::DirList,
PT_File = LightApp_Preferences::File,
+ PT_Slider = LightApp_Preferences::Slider,
+ PT_Shortcut = LightApp_Preferences::Shortcut,
+ PT_ShortcutTree = LightApp_Preferences::ShortcutTree,
+ PT_BiColor = LightApp_Preferences::BiColor,
+ PT_Background = LightApp_Preferences::Background,
+ PT_UserDefined = LightApp_Preferences::UserDefined,
+};
+
+class UserDefinedContent: public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit UserDefinedContent();
+
+ virtual void store();
+ virtual void retrieve();
};
//! Orientation
const QString& = QString() );
static QVariant preferenceProperty( const int, const QString& );
static void setPreferenceProperty( const int, const QString&, const QVariant& );
+ static void setPreferencePropertyWg( const int, const QString&, UserDefinedContent* );
static void addPreferenceProperty( const int, const QString&, const int, const QVariant& );
static void message( const QString&, bool = true );
PT_Font,
PT_DirList,
PT_File,
+ PT_Slider,
+ PT_Shortcut,
+ PT_ShortcutTree,
+ PT_BiColor,
+ PT_Background,
+ PT_UserDefined
};
enum Orientation {
QtxTreeView( const QtxTreeView& );
};
+class UserDefinedContent : public QWidget
+{
+%TypeHeaderCode
+#include <SalomePyQt.h>
+%End
+
+%ConvertToSubClassCode
+ if ( qobject_cast<UserDefinedContent*>( sipCpp ) )
+ sipClass = sipClass_UserDefinedContent;
+ else
+ sipClass = NULL;
+%End
+
+public:
+ explicit UserDefinedContent();
+
+ virtual void store();
+ virtual void retrieve();
+};
+
enum VisibilityState
{
ShownState,
static void setPreferenceProperty( const int,
const QString&,
const QVariant& ) /ReleaseGIL/ ;
+ static void setPreferencePropertyWg( const int,
+ const QString&,
+ UserDefinedContent* ) /ReleaseGIL/ ;
static void addPreferenceProperty( const int,
const QString&,
const int,