2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helloworldplugin.h"
|
|
|
|
|
|
2009-01-14 13:28:46 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-09-06 14:10:30 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2009-01-05 12:21:32 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2010-12-06 14:12:38 +01:00
|
|
|
#include <coreplugin/imode.h>
|
2009-01-05 12:21:32 +01:00
|
|
|
#include <coreplugin/modemanager.h>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-06 14:12:38 +01:00
|
|
|
namespace HelloWorld {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
/*! A mode with a push button based on BaseMode. */
|
|
|
|
|
|
|
|
|
|
class HelloMode : public Core::IMode
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-04-13 13:00:30 +02:00
|
|
|
HelloMode()
|
|
|
|
|
{
|
|
|
|
|
setWidget(new QPushButton(tr("Hello World PushButton!")));
|
|
|
|
|
setContext(Core::Context("HelloWorld.MainView"));
|
2011-04-13 16:09:04 +02:00
|
|
|
setDisplayName(tr("Hello world!"));
|
|
|
|
|
setIcon(QIcon());
|
|
|
|
|
setPriority(0);
|
2012-05-07 18:28:03 +02:00
|
|
|
setId("HelloWorld.HelloWorldMode");
|
|
|
|
|
setType("HelloWorld.HelloWorldMode");
|
2011-04-13 16:09:04 +02:00
|
|
|
setContextHelpId(QString());
|
2011-04-13 13:00:30 +02:00
|
|
|
}
|
2010-12-06 14:12:38 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
/*! Constructs the Hello World plugin. Normally plugins don't do anything in
|
|
|
|
|
their constructor except for initializing their member variables. The
|
|
|
|
|
actual work is done later, in the initialize() and extensionsInitialized()
|
|
|
|
|
methods.
|
|
|
|
|
*/
|
|
|
|
|
HelloWorldPlugin::HelloWorldPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Plugins are responsible for deleting objects they created on the heap, and
|
|
|
|
|
to unregister objects from the plugin manager that they registered there.
|
|
|
|
|
*/
|
|
|
|
|
HelloWorldPlugin::~HelloWorldPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Initializes the plugin. Returns true on success.
|
|
|
|
|
Plugins want to register objects with the plugin manager here.
|
|
|
|
|
|
2011-09-21 13:05:15 +02:00
|
|
|
\a errorMessage can be used to pass an error message to the plugin system,
|
2008-12-02 12:01:29 +01:00
|
|
|
if there was any.
|
|
|
|
|
*/
|
2011-09-21 13:05:15 +02:00
|
|
|
bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-05 12:21:32 +01:00
|
|
|
Q_UNUSED(arguments)
|
2011-09-21 13:05:15 +02:00
|
|
|
Q_UNUSED(errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-06 14:12:38 +01:00
|
|
|
// Create a unique context for our own view, that will be used for the
|
2008-12-02 12:01:29 +01:00
|
|
|
// menu entry later.
|
2010-09-06 14:10:30 +02:00
|
|
|
Core::Context context("HelloWorld.MainView");
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Create an action to be triggered by a menu entry
|
2009-04-17 21:11:52 +02:00
|
|
|
QAction *helloWorldAction = new QAction(tr("Say \"&Hello World!\""), this);
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(helloWorldAction, SIGNAL(triggered()), SLOT(sayHelloWorld()));
|
|
|
|
|
|
|
|
|
|
// Register the action with the action manager
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ActionManager *actionManager = Core::ICore::actionManager();
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::Command *command =
|
2008-12-02 12:01:29 +01:00
|
|
|
actionManager->registerAction(
|
|
|
|
|
helloWorldAction, "HelloWorld.HelloWorldAction", context);
|
|
|
|
|
|
|
|
|
|
// Create our own menu to place in the Tools menu
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::ActionContainer *helloWorldMenu =
|
2008-12-02 12:01:29 +01:00
|
|
|
actionManager->createMenu("HelloWorld.HelloWorldMenu");
|
|
|
|
|
QMenu *menu = helloWorldMenu->menu();
|
|
|
|
|
menu->setTitle(tr("&Hello World"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
// Add the Hello World action command to the menu
|
|
|
|
|
helloWorldMenu->addAction(command);
|
|
|
|
|
|
|
|
|
|
// Request the Tools menu and add the Hello World menu to it
|
2009-01-14 13:28:46 +01:00
|
|
|
Core::ActionContainer *toolsMenu =
|
2008-12-02 12:01:29 +01:00
|
|
|
actionManager->actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
toolsMenu->addMenu(helloWorldMenu);
|
|
|
|
|
|
2009-01-05 12:21:32 +01:00
|
|
|
// Add a mode with a push button based on BaseMode. Like the BaseView,
|
|
|
|
|
// it will unregister itself from the plugin manager when it is deleted.
|
2010-12-06 14:12:38 +01:00
|
|
|
Core::IMode *helloMode = new HelloMode;
|
|
|
|
|
addAutoReleasedObject(helloMode);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Notification that all extensions that this plugin depends on have been
|
2010-02-28 14:37:11 +01:00
|
|
|
initialized. The dependencies are defined in the plugins .pluginspec file.
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Normally this method is used for things that rely on other plugins to have
|
|
|
|
|
added objects to the plugin manager, that implement interfaces that we're
|
|
|
|
|
interested in. These objects can now be requested through the
|
|
|
|
|
PluginManagerInterface.
|
|
|
|
|
|
|
|
|
|
The HelloWorldPlugin doesn't need things from other plugins, so it does
|
|
|
|
|
nothing here.
|
|
|
|
|
*/
|
|
|
|
|
void HelloWorldPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HelloWorldPlugin::sayHelloWorld()
|
|
|
|
|
{
|
|
|
|
|
// When passing 0 for the parent, the message box becomes an
|
|
|
|
|
// application-global modal dialog box
|
|
|
|
|
QMessageBox::information(
|
2009-04-17 21:11:52 +02:00
|
|
|
0, tr("Hello World!"), tr("Hello World! Beautiful day today, isn't it?"));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-06 14:12:38 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace HelloWorld
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(HelloWorld::Internal::HelloWorldPlugin)
|