1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "coreplugin.h"
36 #include "editormanager.h"
37 #include "mainwindow.h"
38 #include "modemanager.h"
39 #include "fileiconprovider.h"
40 #include "designmode.h"
41 #include "mimedatabase.h"
43 #include <extensionsystem/pluginmanager.h>
45 #include <QtCore/QtPlugin>
46 #include <QtCore/QDebug>
49 using namespace Core::Internal;
51 CorePlugin::CorePlugin() :
52 m_mainWindow(new MainWindow), m_editMode(0)
56 CorePlugin::~CorePlugin()
59 removeObject(m_editMode);
64 removeObject(m_designMode);
68 // delete FileIconProvider singleton
69 delete FileIconProvider::instance();
74 void CorePlugin::parseArguments(const QStringList &arguments)
76 for (int i = 0; i < arguments.size() - 1; i++) {
77 if (arguments.at(i) == QLatin1String("-color")) {
78 const QString colorcode(arguments.at(i + 1));
79 m_mainWindow->setOverrideColor(QColor(colorcode));
80 i++; // skip the argument
85 bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
87 parseArguments(arguments);
88 const bool success = m_mainWindow->init(errorMessage);
90 EditorManager *editorManager = m_mainWindow->editorManager();
91 m_editMode = new EditMode(editorManager);
92 addObject(m_editMode);
93 m_mainWindow->modeManager()->activateMode(m_editMode->id());
95 m_designMode = new DesignMode(editorManager);
96 addObject(m_designMode);
101 void CorePlugin::extensionsInitialized()
103 m_mainWindow->mimeDatabase()->syncUserModifiedMimeTypes();
104 m_mainWindow->extensionsInitialized();
107 void CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
109 m_mainWindow->openFiles(args, ICore::SwitchMode);
110 m_mainWindow->activateWindow();
113 void CorePlugin::fileOpenRequest(const QString &f)
115 remoteCommand(QStringList(), QStringList(f));
118 ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
120 m_mainWindow->aboutToShutdown();
121 return SynchronousShutdown;
124 Q_EXPORT_PLUGIN(CorePlugin)