1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the style module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "qstylefactory.h"
30
#include "qstyleplugin.h"
31
#include "private/qfactoryloader_p.h"
34
#include "qapplication.h"
35
#include "qwindowsstyle.h"
36
#include "qmotifstyle.h"
37
#include "qcdestyle.h"
38
#ifndef QT_NO_STYLE_PLASTIQUE
39
#include "qplastiquestyle.h"
41
#ifndef QT_NO_STYLE_WINDOWSXP
42
#include "qwindowsxpstyle.h"
45
#if !defined(QT_NO_STYLE_MAC) && defined(Q_WS_MAC)
46
# include <private/qt_mac_p.h>
47
# include "qmacstyle_mac.h"
48
QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp
51
#ifndef QT_NO_COMPONENT
52
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
53
(QStyleFactoryInterface_iid, QCoreApplication::libraryPaths(), "/styles", Qt::CaseInsensitive))
57
\class QStyleFactory qstylefactory.h
58
\brief The QStyleFactory class creates QStyle objects.
62
The style factory creates a QStyle object for a given key with
63
QStyleFactory::create(key).
65
The styles are either built-in or dynamically loaded from a style
66
plugin (see \l QStylePlugin).
68
QStyleFactory::keys() returns a list of valid keys, typically
69
including "windows", "motif", "cde", and "plastique".
70
Depending on the platform, "windowsxp" and "macintosh" may be
77
Creates a QStyle object that matches \a key. This is either a
78
built-in style, or a style from a style plugin.
82
QStyle *QStyleFactory::create(const QString& key)
85
QString style = key.toLower();
86
#ifndef QT_NO_STYLE_WINDOWS
87
if (style == "windows")
88
ret = new QWindowsStyle;
91
#ifndef QT_NO_STYLE_WINDOWSXP
92
if (style == "windowsxp")
93
ret = new QWindowsXPStyle;
96
#ifndef QT_NO_STYLE_MOTIF
98
ret = new QMotifStyle;
101
#ifndef QT_NO_STYLE_CDE
106
#ifndef QT_NO_STYLE_PLASTIQUE
107
if (style == "plastique")
108
ret = new QPlastiqueStyle;
111
#if !defined(QT_NO_STYLE_MAC) && defined(Q_WS_MAC)
112
if(style.left(9) == "macintosh")
116
{ } // Keep these here - they make the #ifdefery above work
117
#ifndef QT_NO_COMPONENT
119
if (QStyleFactoryInterface *factory = qobject_cast<QStyleFactoryInterface*>(loader()->instance(style)))
120
ret = factory->create(style);
124
ret->setObjectName(style);
129
Returns the list of keys this factory can create styles for.
133
QStringList QStyleFactory::keys()
135
#ifndef QT_NO_COMPONENT
136
QStringList list = loader()->keys();
140
#ifndef QT_NO_STYLE_WINDOWS
141
if (!list.contains("Windows"))
144
#ifndef QT_NO_STYLE_WINDOWSXP
145
if (!list.contains("WindowsXP"))
148
#ifndef QT_NO_STYLE_MOTIF
149
if (!list.contains("Motif"))
152
#ifndef QT_NO_STYLE_CDE
153
if (!list.contains("CDE"))
156
#ifndef QT_NO_STYLE_PLASTIQUE
157
if (!list.contains("Plastique"))
160
#if !defined(QT_NO_STYLE_MAC) && defined(Q_WS_MAC)
161
QString mstyle = "Macintosh";
162
Collection c = NewCollection();
167
if(!GetCollectionItem(c, kThemeNameTag, 0, &s, &str))
168
mstyle += " (" + qt_mac_from_pascal_string(str) + ")";
170
if (!list.contains(mstyle))
172
DisposeCollection(c);