src/plugins/accessible/widgets/main.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 plugins 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 "qaccessiblewidgets.h"
       
    43 #include "qaccessiblemenu.h"
       
    44 #include "simplewidgets.h"
       
    45 #include "rangecontrols.h"
       
    46 #include "complexwidgets.h"
       
    47 
       
    48 #include <qaccessibleplugin.h>
       
    49 #include <qplugin.h>
       
    50 #include <qpushbutton.h>
       
    51 #include <qtoolbutton.h>
       
    52 #include <qvariant.h>
       
    53 #include <qaccessible.h>
       
    54 
       
    55 #ifndef QT_NO_ACCESSIBILITY
       
    56 
       
    57 QT_BEGIN_NAMESPACE
       
    58 
       
    59 class AccessibleFactory : public QAccessiblePlugin
       
    60 {
       
    61 public:
       
    62     AccessibleFactory();
       
    63 
       
    64     QStringList keys() const;
       
    65     QAccessibleInterface *create(const QString &classname, QObject *object);
       
    66 };
       
    67 
       
    68 AccessibleFactory::AccessibleFactory()
       
    69 {
       
    70 }
       
    71 
       
    72 QStringList AccessibleFactory::keys() const
       
    73 {
       
    74     QStringList list;
       
    75 #ifndef QT_NO_LINEEDIT
       
    76     list << QLatin1String("QLineEdit");
       
    77 #endif
       
    78 #ifndef QT_NO_COMBOBOX
       
    79     list << QLatin1String("QComboBox");
       
    80 #endif
       
    81 #ifndef QT_NO_SPINBOX
       
    82     list << QLatin1String("QAbstractSpinBox");
       
    83     list << QLatin1String("QSpinBox");
       
    84     list << QLatin1String("QDoubleSpinBox");
       
    85 #endif
       
    86 #ifndef QT_NO_SCROLLBAR
       
    87     list << QLatin1String("QScrollBar");
       
    88 #endif
       
    89 #ifndef QT_NO_SLIDER
       
    90     list << QLatin1String("QSlider");
       
    91 #endif
       
    92     list << QLatin1String("QAbstractSlider");
       
    93 #ifndef QT_NO_TOOLBUTTON
       
    94     list << QLatin1String("QToolButton");
       
    95 #endif
       
    96     list << QLatin1String("QCheckBox");
       
    97     list << QLatin1String("QRadioButton");
       
    98     list << QLatin1String("QPushButton");
       
    99     list << QLatin1String("QAbstractButton");
       
   100     list << QLatin1String("QDialog");
       
   101     list << QLatin1String("QMessageBox");
       
   102     list << QLatin1String("QMainWindow");
       
   103     list << QLatin1String("QLabel");
       
   104     list << QLatin1String("QLCDNumber");
       
   105     list << QLatin1String("QGroupBox");
       
   106     list << QLatin1String("QStatusBar");
       
   107     list << QLatin1String("QProgressBar");
       
   108     list << QLatin1String("QMenuBar");
       
   109     list << QLatin1String("Q3PopupMenu");
       
   110     list << QLatin1String("QMenu");
       
   111     list << QLatin1String("QHeaderView");
       
   112     list << QLatin1String("QTabBar");
       
   113     list << QLatin1String("QToolBar");
       
   114     list << QLatin1String("QWorkspaceChild");
       
   115     list << QLatin1String("QSizeGrip");
       
   116     list << QLatin1String("QAbstractItemView");
       
   117     list << QLatin1String("QWidget");
       
   118 #ifndef QT_NO_SPLITTER
       
   119     list << QLatin1String("QSplitter");
       
   120     list << QLatin1String("QSplitterHandle");
       
   121 #endif
       
   122 #ifndef QT_NO_TEXTEDIT
       
   123     list << QLatin1String("QTextEdit");
       
   124 #endif
       
   125     list << QLatin1String("QTipLabel");
       
   126     list << QLatin1String("QFrame");
       
   127     list << QLatin1String("QStackedWidget");
       
   128     list << QLatin1String("QToolBox");
       
   129     list << QLatin1String("QMdiArea");
       
   130     list << QLatin1String("QMdiSubWindow");
       
   131     list << QLatin1String("QWorkspace");
       
   132     list << QLatin1String("QDialogButtonBox");
       
   133 #ifndef QT_NO_DIAL
       
   134     list << QLatin1String("QDial");
       
   135 #endif
       
   136 #ifndef QT_NO_RUBBERBAND
       
   137     list << QLatin1String("QRubberBand");
       
   138 #endif
       
   139 #ifndef QT_NO_TEXTBROWSER
       
   140     list << QLatin1String("QTextBrowser");
       
   141 #endif
       
   142 #ifndef QT_NO_SCROLLAREA
       
   143     list << QLatin1String("QAbstractScrollArea");
       
   144     list << QLatin1String("QScrollArea");
       
   145 #endif
       
   146 #ifndef QT_NO_CALENDARWIDGET
       
   147     list << QLatin1String("QCalendarWidget");
       
   148 #endif
       
   149 
       
   150 #ifndef QT_NO_DOCKWIDGET
       
   151     list << QLatin1String("QDockWidget");
       
   152 #endif
       
   153     return list;
       
   154 }
       
   155 
       
   156 QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
       
   157 {
       
   158     QAccessibleInterface *iface = 0;
       
   159     if (!object || !object->isWidgetType())
       
   160         return iface;
       
   161     QWidget *widget = static_cast<QWidget*>(object);
       
   162 
       
   163     if (false) {
       
   164 #ifndef QT_NO_LINEEDIT
       
   165     } else if (classname == QLatin1String("QLineEdit")) {
       
   166         iface = new QAccessibleLineEdit(widget);
       
   167 #endif
       
   168 #ifndef QT_NO_COMBOBOX
       
   169     } else if (classname == QLatin1String("QComboBox")) {
       
   170         iface = new QAccessibleComboBox(widget);
       
   171 #endif
       
   172 #ifndef QT_NO_SPINBOX
       
   173     } else if (classname == QLatin1String("QAbstractSpinBox")) {
       
   174         iface = new QAccessibleAbstractSpinBox(widget);
       
   175     } else if (classname == QLatin1String("QSpinBox")) {
       
   176         iface = new QAccessibleSpinBox(widget);
       
   177     } else if (classname == QLatin1String("QDoubleSpinBox")) {
       
   178         iface = new QAccessibleDoubleSpinBox(widget);
       
   179 #endif
       
   180 #ifndef QT_NO_SCROLLBAR
       
   181     } else if (classname == QLatin1String("QScrollBar")) {
       
   182         iface = new QAccessibleScrollBar(widget);
       
   183 #endif
       
   184     } else if (classname == QLatin1String("QAbstractSlider")) {
       
   185         iface = new QAccessibleAbstractSlider(widget);
       
   186 #ifndef QT_NO_SLIDER
       
   187     } else if (classname == QLatin1String("QSlider")) {
       
   188         iface = new QAccessibleSlider(widget);
       
   189 #endif
       
   190 #ifndef QT_NO_TOOLBUTTON
       
   191     } else if (classname == QLatin1String("QToolButton")) {
       
   192         Role role = NoRole;
       
   193 #ifndef QT_NO_MENU
       
   194         QToolButton *tb = qobject_cast<QToolButton*>(widget);
       
   195         if (!tb->menu())
       
   196             role = tb->isCheckable() ? CheckBox : PushButton;
       
   197         else if (!tb->popupMode() != QToolButton::DelayedPopup)
       
   198             role = ButtonDropDown;
       
   199         else
       
   200 #endif
       
   201             role = ButtonMenu;
       
   202         iface = new QAccessibleToolButton(widget, role);
       
   203 #endif // QT_NO_TOOLBUTTON
       
   204     } else if (classname == QLatin1String("QCheckBox")) {
       
   205         iface = new QAccessibleButton(widget, CheckBox);
       
   206     } else if (classname == QLatin1String("QRadioButton")) {
       
   207         iface = new QAccessibleButton(widget, RadioButton);
       
   208     } else if (classname == QLatin1String("QPushButton")) {
       
   209         Role role = NoRole;
       
   210         QPushButton *pb = qobject_cast<QPushButton*>(widget);
       
   211 #ifndef QT_NO_MENU
       
   212         if (pb->menu())
       
   213             role = ButtonMenu;
       
   214         else
       
   215 #endif
       
   216         if (pb->isCheckable())
       
   217             role = CheckBox;
       
   218         else
       
   219             role = PushButton;
       
   220         iface = new QAccessibleButton(widget, role);
       
   221     } else if (classname == QLatin1String("QAbstractButton")) {
       
   222         iface = new QAccessibleButton(widget, PushButton);
       
   223     } else if (classname == QLatin1String("QDialog")) {
       
   224         iface = new QAccessibleWidgetEx(widget, Dialog);
       
   225     } else if (classname == QLatin1String("QMessageBox")) {
       
   226         iface = new QAccessibleWidgetEx(widget, AlertMessage);
       
   227 #ifndef QT_NO_MAINWINDOW
       
   228     } else if (classname == QLatin1String("QMainWindow")) {
       
   229         iface = new QAccessibleMainWindow(widget);
       
   230 #endif
       
   231     } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
       
   232         iface = new QAccessibleDisplay(widget);
       
   233     } else if (classname == QLatin1String("QGroupBox")) {
       
   234         iface = new QAccessibleDisplay(widget, Grouping);
       
   235     } else if (classname == QLatin1String("QStatusBar")) {
       
   236         iface = new QAccessibleWidgetEx(widget, StatusBar);
       
   237 #ifndef QT_NO_PROGRESSBAR
       
   238     } else if (classname == QLatin1String("QProgressBar")) {
       
   239         iface = new QAccessibleProgressBar(widget);
       
   240 #endif
       
   241     } else if (classname == QLatin1String("QToolBar")) {
       
   242         iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle());
       
   243 #ifndef QT_NO_MENUBAR
       
   244     } else if (classname == QLatin1String("QMenuBar")) {
       
   245         iface = new QAccessibleMenuBar(widget);
       
   246 #endif
       
   247 #ifndef QT_NO_MENU
       
   248     } else if (classname == QLatin1String("QMenu")) {
       
   249         iface = new QAccessibleMenu(widget);
       
   250     } else if (classname == QLatin1String("Q3PopupMenu")) {
       
   251         iface = new QAccessibleMenu(widget);
       
   252 #endif
       
   253 #ifndef QT_NO_ITEMVIEWS
       
   254     } else if (classname == QLatin1String("QHeaderView")) {
       
   255         iface = new QAccessibleHeader(widget);
       
   256     } else if (classname == QLatin1String("QAbstractItemView")) {
       
   257         iface = new QAccessibleItemView(widget);
       
   258     } else if (classname == QLatin1String("QWidget")
       
   259                && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
       
   260                && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
       
   261         iface = new QAccessibleItemView(widget);
       
   262 #endif
       
   263 #ifndef QT_NO_TABBAR
       
   264     } else if (classname == QLatin1String("QTabBar")) {
       
   265         iface = new QAccessibleTabBar(widget);
       
   266 #endif
       
   267     } else if (classname == QLatin1String("QWorkspaceChild")) {
       
   268         iface = new QAccessibleWidgetEx(widget, Window);
       
   269     } else if (classname == QLatin1String("QSizeGrip")) {
       
   270         iface = new QAccessibleWidgetEx(widget, Grip);
       
   271 #ifndef QT_NO_SPLITTER
       
   272     } else if (classname == QLatin1String("QSplitter")) {
       
   273         iface = new QAccessibleWidgetEx(widget, Splitter);
       
   274     } else if (classname == QLatin1String("QSplitterHandle")) {
       
   275         iface = new QAccessibleWidgetEx(widget, Grip);
       
   276 #endif
       
   277 #ifndef QT_NO_TEXTEDIT
       
   278     } else if (classname == QLatin1String("QTextEdit")) {
       
   279         iface = new QAccessibleTextEdit(widget);
       
   280 #endif
       
   281     } else if (classname == QLatin1String("QTipLabel")) {
       
   282         iface = new QAccessibleDisplay(widget, ToolTip);
       
   283     } else if (classname == QLatin1String("QFrame")) {
       
   284         iface = new QAccessibleWidget(widget, Border);
       
   285 #ifndef QT_NO_STACKEDWIDGET
       
   286     } else if (classname == QLatin1String("QStackedWidget")) {
       
   287         iface = new QAccessibleStackedWidget(widget);
       
   288 #endif
       
   289 #ifndef QT_NO_TOOLBOX
       
   290     } else if (classname == QLatin1String("QToolBox")) {
       
   291         iface = new QAccessibleToolBox(widget);
       
   292 #endif
       
   293 #ifndef QT_NO_MDIAREA
       
   294     } else if (classname == QLatin1String("QMdiArea")) {
       
   295         iface = new QAccessibleMdiArea(widget);
       
   296     } else if (classname == QLatin1String("QMdiSubWindow")) {
       
   297         iface = new QAccessibleMdiSubWindow(widget);
       
   298 #endif
       
   299 #ifndef QT_NO_WORKSPACE
       
   300     } else if (classname == QLatin1String("QWorkspace")) {
       
   301         iface = new QAccessibleWorkspace(widget);
       
   302 #endif
       
   303     } else if (classname == QLatin1String("QDialogButtonBox")) {
       
   304         iface = new QAccessibleDialogButtonBox(widget);
       
   305 #ifndef QT_NO_DIAL
       
   306     } else if (classname == QLatin1String("QDial")) {
       
   307         iface = new QAccessibleDial(widget);
       
   308 #endif
       
   309 #ifndef QT_NO_RUBBERBAND
       
   310     } else if (classname == QLatin1String("QRubberBand")) {
       
   311         iface = new QAccessibleWidgetEx(widget, QAccessible::Border);
       
   312 #endif
       
   313 #ifndef QT_NO_TEXTBROWSER
       
   314     } else if (classname == QLatin1String("QTextBrowser")) {
       
   315         iface = new QAccessibleTextBrowser(widget);
       
   316 #endif
       
   317 #ifndef QT_NO_SCROLLAREA
       
   318     } else if (classname == QLatin1String("QAbstractScrollArea")) {
       
   319         iface = new QAccessibleAbstractScrollArea(widget);
       
   320     } else if (classname == QLatin1String("QScrollArea")) {
       
   321         iface = new QAccessibleScrollArea(widget);
       
   322 #endif
       
   323 #ifndef QT_NO_CALENDARWIDGET
       
   324     } else if (classname == QLatin1String("QCalendarWidget")) {
       
   325         iface = new QAccessibleCalendarWidget(widget);
       
   326 #endif
       
   327 #ifndef QT_NO_DOCKWIDGET
       
   328     } else if (classname == QLatin1String("QDockWidget")) {
       
   329         iface = new QAccessibleDockWidget(widget);
       
   330 #endif
       
   331     }
       
   332 
       
   333     return iface;
       
   334 }
       
   335 
       
   336 Q_EXPORT_STATIC_PLUGIN(AccessibleFactory)
       
   337 Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
       
   338 
       
   339 QT_END_NAMESPACE
       
   340 
       
   341 #endif // QT_NO_ACCESSIBILITY