summaryrefslogtreecommitdiff
path: root/doc/examples/htmleditor/htmleditorplugin.cpp
blob: 657963f345dec343c9c6536cc233daa1c0dfb1f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "htmleditorplugin.h"
#include "htmleditorfactory.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
#include <QtPlugin>
#include <QString>
#include <QMessageBox>
#include <QFontDialog>

HTMLEditorPlugin::HTMLEditorPlugin()
{
    // Do nothing
}

HTMLEditorPlugin::~HTMLEditorPlugin()
{
    // Do notning
}

void HTMLEditorPlugin::extensionsInitialized()
{
    // Do nothing
}

bool HTMLEditorPlugin::initialize(const QStringList& args, QString *errMsg)
{
    Q_UNUSED(args);

    Core::ActionManager* am = Core::ICore::instance()->actionManager();
    Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_EDIT);
    QAction* Font = ac->menu()->addAction("Font");

    // Create a command for "Font".
    Core::Command* cmd = am->registerAction(new QAction(this),"HTMLEditorPlugin.Font",QList<int>() << 0);
    cmd->action()->setText("Font");

    Core::ICore* core = Core::ICore::instance();
    Core::MimeDatabase* mdb = core->mimeDatabase();

    if(!mdb->addMimeTypes("text-html-mimetype.xml", errMsg))
        return false;

    QMessageBox::information(0, "Msg", *errMsg);

    addAutoReleasedObject(new HTMLEditorFactory(this));
    return true;
}

void HTMLEditorPlugin::shutdown()
{
    // Do nothing
}

Q_EXPORT_PLUGIN(HTMLEditorPlugin)