src/hbcore/devicedialogbase/hbdevicedialogplugin.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    61     determined by popup framework. Last dialog created is on top. Device dialog framework
    61     determined by popup framework. Last dialog created is on top. Device dialog framework
    62     manipulates Z-order of dialogs. Device dialogs themselves should not change the popup Z-order.
    62     manipulates Z-order of dialogs. Device dialogs themselves should not change the popup Z-order.
    63 
    63 
    64     Device dialog widgets have to be derived from HbPopup either directly or by ancestry.
    64     Device dialog widgets have to be derived from HbPopup either directly or by ancestry.
    65 
    65 
       
    66     Device dialog widget can be derived from existing Hb class, eg. HbDialog or constructed from
       
    67     a docml using HbDocumentLoader. Structure of the plugin differs depending on which approach
       
    68     is selected. If docml is used the dialog widget cannot be multiple inherited from HbDialog
       
    69     and HbDeviceDialogInterface. In this case a container can be used to to create and manage the
       
    70     widget. See code example at the end.
       
    71 
    66     <div style="color:gray">
    72     <div style="color:gray">
    67     <b>For future needs. Not implemented.</b>
    73     <b>For future needs. Not implemented.</b>
    68     Device dialog may be shared by several device dialog clients. Each client can update the
    74     Device dialog may be shared by several device dialog clients. Each client can update the
    69     device dialog and receive signals from it equally. Clients attach to a shared device dialog
    75     device dialog and receive signals from it equally. Clients attach to a shared device dialog
    70     instance by agreeing on an unique tag. The tag is appended into device dialog type with a %
    76     instance by agreeing on an unique tag. The tag is appended into device dialog type with a %
   103     - No time consuming operations performed
   109     - No time consuming operations performed
   104 
   110 
   105     Creating a device dialog plugin and widget involves following steps.
   111     Creating a device dialog plugin and widget involves following steps.
   106     - Set in .pro file TEMPLATE = lib and CONFIG += hb plugin
   112     - Set in .pro file TEMPLATE = lib and CONFIG += hb plugin
   107     - Derive a class from HbPopup or derivatives and HbDeviceDialogInterface
   113     - Derive a class from HbPopup or derivatives and HbDeviceDialogInterface
       
   114     The example below is <b>not using docml</b> and dialog widget is derived from HbDialog and
       
   115     HbDeviceDialogInterface.
   108     \code
   116     \code
   109     class HbSampleMessageBoxWidget : public HbMessageBox, public HbDeviceDialogInterface
   117     class HbSampleMessageBoxWidget : public HbMessageBox, public HbDeviceDialogInterface
   110     {
   118     {
   111         Q_OBJECT
   119         Q_OBJECT
   112     \endcode
   120     \endcode
   183             Class3 -> Class1 [label = "dependency"];
   191             Class3 -> Class1 [label = "dependency"];
   184             }
   192             }
   185     }
   193     }
   186     \enddot
   194     \enddot
   187 
   195 
       
   196     The example below is <b>using docml</b> and dialog widget is managed by a container.
       
   197     \code
       
   198     class HbSampleDialogContainer : public QObject, public HbDeviceDialogInterface
       
   199     {
       
   200         Q_OBJECT
       
   201     \endcode
       
   202     - In the constructor create the dialog widget using HbDocumentLoader
       
   203     - Implement HbDeviceDialogInterface functions
       
   204       - From deviceDialogWidget() function return the created (docml) widget
       
   205       - From signalSender() function return the container (HbSampleDialogContainer)
       
   206     - Declare and emit deviceDialogClosed and optionally deviceDialogData signals.
       
   207     - Do not call show(), hide() or setVisible() in the plugin. Device dialog
       
   208       framework calls show() to display the widget.
       
   209     \code
       
   210     public:
       
   211         bool setDeviceDialogParameters(const QVariantMap &parameters);
       
   212         int deviceDialogError() const;
       
   213         void closeDeviceDialog(bool byClient);
       
   214         HbPopup *deviceDialogWidget() const;
       
   215         QObject *signalSender() const;
       
   216     signals:
       
   217         void deviceDialogClosed();
       
   218         void deviceDialogData(QVariantMap data);
       
   219     \endcode
       
   220     - Wrap the widget into a plugin derived from HbDeviceDialogPlugin
       
   221     \code
       
   222     class HbSampleDeviceDialogPlugin : public HbDeviceDialogPlugin
       
   223     {
       
   224         Q_OBJECT
       
   225     \endcode
       
   226     - Implement HbDeviceDialogPlugin pure virtual functions
       
   227       - Return the container (HbSampleDialogContainer) from createDeviceDialog() function
       
   228     \code
       
   229         bool accessAllowed(const QString &deviceDialogType,
       
   230             const QVariantMap &parameters, const QVariantMap &securityInfo) const;
       
   231         HbDeviceDialogInterface *createDeviceDialog(const QString &deviceDialogType, const QVariantMap &parameters);
       
   232         bool deviceDialogInfo(const QString &deviceDialogType,
       
   233             const QVariantMap &parameters, DeviceDialogInfo *info) const;
       
   234         QStringList deviceDialogTypes() const;
       
   235         PluginFlags pluginFlags() const;
       
   236         int error() const;
       
   237     \endcode
       
   238 
       
   239     <b> Class diagram of the sample plugin using docml:</b>
       
   240     \dot
       
   241     digraph G {
       
   242         rankdir=LR;
       
   243 
       
   244         subgraph cluster_class_diagram {
       
   245             style=solid;
       
   246 
       
   247             node [shape = box, style=solid, fontsize = 10];
       
   248             HbSampleDeviceDialogPlugin [label = "HbSampleDeviceDialogPlugin"];
       
   249             QObject [label = "QObject"];
       
   250             HbDeviceDialogPluginInterface [label = "HbDeviceDialogPluginInterface"];
       
   251             HbDeviceDialogPlugin [label = "HbDeviceDialogPlugin"];
       
   252             edge [fontsize = 10, style = filled];
       
   253             QObject -> HbDeviceDialogPlugin [label = "is a"];
       
   254             HbDeviceDialogPluginInterface -> HbDeviceDialogPlugin [label = "is a"];
       
   255             HbDeviceDialogPlugin -> HbSampleDeviceDialogPlugin [label = "is a"];
       
   256 
       
   257             HbSampleDialogContainer [label = "HbSampleDialogContainer"];
       
   258             QObject2 [label = "QObject"];
       
   259             HbDeviceDialogInterface [label = "HbDeviceDialogInterface"];
       
   260             QObject2 -> HbSampleDialogContainer [label = "is a"];
       
   261             HbDeviceDialogInterface -> HbSampleDialogContainer [label = "is a"];
       
   262 
       
   263             edge [fontsize = 10, style = dotted];
       
   264             HbSampleDeviceDialogPlugin -> HbSampleDialogContainer [label = "creates"];
       
   265 
       
   266             DialogWidget [label = "Dialog widget (docml)"];
       
   267             edge [fontsize = 10, style = dotted];
       
   268             HbSampleDialogContainer -> DialogWidget [label = "creates"];
       
   269         }
       
   270 
       
   271         subgraph cluster_key {
       
   272             label = "Key";
       
   273             style=solid;
       
   274             node [shape = box, style=solid, fontsize = 10];
       
   275             Class1 [label = "Class"];
       
   276             Class2 [label = "Class"];
       
   277             Class3 [label = "Class"];
       
   278 
       
   279             edge [fontsize = 10, style = filled];
       
   280             Class2 -> Class1 [label = "generalization"];
       
   281             edge [fontsize = 10, style = dotted];
       
   282             Class3 -> Class1 [label = "dependency"];
       
   283             }
       
   284     }
       
   285     \enddot
       
   286 
   188     Sample plugin implementations can be found in src/hbplugins/devicedialogs directory.
   287     Sample plugin implementations can be found in src/hbplugins/devicedialogs directory.
   189 
   288 
   190     \sa HbDeviceDialogPluginInterface HbDeviceDialogInterface HbDeviceDialog HbPopup
   289     \sa HbDeviceDialogPluginInterface HbDeviceDialogInterface HbDeviceDialog HbPopup
   191 
   290 
   192     \stable
   291     \stable
   243 
   342 
   244 /*!
   343 /*!
   245     \enum HbDeviceDialogPlugin::DeviceDialogFlag
   344     \enum HbDeviceDialogPlugin::DeviceDialogFlag
   246     Defines flags for a device dialog created by the plugin.
   345     Defines flags for a device dialog created by the plugin.
   247 
   346 
   248     \sa deviceDialogInfo DeviceDialogInfo
   347     \sa deviceDialogInfo() HbIndicatorInterface
   249 */
   348 */
   250 /*!
   349 /*!
   251     \var HbDeviceDialogPlugin::DeviceDialogFlag HbDeviceDialogPlugin::NoDeviceDialogFlags
   350     \var HbDeviceDialogPlugin::DeviceDialogFlag HbDeviceDialogPlugin::NoDeviceDialogFlags
   252     No flags specified.
   351     No flags specified.
   253 */
   352 */
   266 /*!
   365 /*!
   267     \var HbDeviceDialogPlugin::DeviceDialogFlag HbDeviceDialogPlugin::SingleInstance
   366     \var HbDeviceDialogPlugin::DeviceDialogFlag HbDeviceDialogPlugin::SingleInstance
   268     If the flag is set, only one instance of the device dialog widget is allowed at
   367     If the flag is set, only one instance of the device dialog widget is allowed at
   269     one time. Attempt to launch the widget while one exists results in an error to be
   368     one time. Attempt to launch the widget while one exists results in an error to be
   270     returned to the client.
   369     returned to the client.
       
   370 */
       
   371 /*!
       
   372     \var HbDeviceDialogPlugin::DeviceDialogFlag HbDeviceDialogPlugin::ReceiveIndicatorStatus
       
   373     Indicates that the device dialog is interested in indicator activation/deactivation events.
       
   374     To receive indicator status the dialog has to implement two slots. Indicator activation is
       
   375     received by a slot indicatorActivated(HbIndicatorInterface*) and deactivation by a slot
       
   376     indicatorDeactivated(HbIndicatorInterface*).
   271 */
   377 */
   272 
   378 
   273 
   379 
   274 /*!
   380 /*!
   275     \var HbDeviceDialogPlugin::DefaultPriority
   381     \var HbDeviceDialogPlugin::DefaultPriority
   336          <td>Client's vendor ID</td>
   442          <td>Client's vendor ID</td>
   337          </tr>
   443          </tr>
   338          <tr>
   444          <tr>
   339          <td>"sym-caps"</td>
   445          <td>"sym-caps"</td>
   340          <td>quint32</td>
   446          <td>quint32</td>
   341          <td>Client's capability set as a bitmap</td>
   447          <td>Client's capability set as a bitmap. Bit positions correspond to Symbian enum TCapability</td>
   342          </tr>
   448          </tr>
   343      </table>
   449      </table>
   344 */
   450 */
   345 
   451 
   346 /*!
   452 /*!