forked from qt-creator/qt-creator
Qt Creator Plugin HOWTO documentation first and second cut
Signed-off-by: Abhishek Patil <abhishek.patil@vcreatelogic.com> Merge-request: 145 Reviewed-by: con <qtc-committer@nokia.com>
This commit is contained in:
64
doc/examples/menu/addingmenu/donothingplugin.cpp
Normal file
64
doc/examples/menu/addingmenu/donothingplugin.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "donothingplugin.h"
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
|
||||
DoNothingPlugin::DoNothingPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
DoNothingPlugin::~DoNothingPlugin()
|
||||
{
|
||||
// Do notning
|
||||
}
|
||||
|
||||
void DoNothingPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool DoNothingPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
|
||||
// Fetch the action manager
|
||||
Core::ActionManager* am = Core::ICore::instance()->actionManager();
|
||||
|
||||
// Create a DoNothing menu
|
||||
Core::ActionContainer* ac = am->createMenu("DoNothingPlugin.DoNothingMenu");
|
||||
ac->menu()->setTitle("DoNothing");
|
||||
|
||||
// Create a command for "About DoNothing".
|
||||
QAction *action = new QAction(tr("About DoNothing"),this);
|
||||
Core::Command* cmd = am->registerAction(action,"DoNothingPlugin.AboutDoNothing",QList<int>() << 0);
|
||||
|
||||
// Add DoNothing menu to the menubar
|
||||
am->actionContainer(Core::Constants::MENU_BAR)->addMenu(ac);
|
||||
|
||||
// Add the "About DoNothing" action to the DoNothing menu
|
||||
ac->addAction(cmd);
|
||||
|
||||
// Connect the action
|
||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(about()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void DoNothingPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
void DoNothingPlugin::about()
|
||||
{
|
||||
QMessageBox::information(0, "About DoNothing Plugin",
|
||||
"Seriously dude, this plugin does nothing");
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(DoNothingPlugin)
|
||||
Reference in New Issue
Block a user