~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to plasma/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <QtDeclarative/qdeclarative.h>
23
23
#include <QtDeclarative/QDeclarativeEngine>
 
24
#include <QtDeclarative/QDeclarativeContext>
 
25
#include <QtDeclarative/QDeclarativeItem>
24
26
 
25
27
#include "qrangemodel.h"
26
28
 
27
29
#include <KSharedConfig>
 
30
#include <KDebug>
28
31
 
29
32
#include "enums.h"
30
33
#include "qmenu.h"
31
34
#include "qmenuitem.h"
32
35
#include "kdialogproxy.h"
 
36
#include "fullscreendialog.h"
 
37
#include "fullscreensheet.h"
 
38
 
 
39
Q_EXPORT_PLUGIN2(plasmacomponentsplugin, PlasmaComponentsPlugin)
 
40
 
 
41
class BKSingleton
 
42
{
 
43
public:
 
44
   EngineBookKeeping self;
 
45
};
 
46
K_GLOBAL_STATIC(BKSingleton, privateBKSelf)
 
47
 
 
48
EngineBookKeeping::EngineBookKeeping()
 
49
{
 
50
}
 
51
 
 
52
EngineBookKeeping *EngineBookKeeping::self()
 
53
{
 
54
    return &privateBKSelf->self;
 
55
}
 
56
 
 
57
QDeclarativeEngine *EngineBookKeeping::engine() const
 
58
{
 
59
    //for components creation, any engine will do, as long is valid
 
60
    if (m_engines.isEmpty()) {
 
61
        kWarning() << "No engines found, this should never happen";
 
62
        return 0;
 
63
    } else {
 
64
        return m_engines.values().first();
 
65
    }
 
66
}
 
67
 
 
68
void EngineBookKeeping::insertEngine(QDeclarativeEngine *engine)
 
69
{
 
70
    connect(engine, SIGNAL(destroyed(QObject *)),
 
71
            this, SLOT(engineDestroyed(QObject *)));
 
72
    m_engines.insert(engine);
 
73
}
 
74
 
 
75
void EngineBookKeeping::engineDestroyed(QObject *deleted)
 
76
{
 
77
    m_engines.remove(static_cast<QDeclarativeEngine *>(deleted));
 
78
}
 
79
 
 
80
 
 
81
 
 
82
void PlasmaComponentsPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
 
83
{
 
84
    QDeclarativeExtensionPlugin::initializeEngine(engine, uri);
 
85
    EngineBookKeeping::self()->insertEngine(engine);
 
86
}
33
87
 
34
88
void PlasmaComponentsPlugin::registerTypes(const char *uri)
35
89
{
41
95
        componentsPlatform = cg.readEntry("name", "desktop");
42
96
    }
43
97
 
 
98
    //platform specific c++ components
44
99
    if (componentsPlatform == "desktop") {
45
100
        qmlRegisterType<KDialogProxy>(uri, 0, 1, "QueryDialog");
46
101
 
47
102
        qmlRegisterType<QMenuProxy>(uri, 0, 1, "Menu");
48
 
        qmlRegisterType<QMenuProxy>(uri, 0, 1, "ContextMenu");
49
103
        qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
 
104
    //on touch systems the dialog is fullscreen, c++ needed to do that
 
105
    } else {
 
106
        qmlRegisterType<FullScreenDialog>(uri, 0, 1, "Dialog");
 
107
        qmlRegisterType<FullScreenSheet>(uri, 0, 1, "Sheet");
50
108
    }
51
109
 
52
110
    qmlRegisterType<Plasma::QRangeModel>(uri, 0, 1, "RangeModel");