tools/designer/src/plugins/activeqt/qaxwidgetplugin.cpp
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Designer of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qaxwidgetplugin.h"
       
    43 #include "qaxwidgetextrainfo.h"
       
    44 #include "qdesigneraxwidget.h"
       
    45 #include "qaxwidgetpropertysheet.h"
       
    46 #include "qaxwidgettaskmenu.h"
       
    47 
       
    48 #include <QtDesigner/QDesignerFormEditorInterface>
       
    49 #include <QtDesigner/QDesignerFormWindowInterface>
       
    50 
       
    51 #include <QtCore/qplugin.h>
       
    52 #include <QtGui/QIcon>
       
    53 #include <ActiveQt/QAxWidget>
       
    54 
       
    55 QT_BEGIN_NAMESPACE
       
    56 
       
    57 QAxWidgetPlugin::QAxWidgetPlugin(QObject *parent) :
       
    58     QObject(parent),
       
    59     m_core(0)
       
    60 {
       
    61 }
       
    62 
       
    63 QString QAxWidgetPlugin::name() const
       
    64 {
       
    65     return QLatin1String("QAxWidget");
       
    66 }
       
    67 
       
    68 QString QAxWidgetPlugin::group() const
       
    69 {
       
    70     return QLatin1String("Containers");
       
    71 }
       
    72 
       
    73 QString QAxWidgetPlugin::toolTip() const
       
    74 {
       
    75     return tr("ActiveX control");
       
    76 }
       
    77 
       
    78 QString QAxWidgetPlugin::whatsThis() const
       
    79 {
       
    80     return tr("ActiveX control widget");
       
    81 }
       
    82 
       
    83 QString QAxWidgetPlugin::includeFile() const
       
    84 {
       
    85     return QLatin1String("qaxwidget.h");
       
    86 }
       
    87 
       
    88 QIcon QAxWidgetPlugin::icon() const
       
    89 {
       
    90     return QIcon(QDesignerAxWidget::widgetIcon());
       
    91 }
       
    92 
       
    93 bool QAxWidgetPlugin::isContainer() const
       
    94 {
       
    95     return false;
       
    96 }
       
    97 
       
    98 QWidget *QAxWidgetPlugin::createWidget(QWidget *parent)
       
    99 {
       
   100     // Construction from Widget box or on a form?
       
   101     const bool isFormEditor = parent != 0 && QDesignerFormWindowInterface::findFormWindow(parent) != 0;
       
   102     QDesignerAxWidget *rc = new QDesignerAxPluginWidget(parent);
       
   103     if (!isFormEditor)
       
   104         rc->setDrawFlags(QDesignerAxWidget::DrawFrame|QDesignerAxWidget::DrawControl);
       
   105     return rc;
       
   106 }
       
   107 
       
   108 bool QAxWidgetPlugin::isInitialized() const
       
   109 {
       
   110     return m_core != 0;
       
   111 }
       
   112 
       
   113 void QAxWidgetPlugin::initialize(QDesignerFormEditorInterface *core)
       
   114 {
       
   115     if (m_core != 0)
       
   116         return;
       
   117 
       
   118     m_core = core;
       
   119 
       
   120     QExtensionManager *mgr = core->extensionManager();
       
   121     ActiveXPropertySheetFactory::registerExtension(mgr);
       
   122     ActiveXTaskMenuFactory::registerExtension(mgr, Q_TYPEID(QDesignerTaskMenuExtension));
       
   123     QAxWidgetExtraInfoFactory *extraInfoFactory = new QAxWidgetExtraInfoFactory(core, mgr);
       
   124     mgr->registerExtensions(extraInfoFactory, Q_TYPEID(QDesignerExtraInfoExtension));
       
   125 }
       
   126 
       
   127 QString QAxWidgetPlugin::domXml() const
       
   128 {
       
   129     return QLatin1String("\
       
   130 <ui language=\"c++\">\
       
   131     <widget class=\"QAxWidget\" name=\"axWidget\">\
       
   132         <property name=\"geometry\">\
       
   133             <rect>\
       
   134                 <x>0</x>\
       
   135                 <y>0</y>\
       
   136                 <width>80</width>\
       
   137                 <height>70</height>\
       
   138             </rect>\
       
   139         </property>\
       
   140     </widget>\
       
   141 </ui>");
       
   142 }
       
   143 
       
   144 Q_EXPORT_PLUGIN(QAxWidgetPlugin)
       
   145 
       
   146 QT_END_NAMESPACE